/// <summary> /// 更新盘点库存 /// </summary> /// <param name="updateAgrs">盘点参数</param> /// <returns></returns> public bool UpdateStockTaking(UpdateStockTakingAgrs updateAgrs) { string UpdateCommand = "UPDATE [Stocktaking] SET [InventoryQty]=@InventoryQty,[ActualQty]=@ActualQty ,[DifferenceQty]=@DifferenceQty,[DiffAmount]=@DiffAmount,[StockDate]=@StockDate WHERE [ID]=@ID"; IList <DbParameter> parms = new List <DbParameter>(); parms.Add(new SqlParameter("@ID", updateAgrs.StockTakingID)); parms.Add(new SqlParameter("@InventoryQty", updateAgrs.InventoryQty)); parms.Add(new SqlParameter("@ActualQty", updateAgrs.InventoryQty)); parms.Add(new SqlParameter("@DifferenceQty", updateAgrs.DifferenceQty)); parms.Add(new SqlParameter("@DiffAmount", updateAgrs.DiffAmount)); parms.Add(new SqlParameter("@StockDate", DateTime.Now)); try { var result = db.ExecuteNonQuery(CommandType.Text, UpdateCommand, parms.ToArray()); if (result > 0) { return(true); } else { return(false); } } catch (Exception exc) { throw exc; return(false); } }
/// <summary> /// 保存盘点数据 /// </summary> private void SaveStockTaking(DataRow datarow) { if (datarow != null) { UpdateStockTakingAgrs agrs = new UpdateStockTakingAgrs(); agrs.StockTakingID = new Guid(datarow["ID"].ToString()); agrs.InventoryQty = int.Parse(datarow["InventoryQty"].ToString()); agrs.DifferenceQty = int.Parse(datarow["DifferenceQty"].ToString()); agrs.DiffAmount = int.Parse(datarow["DiffAmount"].ToString()); if (stock.UpdateStockTaking(agrs)) { this.BindStockTaking(); } } }