private void menu_SetAlarm_Click(object sender, EventArgs e) { int[] rowSelected = this.winGridView1.GridView1.GetSelectedRows(); if (rowSelected == null) { return; } foreach (int iRow in rowSelected) { string ID = this.winGridView1.gridView1.GetRowCellDisplayText(iRow, "ID"); if (!string.IsNullOrEmpty(ID)) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { FrmStockAlert dlg = new FrmStockAlert(); dlg.ID = ID; dlg.WareHouse = info.WareHouseId.ToString(); dlg.ItemNo = info.ItemNo; dlg.ItemName = info.Name; if (DialogResult.OK == dlg.ShowDialog()) { BindData(); } } } break; } }
private void menu_ModifyStock_Click(object sender, EventArgs e) { int[] rowSelected = this.winGridView1.GridView1.GetSelectedRows(); if (rowSelected == null) { return; } foreach (int iRow in rowSelected) { string ID = this.winGridView1.gridView1.GetRowCellDisplayText(iRow, "ID"); if (!string.IsNullOrEmpty(ID)) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { FrmEditStock dlg = new FrmEditStock(); dlg.ID = ID; dlg.WareHouse = info.WareHouseId.ToString(); dlg.InitFunction(this.LoginUserInfo, this.FunctionDict);//初始化权限控制信息 if (DialogResult.OK == dlg.ShowDialog()) { BindData(); } } } break; } }
private void btnOK_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ID)) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { SetInfo(info); try { bool succeed = BLLFactory <Stock> .Instance.Update(info, info.Id); if (succeed) { MessageDxUtil.ShowTips("保存成功"); this.DialogResult = DialogResult.OK; } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmStockAlert)); MessageDxUtil.ShowError(ex.Message); } } } }
private void SetInfo(WareInfo info) { //info.ItemNo = txtItemNo.Text; info.Amount = Convert.ToInt32(txtStockQuantity.Text); info.Balance = Convert.ToDouble(txtStockMoney.Text); info.LowAmountWarning = Convert.ToInt32(txtLowWarning.Text); info.HighAmountWarning = Convert.ToInt32(txtHighWarning.Text); info.Remark = txtNote.Text; }
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(); }
/// <summary> /// Показать панель информации. /// </summary> private void ShowInfoPanel() { WareInfo info = task.GetInfo(dataGrid1.CurrentRowIndex); lName.Text = info.Name; lCode.Text = info.Code; lPlace.Text = info.Place + "/" + info.Adr; if (task.Kind == TaskKind.CheckOut) { planValue.Text = info.PlanOut.ToString(); } panel2.Location = new Point(0, 38); }
private void FrmStockAlert_Load(object sender, EventArgs e) { //this.btnOK.Enabled = HasFunction("Stock/Setting"); if (!string.IsNullOrEmpty(ID)) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { txtLowWarning.Text = info.LowAmountWarning.ToString(); txtHighWarning.Text = info.HighAmountWarning.ToString(); } } }
/// <summary> /// 绑定数据到界面上的分页控件 /// </summary> private void BindData() { this.winGridViewPager1.DisplayColumns = "ID,ItemNo,ItemName,Manufacture,MapNo,Specification,Material,ItemBigType,ItemType,Unit,Price,Source,StoragePos,UsagePos,StockQuantity,AlarmQuantity,Note,Dept,WareHouse"; this.winGridViewPager1.ColumnNameAlias = BLLFactory <ItemDetail> .Instance.GetColumnNameAlias(); string where = GetConditionSql(); List <ItemDetailInfo> list = BLLFactory <ItemDetail> .Instance.FindWithPager(where, this.winGridViewPager1.PagerInfo); string tableColumns = "ID|int,ItemNo,ItemName,StockQuantity|int,Manufacture,MapNo,Specification,Material,ItemBigType,ItemType,Unit,Price|decimal,Source,StoragePos,UsagePos,Note,WareHouse,Dept"; DataTable dt = DataTableHelper.CreateTable(tableColumns); DataRow dr = null; foreach (ItemDetailInfo info in list) { dr = dt.NewRow(); /*dr["ID"] = info.ID; * dr["ItemBigType"] = info.ItemBigType; * dr["ItemName"] = info.ItemName; * dr["ItemNo"] = info.ItemNo; * dr["ItemType"] = info.ItemType; * dr["Manufacture"] = info.Manufacture; * dr["MapNo"] = info.MapNo; * dr["Material"] = info.Material; * dr["Note"] = info.Note; * dr["Price"] = info.Price; * dr["Source"] = info.Source; * dr["Specification"] = info.Specification; * dr["StoragePos"] = info.StoragePos; * dr["Unit"] = info.Unit; * dr["UsagePos"] = info.UsagePos; * dr["WareHouse"] = info.WareHouse; * dr["Dept"] = info.Dept;*/ WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(info.ItemNo); int quantity = 0; if (wareInfo != null) { quantity = wareInfo.Amount; } dr["StockQuantity"] = quantity; dt.Rows.Add(dr); } this.winGridViewPager1.DataSource = dt.DefaultView;//new WHC.Pager.WinControl.SortableBindingList<ItemDetailInfo>(list); this.winGridViewPager1.PrintTitle = this.AppInfo.AppUnit + " -- " + "备件信息报表"; }
private void FrmEditProduct_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(ID)) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { try { ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo); if (detailInfo != null) { txtItemNo.Text = info.ItemNo; txtItemName.Text = info.Name; txtStockQuantity.Text = info.Amount.ToString(); txtStockMoney.Text = (info.Amount * detailInfo.Price).ToString("f2"); txtHighWarning.Text = info.HighAmountWarning.ToString(); txtLowWarning.Text = info.LowAmountWarning.ToString(); txtNote.Text = info.Remark; txtItemType.Text = info.ItemType.ToString(); txtBigType.Text = info.ItemBigtype.ToString(); txtManufacturer.Text = detailInfo.Manufacture; txtMapNo.Text = detailInfo.MapNo; txtSpecification.Text = detailInfo.Specification; txtWareHouse.Text = info.WareHouseId.ToString(); } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditStock)); MessageDxUtil.ShowError(ex.Message); return; } } this.btnOK.Enabled = HasFunction("Stock/Modify"); } else { this.btnOK.Enabled = HasFunction("Stock/Modify"); } }
private void AddStockQuantity(PurchaseDetailInfo detailInfo) { //先更新库存的价格为加权价格 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); info.Price = (double)newPrice; BLLFactory <ItemDetail> .Instance.Update(info, info.Id); } } BLLFactory <Stock> .Instance.AddStockQuantiy(detailInfo.ItemNo, detailInfo.Name, Convert.ToInt32(detailInfo.Amount), this.txtWareHouse.GetComboBoxStrValue().ToInt32()); }
private void txtStockQuantity_Validated(object sender, EventArgs e) { WareInfo info = BLLFactory <Stock> .Instance.FindById(ID); if (info != null) { try { ItemDetailInfo detailInfo = BLLFactory <ItemDetail> .Instance.FindByItemNo(info.ItemNo); if (detailInfo != null) { this.txtStockMoney.Text = (Convert.ToInt32(this.txtStockQuantity.Text) * detailInfo.Price).ToString("f2"); Application.DoEvents(); Thread.Sleep(10); } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditStock)); MessageDxUtil.ShowError(ex.Message); } } }
/// <summary> /// 写入库存信息 /// </summary> private int InsertStockData(Dictionary <string, string> WareHouseDict) { int intOk = 0; int intFail = 0; bool isFirstError = true; if (myDs != null && myDs.Tables[0].Rows.Count > 0) { double step = 50 * (1.0 / myDs.Tables[0].Rows.Count); DataTable dt = myDs.Tables[0]; try { int i = 1; foreach (DataRow dr in dt.Rows) { #region 单条记录操作代码 if (dr[0].ToString() == "") { continue; } string itemNo = dr["备件编号(mm码)"].ToString(); string wareHouseKey = dr["库房编号"].ToString(); if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(wareHouseKey)) { continue; } try { string wareHouse = WareHouseDict[wareHouseKey]; WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(itemNo, wareHouse); if (wareInfo != null) { #region 更新 /*stockInfo.ItemNo = itemNo; * stockInfo.WareHouse = wareHouse; * stockInfo.ItemName = dr["备件名称"].ToString(); * stockInfo.ItemBigType = dr["备件属类"].ToString(); * stockInfo.ItemType = dr["备件类别"].ToString(); * int quantity = 0; * try * { * quantity = Convert.ToInt32(dr["库存量"].ToString()); * } * catch (Exception ex){ * LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); * MessageDxUtil.ShowError(ex.Message); * } * stockInfo.StockQuantity = quantity; * * decimal price = 0M; * try * { * price = Convert.ToDecimal(dr["单价(元)"].ToString()); * } * catch (Exception ex){ * LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); * MessageDxUtil.ShowError(ex.Message); * } * * bool success = BLLFactory<Stock>.Instance.Update(stockInfo, stockInfo.ID.ToString()); * if (success) * { * intOk++; * }*/ #endregion } else { #region 添加 /*stockInfo = new StockInfo(); * stockInfo.ItemNo = itemNo; * stockInfo.WareHouse = wareHouse; * stockInfo.ItemName = dr["备件名称"].ToString(); * stockInfo.ItemBigType = dr["备件属类"].ToString(); * stockInfo.ItemType = dr["备件类别"].ToString(); * * int quantity = 0; * try * { * quantity = Convert.ToInt32(dr["库存量"].ToString()); * } * catch (Exception ex){ * LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); * MessageDxUtil.ShowError(ex.Message); * } * stockInfo.StockQuantity = quantity; * * decimal price = 0M; * try * { * price = Convert.ToDecimal(dr["单价(元)"].ToString()); * } * catch (Exception ex){ * LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); * MessageDxUtil.ShowError(ex.Message); * } * * bool success = BLLFactory<Stock>.Instance.Insert(stockInfo); * if (success) * { * intOk++; * }*/ #endregion } } catch (Exception ex) { intFail++; LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); if (isFirstError) { MessageDxUtil.ShowError(ex.Message); isFirstError = false; } } #endregion int currentStep = Convert.ToInt32(step * i); worker.ReportProgress(50 + currentStep);//50为前面部分进度 i++; } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmImportItemStock)); MessageDxUtil.ShowError(ex.ToString()); } } return(intOk); }
private void SetInfo(WareInfo info) { info.LowAmountWarning = Convert.ToInt32(txtLowWarning.Text); info.HighAmountWarning = Convert.ToInt32(txtHighWarning.Text); }
/// <summary> /// 编辑状态下的数据保存 /// </summary> /// <returns></returns> public override bool SaveUpdated() { bool exist = BLLFactory <ItemDetail> .Instance.CheckExist(this.txtItemNo.Text, Id); if (exist) { MessageDxUtil.ShowTips("指定的备件编号已经存在,不能重复添加,请修改"); return(false); } ItemDetailInfo info = BLLFactory <ItemDetail> .Instance.FindById(Id); if (info != null) { if (txtBelongWareHouse.Text != txtBelongWareHouse.Tag.ToString()) { if (MessageDxUtil.ShowYesNoAndWarning("您的备件所属库存发生了修改,是否继续更改库房数据") == DialogResult.No) { return(false); } } SetInfo(info); try { #region 更新数据 bool succeed = BLLFactory <ItemDetail> .Instance.Update(info, info.Id); if (succeed) { try { WareInfo wareInfo = BLLFactory <Stock> .Instance.FindByItemNo(this.txtItemNo.Text, this.txtBelongWareHouse.Tag.ToString()); if (wareInfo != null) { //wareInfo.wareInfo = txtBelongWareHouse.Text; BLLFactory <Stock> .Instance.Update(wareInfo, wareInfo.Id); } //不管是更新还是新增,如果对应的备件编码在库房没有初始化,初始化之 bool isInit = BLLFactory <Stock> .Instance.CheckIsInitedWareHouse(this.txtBelongWareHouse.Text, this.txtItemNo.Text); if (!isInit) { BLLFactory <Stock> .Instance.InitStockQuantity(info, 0, this.txtBelongWareHouse.Text.ToInt32()); } } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail)); MessageDxUtil.ShowError("初始化库存为0失败:" + ex.Message); } //MessageDxUtil.ShowTips("备件数据保存成功"); //this.DialogResult = DialogResult.OK; return(true); } #endregion } catch (Exception ex) { LogHelper.WriteLog(LogLevel.LOG_LEVEL_CRIT, ex, typeof(FrmEditItemDetail)); MessageDxUtil.ShowError(ex.Message); } } return(false); }