/// <summary> /// 添加物品信息 /// </summary> /// <param name="goods">物品信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回操作是否成功的标志</returns> public bool AddGoods(S_MaterialListReturnedInTheDepot goods, out string error) { try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; if (BillIsFinish(ctx, goods.Bill_ID)) { throw new Exception("单据已完成,无法进行操作"); } error = null; ctx.S_MaterialListReturnedInTheDepot.InsertOnSubmit(goods); ctx.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="context">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="goodsItem">明细信息</param> /// <returns>返回库存信息对象</returns> public S_Stock AssignStockInfo(DepotManagementDataContext context, S_MaterialReturnedInTheDepot bill, S_MaterialListReturnedInTheDepot goodsItem) { if (goodsItem.ShelfArea == null || goodsItem.ColumnNumber == null || goodsItem.LayerNumber == null) { throw new Exception("仓库货架、层、列等信息不能为空,请修改后重新提交"); } bool blIsOnlyForRepair = false; var resultbill = from a in context.S_MaterialReturnedInTheDepot where a.Bill_ID == bill.Bill_ID select a; if (resultbill.Count() != 1) { throw new Exception("数据不唯一或者为空"); } else { blIsOnlyForRepair = resultbill.Single().IsOnlyForRepair.ToString() == "" ? false : Convert.ToBoolean(resultbill.Single().IsOnlyForRepair); } S_Stock stock = new S_Stock(); // 添加信息到库存 IStoreServer storeServer = ServerModuleFactory.GetServerModule <IStoreServer>(); stock.GoodsID = goodsItem.GoodsID; stock.Provider = goodsItem.Provider; stock.ProviderBatchNo = goodsItem.ProviderBatchNo; stock.BatchNo = goodsItem.BatchNo; stock.ShelfArea = goodsItem.ShelfArea; stock.ColumnNumber = goodsItem.ColumnNumber; stock.LayerNumber = goodsItem.LayerNumber; stock.ExistCount = (decimal)goodsItem.ReturnedAmount; stock.Date = ServerModule.ServerTime.Time; stock.StorageID = bill.StorageID; if (blIsOnlyForRepair) { stock.GoodsStatus = 6; } return(stock); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="context">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息对象</returns> public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialReturnedInTheDepot bill, S_MaterialListReturnedInTheDepot item) { IBillTypeServer server = ServerModuleFactory.GetServerModule <IBillTypeServer>(); BASE_BillType billType = server.GetBillTypeFromName("领料退库单"); if (billType == null) { throw new Exception("获取不到单据类型信息"); } View_Department department = UniversalFunction.GetDeptInfo(context, bill.Department); //单价设置 decimal dcStockUnitPrice = m_serverStore.GetGoodsUnitPrice(context, item.GoodsID, item.BatchNo, bill.StorageID); //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息 S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.FetchBIllID = bill.Bill_ID; detailBill.BillTime = ServerTime.Time; detailBill.FetchCount = -item.ReturnedAmount; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.ProviderBatchNo = item.ProviderBatchNo; detailBill.Provider = item.Provider; detailBill.Price = -dcStockUnitPrice * (decimal)item.ReturnedAmount; detailBill.UnitPrice = dcStockUnitPrice; detailBill.Department = department.部门名称; detailBill.FillInPersonnel = bill.FillInPersonnel; detailBill.FinanceSignatory = null; detailBill.DepartDirector = bill.DepartmentDirector; detailBill.DepotManager = bill.DepotManager; detailBill.OperationType = (int)CE_SubsidiaryOperationType.领料退库; detailBill.StorageID = bill.StorageID; detailBill.Remark = "退库原因:" + bill.ReturnReason + ";备注:" + item.Remark; detailBill.FillInDate = bill.Bill_Time; IMaterialRequisitionPurposeServer purposeServer = ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>(); detailBill.Using = string.Format("领料退库,初始用途:{0}", purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose); return(detailBill); }
/// <summary> /// 批量添加物品 /// </summary> /// <param name="lstGoods">要添加的物品信息列表</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回操作是否成功的标志</returns> public bool AddGoods(List <View_S_MaterialListReturnedInTheDepot> lstGoods, out string error) { try { error = null; DepotManagementDataContext ctx = CommentParameter.DepotDataContext; if (lstGoods != null && lstGoods.Count() > 0) { if (BillIsFinish(ctx, lstGoods[0].退库单号)) { throw new Exception("单据已完成,无法进行操作"); } } foreach (var item in lstGoods) { S_MaterialListReturnedInTheDepot goods = new S_MaterialListReturnedInTheDepot(); goods.Bill_ID = item.退库单号; goods.GoodsID = item.物品ID; goods.BatchNo = item.批次号; goods.Provider = item.供应商; goods.ProviderBatchNo = item.供方批次号; goods.ReturnedAmount = item.退库数; goods.ShelfArea = item.货架; goods.LayerNumber = item.层; goods.ColumnNumber = item.列; goods.Remark = item.备注; ctx.S_MaterialListReturnedInTheDepot.InsertOnSubmit(goods); } ctx.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 更新物品信息 /// </summary> /// <param name="goods">物品信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回操作是否成功的标志</returns> public bool UpdateGoods(S_MaterialListReturnedInTheDepot goods, out string error) { try { error = null; DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var result = from r in ctx.S_MaterialListReturnedInTheDepot where r.ID == goods.ID select r; if (result.Count() > 0) { S_MaterialListReturnedInTheDepot updateGoods = result.Single(); if (BillIsFinish(ctx, updateGoods.Bill_ID)) { throw new Exception("单据已完成,无法进行操作"); } updateGoods.Bill_ID = goods.Bill_ID; updateGoods.GoodsID = goods.GoodsID; updateGoods.BatchNo = goods.BatchNo; updateGoods.Provider = goods.Provider; updateGoods.ProviderBatchNo = goods.ProviderBatchNo; updateGoods.ReturnedAmount = goods.ReturnedAmount; updateGoods.ShelfArea = goods.ShelfArea; updateGoods.ColumnNumber = goods.ColumnNumber; updateGoods.LayerNumber = goods.LayerNumber; updateGoods.Remark = goods.Remark; } ctx.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 生成领料退库单 /// </summary> /// <param name="context">数据上下文</param> /// <param name="billNo">单据号</param> void InsertReturnBill(DepotManagementDataContext context, string billNo) { IMaterialReturnedInTheDepot serverReturnedBill = ServerModule.ServerModuleFactory.GetServerModule <IMaterialReturnedInTheDepot>(); var varList = from a in context.S_ScrapGoods where a.Bill_ID == billNo && a.ResponsibilityProvider == a.Provider select a; if (varList.Count() == 0) { return; } var varData = from a in context.S_ScrapBill where a.Bill_ID == billNo select a; if (varData.Count() == 0) { return; } S_ScrapBill bill = varData.Single(); //操作主表 S_MaterialReturnedInTheDepot returnBill = new S_MaterialReturnedInTheDepot(); var data1 = from a in context.BASE_MaterialRequisitionPurpose where a.Purpose == bill.ProductType && a.Code.Substring(0, 1) == "F" select a; returnBill.Bill_ID = m_assignBill.AssignNewNo(context, serverReturnedBill, CE_BillTypeEnum.领料退库单.ToString()); returnBill.Bill_Time = ServerTime.Time; returnBill.BillStatus = MaterialReturnedInTheDepotBillStatus.已完成.ToString(); returnBill.Department = bill.DeclareDepartment; returnBill.ReturnType = "其他退库";//退库类别 returnBill.FillInPersonnel = bill.FillInPersonnel; returnBill.FillInPersonnelCode = bill.FillInPersonnelCode; returnBill.DepartmentDirector = bill.DepartmentDirector; returnBill.QualityInputer = ""; returnBill.DepotManager = BasicInfo.LoginName; returnBill.PurposeCode = data1.First().Code; returnBill.ReturnReason = "由【报废单】:" + billNo + " 生成的报废退库"; returnBill.Remark = "系统自动生成"; returnBill.StorageID = "01"; returnBill.ReturnMode = "领料退库";//退库方式 returnBill.IsOnlyForRepair = false; returnBill.InDepotDate = ServerTime.Time; context.S_MaterialReturnedInTheDepot.InsertOnSubmit(returnBill); context.SubmitChanges(); foreach (S_ScrapGoods goodsInfo in varList) { View_F_GoodsPlanCost goodsView = UniversalFunction.GetGoodsInfo(context, goodsInfo.GoodsID); QueryCondition_Store queryInfo = new QueryCondition_Store(); queryInfo.BatchNo = goodsInfo.BatchNo; queryInfo.GoodsID = goodsInfo.GoodsID; queryInfo.StorageID = "01"; S_Stock stockInfo = UniversalFunction.GetStockInfo(context, queryInfo); S_MaterialListReturnedInTheDepot detailInfo = new S_MaterialListReturnedInTheDepot(); detailInfo.BatchNo = goodsInfo.BatchNo; detailInfo.Bill_ID = returnBill.Bill_ID; detailInfo.GoodsID = goodsInfo.GoodsID; detailInfo.Provider = goodsInfo.Provider; detailInfo.ReturnedAmount = goodsInfo.Quantity; detailInfo.Depot = goodsView.物品类别; detailInfo.ColumnNumber = stockInfo == null ? "" : stockInfo.ColumnNumber; detailInfo.LayerNumber = stockInfo == null ? "" : stockInfo.LayerNumber; detailInfo.ShelfArea = stockInfo == null ? "" : stockInfo.ShelfArea; detailInfo.ProviderBatchNo = stockInfo == null ? "" : stockInfo.ProviderBatchNo; detailInfo.Remark = ""; context.S_MaterialListReturnedInTheDepot.InsertOnSubmit(detailInfo); context.SubmitChanges(); } serverReturnedBill.OpertaionDetailAndStock(context, returnBill); context.SubmitChanges(); }
/// <summary> /// 自动生成领料退库单 /// </summary> /// <param name="contxt">数据上下文</param> /// <param name="djh">单据号</param> void CreateMaterialReturnedInTheDepot(DepotManagementDataContext contxt, string djh) { MaterialReturnedInTheDepot serverReturnedBill = new MaterialReturnedInTheDepot(); try { string strBillID = m_assignBill.AssignNewNo(serverReturnedBill, CE_BillTypeEnum.领料退库单.ToString()); S_StorageCheck billInfo = GetBill(contxt, djh); List <View_S_StorageCheckList> listInfo = (from a in GetList(contxt, djh) where a.盈亏数量 > 0 select a).ToList(); S_MaterialReturnedInTheDepot lnqReturnedInTheDepot = new S_MaterialReturnedInTheDepot(); if (listInfo.Count > 0) { #region 领料退库单主表 lnqReturnedInTheDepot.Bill_ID = strBillID; lnqReturnedInTheDepot.Bill_Time = ServerTime.Time; lnqReturnedInTheDepot.BillStatus = "已完成"; lnqReturnedInTheDepot.Department = "ZZ05"; lnqReturnedInTheDepot.DepartmentDirector = UniversalFunction.GetPersonnelInfo(contxt, billInfo.SHRY).姓名; lnqReturnedInTheDepot.DepotManager = BasicInfo.LoginName; lnqReturnedInTheDepot.FillInPersonnel = UniversalFunction.GetPersonnelInfo(contxt, billInfo.BZRY).姓名; lnqReturnedInTheDepot.FillInPersonnelCode = billInfo.BZRY; lnqReturnedInTheDepot.InDepotDate = ServerTime.Time; lnqReturnedInTheDepot.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.盘点).Code; lnqReturnedInTheDepot.QualityInputer = ""; lnqReturnedInTheDepot.Remark = "库房盘点(盘盈)"; lnqReturnedInTheDepot.ReturnMode = "领料退库"; lnqReturnedInTheDepot.ReturnReason = "库房盘点(盘盈)"; lnqReturnedInTheDepot.ReturnType = null; lnqReturnedInTheDepot.StorageID = billInfo.StorageID; contxt.S_MaterialReturnedInTheDepot.InsertOnSubmit(lnqReturnedInTheDepot); #endregion foreach (View_S_StorageCheckList listSingle in listInfo) { #region 领料单退库明细 S_MaterialListReturnedInTheDepot lnqReturnedInTheDepotList = new S_MaterialListReturnedInTheDepot(); lnqReturnedInTheDepotList.BatchNo = listSingle.批次号; lnqReturnedInTheDepotList.Bill_ID = strBillID; lnqReturnedInTheDepotList.ColumnNumber = listSingle.列; lnqReturnedInTheDepotList.GoodsID = (int)listSingle.物品ID; lnqReturnedInTheDepotList.LayerNumber = listSingle.层; lnqReturnedInTheDepotList.Provider = listSingle.供货单位; lnqReturnedInTheDepotList.ProviderBatchNo = listSingle.供方批次号; lnqReturnedInTheDepotList.Remark = "库房盘点(盘亏)"; lnqReturnedInTheDepotList.ReturnedAmount = (decimal)listSingle.盈亏数量; lnqReturnedInTheDepotList.ShelfArea = listSingle.货架; contxt.S_MaterialListReturnedInTheDepot.InsertOnSubmit(lnqReturnedInTheDepotList); #endregion } contxt.SubmitChanges(); serverReturnedBill.OpertaionDetailAndStock(contxt, lnqReturnedInTheDepot); contxt.SubmitChanges(); m_assignBill.UseBillNo(CE_BillTypeEnum.领料退库单.ToString(), strBillID); } } catch (Exception ex) { throw new Exception(ex.Message); } }
/// <summary> /// 批量生成明细 /// </summary> /// <param name="selectType">单据类型 (“领料”,“领料退库”)</param> /// <param name="billID">单据号</param> /// <param name="billIDGather">数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool BatchCreateList(string selectType, string billID, string billIDGather, out string error) { error = null; try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; if (BillIsFinish(dataContext, billID)) { throw new Exception("单据已完成,无法进行操作"); } Hashtable paramTable = new Hashtable(); paramTable.Add("@SelectType", selectType); paramTable.Add("@BillID", billIDGather); string strErr = ""; DataTable dtBatchCreate = GlobalObject.DatabaseServer.QueryInfoPro("KFYW_BatchCreateListFrom_RequisitionOrReturnedInTheDepot", paramTable, out strErr); if (dtBatchCreate == null) { error = strErr; return(false); } if (selectType == "领料") { var varReturn = from a in dataContext.S_MaterialListReturnedInTheDepot where a.Bill_ID == billID select a; dataContext.S_MaterialListReturnedInTheDepot.DeleteAllOnSubmit(varReturn); for (int i = 0; i < dtBatchCreate.Rows.Count; i++) { S_MaterialListReturnedInTheDepot lnqReturn = new S_MaterialListReturnedInTheDepot(); lnqReturn.BatchNo = dtBatchCreate.Rows[i]["BatchNo"].ToString(); lnqReturn.Bill_ID = billID; lnqReturn.ColumnNumber = dtBatchCreate.Rows[i]["ColumnNumber"].ToString(); lnqReturn.Depot = dtBatchCreate.Rows[i]["Depot"].ToString(); lnqReturn.GoodsID = Convert.ToInt32(dtBatchCreate.Rows[i]["GoodsID"].ToString()); lnqReturn.LayerNumber = dtBatchCreate.Rows[i]["LayerNumber"].ToString(); lnqReturn.Provider = dtBatchCreate.Rows[i]["Provider"].ToString(); lnqReturn.ProviderBatchNo = dtBatchCreate.Rows[i]["ProviderBatchNo"].ToString(); lnqReturn.Remark = "由领料单" + billIDGather + "批量自动生成"; lnqReturn.ReturnedAmount = Convert.ToDecimal(dtBatchCreate.Rows[i]["ReturnedAmount"].ToString()); lnqReturn.ShelfArea = dtBatchCreate.Rows[i]["ShelfArea"].ToString(); dataContext.S_MaterialListReturnedInTheDepot.InsertOnSubmit(lnqReturn); } } else { var varRequisition = from a in dataContext.S_MaterialRequisitionGoods where a.Bill_ID == billID select a; dataContext.S_MaterialRequisitionGoods.DeleteAllOnSubmit(varRequisition); for (int i = 0; i < dtBatchCreate.Rows.Count; i++) { S_MaterialRequisitionGoods lnqRequisition = new S_MaterialRequisitionGoods(); lnqRequisition.BasicCount = Convert.ToDecimal(dtBatchCreate.Rows[i]["BasicCount"].ToString()); lnqRequisition.BatchNo = dtBatchCreate.Rows[i]["BatchNo"].ToString(); lnqRequisition.Bill_ID = billID; lnqRequisition.GoodsID = Convert.ToInt32(dtBatchCreate.Rows[i]["GoodsID"].ToString()); lnqRequisition.ProviderCode = dtBatchCreate.Rows[i]["ProviderCode"].ToString(); lnqRequisition.RealCount = Convert.ToDecimal(dtBatchCreate.Rows[i]["RealCount"].ToString()); lnqRequisition.Remark = "由退库单" + billIDGather + "批量自动生成"; lnqRequisition.RequestCount = Convert.ToDecimal(dtBatchCreate.Rows[i]["RequestCount"].ToString()); lnqRequisition.ShowPosition = i + 1; MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer(); if (!serverMaterialGoods.AutoCreateGoods(dataContext, lnqRequisition, out error)) { return(false); } //dataContext.S_MaterialRequisitionGoods.InsertOnSubmit(lnqRequisition); } } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
public void InsertInfoExcel(string billNo, DataTable tableInfo) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; ctx.Connection.Open(); ctx.Transaction = ctx.Connection.BeginTransaction(); try { var varData = from a in ctx.S_MaterialReturnedInTheDepot where a.Bill_ID == billNo select a; if (BillIsFinish(ctx, billNo)) { throw new Exception("单据已完成,无法进行操作"); } if (varData.Count() != 1) { throw new Exception("获取单据【" + billNo + "】信息有误"); } var varData1 = from a in ctx.S_MaterialListReturnedInTheDepot where a.Bill_ID == billNo select a; ctx.S_MaterialListReturnedInTheDepot.DeleteAllOnSubmit(varData1); ctx.SubmitChanges(); foreach (DataRow dr in tableInfo.Rows) { View_F_GoodsPlanCost goodsInfo = UniversalFunction.GetGoodsInfo(dr["图号型号"].ToString().Trim(), dr["物品名称"].ToString().Trim(), dr["规格"].ToString().Trim()); if (goodsInfo == null) { throw new Exception(string.Format("【图号型号】:{0} ,【物品名称】:{1},【规格】:{2} 获取物品信息失败", dr["图号型号"].ToString().Trim(), dr["物品名称"].ToString().Trim(), dr["规格"].ToString().Trim())); } GlobalObject.QueryCondition_Store condition = new GlobalObject.QueryCondition_Store(); if (dr["批次号"] == null) { throw new Exception(UniversalFunction.GetGoodsMessage(goodsInfo.序号) + "【批次号】为空,获取失败"); } condition.BatchNo = dr["批次号"].ToString().Trim(); condition.GoodsID = goodsInfo.序号; condition.StorageID = varData.Single().StorageID; S_Stock stockInfo = UniversalFunction.GetStockInfo(ctx, condition); if (stockInfo == null) { throw new Exception(UniversalFunction.GetGoodsMessage(goodsInfo.序号) + "【批次号】:" + dr["批次号"].ToString().Trim() + " 获取库存信息失败"); } S_MaterialListReturnedInTheDepot goods = new S_MaterialListReturnedInTheDepot(); goods.BatchNo = stockInfo.BatchNo; goods.Bill_ID = billNo; goods.ColumnNumber = stockInfo.ColumnNumber; goods.Depot = stockInfo.Depot; goods.GoodsID = stockInfo.GoodsID; goods.LayerNumber = stockInfo.LayerNumber; goods.Provider = stockInfo.Provider; goods.ProviderBatchNo = stockInfo.ProviderBatchNo; goods.RepairStatus = false; decimal result = 0; if (!Decimal.TryParse(dr["数量"].ToString(), out result)) { throw new Exception(UniversalFunction.GetGoodsMessage(goodsInfo.序号) + "【批次号】:" + dr["批次号"].ToString().Trim() + "【数量】信息有误"); } goods.ReturnedAmount = result; goods.ShelfArea = stockInfo.ShelfArea; ctx.S_MaterialListReturnedInTheDepot.InsertOnSubmit(goods); } ctx.SubmitChanges(); ctx.Transaction.Commit(); } catch (Exception ex) { ctx.Transaction.Rollback(); throw new Exception(ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 0) { MessageDialog.ShowPromptMessage("请选择要修改的记录后再进行此操作"); return; } else if (dataGridView1.SelectedRows.Count > 1) { MessageDialog.ShowPromptMessage("只能选择要修改的一条记录后再进行此操作"); return; } if (!CheckDataItem()) { return; } S_MaterialListReturnedInTheDepot goods = new S_MaterialListReturnedInTheDepot(); View_S_MaterialListReturnedInTheDepot viewGoods = GetGoodsInfo(dataGridView1.SelectedRows[0]); goods.ID = viewGoods.序号; goods.Bill_ID = m_billNo; if (txtCode.Tag != null && (int)txtCode.Tag != 0) { goods.GoodsID = (int)txtCode.Tag; } else { goods.GoodsID = viewGoods.物品ID; } goods.Provider = txtProvider.Text; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtBatchNo.Text; goods.ReturnedAmount = numReturnedCount.Value; goods.Remark = txtRemark.Text; //产品状态 设置 2012.3.30 by cjb if (cmbProductStatus.Text.Trim() != "") { if (cmbProductStatus.Text.Trim() == "已返修") { goods.RepairStatus = true; } else { goods.RepairStatus = false; } } if (m_operateMode == CE_BusinessOperateMode.仓库核实) { goods.ShelfArea = txtShelf.Text; goods.ColumnNumber = txtColumn.Text; goods.LayerNumber = txtLayer.Text; } else { goods.ColumnNumber = ""; goods.LayerNumber = ""; goods.ShelfArea = ""; } if (!m_goodsServer.UpdateGoods(goods, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetGoods(m_billNo); RefreshDataGridView(m_queryGoodsInfo); PositioningRecord(m_goodsCode, m_goodsName, m_spec); }
private void btnAdd_Click(object sender, EventArgs e) { if (!CheckDataItem()) { return; } for (int i = 0; i < dataGridView1.Rows.Count; i++) { if (m_strReturnMode == "返修退库") { if ((int)txtCode.Tag == Convert.ToInt32(dataGridView1.Rows[i].Cells["物品ID"].Value)) { MessageDialog.ShowPromptMessage("不可重复添加同一种物品"); return; } } else { if (txtBatchNo.Text.Trim() == dataGridView1.Rows[i].Cells["批次号"].Value.ToString() && (int)txtCode.Tag == Convert.ToInt32(dataGridView1.Rows[i].Cells["物品ID"].Value)) { MessageDialog.ShowPromptMessage("不可重复添加同批次同一种物品"); return; } } } S_MaterialListReturnedInTheDepot goods = new S_MaterialListReturnedInTheDepot(); goods.Bill_ID = m_billNo; goods.GoodsID = (int)txtCode.Tag; goods.Provider = txtProvider.Text; goods.ProviderBatchNo = txtProviderBatchNo.Text; goods.BatchNo = txtBatchNo.Text == "系统自动生成" ? GetBatchNo(goods.GoodsID) : txtBatchNo.Text; goods.ReturnedAmount = numReturnedCount.Value; goods.Remark = txtRemark.Text; goods.ShelfArea = ""; goods.ColumnNumber = ""; goods.LayerNumber = ""; //产品状态 设置 2012.3.30 by cjb if (cmbProductStatus.Text.Trim() != "") { if (cmbProductStatus.Text.Trim() == "已返修") { goods.RepairStatus = true; } else { goods.RepairStatus = false; } } if (!m_goodsServer.AddGoods(goods, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } GetCodeInfoFromForm(); m_queryGoodsInfo = m_goodsServer.GetGoods(m_billNo); RefreshDataGridView(m_queryGoodsInfo); PositioningRecord(m_goodsCode, m_goodsName, m_spec); }
private void btnMaterialsTransfer_Click(object sender, EventArgs e) { if (m_lnqWSCode == null) { return; } FormDataTableCheck frm = new FormDataTableCheck(m_serverMaterials.GetMaterialsTransferInfo(m_lnqWSCode.WSCode)); frm.OnFormDataTableCheckFind += new GlobalObject.DelegateCollection.FormDataTableCheckFindDelegate(frm_OnFormDataTableCheckFind); frm._BlDateTimeControlShow = true; if (frm.ShowDialog() == DialogResult.OK) { List <string> listRequisition = DataSetHelper.ColumnsToList_Distinct(frm._DtResult, "单据号"); DataTable tempTable = m_serverMaterials.SumMaterialsTransferGoods(listRequisition, (int)CE_SubsidiaryOperationType.物料转换后, (int)CE_SubsidiaryOperationType.领料退库, m_lnqWSCode.WSCode); foreach (DataRow dr in tempTable.Rows) { S_MaterialListReturnedInTheDepot goods = new S_MaterialListReturnedInTheDepot(); goods.Bill_ID = m_billNo; goods.GoodsID = Convert.ToInt32(dr["物品ID"]); StoreQueryCondition condition = new StoreQueryCondition(); condition.GoodsID = Convert.ToInt32(txtCode.Tag); condition.BatchNo = dr["批次号"].ToString(); condition.StorageID = m_strStorage; S_Stock tempStock = m_serverStock.GetStockInfo(condition); if (tempStock != null) { goods.Provider = tempStock.Provider; goods.ProviderBatchNo = tempStock.ProviderBatchNo; } else { goods.Provider = ""; goods.ProviderBatchNo = ""; } goods.BatchNo = dr["批次号"].ToString(); goods.ReturnedAmount = Convert.ToDecimal(dr["数量"]); goods.Remark = txtRemark.Text; goods.ShelfArea = ""; goods.ColumnNumber = ""; goods.LayerNumber = ""; //产品状态 设置 2012.3.30 by cjb if (cmbProductStatus.Text.Trim() != "") { if (cmbProductStatus.Text.Trim() == "已返修") { goods.RepairStatus = true; } else { goods.RepairStatus = false; } } if (!m_goodsServer.AddGoods(goods, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } } m_queryGoodsInfo = m_goodsServer.GetGoods(m_billNo); RefreshDataGridView(m_queryGoodsInfo); } }