示例#1
0
 public ActionResult Edit(InventoryInfo inventoryInfo)
 {
     if (inventoryInfo.ID == 0)
     {
         return Insert(inventoryInfo);
     }
     else
     {
         return Update(inventoryInfo);
     }
 }
示例#2
0
 /// <summary>
 /// 设置SQL参数表
 /// </summary>
 /// <param name="Inventory">Inventory对象</param>
 /// <returns>Inventory参数数组</returns>
 private SqlParameter[] Set_Inventory_Parameters(InventoryInfo inventoryInfo)
 {
     SqlParameter[] paramArray = new SqlParameter[] {new SqlParameter("@ID",inventoryInfo.ID),
                                                         new SqlParameter("@ItemID",inventoryInfo.ItemID),
                                                         new SqlParameter("@Qty",inventoryInfo.Qty),
                                                         new SqlParameter("@OrderQty",inventoryInfo.OrderQty),
                                                         new SqlParameter("@CreatedBy",string.IsNullOrEmpty(inventoryInfo.CreatedBy)?"":inventoryInfo.CreatedBy),
                                                         new SqlParameter("@UpdatedBy",string.IsNullOrEmpty(inventoryInfo.UpdatedBy)?"":inventoryInfo.UpdatedBy)
                                                     };
     return paramArray;
 }
示例#3
0
 /// <summary>
 /// 初始化InventoryInfo
 /// </summary>
 private InventoryInfo InitInventoryInfoByDataReader(InventoryInfo inventoryInfo, IDataReader reader)
 {
     inventoryInfo = new InventoryInfo(reader["ID"].ToString() != "" ? Int32.Parse(reader["ID"].ToString()) : 0,
     reader["ItemID"].ToString() != "" ? Int32.Parse(reader["ItemID"].ToString()) : 0,
     reader["Qty"].ToString() != "" ? Int32.Parse(reader["Qty"].ToString()) : 0,
     reader["OrderQty"].ToString() != "" ? Int32.Parse(reader["OrderQty"].ToString()) : 0,
     reader["TS"],
     reader["CreatedBy"].ToString(),
     reader["CreatedDate"].ToString() != "" ? DateTime.Parse(reader["CreatedDate"].ToString()) : new DateTime(),
     reader["UpdatedBy"].ToString(),
     reader["UpdatedDate"].ToString() != "" ? DateTime.Parse(reader["UpdatedDate"].ToString()) : new DateTime());
     return inventoryInfo;
 }
示例#4
0
 /// <summary>
 /// 更新一条Inventory记录
 /// </summary>
 /// <param name="db">DataBase对象</param>
 /// <param name="tran">一个有效的DbTransaction</param>
 /// <param name="inventory">Inventory对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateInventory(Database db, DbTransaction tran, InventoryInfo inventoryInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_Inventory_Parameters(inventoryInfo);
     if (paras != null)
     {
         result += DBHelper.ExecuteNonQuery(db, tran, CommandType.Text, SQL_UPDATE_INVENTORY, paras);
     }
     return result;
 }
示例#5
0
 /// <summary>
 /// 新增一条Inventory记录
 /// </summary>
 /// <param name="inventory">Inventory对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertInventory(InventoryInfo inventoryInfo)
 {
     int result = 0;
     SqlParameter[] paras = Set_Inventory_Parameters(inventoryInfo);
     if (paras != null)
     {
         result = DBHelper.ExecuteNonQuery(CommandType.Text, SQL_INSERT_INVENTORY, paras);
     }
     return result;
 }
示例#6
0
 /// <summary>
 /// 更新一条Inventory记录
 /// </summary>
 /// <param name="inventory">Inventory对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行更新对数据库影响的行数</returns>
 public int UpdateInventory(InventoryInfo inventoryInfo)
 {
     return inventoryDA.UpdateInventory(inventoryInfo);
 }
示例#7
0
 /// <summary>
 /// 新增一条Inventory记录
 /// </summary>
 /// <param name="inventory">Inventory对象</param>
 /// <param name="whLoginID">要查询的仓库的前缀</param>
 /// <returns>执行新增对数据库影响的行数</returns>
 public int InsertInventory(InventoryInfo inventoryInfo)
 {
     return inventoryDA.InsertInventory(inventoryInfo);
 }
示例#8
0
 public ActionResult Insert(InventoryInfo inventoryInfo)
 {
     try
     {
         inventoryInfo.CreatedDate = DateTime.Now;
         inventoryInfo.UpdatedDate = DateTime.Now;
         inventoryInfo.CreatedBy = CurrentUserInfo.UserCode;
         inventoryInfo.UpdatedBy = CurrentUserInfo.UserCode;
         IInventoryService inventoryService = UnityHelper.UnityResolve<IInventoryService>();
         var data = inventoryService.InsertInventory(inventoryInfo);
         LogHelper.LogOperation(CurrentUserInfo.UserCode, string.Format("Insert InventoryInfo {0},{1}", LogHelper.ChangeEntityToLog(inventoryInfo), data));
         if (data > 0)
         {
             return Content("OK");
         }
         else
         {
             return Content("Failed");
         }
     }
     catch (BusinessException bex)
     {
         return Content(bex.Message);
     }
     catch (Exception ex)
     {
         LogHelper.LogError(ex, "");
         return Content(ex.Message);
     }
 }