/// <summary> /// 获取某一条形码的货物信息 /// </summary> /// <param name="barCode">条形码序号即条形码</param> /// <param name="goodsInfo">物品信息</param> /// <param name="error">获取失败时返回的错误信息</param> /// <returns>获取成功返回True,获取失败返回False</returns> public bool GetData(int barCode, out S_InDepotGoodsBarCodeTable goodsInfo, out string error) { goodsInfo = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.S_InDepotGoodsBarCodeTable where r.ID == barCode select r; if (result.Count() == 0) { error = "条形码有误"; return(false); } goodsInfo = result.Single(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 用户删除指定条形码多批次信息 /// </summary> /// <param name="purposeID">用途编号</param> /// <param name="barCodeId">条形码编号</param> /// <param name="cvtNumber">变速箱号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回true</returns> public bool Delete(int purposeID, int barCodeId, string cvtNumber, out string error) { error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; IBarCodeServer barCodeServer = BasicServerFactory.GetServerModule <IBarCodeServer>(); S_InDepotGoodsBarCodeTable barCode = null; if (!barCodeServer.GetData(barCodeId, out barCode, out error)) { return(false); } var result = from r in ctx.ZPX_MultiBatchPart where r.BarCode == barCodeId && r.PurposeID == purposeID && r.CVTNumber == cvtNumber select r; if (result.Count() == 0) { error = string.Format("您所属部门对应的多批次条形码 [{0}] 的物品不存在!", barCode.ID); return(false); } ctx.ZPX_MultiBatchPart.DeleteAllOnSubmit(result); ctx.SubmitChanges(); return(true); } catch (Exception err) { error = err.Message; return(false); } }
/// <summary> /// 由用户更新多批次信息 /// </summary> /// <param name="userCode">用户编号</param> /// <param name="purposeID">用途编号</param> /// <param name="barCodeId">条形码ID</param> /// <param name="cvtNumber">变速箱号</param> /// <param name="count">装配数量</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回true</returns> public bool Update(string userCode, int purposeID, int barCodeId, string cvtNumber, int count, out string error) { error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; IBarCodeServer barCodeServer = BasicServerFactory.GetServerModule <IBarCodeServer>(); S_InDepotGoodsBarCodeTable barCode = null; if (!barCodeServer.GetData(barCodeId, out barCode, out error)) { return(false); } var result = from r in ctx.ZPX_MultiBatchPart where r.BarCode == barCodeId && r.PurposeID == purposeID && r.CVTNumber == cvtNumber select r; if (result.Count() == 0) { error = string.Format("您所属部门对应的多批次条形码 [{0}] 的物品不存在!", barCode.ID); return(false); } ZPX_MultiBatchPart mbp = result.Single(); if (mbp.Counts == count) { error = string.Format("条形码 [{0}] 的物品中原有数量与您当前设置的数量一致,不需要更改!", barCode.ID); return(false); } mbp.Counts = count; if (mbp.Remark.Length > 0) { mbp.Remark += "\r\n"; } mbp.Remark += ServerTime.Time.ToString("yyyy-MM-dd HH:mm:ss") + ", 用户 " + userCode + " 更新数量为:" + count.ToString() + " ;"; ctx.SubmitChanges(); return(true); } catch (Exception err) { error = err.Message; return(false); } }
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 btnPrintBarCode_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 batchCode = dataGridView1.SelectedRows[i].Cells["批次号"].Value.ToString(); 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 StorageID = dataGridView1.SelectedRows[i].Cells["库房代码"].Value.ToString(); View_S_InDepotGoodsBarCodeTable barcode = m_barCodeServer.GetBarCodeInfo( goodsCode, goodsName, spec, provider, batchCode, StorageID); // 找不到此物品的条形码时生成一个 if (barcode == null) { S_InDepotGoodsBarCodeTable newBarcode = new S_InDepotGoodsBarCodeTable(); newBarcode.GoodsID = (int)dataGridView1.SelectedRows[i].Cells["物品ID"].Value; newBarcode.Provider = provider; newBarcode.BatchNo = batchCode; newBarcode.ProductFlag = "0"; newBarcode.StorageID = StorageID; if (!m_barCodeServer.Add(newBarcode, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } barcode = m_barCodeServer.GetBarCodeInfo(goodsCode, goodsName, spec, provider, batchCode, StorageID); } lstBarCodeInfo.Add(barcode); } foreach (var item in lstBarCodeInfo) { ServerModule.PrintPartBarcode.PrintBarcodeList(item); } }
/// <summary> /// 在添加库存信息时添加条形码信息 /// </summary> /// <param name="context">数据库上下文</param> /// <param name="stockInfo">库存表的一条库存信息</param> public void Add(DepotManagementDataContext context, S_Stock stockInfo) { if (IsExists(context, stockInfo.GoodsID, stockInfo.StorageID, stockInfo.BatchNo, stockInfo.Provider)) { return; } S_InDepotGoodsBarCodeTable lnqBarCodeInfo = new S_InDepotGoodsBarCodeTable(); lnqBarCodeInfo.GoodsID = (int)stockInfo.GoodsID; lnqBarCodeInfo.Provider = stockInfo.Provider; lnqBarCodeInfo.BatchNo = stockInfo.BatchNo; lnqBarCodeInfo.StorageID = stockInfo.StorageID; context.S_InDepotGoodsBarCodeTable.InsertOnSubmit(lnqBarCodeInfo); }
/// <summary> /// 新建条码 /// </summary> /// <param name="goodsID">物品ID</param> /// <param name="batchNo">批次号</param> /// <param name="storageID">库房ID</param> /// <param name="provider">供应商编码</param> /// <returns>返回新建的条码号</returns> private int CreateBarCode(int goodsID, string batchNo, string storageID, string provider) { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; S_InDepotGoodsBarCodeTable lnqNew = new S_InDepotGoodsBarCodeTable(); lnqNew.GoodsID = goodsID; lnqNew.BatchNo = batchNo; lnqNew.Provider = provider; lnqNew.StorageID = storageID; dataContext.S_InDepotGoodsBarCodeTable.InsertOnSubmit(lnqNew); dataContext.SubmitChanges(); return(GetBarCode(goodsID, batchNo, storageID, provider)); }
/// <summary> /// 获取指定领料单的物品信息 /// </summary> /// <param name="billNo">领料单号</param> /// <param name="goodsBarCode">条形码物品表信息</param> /// <returns>返回获取的物品信息</returns> public View_S_MaterialRequisitionGoods GetGoods(string billNo, S_InDepotGoodsBarCodeTable goodsBarCode) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfoView(goodsBarCode.GoodsID); var result = from r in ctx.View_S_MaterialRequisitionGoods where r.领料单号 == billNo && r.图号型号 == basicGoods.图号型号 && r.物品名称 == basicGoods.物品名称 && r.规格 == basicGoods.规格 && r.供应商编码 == goodsBarCode.Provider && r.批次号 == goodsBarCode.BatchNo select r; if (result.Count() == 0) { return(null); } return(result.Single()); }
/// <summary> /// 接收事件 /// </summary> /// <param name="sender"></param> /// <param name="re">事件参数</param> public Socket_FetchMaterial ReceiveReadBarCodeInfo(Socket_FetchMaterial fetchMaterialInfo) { string error; // 获取物品条形码信息 S_InDepotGoodsBarCodeTable goodsInfo = null; if (!m_barCodeServer.GetData(Convert.ToInt32(fetchMaterialInfo.BarCode), out goodsInfo, out error)) { fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.条形码有误; return(fetchMaterialInfo); } // 检查领料物品清单中是否存在接收的单据号 if (!m_requestMaterialServer.IsExist(fetchMaterialInfo.BillID)) { fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.单据号有误; return(fetchMaterialInfo); } // 获取领料单中的物品信息 View_S_MaterialRequisitionGoods goods = m_requestMaterialServer.GetGoods(fetchMaterialInfo.BillID, goodsInfo); if (goods == null) { fetchMaterialInfo.DesireCount = 0; fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.领料单中无该零件的领料信息; return(fetchMaterialInfo); } View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfoView(goodsInfo.GoodsID); fetchMaterialInfo.GoodsCode = basicGoods.图号型号; fetchMaterialInfo.GoodsName = basicGoods.物品名称; fetchMaterialInfo.Spec = basicGoods.规格; fetchMaterialInfo.Provider = goodsInfo.Provider; fetchMaterialInfo.BatchNo = goodsInfo.BatchNo; fetchMaterialInfo.DesireCount = Convert.ToInt32(goods.请领数); fetchMaterialInfo.FetchState = Socket_FetchMaterial.FetchStateEnum.操作成功; return(fetchMaterialInfo); }
/// <summary> /// 在更新条形码管理表中的信息 /// </summary> /// <param name="context">数据库上下文</param> /// <param name="oldInfo">旧库存信息</param> /// <param name="newInfo">新库存信息</param> public void Update(DepotManagementDataContext context, S_Stock oldInfo, S_Stock newInfo) { if (IsExists(oldInfo.GoodsID, oldInfo.StorageID, oldInfo.BatchNo, oldInfo.Provider)) { var result = from r in context.S_InDepotGoodsBarCodeTable where r.GoodsID == oldInfo.GoodsID && r.Provider == oldInfo.Provider && r.BatchNo == oldInfo.BatchNo && r.StorageID == oldInfo.StorageID select r; if (result.Count() == 1) { S_InDepotGoodsBarCodeTable lnqBarcode = result.Single(); lnqBarcode.GoodsID = (int)newInfo.GoodsID; lnqBarcode.Provider = newInfo.Provider; lnqBarcode.BatchNo = newInfo.BatchNo; lnqBarcode.StorageID = newInfo.StorageID; } } }
/// <summary> /// 向条形码管理表中添加一条记录 /// </summary> /// <param name="barcode">要添加的一条条形码管理视图条形码信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>添加成功返回True,添加失败返回False</returns> /// <remarks>打印条形码时如果找不到此物品的条形码时直接生成条形码用</remarks> public bool Add(S_InDepotGoodsBarCodeTable barcode, out string error) { error = null; try { if (IsExists(barcode.GoodsID, barcode.StorageID, barcode.BatchNo, barcode.Provider)) { return(true); } DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.S_InDepotGoodsBarCodeTable.InsertOnSubmit(barcode); dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
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()); } }