/// <summary> /// 获取新建单据号 /// </summary> /// <returns>返回获取到的单据号</returns> public String GetNewBillNo(DepotManagementDataContext dataContxt) { string billNo = ""; bool bFind = false; for (int i = 0; i < m_lstNewBillId.Count; i++) { if (!m_billServer.IsExist(dataContxt, m_lstNewBillId[i])) { // 使用旧单据 bFind = true; billNo = m_lstNewBillId[i]; } else { m_lstNewBillId.RemoveAt(i); i--; } } if (!bFind) { billNo = m_assignBill.AssignNewNo(dataContxt, m_billServer, m_billType.ToString()); m_lstNewBillId.Add(billNo); } return(billNo); }
/// <summary> /// 添加自制件入库单 /// </summary> /// <param name="bill">自制件单据信息</param> /// <param name="returnBill">添加完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool AddBill(S_HomemadePartBill bill, out IQueryResult returnBill, out string error) { returnBill = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; string billID = m_assignBill.AssignNewNo(this, CE_BillTypeEnum.自制件入库单.ToString()); bill.Bill_ID = billID; bill.BatchNo = bill.BatchNo == "系统自动生成" ? billID : bill.BatchNo; bill.Bill_Time = ServerModule.ServerTime.Time; #region 获取计划价格 View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfoView(bill.GoodsID); decimal planUnitPrice = basicGoods.单价; bill.PlanUnitPrice = planUnitPrice; bill.PlanPrice = bill.DeclareCount * planUnitPrice; #endregion #region 获取单价 bill.UnitPrice = 0; bill.Price = bill.UnitPrice * bill.DeclareCount; bill.TotalPrice = CalculateClass.GetTotalPrice((decimal)bill.Price); #endregion if (GlobalObject.GeneralFunction.IsNullOrEmpty(bill.Bill_ID)) { throw new Exception("【单据号】获取失败,请重新再试"); } dataContxt.S_HomemadePartBill.InsertOnSubmit(bill); dataContxt.SubmitChanges(); return(GetAllBill(out returnBill, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 添加CVT出厂检验记录 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="djh">营销入库单据号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>添加成功返回True,添加失败返回False</returns> private bool AddDeliveryInspection(DepotManagementDataContext dataContext, string djh, out string error) { error = null; try { var varData = from a in dataContext.ProductsCodes where a.DJH == djh select a; foreach (var item in varData) { object goodsAttirbute = UniversalFunction.GetGoodsAttributeInfo(dataContext, item.GoodsID, CE_GoodsAttributeName.CVT); if (goodsAttirbute == null || !Convert.ToBoolean(goodsAttirbute)) { continue; } string strDJH = m_assignBill.AssignNewNo(dataContext, this, CE_BillTypeEnum.CVT出厂检验记录表.ToString()); P_DeliveryInspection lnqDelivery = new P_DeliveryInspection(); lnqDelivery.AssociatedBillNo = djh; lnqDelivery.DJH = strDJH; lnqDelivery.DJZT = "等待检验"; lnqDelivery.Date = ServerTime.Time; lnqDelivery.ProductCode = item.ProductCode; lnqDelivery.ProductType = item.GoodsCode; dataContext.P_DeliveryInspection.InsertOnSubmit(lnqDelivery); DataTable dtNullList = GetEmptyTable(item.GoodsCode); for (int i = 0; i < dtNullList.Rows.Count; i++) { P_DeliveryInspectionItems lnqItem = new P_DeliveryInspectionItems(); lnqItem.DJH = strDJH; lnqItem.TechnicalID = Convert.ToInt32(dtNullList.Rows[i]["技术要求ID"]); lnqItem.TestItemName = dtNullList.Rows[i]["检测项目"].ToString(); lnqItem.TechnicalRequirementsName = dtNullList.Rows[i]["技术要求"].ToString(); dataContext.P_DeliveryInspectionItems.InsertOnSubmit(lnqItem); } } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 创建挑返单 /// </summary> /// <param name="djh">报检单单据号</param> /// <param name="logID">挑返单创建人工号</param> /// <param name="error">出错时返回错误信息</param> /// <param name="tfDJH">挑返单单据号</param> /// <returns>操作是否成功的标志</returns> public bool Create(string djh, string logID, out string error, out string tfDJH) { error = null; tfDJH = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var varData = from a in dataContxt.S_CheckReturnRepairBill where a.InDepotBillID == djh && a.DJZT != "单据已报废" select a; if (varData.Count() > 0) { error = "此批次的挑选返工返修单已存在"; return(false); } S_CheckReturnRepairBill lnqReturn = new S_CheckReturnRepairBill(); lnqReturn.DJH = m_assignBill.AssignNewNo(this, CE_BillTypeEnum.挑选返工返修单.ToString()); lnqReturn.InDepotBillID = djh; lnqReturn.DJZT = "新建单据"; lnqReturn.CJRQ = ServerTime.Time; lnqReturn.CJRY = logID; dataContxt.S_CheckReturnRepairBill.InsertOnSubmit(lnqReturn); dataContxt.SubmitChanges(); tfDJH = lnqReturn.DJH; return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 插入工装所有信息 /// </summary> /// <param name="ordinarybill">普通入库单信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> bool CreateNewFrockMessage(S_OrdinaryInDepotBill ordinarybill, out string error) { error = null; FrockProvingReport serverFrockProvingReport = new FrockProvingReport(); try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.S_OrdinaryInDepotGoodsBill where a.Bill_ID == ordinarybill.Bill_ID select a; foreach (var item in varData) { for (int i = 0; i < item.Amount; i++) { string strFrockNumber = m_serverFrockStandingBook.GetNewFrockNumber(); S_FrockProvingReport lnqReport = new S_FrockProvingReport(); lnqReport.DJH = m_assignBill.AssignNewNo(serverFrockProvingReport, "工装验证报告单"); lnqReport.DJZT = "等待检验要求"; lnqReport.BillType = "入库检验"; lnqReport.BZRQ = ServerTime.Time; lnqReport.ConnectBillNumber = ordinarybill.Bill_ID; lnqReport.FrockNumber = strFrockNumber; lnqReport.GoodsID = item.GoodsID; if (!serverFrockProvingReport.AddBill(lnqReport, null, out error)) { return(false); } S_FrockStandingBook lnqBook = new S_FrockStandingBook(); lnqBook.GoodsID = item.GoodsID; lnqBook.FrockNumber = strFrockNumber; lnqBook.Designer = UniversalFunction.GetPersonnelName(ordinarybill.Designer); if (!m_serverFrockStandingBook.UpdateFrockStandingBook(lnqBook, null, out error)) { return(false); } View_F_GoodsPlanCost goodsInfo = UniversalFunction.GetGoodsInfo(lnqBook.GoodsID); m_billMessageServer.DestroyMessage(lnqReport.DJH); m_billMessageServer.SendNewFlowMessage(lnqReport.DJH, string.Format("【工装编号】:{0} 【图号型号】:{1} 【物品名称】:{2},※※※ 等待【工艺人员】处理", lnqReport.FrockNumber, goodsInfo.图号型号, goodsInfo.物品名称), CE_RoleEnum.工艺人员); } } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 生成采购退货单 /// </summary> /// <param name="context">数据上下文</param> /// <param name="billNo">单据号</param> void InsertRejectBill(DepotManagementDataContext context, string billNo) { string error = null; IMaterialRejectBill serverRejectBill = ServerModule.ServerModuleFactory.GetServerModule <IMaterialRejectBill>(); IMaterialListRejectBill serverRejectListBill = ServerModule.ServerModuleFactory.GetServerModule <IMaterialListRejectBill>(); var varData = from a in context.S_ScrapBill where a.Bill_ID == billNo select a; if (varData.Count() == 0) { return; } S_ScrapBill scarpBill = varData.Single(); List <string> lstProvider = (from a in context.S_ScrapGoods where a.Bill_ID == billNo && a.ResponsibilityProvider == a.Provider select a.Provider).Distinct().ToList(); foreach (string provider in lstProvider) { var dataProviderWork = from a in context.ProviderPrincipal where a.Provider == provider && a.IsMainDuty == true select a; View_HR_Personnel personnelInfo = UniversalFunction.GetPersonnelInfo(context, dataProviderWork.First().PrincipalWorkId); S_MaterialRejectBill bill = new S_MaterialRejectBill(); bill.Bill_ID = m_assignBill.AssignNewNo(context, serverRejectBill, CE_BillTypeEnum.采购退货单.ToString()); bill.Bill_Time = ServerTime.Time; bill.BillStatus = MaterialRejectBillBillStatus.已完成.ToString(); bill.Department = personnelInfo.部门编码; bill.FillInPersonnel = personnelInfo.姓名; bill.FillInPersonnelCode = personnelInfo.工号; bill.DepotManager = BasicInfo.LoginName; bill.Provider = provider; bill.Reason = "由【报废单】:" + billNo + " 生成的报废退货"; bill.Remark = "系统自动生成"; bill.BillType = "总仓库退货单"; bill.StorageID = "01"; bill.OutDepotDate = ServerTime.Time; context.S_MaterialRejectBill.InsertOnSubmit(bill); context.SubmitChanges(); var varData2 = from a in context.S_ScrapGoods where a.Provider == provider && a.Bill_ID == billNo && a.ResponsibilityProvider == a.Provider select a; foreach (S_ScrapGoods goodsInfo in varData2) { string orderForm = GetOrderForm(context, goodsInfo.GoodsID, goodsInfo.BatchNo, provider); if (orderForm == null) { throw new Exception(UniversalFunction.GetGoodsMessage(context, goodsInfo.GoodsID) + " 批次号:【" + goodsInfo.BatchNo + "】 供应商:【" + provider + "】 找不到对应的【订单号】"); } 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_MaterialListRejectBill goods = new S_MaterialListRejectBill(); goods.Bill_ID = bill.Bill_ID; goods.GoodsID = goodsInfo.GoodsID; goods.Provider = provider; goods.ProviderBatchNo = stockInfo == null ? "" : stockInfo.ProviderBatchNo; goods.BatchNo = goodsInfo.BatchNo; goods.Amount = (decimal)goodsInfo.Quantity; goods.Remark = ""; goods.AssociateID = orderForm; if (!serverRejectListBill.SetPriceInfo(goods.AssociateID, goods, bill.StorageID, out error)) { throw new Exception(error); } context.S_MaterialListRejectBill.InsertOnSubmit(goods); context.SubmitChanges(); } serverRejectBill.OpertaionDetailAndStock(context, bill); context.SubmitChanges(); } }
/// <summary> /// 有检测废的物品直接生成领料单 /// </summary> /// <param name="ctx">数据上下文</param> /// <param name="billInfo">单据信息</param> void InsertIntoMaterialRequisition(DepotManagementDataContext ctx, Business_QualityManagement_Isolation billInfo) { string error = null; string billNo = null; ServerModule.IMaterialRequisitionServer serverMaterialBill = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionServer>(); try { billNo = _assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); var varData = from a in ctx.S_MaterialRequisition where a.Bill_ID == billNo select a; S_MaterialRequisition lnqMaterial = null; List <string> listPersonnel = UniversalFunction.GetStorageOrStationPrincipal(billInfo.StorageID); if (listPersonnel.Contains("0008")) { listPersonnel.Remove("0008"); } if (listPersonnel.Contains("0417")) { listPersonnel.Remove("0417"); } if (varData.Count() != 0) { error = string.Format("自动生成的报废物品领料单单号 {0} 已被占用,请尝试重新进行此操作" + ",再三出现无法生成可用的单号时与管理员联系", billNo); throw new Exception(error); } else { lnqMaterial = new S_MaterialRequisition(); lnqMaterial.Bill_ID = billNo; lnqMaterial.Bill_Time = ServerModule.ServerTime.Time; lnqMaterial.AssociatedBillNo = billInfo.BillNo; lnqMaterial.AssociatedBillType = "不合格品隔离处置单"; lnqMaterial.BillStatus = "已出库"; lnqMaterial.Department = "ZK03"; lnqMaterial.DepartmentDirector = ""; lnqMaterial.DepotManager = UniversalFunction.GetPersonnelInfo(listPersonnel[0]).姓名; lnqMaterial.FetchCount = 0; lnqMaterial.FetchType = "零星领料"; lnqMaterial.FillInPersonnel = UniversalFunction.GetPersonnelInfo(BasicInfo.LoginID).姓名; lnqMaterial.FillInPersonnelCode = BasicInfo.LoginID; lnqMaterial.ProductType = ""; lnqMaterial.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code; lnqMaterial.Remark = "因入库零件进行了破坏性检测,由系统自动生成的破坏件领料单,对应单据号:" + billInfo.BillNo; lnqMaterial.StorageID = billInfo.StorageID; lnqMaterial.OutDepotDate = ServerTime.Time; if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterial, out error)) { throw new Exception(error); } S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods(); lnqMaterialGoods.Bill_ID = billNo; lnqMaterialGoods.BasicCount = 0; lnqMaterialGoods.BatchNo = billInfo.BatchNo; lnqMaterialGoods.GoodsID = billInfo.GoodsID; lnqMaterialGoods.ProviderCode = billInfo.Provider; lnqMaterialGoods.RealCount = Convert.ToDecimal(billInfo.QC_ScraptCount); lnqMaterialGoods.Remark = ""; lnqMaterialGoods.RequestCount = Convert.ToDecimal(billInfo.QC_ScraptCount); lnqMaterialGoods.ShowPosition = 1; ServerModule.IMaterialRequisitionGoodsServer serverMaterialGoods = ServerModule.ServerModuleFactory.GetServerModule <ServerModule.IMaterialRequisitionGoodsServer>(); if (!serverMaterialGoods.AutoCreateGoods(ctx, lnqMaterialGoods, out error)) { throw new Exception(error); } ctx.SubmitChanges(); if (!serverMaterialBill.FinishBill(ctx, lnqMaterial.Bill_ID, "", out error)) { throw new Exception(error); } ctx.SubmitChanges(); } } catch (Exception ex) { serverMaterialBill.DeleteBill(billNo, out error); throw new Exception(ex.Message); } }
/// <summary> /// 插入工装所有信息 /// </summary> /// <param name="frockBill">自制件工装信息</param> /// <param name="flag">是否进入工装台帐</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> bool CreateNewFrockMessage(S_FrockInDepotBill frockBill, bool flag, out string error) { error = null; FrockProvingReport serverFrockProvingReport = new FrockProvingReport(); try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.S_FrockInDepotGoodsBill where a.Bill_ID == frockBill.Bill_ID select a; foreach (var item in varData) { for (int i = 0; i < item.Amount; i++) { string strFrockNumber = GetNewFrockNumber(); S_FrockProvingReport lnqReport = new S_FrockProvingReport(); lnqReport.DJH = m_assignBill.AssignNewNo(serverFrockProvingReport, "工装验证报告单"); lnqReport.DJZT = "等待检验要求"; lnqReport.BillType = "入库检验"; lnqReport.BZRQ = ServerTime.Time; lnqReport.ConnectBillNumber = frockBill.Bill_ID; lnqReport.FrockNumber = strFrockNumber; lnqReport.GoodsID = item.GoodsID; if (!serverFrockProvingReport.AddBill(lnqReport, null, out error)) { return(false); } m_billMessageServer.SendNewFlowMessage(lnqReport.DJH, string.Format("{0} ※※※ 请【{1}】处理", UniversalFunction.GetGoodsMessage(lnqReport.GoodsID), CE_RoleEnum.工艺人员.ToString()), CE_RoleEnum.工艺人员); if (flag) { S_FrockStandingBook lnqBook = new S_FrockStandingBook(); lnqBook.GoodsID = item.GoodsID; lnqBook.FrockNumber = strFrockNumber; lnqBook.Designer = UniversalFunction.GetPersonnelName(frockBill.DesignerID); if (!m_serverFrockStandingBook.UpdateFrockStandingBook(lnqBook, null, out error)) { return(false); } } } } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 插入领料单 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="threePacketsOfTheRepairBill">三包外返修处置单主表信息</param> /// <param name="dtListOfStorageID">库房信息</param> /// <param name="threePacketsOfTheRepairList">三包外返修处置单明细信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> bool InsertMaterialRequisition(DepotManagementDataContext dataContext, YX_ThreePacketsOfTheRepairBill threePacketsOfTheRepairBill, DataTable dtListOfStorageID, DataTable threePacketsOfTheRepairList, out string error) { error = null; try { if (dtListOfStorageID == null || dtListOfStorageID.Rows.Count == 0) { return(true); } else { for (int k = 0; k < dtListOfStorageID.Rows.Count; k++) { //领表主表信息 MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer(); string strBillID = m_serverAssignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); S_MaterialRequisition lnqMaterial = new S_MaterialRequisition(); lnqMaterial.Bill_ID = strBillID; lnqMaterial.Bill_Time = ServerModule.ServerTime.Time; lnqMaterial.AssociatedBillNo = threePacketsOfTheRepairBill.Bill_ID; lnqMaterial.AssociatedBillType = "三包外返修处置单"; lnqMaterial.BillStatus = "已出库"; lnqMaterial.Department = m_serverDepartment.GetDeptInfoFromPersonnelInfo(threePacketsOfTheRepairBill.WorkShopPersonnel).Rows[0]["DepartmentCode"].ToString(); lnqMaterial.DepartmentDirector = threePacketsOfTheRepairBill.WorkshopManagerPersonnel; lnqMaterial.DepotManager = threePacketsOfTheRepairBill.StockPersonnel; lnqMaterial.FetchCount = 0; lnqMaterial.FetchType = "零星领料"; lnqMaterial.FillInPersonnel = threePacketsOfTheRepairBill.WorkShopPersonnel; lnqMaterial.FillInPersonnelCode = UniversalFunction.GetPersonnelCode(threePacketsOfTheRepairBill.WorkShopPersonnel); lnqMaterial.ProductType = ""; lnqMaterial.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.包外维修).Code; lnqMaterial.Remark = "由三包外返修处置单自动生成,对应的三包外返修处置单号为" + threePacketsOfTheRepairBill.Bill_ID; lnqMaterial.StorageID = dtListOfStorageID.Rows[k][0].ToString(); lnqMaterial.OutDepotDate = ServerTime.Time; if (!serverMaterialBill.AutoCreateBill(dataContext, lnqMaterial, out error)) { return(false); } for (int i = 0; i < threePacketsOfTheRepairList.Rows.Count; i++) { if (!Convert.ToBoolean(threePacketsOfTheRepairList.Rows[i]["是否为客户责任"]) && threePacketsOfTheRepairList.Rows[i][13].ToString().Trim() == dtListOfStorageID.Rows[k][0].ToString().Trim()) { var varStock = from a in dataContext.S_Stock where a.StorageID == dtListOfStorageID.Rows[k][0].ToString() && a.GoodsID == Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]) && a.BatchNo == threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() && a.Provider == threePacketsOfTheRepairList.Rows[i][14].ToString() select a; if (varStock.Count() != 1) { error = "库存信息不唯一或者为空"; return(false); } else { if (varStock.Single().GoodsStatus == 3) { error = "【" + varStock.Single().GoodsCode + "】 【" + varStock.Single().GoodsName + "】 【" + varStock.Single().Spec + "】【" + threePacketsOfTheRepairList.Rows[i]["批次号"].ToString() + "】物品库存状态为“隔离”不允许出库"; return(false); } } S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods(); lnqMaterialGoods.Bill_ID = strBillID; lnqMaterialGoods.BasicCount = 0; lnqMaterialGoods.BatchNo = threePacketsOfTheRepairList.Rows[i]["批次号"].ToString(); lnqMaterialGoods.GoodsID = Convert.ToInt32(threePacketsOfTheRepairList.Rows[i]["物品ID"]); lnqMaterialGoods.ProviderCode = threePacketsOfTheRepairList.Rows[i][14].ToString(); lnqMaterialGoods.RealCount = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]); lnqMaterialGoods.Remark = threePacketsOfTheRepairList.Rows[i]["备注"].ToString(); lnqMaterialGoods.RequestCount = Convert.ToDecimal(threePacketsOfTheRepairList.Rows[i]["领用数量"]); lnqMaterialGoods.ShowPosition = 1; MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer(); if (!serverMaterialGoods.AutoCreateGoods(dataContext, lnqMaterialGoods, out error)) { return(false); } } } dataContext.SubmitChanges(); new MaterialRequisitionServer().OpertaionDetailAndStock(dataContext, lnqMaterial); dataContext.SubmitChanges(); } } return(true); } catch (Exception ex) { error = error + ex.Message; return(false); } }
/// <summary> /// 插入领料退库表 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="billList">扣货子表</param> /// <param name="billTable">扣货主表</param> /// <param name="billNo">单据号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作成功返回True,操作失败返回False</returns> bool InsertMaterialReturnedInTheDepot(DepotManagementDataContext dataContxt, DataTable billList, DataTable billTable, string billNo, out string error) { error = null; try { MaterialReturnedInTheDepot serverReturnedBill = new MaterialReturnedInTheDepot(); string strLLBillNo = m_assignBill.AssignNewNo(serverReturnedBill, "领料退库单"); string storageID = UniversalFunction.GetStorageID(billList.Rows[0]["库房名称"].ToString()); //插入主表信息 S_MaterialReturnedInTheDepot depotBill = new S_MaterialReturnedInTheDepot(); depotBill.Bill_ID = strLLBillNo; depotBill.Bill_Time = ServerTime.Time; depotBill.BillStatus = MaterialReturnedInTheDepotBillStatus.已完成.ToString(); depotBill.Department = billList.Rows[0]["部门编码"].ToString(); depotBill.ReturnType = "机加退库";//退库类别 depotBill.FillInPersonnel = billList.Rows[0]["建单人"].ToString(); depotBill.FillInPersonnelCode = billList.Rows[0]["建单人编号"].ToString(); depotBill.DepartmentDirector = billList.Rows[0]["审核人"].ToString(); depotBill.QualityInputer = billList.Rows[0]["质管批准"].ToString(); depotBill.DepotManager = billList.Rows[0]["采购确认人"].ToString(); throw new Exception("用途不明,无法使用此单据"); //depotBill.PurposeCode = "30";//用途 //depotBill.ReturnReason = billList.Rows[0]["扣货原因"].ToString(); //depotBill.Remark = billList.Rows[0]["备注"].ToString() + "(根据物料扣货单【" + billNo + "】系统自动生成)"; //depotBill.StorageID = storageID; //depotBill.ReturnMode = "领料退库";//退库方式 //depotBill.IsOnlyForRepair = false; //depotBill.InDepotDate = ServerTime.Time; //dataContxt.S_MaterialReturnedInTheDepot.InsertOnSubmit(depotBill); //View_Department department = ServerModuleFactory.GetServerModule<IDepartmentServer>().GetDepartments(depotBill.Department); //for (int i = 0; i < billTable.Rows.Count; i++) //{ // #region 领料退库明细 // //插入业务明细 // S_MaterialListReturnedInTheDepot lnqDepotList = new S_MaterialListReturnedInTheDepot(); // lnqDepotList.Bill_ID = strLLBillNo; // lnqDepotList.GoodsID = Convert.ToInt32(billTable.Rows[i]["物品ID"].ToString()); // lnqDepotList.Provider = billTable.Rows[i]["供应商"].ToString(); // lnqDepotList.ProviderBatchNo = ""; // lnqDepotList.BatchNo = billTable.Rows[i]["批次号"].ToString(); // lnqDepotList.ReturnedAmount = Convert.ToDecimal(billTable.Rows[i]["扣货数"].ToString()); // lnqDepotList.Remark = billTable.Rows[i]["备注"].ToString(); // DataRow dtTemp = GetShelfArea(Convert.ToInt32(billTable.Rows[i]["物品ID"].ToString()), // billTable.Rows[i]["批次号"].ToString(), out error); // lnqDepotList.ShelfArea = dtTemp == null ? "" : dtTemp["货架"].ToString();//货架 // lnqDepotList.ColumnNumber = dtTemp == null ? "" : dtTemp["列"].ToString();//列 // lnqDepotList.LayerNumber = dtTemp == null ? "" : dtTemp["层"].ToString();//层 // lnqDepotList.Depot = dtTemp == null ? "" : dtTemp["材料类别编码"].ToString(); // dataContxt.S_MaterialListReturnedInTheDepot.InsertOnSubmit(lnqDepotList); // #endregion //} //serverReturnedBill.OpertaionDetailAndStock(dataContxt, depotBill); //return true; } catch (Exception ex) { error = ex.Message; return(false); } }
/// <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="ctx">数据上下文</param> /// <param name="inDepotInfo">报检单信息</param> /// <param name="mrBillNo">分配的领料单单号</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool InsertIntoMaterialRequisition(DepotManagementDataContext ctx, S_CheckOutInDepotBill inDepotInfo, out string mrBillNo, out string error) { error = null; mrBillNo = null; string billNo = null; MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer(); try { billNo = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); mrBillNo = billNo; var varData = from a in ctx.S_MaterialRequisition where a.Bill_ID == billNo select a; S_MaterialRequisition lnqMaterial = null; if (varData.Count() != 0) { error = string.Format("自动生成的报废物品领料单单号 {0} 已被占用,请尝试重新进行此操作,再三出现无法生成可用的单号时与管理员联系", billNo); return(false); } else { DateTime dt = ServerTime.Time; lnqMaterial = new S_MaterialRequisition(); lnqMaterial.Bill_ID = billNo; lnqMaterial.Bill_Time = dt; lnqMaterial.AssociatedBillNo = inDepotInfo.Bill_ID; lnqMaterial.AssociatedBillType = CE_BillTypeEnum.报检入库单.ToString(); lnqMaterial.BillStatus = "已出库"; lnqMaterial.Department = "ZK03"; lnqMaterial.DepartmentDirector = ""; lnqMaterial.DepotManager = inDepotInfo.DepotManager; lnqMaterial.FetchCount = 0; lnqMaterial.FetchType = "零星领料"; lnqMaterial.FillInPersonnel = inDepotInfo.QualityInputer; lnqMaterial.FillInPersonnelCode = m_personnelInfoServer.GetPersonnelInfo(inDepotInfo.QualityInputer).工号; lnqMaterial.ProductType = ""; lnqMaterial.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code; lnqMaterial.Remark = "因入库零件进行了破坏性检测,由系统自动生成的破坏件领料单,对应单据号:" + inDepotInfo.Bill_ID; lnqMaterial.StorageID = inDepotInfo.StorageID; lnqMaterial.OutDepotDate = dt; if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterial, out error)) { return(false); } } var varDataList = from a in ctx.S_MaterialRequisitionGoods where a.Bill_ID == billNo select a; if (varDataList.Count() != 0) { error = "此单据号已被占用"; return(false); } else { S_MaterialRequisitionGoods lnqMaterialGoods = new S_MaterialRequisitionGoods(); lnqMaterialGoods.Bill_ID = billNo; lnqMaterialGoods.BasicCount = 0; lnqMaterialGoods.BatchNo = inDepotInfo.BatchNo; lnqMaterialGoods.GoodsID = inDepotInfo.GoodsID; lnqMaterialGoods.ProviderCode = inDepotInfo.Provider; lnqMaterialGoods.RealCount = Convert.ToDecimal(inDepotInfo.DeclareWastrelCount); lnqMaterialGoods.Remark = ""; lnqMaterialGoods.RequestCount = Convert.ToDecimal(inDepotInfo.DeclareWastrelCount); lnqMaterialGoods.ShowPosition = 1; MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer(); if (!serverMaterialGoods.AutoCreateGoods(ctx, lnqMaterialGoods, out error)) { return(false); } } ctx.SubmitChanges(); if (!serverMaterialBill.FinishBill(ctx, lnqMaterial.Bill_ID, "", out error)) { throw new Exception(error); } ctx.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; //if (serverMaterialBill.DeleteBill(billNo, out error)) //{ // error = ex.Message; //} return(false); } }
/// <summary> /// 确认防锈 /// </summary> /// <param name="goodsTable">需要执行的物品数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>True 成功 false 失败</returns> public bool AuthorizeAntirustInfo(DataTable goodsTable, out string error) { error = null; MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer(); DepotManagementDataContext contxt = CommentParameter.DepotDataContext; contxt.Connection.Open(); contxt.Transaction = contxt.Connection.BeginTransaction(); try { DataTable dtTemp = GlobalObject.DataSetHelper.SelectDistinct("", goodsTable, "库房ID"); for (int k = 0; k < dtTemp.Rows.Count; k++) { DataTable dtgoodsTable = GlobalObject.DataSetHelper.SiftDataTable(goodsTable, "库房ID = '" + dtTemp.Rows[k][0].ToString() + "'", out error); if (error != null) { throw new Exception(error); } string billID = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); for (int i = 0; i < dtgoodsTable.Rows.Count; i++) { var varStock = from a in contxt.S_Stock where a.GoodsID == (int)dtgoodsTable.Rows[i]["物品ID"] && a.BatchNo == dtgoodsTable.Rows[i]["批次号"].ToString() && a.StorageID == dtgoodsTable.Rows[i]["库房ID"].ToString() && a.Provider == dtgoodsTable.Rows[i]["供应商"].ToString() select a; var varAntirust = from a in contxt.KF_GoodsAntirust where a.GoodsID == (int)dtgoodsTable.Rows[i]["物品ID"] && a.BatchNo == dtgoodsTable.Rows[i]["批次号"].ToString() && a.StorageID == dtgoodsTable.Rows[i]["库房ID"].ToString() && a.Provider == dtgoodsTable.Rows[i]["供应商"].ToString() select a; if (varStock.Count() != 1) { error = "数据不唯一或者为空"; throw new Exception(error); } else { S_Stock lnqStock = varStock.Single(); KF_GoodsAntirust lnqAntirust = varAntirust.Single(); if (Convert.ToDecimal(lnqAntirust.AntirustUnqualifiedCount) > 0) { if (!CreateMaterialRequisitionGoods(contxt, lnqAntirust, billID, out error)) { throw new Exception(error); } } lnqAntirust.AntirustUnqualifiedCount = 0; lnqAntirust.AuthorizePersonnel = BasicInfo.LoginName; if (lnqAntirust.AntirustState.ToString() == "等待确认") { lnqAntirust.AntirustDate = ServerTime.Time; lnqAntirust.AntirustState = "未防锈"; } else { error = "状态不符,请重新确认"; throw new Exception(error); } } } contxt.SubmitChanges(); var requistionVar = from a in contxt.S_MaterialRequisition where a.Bill_ID == billID select a; IMaterialRequisitionServer requisitionService = ServerModule.ServerModuleFactory.GetServerModule <IMaterialRequisitionServer>(); requisitionService.OpertaionDetailAndStock(contxt, requistionVar.Single()); m_assignBill.UseBillNo(CE_BillTypeEnum.领料单.ToString(), billID); } contxt.SubmitChanges(); contxt.Transaction.Commit(); return(true); } catch (Exception ex) { contxt.Transaction.Rollback(); error = ex.Message; return(false); } }
/// <summary> /// 插入数据 /// </summary> /// <param name="afterService">数据集</param> /// <param name="listInfo">明细表</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool InsertBill(Out_AfterServicePartsApplyBill afterService, DataTable listInfo, out string error) { error = null; try { DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; var varData = from a in dataContext.Out_AfterServicePartsApplyBill where a.Bill_ID == afterService.Bill_ID select a; if (varData.Count() == 0) { afterService.Bill_ID = m_serverBillNo.AssignNewNo(this, "售后配件申请单"); afterService.BillStatus = "等待主管审核"; afterService.Proposer = BasicInfo.LoginName; afterService.ProposerTime = ServerTime.Time; if (!InsertListInfo(dataContext, afterService.Bill_ID, listInfo, out error)) { return(false); } dataContext.Out_AfterServicePartsApplyBill.InsertOnSubmit(afterService); m_billMessageServer.DestroyMessage(afterService.Bill_ID); m_billMessageServer.SendNewFlowMessage(afterService.Bill_ID, string.Format("{0}号售后配件申请单已提交,请营销主管审核", afterService.Bill_ID), CE_RoleEnum.营销主管); } else if (varData.Count() == 1) { Out_AfterServicePartsApplyBill lnqBill = varData.Single(); lnqBill._4SLinkMan = afterService._4SLinkMan; lnqBill._4SPhone = afterService._4SPhone; lnqBill.Address = afterService.Address; lnqBill.ApplyState = afterService.ApplyState; lnqBill.CVTType = afterService.CVTType; lnqBill.InStorageID = afterService.InStorageID; lnqBill.OutStorageID = afterService.OutStorageID; lnqBill.ProductCode = afterService.ProductCode; lnqBill.Proposer = BasicInfo.LoginName; lnqBill.ProposerTime = ServerTime.Time; lnqBill.Remark = afterService.Remark; lnqBill.ServiceErea = afterService.ServiceErea; if (!DeleteListInfo(dataContext, lnqBill.Bill_ID, out error)) { return(false); } if (!InsertListInfo(dataContext, lnqBill.Bill_ID, listInfo, out error)) { return(false); } m_billMessageServer.DestroyMessage(afterService.Bill_ID); m_billMessageServer.SendNewFlowMessage(afterService.Bill_ID, string.Format("{0}号售后配件申请单已提交,请营销主管审核", afterService.Bill_ID), CE_RoleEnum.营销主管); } else { error = "数据重复"; return(false); } dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 自动生成领料单 /// </summary> /// <param name="context">数据上下文</param> /// <param name="isolation">隔离单单据信息</param> /// <param name="flag">是否为废弃数,若为废弃数则用“废弃数”表示</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>自动生成成功返回True,自动生成失败返回False</returns> private bool CreateMeterialRequisition(DepotManagementDataContext context, S_IsolationManageBill isolation, string flag, out string error) { error = null; MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer(); try { string strBillID = m_assignBill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); var varIsolation = from a in context.S_IsolationManageBill where a.DJH == isolation.DJH select a; S_IsolationManageBill lnqNewIsolation = new S_IsolationManageBill(); if (varIsolation.Count() != 1) { error = "数据不唯一或者为空"; return(false); } else { lnqNewIsolation = varIsolation.Single(); } #region 领料总单 S_MaterialRequisition lnqMater = new S_MaterialRequisition(); lnqMater.Bill_Time = ServerTime.Time; lnqMater.Bill_ID = strBillID; lnqMater.BillStatus = "已出库"; lnqMater.Department = "ZK"; lnqMater.DepartmentDirector = ""; lnqMater.DepotManager = ""; lnqMater.FetchCount = 0; lnqMater.FetchType = "零星领料"; lnqMater.FillInPersonnel = flag == "废弃数" ? "陈岁年" : UniversalFunction.GetPersonnelName(lnqNewIsolation.JYRY); //质管部要求[废弃数]变更编制人为陈岁年 2012.3.15 lnqMater.FillInPersonnelCode = flag == "废弃数" ? "0621" : lnqNewIsolation.JYRY; //质管部要求[废弃数]变更编制人为陈岁年 2012.3.15 lnqMater.OutDepotDate = ServerTime.Time; lnqMater.ProductType = ""; lnqMater.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code; lnqMater.Remark = flag == "废弃数" ? "不合格品隔离处置单废弃处理,关联的隔离单号: " + isolation.DJH : "不合格品隔离处置单检测报废,关联的隔离单号: " + isolation.DJH; lnqMater.StorageID = isolation.StorageID; lnqMater.AssociatedBillNo = ""; lnqMater.AssociatedBillType = ""; if (!serverMaterialBill.AutoCreateBill(context, lnqMater, out error)) { return(false); } #endregion #region 领料单明细 S_MaterialRequisitionGoods lnqMaterGoods = new S_MaterialRequisitionGoods(); var varMaterialStock = from a in context.S_Stock where a.GoodsID == isolation.GoodsID && a.BatchNo == isolation.BatchNo && a.StorageID == isolation.StorageID && a.Provider == isolation.Provider select a; S_Stock lnqStock = new S_Stock(); if (varMaterialStock.Count() != 1) { error = "数据不唯一或者为空"; return(false); } else { lnqStock = varMaterialStock.Single(); } lnqMaterGoods.BasicCount = 0; lnqMaterGoods.BatchNo = isolation.BatchNo; lnqMaterGoods.Bill_ID = strBillID; lnqMaterGoods.GoodsID = (int)isolation.GoodsID; lnqMaterGoods.ProviderCode = isolation.Provider; lnqMaterGoods.RealCount = flag == "废弃数" ? isolation.QC_FQS : isolation.QC_BFS; lnqMaterGoods.Remark = flag == "废弃数" ? "不合格品隔离处置单废弃处理,关联的隔离单号: " + isolation.DJH : "不合格品隔离处置单检测报废,关联的隔离单号: " + isolation.DJH; lnqMaterGoods.RequestCount = flag == "废弃数" ? isolation.QC_FQS : isolation.QC_BFS; lnqMaterGoods.ShowPosition = 1; MaterialRequisitionGoodsServer serverMaterialGoods = new MaterialRequisitionGoodsServer(); if (!serverMaterialGoods.AutoCreateGoods(context, lnqMaterGoods, out error)) { return(false); } context.SubmitChanges(); #endregion serverMaterialBill.OpertaionDetailAndStock(context, lnqMater); context.SubmitChanges(); m_assignBill.UseBillNo(CE_BillTypeEnum.领料单.ToString(), strBillID); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 自动生成领料单 /// </summary> /// <param name="billID">售后服务配件申请单单号且为生成后的领料单的关联单据</param> /// <param name="storageID">库房ID</param> /// <param name="error">失败时返回的错误信息</param> /// <returns>True 自动生成成功,False 自动生成失败</returns> public bool AutogenerationMaterialRequisition(string billID, string storageID, out string error) { error = null; string strMaterialBillID = ""; string strOutMessage = ""; try { DataTable dtListOfStraogeID = GetListStorageID(billID); if (dtListOfStraogeID.Rows.Count == 0) { throw new Exception("此物品无【领料清单】相关信息,无法生成领料单"); } else { DataTable tempGoodsTable = GetSumRequestCount(billID); for (int k = 0; k < dtListOfStraogeID.Rows.Count; k++) { MaterialRequisitionServer serverMaterialBill = new MaterialRequisitionServer(); DepotManagementDataContext ctx = CommentParameter.DepotDataContext; strMaterialBillID = m_Assignbill.AssignNewNo(serverMaterialBill, CE_BillTypeEnum.领料单.ToString()); S_MaterialRequisition lnqMaterialBill = new S_MaterialRequisition(); lnqMaterialBill.AssociatedBillNo = ""; lnqMaterialBill.AssociatedBillType = ""; lnqMaterialBill.Bill_ID = strMaterialBillID; lnqMaterialBill.Bill_Time = ServerTime.Time; lnqMaterialBill.BillStatus = "新建单据"; lnqMaterialBill.Department = m_serverDepartment.GetDeptInfoFromPersonnelInfo( BasicInfo.LoginName).Rows[0]["DepartmentCode"].ToString(); lnqMaterialBill.DepartmentDirector = ""; lnqMaterialBill.DepotManager = ""; lnqMaterialBill.FetchCount = 0; lnqMaterialBill.FetchType = "零星领料"; lnqMaterialBill.FillInPersonnel = BasicInfo.LoginName; lnqMaterialBill.FillInPersonnelCode = BasicInfo.LoginID; lnqMaterialBill.ProductType = ""; lnqMaterialBill.PurposeCode = UniversalFunction.GetPurpose(CE_PickingPurposeProperty.包外装配).Code; lnqMaterialBill.Remark = "由系统自动生成 售后服务配件制造申请单【" + billID + "】"; lnqMaterialBill.StorageID = dtListOfStraogeID.Rows[k][0].ToString(); int rowCount = tempGoodsTable.Rows.Count; if (!InsertMaterialRequisitionList(ctx, ref tempGoodsTable, lnqMaterialBill.StorageID, strMaterialBillID, out error)) { m_Assignbill.CancelBillNo("领料单", strMaterialBillID); return(false); } if (error != null && error.Contains("【图号型号】")) { strOutMessage = "【领料单号】:" + strMaterialBillID + "\r\n" + error; } //tempGoodsTable = GlobalObject.DataSetHelper.SiftDataTable(tempGoodsTable, "RequestCount > 0", out error); //if (rowCount == tempGoodsTable.Rows.Count) //{ // continue; //} if (!serverMaterialBill.AutoCreateBill(ctx, lnqMaterialBill, out error)) { throw new Exception(error); } //ctx.S_MaterialRequisition.InsertOnSubmit(lnqMaterialBill); ctx.SubmitChanges(); } } error = strOutMessage; return(true); } catch (Exception ex) { error = ex.Message; m_Assignbill.CancelBillNo("领料单", strMaterialBillID); return(false); } }
/// <summary> /// 提交单据 /// </summary> /// <param name="produtctReleases">LINQ实体集</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool SubmitBill(ZL_ProductReleases produtctReleases, out string error) { error = null; DepotManagementDataContext ctx = CommentParameter.DepotDataContext; try { var varData = from a in ctx.ZL_ProductReleases where a.BillNo == produtctReleases.BillNo select a; ZL_ProductReleases lnqProductReleases = new ZL_ProductReleases(); if (varData.Count() == 0) { lnqProductReleases.BillNo = m_serverAssginBillNo.AssignNewNo(this, CE_BillTypeEnum.线不合格品放行单.ToString()); lnqProductReleases.BillStatus = "等待审核"; lnqProductReleases.FaultPhenomenon = produtctReleases.FaultPhenomenon; lnqProductReleases.ProductCode = produtctReleases.ProductCode; lnqProductReleases.ProductModel = produtctReleases.ProductModel; lnqProductReleases.Proposer = BasicInfo.LoginName; lnqProductReleases.ProposerDate = ServerTime.Time; lnqProductReleases.Remark = produtctReleases.Remark; ctx.ZL_ProductReleases.InsertOnSubmit(lnqProductReleases); } else if (varData.Count() == 1) { lnqProductReleases = varData.Single(); switch (lnqProductReleases.BillStatus) { case "新建单据": lnqProductReleases.BillStatus = "等待审核"; lnqProductReleases.FaultPhenomenon = produtctReleases.FaultPhenomenon; lnqProductReleases.ProductCode = produtctReleases.ProductCode; lnqProductReleases.ProductModel = produtctReleases.ProductModel; lnqProductReleases.Proposer = BasicInfo.LoginName; lnqProductReleases.ProposerDate = ServerTime.Time; lnqProductReleases.Remark = produtctReleases.Remark; break; case "等待审核": lnqProductReleases.BillStatus = "等待批准"; lnqProductReleases.Auditing = BasicInfo.LoginName; lnqProductReleases.AuditingDate = ServerTime.Time; break; case "等待批准": lnqProductReleases.BillStatus = "已完成"; lnqProductReleases.Authorize = BasicInfo.LoginName; lnqProductReleases.AuthorizeDate = ServerTime.Time; break; ; default: break; } } ctx.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 提交申请 /// </summary> /// <param name="maneuverBill">单据信息数据集</param> /// <param name="listInfo">明细信息</param> /// <param name="error">错误信息</param> /// <returns>成功返回True,失败返回False</returns> public bool InsertBill(Out_ManeuverBill maneuverBill, DataTable listInfo, out string error) { error = null; DepotManagementDataContext dataContext = CommentParameter.DepotDataContext; try { dataContext.Connection.Open(); dataContext.Transaction = dataContext.Connection.BeginTransaction(); var varData = from a in dataContext.Out_ManeuverBill where a.Bill_ID == maneuverBill.Bill_ID select a; if (varData.Count() == 0) { maneuverBill.Bill_ID = m_serverBillNo.AssignNewNo(this, "调运单"); maneuverBill.BillStatus = "等待主管审核"; if (!InsertList(dataContext, maneuverBill.Bill_ID, listInfo, out error)) { throw new Exception(error); } dataContext.Out_ManeuverBill.InsertOnSubmit(maneuverBill); m_billMessageServer.DestroyMessage(maneuverBill.Bill_ID); m_billMessageServer.SendNewFlowMessage(maneuverBill.Bill_ID, string.Format("{0}号调运单已提交,请营销主管审核", maneuverBill.Bill_ID), CE_RoleEnum.营销主管); } else if (varData.Count() == 1) { Out_ManeuverBill lnqBill = varData.Single(); lnqBill.BillStatus = "等待主管审核"; lnqBill.Remark = maneuverBill.Remark; lnqBill.InStorageID = maneuverBill.InStorageID; lnqBill.OutStorageID = maneuverBill.OutStorageID; lnqBill.ScrapBillNo = maneuverBill.ScrapBillNo; if (!DeleteList(dataContext, maneuverBill.Bill_ID, out error)) { throw new Exception(error); } if (!InsertList(dataContext, maneuverBill.Bill_ID, listInfo, out error)) { throw new Exception(error); } m_billMessageServer.DestroyMessage(maneuverBill.Bill_ID); m_billMessageServer.SendNewFlowMessage(maneuverBill.Bill_ID, string.Format("{0}号调运单已提交,请营销主管审核", maneuverBill.Bill_ID), CE_RoleEnum.营销主管); } else { error = "数据重复"; throw new Exception(error); } dataContext.SubmitChanges(); dataContext.Transaction.Commit(); return(true); } catch (Exception ex) { dataContext.Transaction.Rollback(); error = ex.Message; return(false); } }