/// <summary> /// 添加计划价格信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="goodsCost">物品价格信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回是否成功添加计划价格信息</returns> public bool AddGoods(DepotManagementDataContext dataContext, F_GoodsPlanCost goodsCost, out string error) { error = null; try { var result = from r in dataContext.F_GoodsPlanCost where r.GoodsCode == goodsCost.GoodsCode && r.GoodsName == goodsCost.GoodsName && r.Spec == goodsCost.Spec select r; if (result.Count() > 0) { return(true); } goodsCost.Date = ServerTime.Time.Date; dataContext.F_GoodsPlanCost.InsertOnSubmit(goodsCost); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="context">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回库存信息对象</returns> public S_Stock AssignStockInfo(DepotManagementDataContext context, S_MaterialRequisition bill, S_MaterialRequisitionGoods item) { F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID); if (item.RealCount == 0) { throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品实领数为0,请重新输入!", basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo)); } S_Stock stockInfo = new S_Stock(); stockInfo.GoodsID = item.GoodsID; if (basicGoods != null) { stockInfo.GoodsCode = basicGoods.GoodsCode; stockInfo.GoodsName = basicGoods.GoodsName; stockInfo.Spec = basicGoods.Spec; } stockInfo.ExistCount = item.RealCount; stockInfo.Provider = item.ProviderCode; stockInfo.BatchNo = item.BatchNo; stockInfo.StorageID = bill.StorageID; if (item.Remark != null && item.Remark.Contains("无线领料")) { item.Remark = item.Remark.Replace(",无线领料", ""); item.Remark = item.Remark.Replace("无线领料", ""); // 防止用户把前面的逗号删除 } return(stockInfo); }
public 基础物品信息设置界面(int?goodsID, bool isSave) { InitializeComponent(); m_goodsID = goodsID; if (goodsID == null) { MessageDialog.ShowPromptMessage("【物品信息】异常,请退出当前界面,再试"); this.Close(); } else { lbStock.Text = m_serverStock.GetGoodsStock((int)goodsID).ToString(); m_goodsInfo = m_serverGoods.GetGoodsInfo((int)goodsID); m_lstRecord = m_serverGoods.GetGoodsAttirbuteRecordList((int)m_goodsID); } StapleInfo.InitUnitComboBox(cmbUnit); dataGridViewBlankToProduct.DataSource = new BindingList <View_F_GoodsBlankToProduct>(m_lstBlankToProductInfo); dataGridViewReplace.DataSource = new BindingList <View_F_GoodsReplaceInfo>(m_lstReplaceInfo); dataGridViewWaterCode.DataSource = new BindingList <F_ProductWaterCode>(m_lstWaterCode); ShowInfo(m_goodsInfo, m_lstRecord); if (isSave) { ShowRightControl(); } else { btnSave.Visible = isSave; } }
/// <summary> /// 修改计划价格信息 /// </summary> /// <param name="goodsCost">物品价格信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回是否成功添加计划价格信息</returns> public bool UpdateGoods(F_GoodsPlanCost goodsCost, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.F_GoodsPlanCost where r.ID == goodsCost.ID select r; if (result.Count() == 0) { error = "找不到基础物品信息无法进行此操作"; return(false); } F_GoodsPlanCost goodsPlanCost = result.Single(); goodsPlanCost.GoodsType = goodsCost.GoodsType; if (goodsCost.GoodsCode != goodsPlanCost.GoodsCode || goodsCost.GoodsName != goodsPlanCost.GoodsName || goodsCost.Spec != goodsPlanCost.Spec) { if (IsExistInBusiness(goodsCost.ID, out error)) { error += ",不允许进行此操作"; return(false); } } goodsPlanCost.GoodsCode = goodsCost.GoodsCode; goodsPlanCost.GoodsName = goodsCost.GoodsName; goodsPlanCost.Spec = goodsCost.Spec; goodsPlanCost.GoodsUnitPrice = goodsCost.GoodsUnitPrice; goodsPlanCost.UnitID = goodsCost.UnitID; goodsPlanCost.Remark = goodsCost.Remark; goodsPlanCost.UserCode = BasicInfo.LoginID; goodsPlanCost.Date = ServerTime.Time; goodsPlanCost.PY = UniversalFunction.GetPYWBCode(goodsPlanCost.GoodsName, "PY"); goodsPlanCost.WB = UniversalFunction.GetPYWBCode(goodsPlanCost.GoodsName, "WB"); if (goodsPlanCost.GoodsType != goodsCost.GoodsType) { UpdateGoodsType(dataContxt, goodsPlanCost.ID, goodsCost.GoodsType); } dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 修改计划价格信息 /// </summary> /// <param name="id">物品ID</param> /// <param name="newUnitPrice">新计划价格</param> /// <param name="newUnitID">新单位ID</param> /// <param name="userCode">用户编码</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回操作是否成功的标志</returns> public bool UpdateGoodsPrice(int id, decimal newUnitPrice, int newUnitID, string userCode, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.F_GoodsPlanCost where r.ID == id select r; if (result.Count() == 0) { error = "找不到基础物品信息无法进行此操作"; return(false); } F_GoodsPlanCost goodsPlanCost = result.Single(); goodsPlanCost.GoodsUnitPrice = newUnitPrice; goodsPlanCost.UnitID = newUnitID; goodsPlanCost.UserCode = userCode; dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
public 工装总成信息(int goodsID, string frocknumber, bool flag, AuthorityFlag m_authFlag, bool addflag) { InitializeComponent(); m_strAuthFlag = m_authFlag; FaceAuthoritySetting.SetEnable(this.Controls, m_authFlag); FaceAuthoritySetting.SetVisibly(this.toolStrip1, m_authFlag); toolStrip1.Visible = true; lbScarpPersonnel.Text = ""; lbScarpTime.Text = ""; if (!flag) { labelTitle.Text = "工装分装台帐信息"; this.StartPosition = FormStartPosition.WindowsDefaultLocation; tabControl1.TabPages.RemoveAt(1); } else { labelTitle.Text = "工装总装台帐信息"; } if (addflag) { txtName.ShowResultForm = true; txtFrockNumber.Text = m_serverFrockStandingBook.GetNewFrockNumber(); txtFrockNumber.ReadOnly = false; if (goodsID != 0 && frocknumber != "") { txtParentFrockNumber.Text = frocknumber; F_GoodsPlanCost lnqGoodsInfo = m_serverBasicGoods.GetGoodsInfo(goodsID); txtParentCode.Text = lnqGoodsInfo.GoodsCode; txtParentName.Text = lnqGoodsInfo.GoodsName; txtParentName.Tag = goodsID; } } else { txtName.ShowResultForm = false; txtFrockNumber.ReadOnly = true; DataRow drInfo = m_serverFrockStandingBook.GetInDepotBillInfo(frocknumber); if (drInfo != null) { txtProposer.Text = drInfo["申请人"].ToString(); txtProposer.Tag = drInfo["申请人工号"].ToString(); txtProviderCode.Text = drInfo["供应商编码"].ToString(); txtProviderName.Text = drInfo["供应商简称"].ToString(); txtDesigner.Text = drInfo["设计人"].ToString(); txtDesigner.Tag = drInfo["设计人工号"].ToString(); } m_lnqStandingBook = m_serverFrockStandingBook.GetBookInfo(goodsID, frocknumber); } ShowMessage(); }
/// <summary> /// 获得物品ID(没有便插入一个新的物品记录) /// </summary> /// <param name="code">图号型号</param> /// <param name="name">物品名称</param> /// <param name="spec">规格</param> /// <param name="goodsType">材料类别</param> /// <param name="unitID">单位ID</param> /// <param name="remark">备注</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回获得物品ID,返回0则表示获取失败</returns> public int GetGoodsID(string code, string name, string spec, string goodsType, int unitID, string remark, out string error) { try { // 查找到的符合条件的客户信息 IQueryable <View_F_GoodsPlanCost> IQFindGoodsPlanCost; error = null; string strSql = "select * from F_GoodsPlanCost where GoodsCode = '" + code + "' and GoodsName = '" + name + "' and Spec = '" + spec + "'"; DataTable dt = GlobalObject.DatabaseServer.QueryInfo(strSql); if (dt == null || dt.Rows.Count == 0) { F_GoodsPlanCost goodsPlanCost = new F_GoodsPlanCost(); goodsPlanCost.GoodsType = goodsType; goodsPlanCost.GoodsCode = code; goodsPlanCost.GoodsName = name; goodsPlanCost.GoodsUnitPrice = 0; goodsPlanCost.Spec = spec; goodsPlanCost.UserCode = BasicInfo.LoginID; goodsPlanCost.UnitID = unitID; goodsPlanCost.Remark = remark; goodsPlanCost.PY = UniversalFunction.GetPYWBCode(goodsPlanCost.GoodsName, "PY"); goodsPlanCost.WB = UniversalFunction.GetPYWBCode(goodsPlanCost.GoodsName, "WB"); if (!AddGoods(goodsPlanCost, out IQFindGoodsPlanCost, out error)) { return(0); } else { strSql = "select Max(ID) from F_GoodsPlanCost"; dt = GlobalObject.DatabaseServer.QueryInfo(strSql); return(Convert.ToInt32(dt.Rows[0][0].ToString())); } } else { return(Convert.ToInt32(dt.Rows[0]["ID"].ToString())); } } catch (Exception ex) { error = ex.Message; return(0); } }
/// <summary> /// 添加计划价格信息 /// </summary> /// <param name="goodsCost">物品价格信息</param> /// <param name="returnInfo">计划价格信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回是否成功添加计划价格信息</returns> public bool AddGoods(F_GoodsPlanCost goodsCost, out IQueryable <View_F_GoodsPlanCost> returnInfo, out string error) { returnInfo = null; if (!AddGoods(goodsCost, out error)) { return(false); } GetAllGoodsInfo(out returnInfo, out error); return(error == null); }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回库存信息对象</returns> S_Stock AssignStockInfo(DepotManagementDataContext dataContxt, S_HomemadeRejectBill bill, S_HomemadeRejectList item) { F_GoodsPlanCost info = m_basicGoodsServer.GetGoodsInfo(dataContxt, item.GoodsID); S_Stock stockInfo = new S_Stock(); stockInfo.GoodsID = info.ID; stockInfo.GoodsCode = info.GoodsCode; stockInfo.GoodsName = info.GoodsName; stockInfo.Spec = info.Spec; stockInfo.Provider = item.Provider; stockInfo.BatchNo = item.BatchNo; stockInfo.ExistCount = item.Amount; stockInfo.StorageID = bill.StorageID; return(stockInfo); }
/// <summary> /// 创建新的F_GoodsPlanCost /// </summary> /// <returns>返回基础物品信息</returns> private F_GoodsPlanCost CreateGoodsObject() { F_GoodsPlanCost goodscost = new F_GoodsPlanCost(); goodscost.GoodsCode = txtCode.Text; goodscost.GoodsName = txtName.Text.Trim(); goodscost.Spec = txtSpec.Text; goodscost.GoodsType = txtMaterialType.Tag as string; goodscost.GoodsUnitPrice = numFactUnitPrice.Value; goodscost.Remark = ""; goodscost.UserCode = ""; goodscost.UnitID = m_unitServer.GetUnitInfo(cmbUnit.Text).序号; goodscost.PY = UniversalFunction.GetPYWBCode(goodscost.GoodsName, "PY"); goodscost.WB = UniversalFunction.GetPYWBCode(goodscost.GoodsName, "WB"); return(goodscost); }
/// <summary> /// 添加计划价格信息 /// </summary> /// <param name="goodsCost">物品价格信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回是否成功添加计划价格信息</returns> public bool AddGoods(F_GoodsPlanCost goodsCost, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; goodsCost.Date = ServerTime.Time.Date; dataContxt.F_GoodsPlanCost.InsertOnSubmit(goodsCost); dataContxt.SubmitChanges(); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 修改计划价格信息 /// </summary> /// <param name="goodsCost">物品价格信息</param> /// <param name="returnInfo">计划价格信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>返回是否成功添加计划价格信息</returns> public bool UpdateGoods(F_GoodsPlanCost goodsCost, out IQueryable <View_F_GoodsPlanCost> returnInfo, out string error) { returnInfo = null; try { if (UpdateGoods(goodsCost, out error)) { return(GetAllGoodsInfo(out returnInfo, out error)); } else { return(false); } } catch (Exception exce) { error = exce.Message; return(false); } }
public 唯一标识码录入窗体(Out_ManeuverList maneuverList, bool IsOperation) { InitializeComponent(); m_lnqManeuverList = maneuverList; if (!IsOperation) { btnAdd.Visible = false; btnDelete.Visible = false; btnSubmit.Visible = false; } dataGridView1.DataSource = m_serverIdentifier.GetInfo(m_lnqManeuverList.Bill_ID, m_lnqManeuverList.GoodsID, m_lnqManeuverList.StorageID); F_GoodsPlanCost lnqGoodsInfo = IntegrativeQuery.QueryGoodsInfo(m_lnqManeuverList.GoodsID); txtGoodsCode.Text = lnqGoodsInfo.GoodsCode; txtGoodsName.Text = lnqGoodsInfo.GoodsName; txtSpec.Text = lnqGoodsInfo.Spec; txtOperationCount.Text = m_lnqManeuverList.ShipperCount.ToString(); }
/// <summary> /// 更新基础物品表 /// </summary> /// <returns>返回操作是否成功的标志</returns> private bool UpdateBasicGoodsInfo() { View_F_GoodsPlanCost info = m_basicGoodsServer.GetGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, out m_error); if (info != null) { if (info.物品类别名称 != txtMaterialType.Text || info.单位 != cmbUnit.Text) { F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(info.序号); basicGoods.GoodsType = txtMaterialType.Tag as string; basicGoods.UnitID = m_unitServer.GetUnitInfo(cmbUnit.Text).序号; //if (!m_basicGoodsServer.UpdateGoods(basicGoods, out m_error)) //{ // MessageDialog.ShowErrorMessage(m_error); // return false; //} } } return(true); }
/// <summary> /// 匹配物品库存信息 /// </summary> /// <param name="threePacketsOfTheRepairList">数据集</param> /// <param name="error">错误信息</param> /// <returns>返回数据集</returns> DataTable GetStorageTable(DataTable threePacketsOfTheRepairList, out string error) { error = null; threePacketsOfTheRepairList.Columns.Add("StroageID"); threePacketsOfTheRepairList.Columns.Add("Provider"); for (int i = 0; i < threePacketsOfTheRepairList.Rows.Count; i++) { F_GoodsPlanCost lnqGoods = m_serverBasicGoods.GetGoodsInfo(Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"])); string strSql = "select * from S_Stock where GoodsID = " + Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]) + " and StorageID in( '01','08','11') and BatchNo = '" + threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() + "' and ExistCount >= " + Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]) + " order by StorageID desc"; DataTable dtTemp = GlobalObject.DatabaseServer.QueryInfo(strSql); if (dtTemp != null && dtTemp.Rows.Count != 0) { threePacketsOfTheRepairList.Rows[i][13] = dtTemp.Rows[0]["StorageID"].ToString(); threePacketsOfTheRepairList.Rows[i][14] = dtTemp.Rows[0]["Provider"].ToString(); } else { error = "图号型号 【" + lnqGoods.GoodsCode + "】,物品名称 【" + lnqGoods.GoodsName + "】, 规格 【" + lnqGoods.Spec + "】,批次号 【" + threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() + "】 库存不足,请重新核对"; return(null); } } return(threePacketsOfTheRepairList); }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="context">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息对象</returns> public S_FetchGoodsDetailBill AssignDetailInfo(DepotManagementDataContext context, S_MaterialRequisition bill, S_MaterialRequisitionGoods 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); IStoreServer storeServer = ServerModuleFactory.GetServerModule <IStoreServer>(); IProductLendReturnService serverLendReturn = ServerModuleFactory.GetServerModule <IProductLendReturnService>(); F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(context, item.GoodsID); if (basicGoods == null) { throw new Exception(string.Format("物品ID [{0}] 的物品在基础物品表中没有查到,请与系统管理员联系!", item.GoodsID)); } StoreQueryCondition condition = new StoreQueryCondition(); condition.GoodsID = item.GoodsID; condition.Provider = item.ProviderCode; condition.BatchNo = item.BatchNo; condition.StorageID = bill.StorageID; S_Stock stock = storeServer.GetStockInfoOverLoad(context, condition); if (stock == null && GlobalObject.GeneralFunction.IsNullOrEmpty(basicGoods.GoodsType)) { throw new Exception(string.Format("图号:{0}, 名称:{1}, 规格:{2}, 供应商:{3}, 批次号:{4} 的物品在库存中没有查到相关物品,请仓管员核实!", basicGoods.GoodsCode, basicGoods.GoodsName, basicGoods.Spec, item.ProviderCode, item.BatchNo)); } //S_FetchGoodsDetailBill用于存放每次领料、领料退库的明细信息 decimal dcRealCount = item.RealCount; decimal dcSumCount = 0; var varData = from a in context.View_S_MaterialRequisitionProductReturnList where a.单据号 == item.Bill_ID && a.还账物品ID == item.GoodsID && a.还账物品批次号 == item.BatchNo && a.还账物品供应商 == item.ProviderCode select a; if (varData.Count() > 0) { dcSumCount = varData.Sum(a => a.还账数量); if (dcRealCount < dcSumCount) { throw new Exception("实际领用数量不能大于还货数量,请重新核对"); } } S_FetchGoodsDetailBill detailBill = new S_FetchGoodsDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.FetchBIllID = bill.Bill_ID; detailBill.BillTime = (DateTime)bill.OutDepotDate; detailBill.AssociatedBillType = bill.AssociatedBillType; detailBill.AssociatedBillNo = bill.AssociatedBillNo; detailBill.Department = department.部门名称; detailBill.FetchCount = item.RealCount; detailBill.GoodsID = item.GoodsID; detailBill.StorageID = bill.StorageID; detailBill.Price = dcSumCount; detailBill.UnitPrice = stock == null ? 0 : stock.UnitPrice; detailBill.OperationType = (int)CE_SubsidiaryOperationType.领料; detailBill.Provider = item.ProviderCode; if (stock != null) { detailBill.ProviderBatchNo = stock.ProviderBatchNo; } else { detailBill.ProviderBatchNo = ""; } detailBill.BatchNo = item.BatchNo; detailBill.FillInPersonnel = bill.FillInPersonnel; detailBill.FinanceSignatory = null; detailBill.DepartDirector = bill.DepartmentDirector; detailBill.DepotManager = bill.DepotManager; detailBill.Remark = (bill.Remark == null ? "" : bill.Remark.Trim()) + (item.Remark == null ? "" : item.Remark.Trim()); detailBill.FillInDate = bill.Bill_Time; IMaterialRequisitionPurposeServer purposeServer = ServerModuleFactory.GetServerModule <IMaterialRequisitionPurposeServer>(); detailBill.Using = purposeServer.GetBillPurpose(context, bill.PurposeCode).Purpose; return(detailBill); }
/// <summary> /// 自动插入报检入库单 /// </summary> /// <param name="dateTable">需要插入的数据集</param> /// <param name="storageID">库房ID</param> /// <param name="version">版次号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> public bool AddCheckInDepotBill(DataTable dateTable, string storageID, string version, out string error) { error = null; BargainInfoServer serverBargainInfo = new BargainInfoServer(); CheckOutInDepotServer serverCheckInDepot = new CheckOutInDepotServer(); try { string strBatchNo = serverCheckInDepot.GetNextBillNo(1); DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; for (int i = 0; i < dateTable.Rows.Count; i++) { S_CheckOutInDepotBill bill = new S_CheckOutInDepotBill(); decimal dcUnitPrice = serverBargainInfo.GetBargainUnitPrice(dateTable.Rows[i]["订单号"].ToString(), Convert.ToInt32(dateTable.Rows[i]["物品ID"])); F_GoodsPlanCost lnqGoods = ServerModuleFactory.GetServerModule <IBasicGoodsServer>().GetGoodsInfo( Convert.ToInt32(dateTable.Rows[i]["物品ID"])); bill.Bill_ID = GetBillID(strBatchNo, i); bill.OrderFormNumber = dateTable.Rows[i]["订单号"].ToString(); bill.ArriveGoods_Time = ServerTime.Time; // 到货日期 bill.Bill_Time = ServerTime.Time; // 报检日期 bill.BillStatus = CheckInDepotBillStatus.新建单据.ToString(); bill.Buyer = dateTable.Rows[i]["订货人"].ToString(); // 采购员签名 bill.DeclarePersonnelCode = dateTable.Rows[i]["订货人编号"].ToString(); // 报检员编码 bill.DeclarePersonnel = dateTable.Rows[i]["订货人"].ToString(); // 报检员签名 bill.DeclareCount = Convert.ToInt32(dateTable.Rows[i]["到货数量"]); // 报检数 bill.Provider = dateTable.Rows[i]["供应商"].ToString(); // 供应商编码 bill.ProviderBatchNo = ""; // 供应商批次 bill.GoodsID = (int)dateTable.Rows[i]["物品ID"]; bill.BatchNo = strBatchNo + "Auto"; // xsy, 没有废除OA前暂用 bill.Remark = "由自动订单自动生成的报检入库单"; bill.CheckOutGoodsType = 1; bill.OnlyForRepairFlag = false; bill.UnitPrice = dcUnitPrice; bill.Price = decimal.Round(bill.UnitPrice * Convert.ToDecimal(dateTable.Rows[i]["到货数量"]), 2); bill.PlanUnitPrice = Convert.ToDecimal(lnqGoods.GoodsUnitPrice); bill.PlanPrice = decimal.Round(bill.PlanUnitPrice * Convert.ToDecimal(dateTable.Rows[i]["到货数量"]), 2); bill.TotalPrice = CalculateClass.GetTotalPrice(bill.Price); bill.StorageID = storageID; bill.Version = version; bill.IsExigenceCheck = false; bill.UnitInvoicePrice = 0; bill.InvoicePrice = 0; if (UniversalFunction.GetStorageInfo_View(bill.StorageID).零成本控制) { throw new Exception("【零成本】库房,无法通过【报检入库单】入库"); } dataContext.S_CheckOutInDepotBill.InsertOnSubmit(bill); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 对BOM表中数据进行变更 /// </summary> /// <param name="datatContxt">数据上下文</param> /// <param name="technology">单据信息数据集</param> /// <param name="listInfo">变更单信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>变更成功返回True,变更失败返回False</returns> public bool UpdateBOMDate(DepotManagementDataContext datatContxt, S_TechnologyAlterationBill technology, DataTable listInfo, out string error) { error = null; DateTime time = ServerTime.Time; try { for (int i = 0; i < listInfo.Rows.Count; i++) { F_GoodsPlanCost lnqGoodsPlan = new F_GoodsPlanCost(); BASE_BomStruct lnqBomStruct = new BASE_BomStruct(); BASE_BomPartsLibrary lnqLibrary = new BASE_BomPartsLibrary(); DataRow row = listInfo.Rows[i]; if (row["变更模式"].ToString() == "新增") { if (row["NewGoodsID"] != null) { var resultGoods = from a in datatContxt.F_GoodsPlanCost where a.GoodsCode == row["新零件编码"].ToString() && a.GoodsName == row["新零件名称"].ToString() && a.Spec == row["新零件规格"].ToString() select a; if (resultGoods.Count() == 0) { lnqGoodsPlan.UserCode = technology.Applicant; lnqGoodsPlan.Date = time; lnqGoodsPlan.GoodsCode = row["新零件编码"].ToString(); lnqGoodsPlan.GoodsName = row["新零件名称"].ToString(); lnqGoodsPlan.Spec = row["新零件规格"].ToString(); lnqGoodsPlan.GoodsType = "030101"; lnqGoodsPlan.GoodsUnitPrice = 0; lnqGoodsPlan.IsDisable = false; lnqGoodsPlan.PY = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "PY"); lnqGoodsPlan.WB = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "WB"); lnqGoodsPlan.Remark = "由技术变更单【" + technology.BillNo + "】新增"; lnqGoodsPlan.UnitID = 1; datatContxt.F_GoodsPlanCost.InsertOnSubmit(lnqGoodsPlan); } var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) select a; if (varBomPartsLibrary.Count() == 0) { lnqLibrary.CreateDate = time; lnqLibrary.CreatePersonnel = technology.Applicant; lnqLibrary.GoodsID = Convert.ToInt32(row["NewGoodsID"]); lnqLibrary.Material = "未知"; lnqLibrary.PartType = "产品"; lnqLibrary.PivotalPart = "A"; lnqLibrary.Remark = "由技术变更单【" + technology.BillNo + "】生成"; lnqLibrary.Version = row["新零件版次号"].ToString(); datatContxt.BASE_BomPartsLibrary.InsertOnSubmit(lnqLibrary); } else if (varBomPartsLibrary.Count() == 1) { lnqLibrary = varBomPartsLibrary.Single(); lnqLibrary.Version = row["新零件版次号"].ToString() == "" ? varBomPartsLibrary.Single().Version : row["新零件版次号"].ToString(); lnqLibrary.CreateDate = time; lnqLibrary.CreatePersonnel = technology.Applicant; } } if (row["NewParentID"] != null && row["NewGoodsID"] != null) { lnqBomStruct.CreateDate = time; lnqBomStruct.CreatePersonnel = technology.Applicant; lnqBomStruct.GoodsID = Convert.ToInt32(row["NewGoodsID"]); lnqBomStruct.ParentID = Convert.ToInt32(row["NewParentID"]); lnqBomStruct.SysVersion = 1; lnqBomStruct.Usage = Convert.ToDecimal(row["新零件基数"]); datatContxt.BASE_BomStruct.InsertOnSubmit(lnqBomStruct); } } else if (row["变更模式"].ToString() == "修改" && row["是否修改零件本身"].ToString() == "否") { if (row["NewGoodsID"] != null) { var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) select a; if (varBomPartsLibrary.Count() == 0) { lnqLibrary.CreateDate = time; lnqLibrary.CreatePersonnel = technology.Applicant; lnqLibrary.GoodsID = Convert.ToInt32(row["NewGoodsID"]); lnqLibrary.Material = "未知"; lnqLibrary.PartType = "产品"; lnqLibrary.PivotalPart = "A"; lnqLibrary.Remark = "由技术变更单【" + technology.BillNo + "】生成"; lnqLibrary.Version = row["新零件版次号"].ToString(); datatContxt.BASE_BomPartsLibrary.InsertOnSubmit(lnqLibrary); } else { lnqLibrary = varBomPartsLibrary.Single(); lnqLibrary.Version = row["新零件版次号"].ToString(); } } if (row["OldParentID"] != null && row["NewParentID"] != null && row["OldGoodsID"] != null && row["NewGoodsID"] != null && (int)row["OldParentID"] != 0 && (int)row["NewParentID"] != 0) { var varBomStruct = from a in datatContxt.BASE_BomStruct where a.ParentID == Convert.ToInt32(row["OldParentID"]) && a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) select a; if (varBomStruct.Count() < 1) { error = "BOM结构表中不存在此记录"; return(false); } else { lnqBomStruct = varBomStruct.Single(); lnqBomStruct.CreateDate = time; lnqBomStruct.CreatePersonnel = technology.Applicant; lnqBomStruct.GoodsID = Convert.ToInt32(row["NewGoodsID"]); lnqBomStruct.ParentID = Convert.ToInt32(row["NewParentID"]); lnqBomStruct.SysVersion = lnqBomStruct.SysVersion + Convert.ToDecimal(0.01); lnqBomStruct.Usage = Convert.ToDecimal(row["新零件基数"]); var result = from a in datatContxt.BASE_BomStruct where a.ParentID == Convert.ToInt32(row["OldGoodsID"]) select a; foreach (BASE_BomStruct item in result) { if (item.ParentID != Convert.ToInt32(row["NewGoodsID"])) { BASE_BomStruct baseBom = new BASE_BomStruct(); baseBom.ParentID = Convert.ToInt32(row["NewGoodsID"]); baseBom.CreateDate = time; baseBom.CreatePersonnel = technology.Applicant; baseBom.GoodsID = item.GoodsID; baseBom.SysVersion = item.SysVersion; baseBom.Usage = item.Usage; datatContxt.BASE_BomStruct.InsertOnSubmit(baseBom); } } } } else { var varBomStruct = from a in datatContxt.BASE_BomStruct where a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) select a; foreach (BASE_BomStruct item in varBomStruct) { item.CreateDate = ServerTime.Time; item.CreatePersonnel = technology.Applicant; item.GoodsID = Convert.ToInt32(row["NewGoodsID"]); item.ParentID = item.ParentID; item.SysVersion = lnqBomStruct.SysVersion + Convert.ToDecimal(0.01); item.Usage = Convert.ToDecimal(row["新零件基数"]); } } } else if (row["变更模式"].ToString() == "修改" && row["是否修改零件本身"].ToString() == "是") { if (row["NewGoodsID"] != null && row["OldGoodsID"] != null) { var resultGoods = from a in datatContxt.F_GoodsPlanCost where a.ID == Convert.ToInt32(row["OldGoodsID"]) select a; if (resultGoods.Count() == 1) { lnqGoodsPlan = resultGoods.Single(); lnqGoodsPlan.UserCode = technology.Applicant; lnqGoodsPlan.Date = ServerTime.Time; lnqGoodsPlan.GoodsCode = row["新零件编码"].ToString(); lnqGoodsPlan.GoodsName = row["新零件名称"].ToString(); lnqGoodsPlan.Spec = row["新零件规格"].ToString(); lnqGoodsPlan.PY = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "PY"); lnqGoodsPlan.WB = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "WB"); lnqGoodsPlan.Remark = "由技术变更单【" + technology.BillNo + "】修改零件"; } else { error = row["新零件名称"].ToString() + "修改失败"; return(false); } var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) select a; if (varBomPartsLibrary.Count() != 1) { error = "新零件在零件库中不存在"; return(false); } else { lnqLibrary = varBomPartsLibrary.Single(); lnqLibrary.Version = row["新零件版次号"].ToString(); } } } else if (row["变更模式"].ToString() == "删除") { if (row["OldParentID"] == null) { var varStruct = from a in datatContxt.BASE_BomStruct where a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) select a; datatContxt.BASE_BomStruct.DeleteAllOnSubmit(varStruct); var varLibrary = from a in datatContxt.BASE_BomPartsLibrary where a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) select a; datatContxt.BASE_BomPartsLibrary.DeleteAllOnSubmit(varLibrary); } else { var varStruct = from a in datatContxt.BASE_BomStruct where a.ParentID == Convert.ToInt32(row["OldParentID"]) && a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) select a; if (varStruct.Count() != 1) { error = "BOM结构表中不存在此记录"; return(false); } else { lnqBomStruct = varStruct.Single(); datatContxt.BASE_BomStruct.DeleteOnSubmit(lnqBomStruct); } } } datatContxt.SubmitChanges(); } #region //switch (technology.ChangeMode) //{ // case "新增": // #region 新增 // for (int i = 0; i < listInfo.Rows.Count; i++) // { // DataRow row = listInfo.Rows[i]; // if (row["NewGoodsID"] != null) // { // var resultGoods = from a in datatContxt.F_GoodsPlanCost // where a.GoodsCode == row["新零件编码"].ToString() // && a.GoodsName == row["新零件名称"].ToString() && a.Spec == row["新零件规格"].ToString() // select a; // if (resultGoods.Count() == 0) // { // lnqGoodsPlan.UserCode = technology.Applicant; // lnqGoodsPlan.Date = ServerTime.Time; // lnqGoodsPlan.GoodsCode = row["新零件编码"].ToString(); // lnqGoodsPlan.GoodsName = row["新零件名称"].ToString(); // lnqGoodsPlan.Spec = row["新零件规格"].ToString(); // lnqGoodsPlan.GoodsType = "ZZLJJXLFBZ"; // lnqGoodsPlan.GoodsUnitPrice = 0; // lnqGoodsPlan.IsDisable = false; // lnqGoodsPlan.IsShelfLife = false; // lnqGoodsPlan.PY = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "PY"); // lnqGoodsPlan.WB = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "WB"); // lnqGoodsPlan.Remark = "由技术变更单【" + technology.BillNo + "】新增"; // lnqGoodsPlan.UnitID = 1; // datatContxt.F_GoodsPlanCost.InsertOnSubmit(lnqGoodsPlan); // } // var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary // where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) // select a; // if (varBomPartsLibrary.Count() == 0) // { // lnqLibrary.CreateDate = ServerTime.Time; // lnqLibrary.CreatePersonnel = technology.Applicant; // lnqLibrary.GoodsID = Convert.ToInt32(row["NewGoodsID"]); // lnqLibrary.Material = "未知"; // lnqLibrary.PartType = "产品"; // lnqLibrary.PivotalPart = "A"; // lnqLibrary.Remark = "由技术变更单【" + technology.BillNo + "】生成"; // lnqLibrary.Version = row["新零件版次号"].ToString(); // datatContxt.BASE_BomPartsLibrary.InsertOnSubmit(lnqLibrary); // } // else if (varBomPartsLibrary.Count() == 1) // { // lnqLibrary = varBomPartsLibrary.Single(); // lnqLibrary.Version = row["新零件版次号"].ToString(); // lnqLibrary.CreateDate = ServerTime.Time; // lnqLibrary.CreatePersonnel = technology.Applicant; // } // } // if (row["NewParentID"] != null && row["NewGoodsID"] != null) // { // lnqBomStruct.CreateDate = ServerTime.Time; // lnqBomStruct.CreatePersonnel = technology.Applicant; // lnqBomStruct.GoodsID = Convert.ToInt32(row["NewGoodsID"]); // lnqBomStruct.ParentID = Convert.ToInt32(row["NewParentID"]); // lnqBomStruct.SysVersion = 1; // lnqBomStruct.Usage = Convert.ToDecimal(row["新零件基数"]); // datatContxt.BASE_BomStruct.InsertOnSubmit(lnqBomStruct); // } // } // #endregion // break; // case "修改": // #region // for (int i = 0; i < listInfo.Rows.Count; i++) // { // DataRow row = listInfo.Rows[i]; // if (row["NewGoodsID"] != null) // { // var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary // where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) // select a; // if (varBomPartsLibrary.Count() != 1) // { // error = "新零件在零件库中不存在"; // return false; // } // else // { // lnqLibrary = varBomPartsLibrary.Single(); // lnqLibrary.Version = row["新零件版次号"].ToString(); // } // } // if (row["OldParentID"] != null && row["NewParentID"] != null // && row["OldGoodsID"] != null && row["NewGoodsID"] != null) // { // var varBomStruct = from a in datatContxt.BASE_BomStruct // where a.ParentID == Convert.ToInt32(row["OldParentID"]) // && a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) // select a; // if (varBomStruct.Count() != 1) // { // error = "BOM结构表中不存在此记录"; // return false; // } // else // { // lnqBomStruct = varBomStruct.Single(); // lnqBomStruct.CreateDate = ServerTime.Time; // lnqBomStruct.CreatePersonnel = technology.Applicant; // lnqBomStruct.GoodsID = Convert.ToInt32(row["NewGoodsID"]); // lnqBomStruct.ParentID = Convert.ToInt32(row["NewParentID"]); // lnqBomStruct.SysVersion = lnqBomStruct.SysVersion + Convert.ToDecimal(0.01); // lnqBomStruct.Usage = Convert.ToDecimal(row["新零件基数"]); // } // } // } // #endregion // break; // case "删除": // #region 删除 // for (int i = 0; i < listInfo.Rows.Count; i++) // { // DataRow row = listInfo.Rows[i]; // if (row["OldParentID"] == null) // { // var varStruct = from a in datatContxt.BASE_BomStruct // where a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) // select a; // datatContxt.BASE_BomStruct.DeleteAllOnSubmit(varStruct); // var varLibrary = from a in datatContxt.BASE_BomPartsLibrary // where a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) // select a; // datatContxt.BASE_BomPartsLibrary.DeleteAllOnSubmit(varLibrary); // } // else // { // var varStruct = from a in datatContxt.BASE_BomStruct // where a.ParentID == Convert.ToInt32(row["OldParentID"]) // && a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) // select a; // if (varStruct.Count() != 1) // { // error = "BOM结构表中不存在此记录"; // return false; // } // else // { // lnqBomStruct = varStruct.Single(); // datatContxt.BASE_BomStruct.DeleteOnSubmit(lnqBomStruct); // } // } // } // #endregion // break; // case "修改零件本身": // for (int i = 0; i < listInfo.Rows.Count; i++) // { // DataRow row = listInfo.Rows[i]; // if (row["NewGoodsID"] != null && row["OldGoodsID"] != null) // { // var resultGoods = from a in datatContxt.F_GoodsPlanCost // where a.ID == Convert.ToInt32(row["OldGoodsID"]) // select a; // if (resultGoods.Count() == 1) // { // lnqGoodsPlan = resultGoods.Single(); // lnqGoodsPlan.UserCode = technology.Applicant; // lnqGoodsPlan.Date = ServerTime.Time; // lnqGoodsPlan.GoodsCode = row["新零件编码"].ToString(); // lnqGoodsPlan.GoodsName = row["新零件名称"].ToString(); // lnqGoodsPlan.Spec = row["新零件规格"].ToString(); // lnqGoodsPlan.PY = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "PY"); // lnqGoodsPlan.WB = UniversalFunction.GetPYWBCode(row["新零件名称"].ToString(), "WB"); // lnqGoodsPlan.Remark = "由技术变更单【" + technology.BillNo + "】修改零件"; // } // else // { // error = row["新零件名称"].ToString() + "修改失败"; // return false; // } // //var varBomPartsLibrary = from a in datatContxt.BASE_BomPartsLibrary // // where a.GoodsID == Convert.ToInt32(row["NewGoodsID"]) // // select a; // //if (varBomPartsLibrary.Count() == 0) // //{ // // lnqLibrary.CreateDate = ServerTime.Time; // // lnqLibrary.CreatePersonnel = technology.Applicant; // // lnqLibrary.GoodsID = Convert.ToInt32(row["NewGoodsID"]); // // lnqLibrary.Material = "未知"; // // lnqLibrary.PartType = "产品"; // // lnqLibrary.PivotalPart = "A"; // // lnqLibrary.Remark = "由技术变更单【" + technology.BillNo + "】生成"; // // lnqLibrary.Version = row["新零件版次号"].ToString(); // // datatContxt.BASE_BomPartsLibrary.InsertOnSubmit(lnqLibrary); // //} // //else if (varBomPartsLibrary.Count() == 1) // //{ // // lnqLibrary = varBomPartsLibrary.Single(); // // lnqLibrary.Version = row["新零件版次号"].ToString(); // // lnqLibrary.CreateDate = ServerTime.Time; // // lnqLibrary.CreatePersonnel = technology.Applicant; // //} // } // //if (row["OldParentID"] != null && row["NewParentID"] != null // // && row["OldGoodsID"] != null && row["NewGoodsID"] != null) // //{ // // var varBomStruct = from a in datatContxt.BASE_BomStruct // // where a.ParentID == Convert.ToInt32(row["OldParentID"]) // // && a.GoodsID == Convert.ToInt32(row["OldGoodsID"]) // // select a; // // if (varBomStruct.Count() != 1) // // { // // error = "BOM结构表中不存在此记录"; // // return false; // // } // // else // // { // // lnqBomStruct = varBomStruct.Single(); // // lnqBomStruct.CreateDate = ServerTime.Time; // // lnqBomStruct.CreatePersonnel = technology.Applicant; // // lnqBomStruct.GoodsID = Convert.ToInt32(row["NewGoodsID"]); // // lnqBomStruct.ParentID = Convert.ToInt32(row["NewParentID"]); // // lnqBomStruct.SysVersion = lnqBomStruct.SysVersion + Convert.ToDecimal(0.01); // // lnqBomStruct.Usage = Convert.ToDecimal(row["新零件基数"]); // // } // //} // } // break; // default: // break; //} #endregion datatContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 提交单据 /// </summary> /// <param name="billNo">单号</param> /// <param name="listInfo">明细信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,否则False</returns> public bool SubmitInfo(string billNo, System.Collections.Generic.List <View_S_GoodsEnteringBill> listInfo, out string error) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; ctx.Connection.Open(); ctx.Transaction = ctx.Connection.BeginTransaction(); IFlowServer serverFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); string billStatus = serverFlow.GetNextBillStatus(billNo); if (billStatus == null) { throw new Exception("单据状态为空,请重新确认"); } error = null; try { EditListInfo(ctx, billNo, listInfo); if (billStatus == GoodsEnteringBillStatus.单据完成.ToString()) { foreach (View_S_GoodsEnteringBill item in listInfo) { F_GoodsPlanCost tempGoodsInfo = new F_GoodsPlanCost(); tempGoodsInfo.Date = ServerTime.Time; tempGoodsInfo.GoodsCode = item.图号型号; tempGoodsInfo.GoodsName = item.物品名称; if (item.材料类别编码 == null || item.材料类别编码.Trim().Length == 0) { throw new Exception("材料类别不能为空"); } tempGoodsInfo.GoodsType = item.材料类别编码; tempGoodsInfo.GoodsUnitPrice = 0; tempGoodsInfo.IsDisable = false; tempGoodsInfo.PY = ctx.Fun_get_bm(item.物品名称, 1); tempGoodsInfo.WB = ctx.Fun_get_bm(item.物品名称, 0); tempGoodsInfo.Remark = item.备注; tempGoodsInfo.Spec = item.规格; tempGoodsInfo.UnitID = item.单位 == "" ? 1 : Convert.ToInt32(UniversalFunction.GetUnitID(item.单位)); List <Flow_FlowData> tempList = serverFlow.GetBusinessOperationInfo(billNo, GoodsEnteringBillStatus.新建单据.ToString()); if (tempList == null) { throw new Exception("获取操作人员失败"); } tempGoodsInfo.UserCode = tempList[0].OperationPersonnel; ctx.F_GoodsPlanCost.InsertOnSubmit(tempGoodsInfo); } } ctx.SubmitChanges(); ctx.Transaction.Commit(); return(true); } catch (Exception ex) { error = ex.Message; ctx.Transaction.Rollback(); return(false); } }
/// <summary> /// 收集信息 /// </summary> void GetInfo() { m_lstRecord = new List <F_GoodsAttributeRecord>(); F_GoodsAttributeRecord tempRecord = new F_GoodsAttributeRecord(); m_goodsInfo = new F_GoodsPlanCost(); string TrueStr = System.Boolean.TrueString; m_goodsInfo.ID = m_goodsID == null ? 0 : (int)m_goodsID; m_goodsInfo.GoodsName = txtName.Text; m_goodsInfo.GoodsCode = txtCode.Text; m_goodsInfo.Spec = txtSpec.Text; m_goodsInfo.UnitID = Convert.ToInt32(cmbUnit.SelectedValue); m_goodsInfo.GoodsType = txtDepot.Tag.ToString(); m_goodsInfo.IsDisable = chbIsDisable.Checked; tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.物料价值ABC分类; tempRecord.AttributeValue = cmbGoodsValueABC.Text; m_lstRecord.Add(tempRecord); if (chbIsEol.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.停产; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbAssemblyUnit.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.部件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbBlank.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.毛坯; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); m_lstBlankToProductInfo = ((BindingList <View_F_GoodsBlankToProduct>)dataGridViewBlankToProduct.DataSource).ToList(); } if (chbCVT.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.CVT; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbGoodsTechnologyABC.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.技术等级ABC分类; tempRecord.AttributeValue = cmbGoodsTechnologyABC.Text; m_lstRecord.Add(tempRecord); } if (chbNeedDetection.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.来料须依据检验结果入库; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbOption.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.配件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbOutsourceGoods.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.委外加工; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbPart.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.零件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbProductionUse.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.生产耗用; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbPackageSending.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.整包发料; tempRecord.AttributeValue = "B_GoodsLeastPackAndStock"; tempRecord.IsHavingChildTable = true; m_lstRecord.Add(tempRecord); } if (chbPurchaseGoods.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.采购件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbReplace.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.替换件; tempRecord.AttributeValue = "F_GoodsReplaceInfo"; tempRecord.IsHavingChildTable = true; m_lstRecord.Add(tempRecord); m_lstReplaceInfo = ((BindingList <View_F_GoodsReplaceInfo>)dataGridViewReplace.DataSource).ToList(); } if (chbRustLife.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.防锈期; tempRecord.AttributeValue = numRustLife.Value.ToString(); m_lstRecord.Add(tempRecord); } if (chbSafeStock.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.安全库存; tempRecord.AttributeValue = numSafeStock.Value.ToString(); m_lstRecord.Add(tempRecord); } if (chbSelfmade.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.自制件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbShelfLife.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.保质期; tempRecord.AttributeValue = "KF_GoodsShelfLife"; tempRecord.IsHavingChildTable = true; m_lstRecord.Add(tempRecord); } if (chbBlank.Checked && chbStarvingBlank.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.缺料计算考虑毛坯; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbTCU.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.TCU; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (chbTopStock.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.最高库存; tempRecord.AttributeValue = numTopStock.Value.ToString(); m_lstRecord.Add(tempRecord); } if (chbVirtualPart.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.虚拟件; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); } if (num_CutterLife.Value > 0) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.刀具寿命; tempRecord.AttributeValue = num_CutterLife.Value.ToString(); m_lstRecord.Add(tempRecord); } if (num_PCS.Value > 0) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.装箱数; tempRecord.AttributeValue = num_PCS.Value.ToString(); m_lstRecord.Add(tempRecord); } if (chbWaterCode.Checked) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.流水码; tempRecord.AttributeValue = TrueStr; m_lstRecord.Add(tempRecord); m_lstWaterCode = ((BindingList <F_ProductWaterCode>)dataGridViewWaterCode.DataSource).ToList(); if (txtCSCODE.Text.Trim().Length > 0) { tempRecord = new F_GoodsAttributeRecord(); tempRecord.AttributeID = (int)CE_GoodsAttributeName.厂商编码; tempRecord.AttributeValue = txtCSCODE.Text; m_lstRecord.Add(tempRecord); } } }
/// <summary> /// 显示信息 /// </summary> /// <param name="listRecord">信息列表</param> void ShowInfo(F_GoodsPlanCost goodsInfo, List <F_GoodsAttributeRecord> listRecord) { if (goodsInfo == null) { return; } View_F_GoodsPlanCost goodsView = UniversalFunction.GetGoodsInfo(goodsInfo.ID); txtCode.Tag = m_goodsID; txtCode.Text = goodsView.图号型号; txtName.Text = goodsView.物品名称; txtSpec.Text = goodsView.规格; chbIsDisable.Checked = m_goodsInfo.IsDisable; txtDepot.Text = goodsView.物品类别名称; txtDepot.Tag = goodsView.物品类别; cmbUnit.Text = goodsView.单位; cmbUnit.Tag = goodsView.单位ID; if (listRecord == null) { return; } foreach (F_GoodsAttributeRecord record in listRecord) { if (record.AttributeValue == null) { continue; } F_GoodsAttribute attribute = m_serverGoods.GetGoodsAttirbute(record.AttributeID); CE_GoodsAttributeName attributeName = GlobalObject.GeneralFunction.StringConvertToEnum <CE_GoodsAttributeName>(attribute.AttributeName); bool valuesFlag = false; Boolean.TryParse(record.AttributeValue, out valuesFlag); switch (attributeName) { case CE_GoodsAttributeName.生产耗用: chbProductionUse.Checked = valuesFlag; break; case CE_GoodsAttributeName.防锈期: chbRustLife.Checked = true; numRustLife.Value = Convert.ToDecimal(record.AttributeValue); break; case CE_GoodsAttributeName.保质期: chbShelfLife.Checked = true; break; case CE_GoodsAttributeName.安全库存: chbSafeStock.Checked = true; numSafeStock.Value = Convert.ToDecimal(record.AttributeValue); break; case CE_GoodsAttributeName.最高库存: chbTopStock.Checked = true; numTopStock.Value = Convert.ToDecimal(record.AttributeValue); break; case CE_GoodsAttributeName.毛坯: chbBlank.Checked = valuesFlag; m_lstBlankToProductInfo = m_serverGoods.GetBlankToProductListInfo(record.AttributeRecordID); dataGridViewBlankToProduct.DataSource = new BindingList <View_F_GoodsBlankToProduct>(m_lstBlankToProductInfo); chbBlank_CheckedChanged(null, null); break; case CE_GoodsAttributeName.缺料计算考虑毛坯: chbStarvingBlank.Checked = valuesFlag; break; case CE_GoodsAttributeName.物料价值ABC分类: cmbGoodsValueABC.Text = record.AttributeValue; break; case CE_GoodsAttributeName.技术等级ABC分类: chbGoodsTechnologyABC.Checked = true; cmbGoodsTechnologyABC.Text = record.AttributeValue; break; case CE_GoodsAttributeName.来料须依据检验结果入库: chbNeedDetection.Checked = valuesFlag; break; case CE_GoodsAttributeName.采购件: chbPurchaseGoods.Checked = valuesFlag; break; case CE_GoodsAttributeName.自制件: chbSelfmade.Checked = valuesFlag; break; case CE_GoodsAttributeName.委外加工: chbOutsourceGoods.Checked = valuesFlag; break; case CE_GoodsAttributeName.部件: chbAssemblyUnit.Checked = valuesFlag; break; case CE_GoodsAttributeName.零件: chbPart.Checked = valuesFlag; break; case CE_GoodsAttributeName.配件: chbOption.Checked = valuesFlag; break; case CE_GoodsAttributeName.替换件: chbReplace.Checked = valuesFlag; m_lstReplaceInfo = m_serverGoods.GetReplaceListInfo(record.AttributeRecordID); dataGridViewReplace.DataSource = new BindingList <View_F_GoodsReplaceInfo>(m_lstReplaceInfo); break; case CE_GoodsAttributeName.CVT: chbCVT.Checked = valuesFlag; break; case CE_GoodsAttributeName.TCU: chbTCU.Checked = valuesFlag; break; case CE_GoodsAttributeName.虚拟件: chbVirtualPart.Checked = valuesFlag; break; case CE_GoodsAttributeName.领用上限: break; case CE_GoodsAttributeName.整包发料: chbPackageSending.Checked = valuesFlag; break; case CE_GoodsAttributeName.刀具寿命: num_CutterLife.Value = Convert.ToDecimal(record.AttributeValue); break; case CE_GoodsAttributeName.流水码: chbWaterCode.Checked = valuesFlag; m_lstWaterCode = m_serverGoods.GetWaterCodeListInfo(record.AttributeRecordID); dataGridViewWaterCode.DataSource = new BindingList <F_ProductWaterCode>(m_lstWaterCode); break; case CE_GoodsAttributeName.厂商编码: txtCSCODE.Text = record.AttributeValue == null ? "" : record.AttributeValue.ToString(); break; case CE_GoodsAttributeName.停产: chbIsEol.Checked = valuesFlag; break; case CE_GoodsAttributeName.装箱数: num_PCS.Value = Convert.ToDecimal(record.AttributeValue); break; default: break; } } }
/// <summary> /// 操作库存 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="outDetail">业务明细数据集</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool OperationStock(DepotManagementDataContext dataContext, Out_DetailAccount outDetail, out string error) { error = null; try { if (IntegrativeQuery.IsSalesStorage(outDetail.SecStorageID)) { return(true); } var varData = from a in dataContext.Out_Stock where a.GoodsID == outDetail.GoodsID && a.SecStorageID == outDetail.SecStorageID && a.StorageID == outDetail.StorageID select a; F_GoodsPlanCost lnqGoods = IntegrativeQuery.QueryGoodsInfo(Convert.ToInt32(outDetail.GoodsID)); if (varData.Count() == 0) { if (outDetail.OperationCount < 0) { error = "不能添加负数的库存记录" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]"; return(false); } else { Out_Stock lnqStock = new Out_Stock(); lnqStock.GoodsID = Convert.ToInt32(outDetail.GoodsID); lnqStock.Remark = outDetail.Remark; lnqStock.SecStorageID = outDetail.SecStorageID; lnqStock.StockQty = Convert.ToDecimal(outDetail.OperationCount); lnqStock.Date = ServerTime.Time; lnqStock.Personnel = BasicInfo.LoginName; lnqStock.StorageID = outDetail.StorageID; dataContext.Out_Stock.InsertOnSubmit(lnqStock); } } else if (varData.Count() == 1) { Out_Stock lnqStock = varData.Single(); decimal dcSum = Convert.ToDecimal(lnqStock.StockQty) + Convert.ToDecimal(outDetail.OperationCount); if (dcSum < 0) { error = "不允许库存数量为负数" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]"; return(false); } else { lnqStock.StockQty = Convert.ToDecimal(lnqStock.StockQty) + Convert.ToDecimal(outDetail.OperationCount); lnqStock.Date = ServerTime.Time; lnqStock.Personnel = BasicInfo.LoginName; } } else { error = "库存数据不唯一" + "[" + lnqGoods.GoodsCode + "] [" + lnqGoods.GoodsName + "] [" + lnqGoods.Spec + "]"; return(false); } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 更改数据CVT客户基础信息 /// </summary> /// <param name="cvtCustomer">CVT客户信息</param> /// <param name="error">c错误信息</param> /// <returns>更改成功返回True,更改失败返回False</returns> public bool UpdateCVTCustomerInformation(YX_CVTCustomerInformation cvtCustomer, out string error) { error = null; try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.YX_CVTCustomerInformation where a.ID != cvtCustomer.ID && a.VehicleShelfNumber == cvtCustomer.VehicleShelfNumber select a; if (varData.Count() != 0) { error = "数据不唯一"; return(false); } else { var varCVT = from a in dataContext.YX_CVTCustomerInformation where a.ID == cvtCustomer.ID select a; if (varCVT.Count() == 1) { YX_CVTCustomerInformation lnqCustomer = varCVT.Single(); lnqCustomer.CarModelID = cvtCustomer.CarModelID; lnqCustomer.ClientName = cvtCustomer.ClientName; lnqCustomer.CVTNumber = cvtCustomer.CVTNumber; lnqCustomer.DealerName = cvtCustomer.DealerName; lnqCustomer.FullAddress = cvtCustomer.FullAddress; lnqCustomer.PhoneNumber = cvtCustomer.PhoneNumber; lnqCustomer.ProductID = cvtCustomer.ProductID; lnqCustomer.Remark = cvtCustomer.Remark; lnqCustomer.SellDate = cvtCustomer.SellDate; lnqCustomer.SiteCity = cvtCustomer.SiteCity; lnqCustomer.SiteProvince = cvtCustomer.SiteProvince; lnqCustomer.VehicleShelfNumber = cvtCustomer.VehicleShelfNumber; lnqCustomer.VKT = cvtCustomer.VKT; lnqCustomer.OverTheReason = cvtCustomer.OverTheReason; lnqCustomer.ProofNo = cvtCustomer.ProofNo; var varInfo = from a in dataContext.YX_CVTCustomerInformation where a.VehicleShelfNumber == cvtCustomer.VehicleShelfNumber select a; if (varInfo.Count() == 1) { YX_CVTCustomerInformation lnqInfo = varInfo.Single(); if (lnqInfo.CVTNumber != cvtCustomer.CVTNumber) { YX_CVTCustomerInformationHistory lnqCustomerHistory = new YX_CVTCustomerInformationHistory(); IProductListServer serverProcutList = ServerModuleFactory.GetServerModule <IProductListServer>(); lnqCustomerHistory.CarModel = serverProcutList.GetMotorcycleInfo(Convert.ToInt32(cvtCustomer.CarModelID)); lnqCustomerHistory.ClientName = cvtCustomer.ClientName; IBasicGoodsServer serverBasicGoods = ServerModuleFactory.GetServerModule <IBasicGoodsServer>(); F_GoodsPlanCost lnqGoods = serverBasicGoods.GetGoodsInfo(Convert.ToInt32(cvtCustomer.ProductID)); lnqCustomerHistory.CVTType = lnqGoods.GoodsCode; lnqCustomerHistory.DealerName = cvtCustomer.DealerName; lnqCustomerHistory.FinishDate = ServerTime.Time; lnqCustomerHistory.FinishPersonnel = BasicInfo.LoginName; lnqCustomerHistory.NewPartCode = cvtCustomer.CVTNumber; lnqCustomerHistory.OldPartCode = lnqInfo.CVTNumber; lnqCustomerHistory.Remark = "手动修改"; lnqCustomerHistory.ReplaceCode = lnqGoods.GoodsCode; lnqCustomerHistory.ReplaceName = lnqGoods.GoodsName; lnqCustomerHistory.ReplaceSpec = lnqGoods.Spec; lnqCustomerHistory.VehicleShelfNumber = cvtCustomer.VehicleShelfNumber; dataContext.YX_CVTCustomerInformationHistory.InsertOnSubmit(lnqCustomerHistory); } } } } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }