/// <summary> /// —оздает форму дл¤ редактировани¤/добавлени¤ <see cref="StockDetailInfo"/> /// </summary> /// <param name="stockDetailInfo">StockDetailInfo</param> public StockDetailInfoForm(StockDetailInfo stockDetailInfo) { currentStockDetailInfo = stockDetailInfo; mode = ScreenMode.Edit; InitializeComponent(); UpdateInformation(); }
private void stockDetailInfo_Reloading(object sender, CancelEventArgs e) { if (!InvokeRequired) { stockDetailInfoBeforeReload = (StockDetailInfo)sender; } }
/// <summary> /// —оздает форму дл¤ редактировани¤/добавлени¤ <see cref="StockDetailInfo"/> /// </summary> /// <param name="parentStore">—клад, куда добавл¤етс¤ StockDetailInfo</param> public StockDetailInfoForm(Store parentStore) { this.parentStore = parentStore; currentStockDetailInfo = new StockDetailInfo(); mode = ScreenMode.Add; InitializeComponent(); UpdateInformation(); }
/// <summary> /// 保存库存明细(加库存) /// </summary> /// <param name="errText"></param> /// <param name="warehouseId"></param> /// <param name="commodityId"></param> /// <param name="count"></param> /// <param name="remark"></param> /// <returns></returns> private int SaveStockDetailInfo(out string errText, Guid warehouseId, Guid commodityId, int count, string remark) { errText = ""; if (warehouseId == Guid.Empty || commodityId == Guid.Empty || count == 0) { errText = "无效信息!"; return(0); } var list = _stockDetailInfoDal.GetEntityList(out errText, warehouseId, commodityId); int i = 0; if (list == null || list.Count == 0) { StockDetailInfo info = new StockDetailInfo() { CommodityId = commodityId, WarehouseId = warehouseId, Count = count, Remark = remark }; i = _stockDetailInfoDal.InsertEntity(out errText, info); } else { var info2 = list[0]; info2.Count += count; i = _stockDetailInfoDal.UpdateEntity(out errText, info2); } if (i <= 0) { return(i); } var stock = _stockInfoDal.GetEntityList(out errText, warehouseId, true); if (stock == null || stock.Count == 0) { return(0); } var info3 = stock[0]; info3.Count += count; i = _stockInfoDal.UpdateEntity(out errText, info3); return(i); }
/// <summary> /// 新增一条仓库信息 /// </summary> /// <param name="errText"></param> /// <param name="StockInfo"></param> /// <returns></returns> public int InsertEntity(out string errText, StockDetailInfo stockInfo) { errText = ""; try { using (SqlConnection conn = new SqlConnection(SQL_CON)) { var sql = "insert into StockDetail (WarehouseId,CommodityId,Count,Remark) values(@WarehouseId,@CommodityId,@Count,@Remark)"; conn.Open(); SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@WarehouseId", stockInfo.WarehouseId); cmd.Parameters.AddWithValue("@CommodityId", stockInfo.CommodityId); cmd.Parameters.AddWithValue("@Count", stockInfo.Count); cmd.Parameters.AddWithValue("@Remark", stockInfo.Remark); var i = cmd.ExecuteNonQuery(); conn.Close(); return(i); } } catch (Exception ex) { errText = ex.Message; return(0); } }
/// <summary> /// 修改仓库列表 /// </summary> /// <param name="errText"></param> /// <param name="StockInfo"></param> /// <returns></returns> public int UpdateEntity(out string errText, StockDetailInfo stockInfo) { errText = ""; try { using (SqlConnection conn = new SqlConnection(SQL_CON)) { conn.Open(); var sql = "update StockDetail set WarehouseId=@WarehouseId,Count=@Count,Remark=@Remark where CommodityId=@CommodityId"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@WarehouseId", stockInfo.WarehouseId); cmd.Parameters.AddWithValue("@CommodityId", stockInfo.CommodityId); cmd.Parameters.AddWithValue("@Count", stockInfo.Count); cmd.Parameters.AddWithValue("@Remark", stockInfo.Remark); var i = cmd.ExecuteNonQuery(); conn.Close(); return(i); } } catch (Exception ex) { errText = ex.Message; return(0); } }
private void stockDetailInfo_Saving(object sender, CancelEventArgs e) { stockDetailInfoBeforeSave = (StockDetailInfo)sender; }