|
|
/////////////////////////////////////////////////////////////////
|
|
|
//
|
|
|
// (C) Copyright 2013, Kenneth, Inc.
|
|
|
// All rights reserved. Confidential. Except as pursuant
|
|
|
// to a written agreement with Kenneth, this software may
|
|
|
// not be used or distributed. This software may be covered
|
|
|
// by one or more patents.
|
|
|
//
|
|
|
// 本软件为 ** 公司开发,版权所有,违者必究,23810511@qq.com
|
|
|
//
|
|
|
/////////////////////////////////////////////////////////////////
|
|
|
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using Newtonsoft.Json;
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
using NPOI.HSSF.UserModel;
|
|
|
using NPOI.SS.UserModel;
|
|
|
using System.IO;
|
|
|
using System.Reflection;
|
|
|
using System.Data;
|
|
|
using System.Data.SqlClient;
|
|
|
using System.Transactions;
|
|
|
using QuiltingCommon;
|
|
|
using MySql.Data.MySqlClient;
|
|
|
|
|
|
namespace QuiltingBusiness
|
|
|
{
|
|
|
public partial class Itemtype
|
|
|
{
|
|
|
private static void ConvertSingleData(ItemtypeEntityExtension data)
|
|
|
{
|
|
|
var user = SysUserPool.GetById(data.CreateBy);
|
|
|
if (user != null)
|
|
|
{
|
|
|
data.CreateByDisplayer = user.UserName;
|
|
|
}
|
|
|
user = SysUserPool.GetById(data.ModifyBy);
|
|
|
if (user != null)
|
|
|
{
|
|
|
data.ModifyByDisplayer = user.UserName;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
public static string SaveResultFromTesetItem(MySqlConnection connection, string currentUserId, ItemtypeEntity send)
|
|
|
{
|
|
|
lock (lockobj)
|
|
|
{
|
|
|
MySqlParameter paramRecId = new MySqlParameter("@RecId", MySqlDbType.VarChar) { Value = send.RecId };
|
|
|
MySqlParameter paramTypeName = new MySqlParameter("@TypeName", MySqlDbType.VarChar) { Value = send.TypeName };
|
|
|
MySqlParameter paramTypeCode = new MySqlParameter("@TypeCode", MySqlDbType.VarChar) { Value = send.TypeCode };
|
|
|
MySqlParameter paramCreateBy = new MySqlParameter("@CreateBy", MySqlDbType.VarChar) { Value = currentUserId };
|
|
|
MySqlParameter paramCreateTime = new MySqlParameter("@CreateTime", MySqlDbType.DateTime) { Value = send.CreateTime == null ? System.DateTime.Now : send.CreateTime };
|
|
|
MySqlParameter paramModifyBy = new MySqlParameter("@ModifyBy", MySqlDbType.VarChar) { Value = currentUserId };
|
|
|
MySqlParameter paramModifyTime = new MySqlParameter("@ModifyTime", MySqlDbType.DateTime) { Value = send.ModifyTime == null ? System.DateTime.Now : send.ModifyTime };
|
|
|
MySqlParameter paramIsActive = new MySqlParameter("@IsActive", MySqlDbType.Int16) { Value = 1 };
|
|
|
|
|
|
DataTable dt = MysqlHelper.ExecuteDataTable(connection, "select RecId from ItemType where RecId = @RecId and IsActive > 0 limit 1", paramRecId);
|
|
|
var opertype = "";
|
|
|
if (dt.Rows.Count == 0)
|
|
|
{
|
|
|
opertype = ((int)AppEnum.OperType.New).ToString();
|
|
|
if (string.IsNullOrEmpty(send.RecId))
|
|
|
{
|
|
|
paramRecId.Value = Guid.NewGuid().ToString();
|
|
|
}
|
|
|
paramIsActive.Value = 1;
|
|
|
MysqlHelper.ExecuteNonQuery(connection, "insert into ItemType (RecId,TypeName,TypeCode,CreateBy,CreateTime,ModifyBy,ModifyTime,IsActive) values (@RecId,@TypeName,@TypeCode,@CreateBy,@CreateTime,@ModifyBy,@ModifyTime,@IsActive)",
|
|
|
new MySqlParameter[] { paramRecId, paramTypeName, paramTypeCode, paramCreateBy, paramCreateTime, paramModifyBy, paramModifyTime, paramIsActive });
|
|
|
}
|
|
|
//更新池,由于事物可能未提交,先不更新缓存,在提交后在更新缓存
|
|
|
ItemtypePool.Update(LoadResult(connection, paramRecId.Value.ToString()));
|
|
|
//save log
|
|
|
InsertToLog(connection, paramRecId.Value.ToString(), currentUserId, opertype);
|
|
|
return paramRecId.Value.ToString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|