/// <summary> /// 添加发票记录 /// </summary> /// <param name="invoiceTable">需要添加的发票信息数据</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>添加成功返回True,添加失败返回False</returns> public bool AddInvoiceInfo(DataTable invoiceTable, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; List <B_Invoice> lstInvoice = new List <B_Invoice>(); if (invoiceTable.Rows.Count == 0) { return(false); } else { for (int i = 0; i <= invoiceTable.Rows.Count - 1; i++) { B_Invoice lnqInvoice = new B_Invoice(); int intGoodsID = m_basicGoodsServer.GetGoodsID( invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); lnqInvoice.InvoiceCode = invoiceTable.Rows[i]["InvoiceCode"].ToString(); //发票号 lnqInvoice.GoodsID = intGoodsID; lnqInvoice.Provider = invoiceTable.Rows[i]["Provider"].ToString(); //供应商 lnqInvoice.Count = Convert.ToDecimal(invoiceTable.Rows[i]["Count"]); //数量 lnqInvoice.UnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); //单价 lnqInvoice.OrderNumber = invoiceTable.Rows[i]["OrderNumber"].ToString(); //订单号 lnqInvoice.Bill_ID = invoiceTable.Rows[i]["Bill_ID"].ToString(); //入库单号 lnqInvoice.BatchNo = invoiceTable.Rows[i]["BatchNo"].ToString(); //批次号 lnqInvoice.InvoiceType = Convert.ToInt32(invoiceTable.Rows[i]["InvoiceType"]); //发票类型 lnqInvoice.Date = ServerTime.Time; //日期 lnqInvoice.BeforTax = Convert.ToDecimal(invoiceTable.Rows[i]["BeforTax"]); //含税单价 lnqInvoice.TaxRat = Convert.ToInt32(invoiceTable.Rows[i]["TaxRat"]); //税率 lnqInvoice.Tax = Convert.ToDecimal(invoiceTable.Rows[i]["Tax"]); //税额 lnqInvoice.Price = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); //金额 lnqInvoice.PZH = invoiceTable.Rows[i]["PZH"].ToString(); //凭证号 lstInvoice.Add(lnqInvoice); } } dataContxt.B_Invoice.InsertAllOnSubmit(lstInvoice); dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { txtGoodsName.Text = dataGridView1.CurrentRow.Cells["OldGoodsName"].Value.ToString(); txtGoodsSpec.Text = dataGridView1.CurrentRow.Cells["OldSpec"].Value.ToString(); txtOldCode.Text = dataGridView1.CurrentRow.Cells["OldGoodsCode"].Value.ToString(); txtOldCode.Tag = m_basicGoodsServer.GetGoodsIDByGoodsCode(txtOldCode.Text, txtGoodsName.Text, txtGoodsSpec.Text).ToString(); textBox1.Text = dataGridView1.CurrentRow.Cells["NewSpec"].Value.ToString(); textBox2.Text = dataGridView1.CurrentRow.Cells["NewGoodsName"].Value.ToString(); txtNewCode.Text = dataGridView1.CurrentRow.Cells["NewGoodsCode"].Value.ToString(); txtNewCode.Tag = m_basicGoodsServer.GetGoodsIDByGoodsCode(txtNewCode.Text, textBox2.Text, textBox1.Text).ToString(); txtOldCvtID.Text = dataGridView1.CurrentRow.Cells["OldCvtID"].Value.ToString(); txtNewCvtID.Text = dataGridView1.CurrentRow.Cells["NewCvtID"].Value.ToString(); txtNewGoodsID.Text = dataGridView1.CurrentRow.Cells["NewGoods"].Value.ToString(); txtOldGoodsID.Text = dataGridView1.CurrentRow.Cells["OldGoods"].Value.ToString(); if (dataGridView1.CurrentRow.Cells["Count"].Value.ToString().Trim() == "" || dataGridView1.CurrentRow.Cells["Count"].Value.ToString() == null) { txtCount.Value = 0; } else { txtCount.Value = Convert.ToDecimal(dataGridView1.CurrentRow.Cells["Count"].Value.ToString()); } txtUnit.Text = dataGridView1.CurrentRow.Cells["Unit"].Value.ToString(); m_intOldGoodsID = m_basicGoodsServer.GetGoodsID(txtOldCode.Text, txtGoodsName.Text, txtOldCode.Text); }
private void btnAdd_Click(object sender, EventArgs e) { if (!CheckDataItem()) { return; } if (Convert.ToBoolean(BasicInfo.BaseSwitchInfo[(int)GlobalObject.CE_SwitchName.开启车间管理模块]) && txtBatchNo.Text.Trim().Length == 0) { btnBatchNo.Focus(); MessageDialog.ShowPromptMessage("批次号不能为空!"); return; } int planCode = m_planCostServer.GetGoodsID(txtCode.Text, txtName.Text, txtSpec.Text, "030502", (int)cmbUnit.SelectedValue, "自制件工装报检【" + m_billNo + "】自动生成", out m_strErr); S_FrockInDepotGoodsBill goods = new S_FrockInDepotGoodsBill(); View_F_GoodsPlanCost planCost = m_planCostServer.GetGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, out m_strErr); if (planCost == null) { return; } goods.Bill_ID = m_billNo; goods.BatchNo = txtBatchNo.Text; goods.Amount = numGoodsAmount.Value; goods.ShelfArea = ""; goods.ColumnNumber = ""; goods.LayerNumber = ""; goods.Remark = txtRemarkList.Text; goods.StorageID = UniversalFunction.GetStorageID(cmbStorage.Text); goods.GoodsID = planCost.序号; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["图号型号"].Value.ToString() == txtCode.Text && row.Cells["物品名称"].Value.ToString() == txtName.Text && row.Cells["规格"].Value.ToString() == txtSpec.Text) { MessageDialog.ShowPromptMessage("已经存在相同的物品信息列不允许再进行重复添加!"); return; } } if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResultGoods, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } RefreshDataGridView(m_queryResultGoods); PositioningRecord(planCost.图号型号, planCost.物品名称, planCost.规格); }
private void btnAdd_Click(object sender, EventArgs e) { if (CheckDate()) { int intGoodsID = m_basicGoodsServer.GetGoodsID(txtCode.Text.Trim(), txtName.Text.Trim(), txtSpec.Text.Trim(), txtMaterialType.Tag.ToString().Trim(), (int)cmbUnit.SelectedValue, "盘点单自动生成", out m_err); if (intGoodsID == 0) { MessageDialog.ShowPromptMessage(m_err); return; } txtZMJE.Tag = m_serverStore.GetGoodsAveragePrice(intGoodsID, txtBatchNo.Text); m_dtMx = (DataTable)dataGridView1.DataSource; DataRow dr = m_dtMx.NewRow(); dr["物品ID"] = intGoodsID; dr["图号型号"] = txtCode.Text; dr["物品名称"] = txtName.Text; dr["规格"] = txtSpec.Text; dr["批次号"] = txtBatchNo.Text; dr["账面数量"] = Convert.ToDecimal(txtZMSL.Text); dr["账面金额"] = Convert.ToDecimal(txtZMJE.Tag) * Convert.ToDecimal(txtZMSL.Text); dr["盘点数量"] = Convert.ToDecimal(txtPDSL.Text); dr["盘点金额"] = Convert.ToDecimal(txtZMJE.Tag) * Convert.ToDecimal(txtPDJE.Text); dr["盈亏数量"] = Convert.ToDecimal(dr["盘点数量"]) - Convert.ToDecimal(dr["账面数量"]); dr["盈亏金额"] = Convert.ToDecimal(dr["盘点金额"]) - Convert.ToDecimal(dr["账面金额"]); dr["供货单位"] = txtProvider.Text; dr["单位"] = cmbUnit.Text; dr["物品状态"] = cmbGoodsStatus.Text; dr["材料类别名称"] = txtMaterialType.Text; dr["货架"] = txtShelf.Text; dr["列"] = txtColumn.Text; dr["层"] = txtLayer.Text; dr["供方批次号"] = txtProviderBatchNo.Text; dr["备注"] = txtRemark.Text; dr["单位ID"] = Convert.ToInt32(cmbUnit.SelectedValue); dr["物品状态ID"] = Convert.ToInt32(cmbGoodsStatus.SelectedValue); dr["材料类别编码"] = txtMaterialType.Tag; dr["单据号"] = m_billInfo.DJH; m_dtMx.Rows.Add(dr); m_dtMx.AcceptChanges(); dataGridView1.DataSource = m_dtMx; } }
private void 条形码打印ToolStripMenuItem_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count < 1) { MessageDialog.ShowPromptMessage("请选择记录后再打印条形码"); return; } List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>(); for (int i = 0; i < dataGridView1.SelectedRows.Count; i++) { string goodsCode = dataGridView1.SelectedRows[i].Cells["图号型号"].Value.ToString(); string goodsName = dataGridView1.SelectedRows[i].Cells["物品名称"].Value.ToString(); string spec = dataGridView1.SelectedRows[i].Cells["规格"].Value.ToString(); string provider = dataGridView1.SelectedRows[i].Cells["供应商"].Value.ToString(); string batchCode = dataGridView1.SelectedRows[i].Cells["批次号"].Value.ToString(); string StorageID = dataGridView1.SelectedRows[i].Cells["库房编码"].Value.ToString(); IBarCodeServer server = ServerModuleFactory.GetServerModule <IBarCodeServer>(); View_S_InDepotGoodsBarCodeTable barcode = server.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID); if (barcode == null) { S_InDepotGoodsBarCodeTable newBarcode = new S_InDepotGoodsBarCodeTable(); IBasicGoodsServer basicServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>(); newBarcode.GoodsID = basicServer.GetGoodsID(goodsCode, goodsName, spec); newBarcode.Provider = provider; newBarcode.BatchNo = batchCode; newBarcode.ProductFlag = "0"; newBarcode.StorageID = StorageID; if (!server.Add(newBarcode, out m_err)) { MessageDialog.ShowErrorMessage(m_err); return; } barcode = server.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID); } lstBarCodeInfo.Add(barcode); } foreach (var item in lstBarCodeInfo) { ServerModule.PrintPartBarcode.PrintBarcodeList(item); } }
private void dataGridView1_DoubleClick(object sender, EventArgs e) { IGaugeManage serviceGauge = ServerModuleFactory.GetServerModule <IGaugeManage>(); int intGoodsID = m_basicGoodsServer.GetGoodsID(dataGridView1.CurrentRow.Cells["图号型号"].Value.ToString(), dataGridView1.CurrentRow.Cells["物品名称"].Value.ToString(), dataGridView1.CurrentRow.Cells["规格"].Value.ToString()); if (UniversalFunction.GetGoodsType(intGoodsID, m_billInfo.StorageID) == CE_GoodsType.量检具 && m_operateMode == CE_BusinessOperateMode.仓库核实) { 量检具编号录入窗体 form = new 量检具编号录入窗体(m_billNo, intGoodsID, Convert.ToDecimal(dataGridView1.CurrentRow.Cells["数量"].Value), CE_BusinessBillType.入库, true); form.ShowDialog(); } }
private void btnSave_Click(object sender, EventArgs e) { if (!CheckInfo()) { return; } GetInfo(); if (!m_serverGoods.EditGoodsInfo(m_goodsInfo, m_lstRecord, m_lstReplaceInfo, m_lstBlankToProductInfo, m_lstWaterCode, out m_strErr)) { MessageDialog.ShowErrorMessage(m_strErr); return; } else { MessageDialog.ShowPromptMessage("保存成功"); m_goodsID = m_serverGoods.GetGoodsID(m_goodsInfo.GoodsCode, m_goodsInfo.GoodsName, m_goodsInfo.Spec); this.Close(); } }
private void btnPrintCVTBarcodes_Click(object sender, EventArgs e) { StringBuilder error = new StringBuilder(); string errorTemp = null; 打印整台份返修箱条码 form = new 打印整台份返修箱条码(); form.ShowDialog(); List <View_ZPX_ReparativeBarcode> lstPrintData = form.PrintData; if (lstPrintData != null && form.blPrintFlag && lstPrintData.Count > 0) { if (MessageDialog.ShowEnquiryMessage("此过程需要一段时间,是否继续?") == DialogResult.No) { return; } List <View_S_InDepotGoodsBarCodeTable> lstBarCodeInfo = new List <View_S_InDepotGoodsBarCodeTable>(); DateTime dt = ServerModule.ServerTime.Time; IBasicGoodsServer basicGoodsServer = ServerModuleFactory.GetServerModule <IBasicGoodsServer>(); Dictionary <int, int> dicBarcode = new Dictionary <int, int>(); try { Cursor.Current = Cursors.WaitCursor; foreach (var item in lstPrintData) { // 装配挑选回收件 string batchCode = "ZTJ" + dt.ToString("yyyyMMdd"); string goodsCode = item.零部件编码; string goodsName = item.零部件名称; string spec = item.规格; string provider = item.供货单位; string StorageID = "01"; View_S_InDepotGoodsBarCodeTable barcode = null; S_InDepotGoodsBarCodeTable newBarcode = new S_InDepotGoodsBarCodeTable(); newBarcode.GoodsID = basicGoodsServer.GetGoodsID(goodsCode, goodsName, spec); if (newBarcode.GoodsID == 0) { error.AppendLine("[" + goodsCode + "]" + "[" + goodsName + "]" + "[" + spec + "] 无物品ID"); continue; } newBarcode.Provider = provider; newBarcode.BatchNo = batchCode; newBarcode.ProductFlag = "0"; newBarcode.StorageID = StorageID; barcode = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID); if (barcode == null) { if (!m_barCodeServer.Add(newBarcode, out errorTemp)) { MessageDialog.ShowErrorMessage(errorTemp); return; } } barcode = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID); barcode.物品ID = item.数量; dicBarcode.Add(barcode.条形码, item.数量); if (barcode.工位 != null) { string[] workBench = barcode.工位.Split(new char[] { ',' }); if (workBench.Length == 1) { lstBarCodeInfo.Add(barcode); } else { foreach (var wb in workBench) { View_S_InDepotGoodsBarCodeTable barCode = GlobalObject.CloneObject.CloneProperties <View_S_InDepotGoodsBarCodeTable>(barcode); barCode.工位 = wb; lstBarCodeInfo.Add(barCode); } } } else { barcode.工位 = ""; lstBarCodeInfo.Add(barcode); } } lstBarCodeInfo.Sort(this.SortMethod); foreach (var barcode in lstBarCodeInfo) { // barcode.物品ID 中保存的为数量 ServerModule.PrintPartBarcode.PrintBarcodeList(barcode, barcode.物品ID); } if (MessageDialog.ShowEnquiryMessage("是否将当前打印物品数量增加到多批次管理信息中?") == DialogResult.Yes) { IMultiBatchPartServer multiBatchPartServer = ServerModuleFactory.GetServerModule <IMultiBatchPartServer>(); if (!multiBatchPartServer.AddFromReparativePartList(GlobalObject.BasicInfo.LoginID, form.PurposeID, dicBarcode, out m_err)) { MessageDialog.ShowErrorMessage(m_err); } } } catch (Exception exce) { MessageDialog.ShowErrorMessage(exce.Message); } finally { Cursor.Current = Cursors.Arrow; } } if (error.Length > 0) { MessageDialog.ShowErrorMessage(error.ToString()); } }
/// <summary> /// 更新返修零件信息 /// </summary> /// <param name="lstInfo">要添加的条形码信息</param> /// <param name="error">出错时输出错误信息</param> /// <returns>返回操作是否成功的标志</returns> /// <remarks>打印条形码时如果找不到此物品的条形码时直接生成条形码用</remarks> public bool Update(List <StateData <View_ZPX_ReparativeBarcode> > lstInfo, out string error) { error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; IBasicGoodsServer serverBasicGoods = SCM_Level01_ServerFactory.GetServerModule <IBasicGoodsServer>(); int intGoodsID = 0; foreach (var item in lstInfo) { intGoodsID = serverBasicGoods.GetGoodsID(item.Data.零部件编码, item.Data.零部件名称, item.Data.规格); if (intGoodsID == 0) { error = string.Format("获取不到 {0}, {1}, 规格:{2} 的物品的物品编号,请与管理员联系", item.Data.零部件编码, item.Data.零部件名称, item.Data.规格); return(false); } ZPX_ReparativeBarcode data = new ZPX_ReparativeBarcode(); data.ID = item.Data.序号; data.Edition = item.Data.产品编码; data.GoodsID = intGoodsID; data.Amount = item.Data.数量; data.Provider = item.Data.供货单位; data.Position = item.Data.位置; IQueryable <ZPX_ReparativeBarcode> result = null; if (data.ID != 0) { result = from r in ctx.ZPX_ReparativeBarcode where r.ID == data.ID select r; } else { result = from r in ctx.ZPX_ReparativeBarcode where r.Edition == data.Edition && r.GoodsID == intGoodsID select r; } switch (item.DataStatus) { case StateData <View_ZPX_ReparativeBarcode> .DataStatusEnum.Add: if (result.Count() > 0) { error = string.Format("{0}, {1}, 规格:{2} 的物品已经存在不允许重复添加", item.Data.零部件编码, item.Data.零部件名称, item.Data.规格); return(false); } ctx.ZPX_ReparativeBarcode.InsertOnSubmit(data); break; case StateData <View_ZPX_ReparativeBarcode> .DataStatusEnum.Delete: if (result.Count() == 0) { error = string.Format("{0}, {1}, 规格:{2} 的物品不存在无法删除", item.Data.零部件编码, item.Data.零部件名称, item.Data.规格); return(false); } ctx.ZPX_ReparativeBarcode.DeleteOnSubmit(result.Single()); break; case StateData <View_ZPX_ReparativeBarcode> .DataStatusEnum.Update: if (result.Count() == 0) { error = string.Format("{0}, {1}, 规格:{2} 的物品不存在无法更新", item.Data.零部件编码, item.Data.零部件名称, item.Data.规格); return(false); } var record = result.Single(); record.Amount = data.Amount; record.Provider = data.Provider; record.Position = data.Position; break; } } ctx.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }