private void btnPrintBill_Click(object sender, EventArgs e) { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreateDate = txtCreateDate.DateTime; headInfo.Creator = this.txtCreator.Text; headInfo.HandNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.Text; headInfo.Note = this.txtNote.Text; headInfo.OperationType = "入库"; headInfo.WareHouse = this.txtWareHouse.Text; headInfo.CreateYear = DateTime.Now.Year; headInfo.CreateMonth = DateTime.Now.Month; List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>(); for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { StockInfo stockInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.Text); if (stockInfo != null) { int oldQuantity = stockInfo.StockQuantity; decimal oldPrice = 0M; ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo); if (info != null) { oldPrice = info.Price; decimal newPrice = ((Convert.ToInt32(detailInfo.Quantity) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Quantity) + oldQuantity); detailInfo.Price = newPrice; } } detailList.Add(detailInfo); } } ReportViewerDialog dlg = new ReportViewerDialog(); dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>() { headInfo }); dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList); dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc"; dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit); dlg.ShowDialog(); }
private void btnPrintBill_Click(object sender, EventArgs e) { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreatorTime = txtCreateDate.DateTime; headInfo.CreatorId = this.txtCreator.Text.ToInt32(); headInfo.OrderNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.Text; headInfo.Remark = this.txtNote.Text; headInfo.OperationType = (short)OperationType.新增; headInfo.WareHouseId = this.txtWareHouse.GetComboBoxStrValue().ToInt32(); headInfo.CreatorYear = DateTimeHelper.GetServerDateTime2().Year; headInfo.CreatorMonth = (short)DateTimeHelper.GetServerDateTime2().Month; List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>(); for (int i = 0; i < this.lvwDetail.gridView1.RowCount; i++) { PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo; if (detailInfo != null) { WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(detailInfo.ItemNo, this.txtWareHouse.GetComboBoxStrValue()); if (wareInfo != null) { int oldQuantity = wareInfo.Amount; double oldPrice = 0; ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindByItemNo(detailInfo.ItemNo); if (info != null) { oldPrice = info.Price; double newPrice = ((Convert.ToInt32(detailInfo.Amount) * detailInfo.Price) + (oldQuantity * oldPrice)) / (Convert.ToInt32(detailInfo.Amount) + oldQuantity); detailInfo.Price = newPrice; } } detailList.Add(detailInfo); } } ReportViewerDialog dlg = new ReportViewerDialog(); dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>() { headInfo }); dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList); dlg.ReportFilePath = "Report/WHC.WareHouseMis.PurchaseReport.rdlc"; dlg.Parameters.Add("CompanyName", this.AppInfo.AppUnit); dlg.ShowDialog(); }
private void btnPrintBill_Click(object sender, EventArgs e) { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreateDate = txtCreateDate.DateTime; headInfo.Creator = this.txtCreator.Text; headInfo.HandNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.Text; headInfo.Note = this.txtNote.Text; headInfo.OperationType = "出库"; headInfo.WareHouse = this.txtWareHouse.Text; headInfo.CostCenter = this.txtCostCenter.Text; headInfo.CreateYear = DateTime.Now.Year; headInfo.CreateMonth = DateTime.Now.Month; headInfo.PickingPeople = this.txtPickingPeople.Text;//领料人 List <PurchaseDetailInfo> detailList = new List <PurchaseDetailInfo>(); for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { detailList.Add(detailInfo); } } //WHC.WareHouseMis.TakeOutReport.rdlc ReportViewerDialog dlg = new ReportViewerDialog(); dlg.DataSourceDict.Add("PurchaseHeaderInfo", new List <PurchaseHeaderInfo>() { headInfo }); dlg.DataSourceDict.Add("PurchaseDetailInfo", detailList); dlg.ReportFilePath = "Report/WHC.WareHouseMis.TakeOutReport.rdlc"; dlg.Parameters.Add("CompanyName", Portal.gc.gAppUnit); dlg.ShowDialog(); }
private void btnOK_Click(object sender, EventArgs e) { #region 验证输入 //检查是否可以入库出库 for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo); if (!isInit) { if (MessageDxUtil.ShowYesNoAndTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,您是否要进行期初建账,初始化库存为0?\r\n按【是】初始化库房并继续,按【否】退出。", detailInfo.ItemNo, this.txtWareHouse.Text)) == DialogResult.No) { return; } else { ItemDetailInfo itemInfo = new ItemDetailInfo(); itemInfo.ItemNo = detailInfo.ItemNo; itemInfo.ItemName = detailInfo.ItemName; itemInfo.ItemBigType = detailInfo.ItemBigType; itemInfo.ItemType = detailInfo.ItemType; BLLFactory <Stock> .Instance.InitStockQuantity(itemInfo, 0, this.txtWareHouse.Text); } } } } if (this.txtHandNo.Text.Trim() == "") { MessageDxUtil.ShowTips("货单编号不能为空"); this.txtHandNo.Focus(); return; } else if (this.txtManufacture.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择供应商"); this.txtManufacture.Focus(); return; } else if (this.txtWareHouse.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择仓库"); this.txtWareHouse.Focus(); return; } else if (this.lvwDetail.Items.Count == 0) { MessageDxUtil.ShowTips("请添加商品"); return; } else if (this.txtCreator.Text.Length == 0) { MessageDxUtil.ShowTips("请选择经手人"); this.txtCreator.Focus(); return; } #endregion try { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreateDate = txtCreateDate.DateTime; headInfo.Creator = this.txtCreator.Text; headInfo.HandNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.Text; headInfo.Note = this.txtNote.Text; headInfo.OperationType = "入库"; headInfo.WareHouse = this.txtWareHouse.Text; headInfo.CreateYear = DateTime.Now.Year; headInfo.CreateMonth = DateTime.Now.Month; int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo); if (headId > 0) { for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { detailInfo.PurchaseHead_ID = headId; BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo); AddStockQuantity(detailInfo);//增加库存 } } MessageDxUtil.ShowTips("保存成功"); ClearContent(); //超库存预警检查 bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(this.txtWareHouse.Text); if (highWarning) { string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text); WareHouseHelper.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message); } } else { MessageDxUtil.ShowError("保存失败"); } } catch (Exception ex) { LogTextHelper.Error(ex); MessageDxUtil.ShowError(ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { #region 验证输入 //检查是否可以入库出库 for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++) { PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo; if (detailInfo != null) { bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.GetComboBoxStrValue(), detailInfo.ItemNo); if (!isInit) { if (MessageDxUtil.ShowYesNoAndTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,您是否要进行期初建账,初始化库存为0?\r\n按【是】初始化库房并继续,按【否】退出。", detailInfo.ItemNo, this.txtWareHouse.Text)) == DialogResult.No) { return; } else { ItemDetailInfo itemInfo = new ItemDetailInfo(); itemInfo.ItemNo = detailInfo.ItemNo; itemInfo.Name = detailInfo.Name; itemInfo.ItemBigtype = detailInfo.ItemBigtype; itemInfo.ItemType = detailInfo.ItemType; BLLFactory <Stock> .Instance.InitStockQuantity(itemInfo, 0, this.txtWareHouse.GetComboBoxStrValue().ToInt32()); } } } } if (this.txtHandNo.Text.Trim() == "") { MessageDxUtil.ShowTips("货单编号不能为空"); this.txtHandNo.Focus(); return; } else if (this.txtManufacture.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择供应商"); this.txtManufacture.Focus(); return; } else if (this.txtWareHouse.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择仓库"); this.txtWareHouse.Focus(); return; } else if (this.lvwDetail.gridView1.RowCount == 0) { MessageDxUtil.ShowTips("请添加商品"); return; } else if (this.txtCreator.Text.Length == 0) { MessageDxUtil.ShowTips("请选择经手人"); this.txtCreator.Focus(); return; } #endregion try { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreatorTime = txtCreateDate.DateTime; headInfo.CreatorId = this.txtCreator.Text.ToInt32(); headInfo.OrderNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.GetComboBoxStrValue(); headInfo.Remark = this.txtNote.Text; headInfo.OperationType = (short)OperationType.新增;// 入库 headInfo.WareHouseId = this.txtWareHouse.GetComboBoxStrValue().ToInt32(); headInfo.CreatorYear = DateTimeHelper.GetServerDateTime2().Year; headInfo.CreatorMonth = (short)DateTimeHelper.GetServerDateTime2().Month; int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo); if (headId > 0) { for (int i = 0; i < this.lvwDetail.gridView1.DataRowCount; i++) { PurchaseDetailInfo detailInfo = lvwDetail.gridView1.GetRow(i) as PurchaseDetailInfo; if (detailInfo != null) { detailInfo.PurchaseHeadId = headId; BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo); AddStockQuantity(detailInfo);//增加库存 } } MessageDxUtil.ShowTips("保存成功"); ClearContent(); //超库存预警检查 bool highWarning = BLLFactory <Stock> .Instance.CheckStockHighWarning(this.txtWareHouse.GetComboBoxStrValue()); if (highWarning) { string message = string.Format("{0} 库存量已经高过超预警库存量\r\n请注意减少库存积压", this.txtWareHouse.Text); Portal.gc.Notify(string.Format("{0} 超库存预警", this.txtWareHouse.Text), message); } } else { MessageDxUtil.ShowError("保存失败"); } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmPurchase)); MessageDxUtil.ShowError(ex.Message); } }
private void btnOK_Click(object sender, EventArgs e) { #region 验证输入 //检查是否可以入库出库 for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtWareHouse.Text, detailInfo.ItemNo); if (!isInit) { MessageDxUtil.ShowTips(string.Format("备件项目【{0}】在库房【{1}】还没有期初建账,请先在备件信息管理中进行期初建账。", detailInfo.ItemNo, this.txtWareHouse.Text)); return; } } } if (this.txtHandNo.Text.Trim() == "") { MessageDxUtil.ShowTips("货单编号不能为空"); this.txtHandNo.Focus(); return; } else if (this.txtManufacture.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择供应商"); this.txtManufacture.Focus(); return; } else if (this.txtCostCenter.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择成本中心"); this.txtCostCenter.Focus(); return; } else if (this.txtWareHouse.Text.Trim() == "") { MessageDxUtil.ShowTips("请选择仓库"); this.txtWareHouse.Focus(); return; } else if (this.lvwDetail.Items.Count == 0) { MessageDxUtil.ShowTips("请添加商品"); return; } else if (this.txtCreator.Text.Length == 0) { MessageDxUtil.ShowTips("请选择经手人"); this.txtCreator.Focus(); return; } else if (this.txtPickingPeople.Text.Length == 0) { MessageDxUtil.ShowTips("请输入领料人"); this.txtPickingPeople.Focus(); return; } #endregion try { PurchaseHeaderInfo headInfo = new PurchaseHeaderInfo(); headInfo.CreateDate = txtCreateDate.DateTime; headInfo.Creator = this.txtCreator.Text; headInfo.HandNo = this.txtHandNo.Text; headInfo.Manufacture = this.txtManufacture.Text; headInfo.Note = this.txtNote.Text; headInfo.OperationType = "出库"; headInfo.WareHouse = this.txtWareHouse.Text; headInfo.CostCenter = this.txtCostCenter.Text; headInfo.CreateYear = DateTime.Now.Year; headInfo.CreateMonth = DateTime.Now.Month; //领料人 headInfo.PickingPeople = this.txtPickingPeople.Text; int headId = BLLFactory <PurchaseHeader> .Instance.Insert2(headInfo); if (headId > 0) { for (int i = 0; i < this.lvwDetail.Items.Count; i++) { PurchaseDetailInfo detailInfo = this.lvwDetail.Items[i].Tag as PurchaseDetailInfo; if (detailInfo != null) { detailInfo.PurchaseHead_ID = headId; BLLFactory <PurchaseDetail> .Instance.Insert(detailInfo); AddStockQuantity(detailInfo);//增加库存 } } MessageDxUtil.ShowTips("保存成功"); ClearContent(); //低库存预警检查 bool lowWarning = BLLFactory <Stock> .Instance.CheckStockLowWarning(this.txtWareHouse.Text); if (lowWarning) { string message = string.Format("{0} 库存已经处于低库存预警状态\r\n请及时补充库存", this.txtWareHouse.Text); Portal.gc.Notify(string.Format("{0} 低库存预警", this.txtWareHouse.Text), message); } } else { MessageDxUtil.ShowError("保存失败"); } } catch (Exception ex) { LogTextHelper.Error(ex); MessageDxUtil.ShowError(ex.Message); } }