/// <summary> /// 更新退货建议数据 /// </summary> /// <param name="djh">报检单单号</param> /// <param name="rejectMode">退货建议</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool UpdateRejectMode(string djh, string rejectMode, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var varData = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == djh select a; if (varData.Count() == 1) { S_CheckOutInDepotBill lnqCheck = varData.Single(); lnqCheck.RejectMode = rejectMode; lnqCheck.SQETHRQ = ServerTime.Time; lnqCheck.SQETHRY = BasicInfo.LoginName; } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 报废单据 /// </summary> /// <param name="billID">要报废的单据编号</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool ScrapBill(string billID, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var datevar = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == billID select a; if (datevar.Count() != 1) { error = "报废单据不唯一"; return(false); } else { S_CheckOutInDepotBill lnqCheck = datevar.Single(); lnqCheck.BillStatus = "已报废"; dataContxt.SubmitChanges(); } return(true); //GetAllBill(out returnBill, out error); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 更新报检入库单(记录合格数、报废数、退货数等,并更改单据状态) /// </summary> /// <param name="dataContext">LINQ数据上下文</param> /// <param name="bill">Linq挑返单数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>更改成功返回True,更改失败返回False</returns> private bool UpdateInDepotBill(DepotManagementDataContext dataContext, S_CheckReturnRepairBill bill, out string error) { try { error = null; var varData = from a in dataContext.S_CheckOutInDepotBill where a.Bill_ID == bill.InDepotBillID select a; if (varData.Count() != 1) { error = "记录不唯一"; return(false); } else { S_CheckOutInDepotBill lnqCheck = varData.Single(); lnqCheck.EligibleCount = (int)bill.QC_HGS; lnqCheck.ConcessionCount = (int)bill.QC_RBS; lnqCheck.ReimbursementCount = (int)bill.QC_THS; lnqCheck.DeclareWastrelCount = (int)bill.QC_BFS; lnqCheck.BillStatus = "等待入库"; } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <returns>返回库存信息对象</returns> public S_Stock AssignStockInfo(DepotManagementDataContext dataContext, S_CheckOutInDepotBill bill) { S_Stock stock = new S_Stock(); stock.GoodsID = bill.GoodsID; stock.StorageID = bill.StorageID; stock.ShelfArea = bill.ShelfArea; stock.ColumnNumber = bill.ColumnNumber; stock.LayerNumber = bill.LayerNumber; stock.Provider = bill.Provider; stock.ProviderBatchNo = bill.ProviderBatchNo; stock.BatchNo = bill.BatchNo; stock.ExistCount = bill.InDepotCount; stock.UnitPrice = bill.UnitPrice; stock.StorageID = bill.StorageID; stock.Version = bill.Version; if (bill.OnlyForRepairFlag) { stock.GoodsStatus = 6; } return(stock); }
/// <summary> /// 提交检验报告 /// </summary> /// <param name="qualityInfo">质量信息, 只取其中质量部分</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool SubmitReportInfo(S_CheckOutInDepotBill qualityInfo, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var result = from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == qualityInfo.Bill_ID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的报检入库单!", qualityInfo.Bill_ID); return(false); } S_CheckOutInDepotBill bill = result.Single(); bill.Checker = qualityInfo.Checker; // 检验员 bill.CheckoutReport_ID = qualityInfo.CheckoutReport_ID; // 检验报告编号 bill.CheckoutJoinGoods_Time = ServerTime.Time; // 检验入库时间 dataContxt.SubmitChanges(); return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 报废单据 /// </summary> /// <param name="inReturn">Linq挑返单数据集</param> /// <param name="flag">标志 True 等待质检机检验 False 等待质检电检验</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>报废成功返回True,报废失败返回False</returns> public bool ScrapBill(S_CheckReturnRepairBill inReturn, bool flag, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var varDataFst = from a in dataContxt.S_CheckReturnRepairBill where a.DJH == inReturn.DJH select a; if (varDataFst.Count() != 1) { error = "记录不唯一"; return(false); } else { dataContxt.S_CheckReturnRepairBill.DeleteAllOnSubmit(varDataFst); } var varDataSec = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == inReturn.InDepotBillID select a; if (varDataSec.Count() != 1) { error = "记录不唯一"; return(false); } else { S_CheckOutInDepotBill lnqCheck = varDataSec.Single(); lnqCheck.EligibleCount = 0; lnqCheck.ConcessionCount = 0; lnqCheck.ReimbursementCount = 0; lnqCheck.DeclareWastrelCount = 0; lnqCheck.BillStatus = flag == true ? "等待质检机检验" : "等待质检电检验"; lnqCheck.TFFlag = false; lnqCheck.QualityInputer = null; lnqCheck.CheckTime = null; lnqCheck.CheckoutJoinGoods_Time = null; } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 确认到货数 /// </summary> /// <param name="billID">单据编号</param> /// <param name="confirmAmountSignatory">仓库收货员签名</param> /// <param name="goodsAmount">货物数量</param> /// <param name="billStatusInfo">单据状态信息</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool AffirmGoodsAmount(string billID, string confirmAmountSignatory, int goodsAmount, string billStatusInfo, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var result = from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == billID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的报检入库单!", billID); return(false); } S_CheckOutInDepotBill bill = result.Single(); bill.DepotManagerAffirmCount = goodsAmount; bill.BillStatus = billStatusInfo; bill.ConfirmAmountSignatory = confirmAmountSignatory; bill.DepotAffirmanceTime = ServerTime.Time; bill.RebackReason = ""; dataContxt.SubmitChanges(); View_F_GoodsPlanCost goodsInfo = UniversalFunction.GetGoodsInfo(bill.GoodsID); string strTemp = GlobalObject.GeneralFunction.ListToString <string>(UniversalFunction.GetApplicableMode_CGBOM(bill.GoodsID), ","); List <string> lstText = new List <string>(); lstText.Add(" 物品标识(part list)"); lstText.Add("名称 " + goodsInfo.物品名称); lstText.Add("图号 " + goodsInfo.图号型号); lstText.Add("型号 " + strTemp); lstText.Add("批号 " + bill.BatchNo); lstText.Add("数量 " + bill.DepotManagerAffirmCount.ToString() + "※供应商 " + bill.Provider); lstText.Add("日期 " + ServerTime.Time.ToShortDateString()); ServerModule.PrintPartBarcode.PrintBarcode_Common(lstText); return(true); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 采购员更新报检入库单 /// </summary> /// <param name="updateBill">单据信息</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool UpdateBill(S_CheckOutInDepotBill updateBill, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { S_CheckOutInDepotBill bill = (from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == updateBill.Bill_ID select r).Single(); bill.StorageID = updateBill.StorageID; bill.BatchNo = updateBill.BatchNo; bill.ArriveGoods_Time = updateBill.ArriveGoods_Time; bill.Bill_Time = updateBill.Bill_Time; bill.BillStatus = updateBill.BillStatus; bill.Buyer = updateBill.Buyer; bill.DeclareCount = updateBill.DeclareCount; bill.DeclarePersonnel = updateBill.DeclarePersonnel; bill.DeclarePersonnelCode = updateBill.DeclarePersonnelCode; bill.GoodsID = updateBill.GoodsID; bill.OrderFormNumber = updateBill.OrderFormNumber; bill.Provider = updateBill.Provider; bill.ProviderBatchNo = updateBill.ProviderBatchNo; bill.RebackReason = ""; bill.Remark = updateBill.Remark; bill.PlanUnitPrice = updateBill.PlanUnitPrice; bill.PlanPrice = updateBill.PlanPrice; bill.UnitPrice = updateBill.UnitPrice; bill.Price = updateBill.Price; bill.TotalPrice = updateBill.TotalPrice; bill.PeremptorilyEmit = updateBill.PeremptorilyEmit; // 紧急放行 bill.CheckTime = updateBill.CheckTime; bill.DepotAffirmanceTime = updateBill.DepotAffirmanceTime; bill.InDepotTime = updateBill.InDepotTime; bill.IsExigenceCheck = updateBill.IsExigenceCheck; bill.OnlyForRepairFlag = updateBill.OnlyForRepairFlag; bill.Version = updateBill.Version; dataContxt.SubmitChanges(); return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 提交质量信息 /// </summary> /// <param name="qualityInfo">质量信息, 只取其中质量部分</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool SubmitQualityInfo(S_CheckOutInDepotBill qualityInfo, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var result = from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == qualityInfo.Bill_ID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的报检入库单!", qualityInfo.Bill_ID); return(false); } S_CheckOutInDepotBill bill = result.Single(); bill.QualityInputer = qualityInfo.QualityInputer; // 质量信息输入者 bill.EligibleCount = qualityInfo.EligibleCount; // 合格数量 bill.DeclareWastrelCount = qualityInfo.DeclareWastrelCount; // 报废数量 bill.ConcessionCount = qualityInfo.ConcessionCount; // 让步数 bill.ReimbursementCount = qualityInfo.ReimbursementCount; // 退货数 bill.QualityInfo = qualityInfo.QualityInfo; // 质量信息 bill.BillStatus = qualityInfo.BillStatus; // 单据状态 bill.RebackReason = ""; bill.CheckTime = ServerTime.Time; bill.TFFlag = qualityInfo.TFFlag; // 是否挑返 bill.PeremptorilyEmit = qualityInfo.PeremptorilyEmit; // 是否加急 if (bill.Checker == "") { bill.Checker = qualityInfo.Checker; // 检验员 bill.CheckoutReport_ID = qualityInfo.CheckoutReport_ID; // 检验报告编号 bill.CheckoutJoinGoods_Time = ServerTime.Time; // 检验入库时间 } dataContxt.SubmitChanges(); return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> public void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_CheckOutInDepotBill bill) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); S_InDepotDetailBill detailInfo = AssignDetailInfo(dataContext, bill); S_Stock stockInfo = AssignStockInfo(dataContext, bill); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } if (bill.DeclareCount < bill.InDepotCount) { throw new Exception("入库数不能大于报检数"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); }
/// <summary> /// 插入WEB 数据库 /// </summary> /// <param name="bill">单据信息</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool InsertWebData(S_CheckOutInDepotBill bill, out string error) { try { error = null; int intListID = GetWebListID(bill.Bill_ID); if (intListID == 0) { error = "数据库无记录"; return(false); } WebSeverDataContext dataContext = WebServerModule.WebDatabaseParameter.WebDataContext; OF_OrderForm_ArrivalInfo lnqArrival = new OF_OrderForm_ArrivalInfo(); lnqArrival.ActualDate = bill.ArriveGoods_Time; lnqArrival.ActuaQuantity = Convert.ToDecimal(bill.DepotManagerAffirmCount); lnqArrival.ConcessionQuantity = Convert.ToDecimal(bill.ConcessionCount); lnqArrival.DestructQuantity = Convert.ToDecimal(bill.DeclareWastrelCount); lnqArrival.EligibilityQuantity = Convert.ToDecimal(bill.EligibleCount); lnqArrival.ListID = intListID; lnqArrival.QualityInfo = bill.QualityInfo; lnqArrival.RejectQuantity = Convert.ToDecimal(bill.ReimbursementCount); lnqArrival.BatchNo = bill.BatchNo; lnqArrival.InBillID = bill.Bill_ID; dataContext.OF_OrderForm_ArrivalInfo.InsertOnSubmit(lnqArrival); dataContext.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 变更金额_报检入库单 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="detailInfo">结算单明细</param> void ChangePrice_S_CheckOutInDepotBill(DepotManagementDataContext dataContxt, View_Business_Settlement_ProcurementStatementDetail detailInfo) { var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == detailInfo.入库单号 && a.GoodsID == detailInfo.物品ID && a.BatchNo == detailInfo.批次号 select a; //报检入库单单价修改 if (varCheckOutInDepot.Count() != 0) { S_CheckOutInDepotBill lnqCheckOutInDepotBill = varCheckOutInDepot.Single(); lnqCheckOutInDepotBill.UnitInvoicePrice = detailInfo.发票单价; lnqCheckOutInDepotBill.InvoicePrice = detailInfo.发票金额; lnqCheckOutInDepotBill.HavingInvoice = true; dataContxt.SubmitChanges(); } }
/// <summary> /// 更新出入库的金额 /// </summary> /// <param name="invoiceTable">需要更新的数据集</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>更新成功True,更新失败False</returns> public bool UpdatePrice(DataTable invoiceTable, out string error) { error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; OrdinaryInDepotBillServer serverOrdinaryBill = new OrdinaryInDepotBillServer(); MaterialRejectBill serverMaterialRejectBill = new MaterialRejectBill(); DateTime dtStart = new DateTime(); DateTime dtEnd = new DateTime(); //获得当前日期的月结起始日期与结束日期 ServerTime.GetMonthlyBalance(ServerTime.Time, out dtStart, out dtEnd); for (int i = 0; i <= invoiceTable.Rows.Count - 1; i++) { string code = invoiceTable.Rows[i]["GoodsCode"].ToString(); string name = invoiceTable.Rows[i]["GoodsName"].ToString(); string spec = invoiceTable.Rows[i]["Spec"].ToString(); View_F_GoodsPlanCost basicGoods = m_basicGoodsServer.GetGoodsInfo(code, name, spec, out error); if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error)) { return(false); } #region 改变入库表的单价(普通入库或者报检入库) var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == basicGoods.序号 && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //报检入库单单价修改 if (varCheckOutInDepot.Count() != 0) { S_CheckOutInDepotBill lnqCheckOutInDepotBill = varCheckOutInDepot.Single(); lnqCheckOutInDepotBill.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqCheckOutInDepotBill.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqCheckOutInDepotBill.HavingInvoice = true; dataContxt.SubmitChanges(); } else { int intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //普通入库单单价修改 if (varOrdinaryGoods.Count() != 0) { S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single(); lnqOrdinaryGoods.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqOrdinaryGoods.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqOrdinaryGoods.HavingInvoice = true; dataContxt.SubmitChanges(); int intFlag = serverOrdinaryBill.GetHavingInvoice(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() select a; if (varOrdinaryBill.Count() != 0) { S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single(); lnqOrdinaryBill.InvoiceStatus = intFlag; dataContxt.SubmitChanges(); } } }//采购退货单单价修改 else { intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varRejectList = from a in dataContxt.S_MaterialListRejectBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; if (varRejectList.Count() != 0) { S_MaterialListRejectBill lnqMaterialList = varRejectList.Single(); lnqMaterialList.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqMaterialList.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqMaterialList.HavingInvoice = true; dataContxt.SubmitChanges(); int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(invoiceTable.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varReject = from a in dataContxt.S_MaterialRejectBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() select a; if (varReject.Count() != 0) { S_MaterialRejectBill lnqMaterialBill = varReject.Single(); lnqMaterialBill.InvoiceFlag = intFlag; dataContxt.SubmitChanges(); } } } else { intGoodsID = m_basicGoodsServer.GetGoodsID(invoiceTable.Rows[i]["GoodsCode"].ToString(), invoiceTable.Rows[i]["GoodsName"].ToString(), invoiceTable.Rows[i]["Spec"].ToString()); var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill where a.Bill_ID == invoiceTable.Rows[i]["Bill_ID"].ToString() && a.GoodsID == intGoodsID && a.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select a; //委外报检入库单单价修改 if (varOutsourcing.Count() != 0) { S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single(); lnqOutsourcing.UnitInvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqOutsourcing.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqOutsourcing.HavingInvoice = true; dataContxt.SubmitChanges(); } } } } #endregion #region 改变入库明细表金额 var varInDepotBill = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == basicGoods.序号 && b.InDepotBillID == invoiceTable.Rows[i]["Bill_ID"].ToString() && b.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() select b; if (varInDepotBill.Count() == 1) { S_InDepotDetailBill lnqInDepotBill = varInDepotBill.Single(); lnqInDepotBill.InvoiceUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqInDepotBill.InvoicePrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); if (lnqInDepotBill.FactPrice != Convert.ToDecimal(invoiceTable.Rows[i]["Price"])) { //当查询的记录不在当月的结算日期范围内,插入红冲单据与对冲单据 if (lnqInDepotBill.BillTime < dtStart || lnqInDepotBill.BillTime > dtEnd) { var varDetail = from d in dataContxt.S_InDepotDetailBill where d.GoodsID == basicGoods.序号 && d.InDepotBillID.Contains(invoiceTable.Rows[i]["Bill_ID"].ToString()) && d.BatchNo == invoiceTable.Rows[i]["BatchNo"].ToString() && d.BillTime >= dtStart && d.BillTime <= dtEnd select d; //判断是否已经在当前结算日期范围内插入了红冲与对冲数据 if (varDetail.Count() != 0) { foreach (var item in varDetail) { //针对已经插入的对冲数据进行修改 if (item.InDepotBillID.Contains("(对冲单据)")) { item.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); item.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); } } }//对没有插入的红冲与对冲的记录进行插入 else { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqOldInDepotBill = new S_InDepotDetailBill(); lnqOldInDepotBill.ID = Guid.NewGuid(); lnqOldInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(红冲单据)"; lnqOldInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqOldInDepotBill.BillTime = ServerTime.Time; lnqOldInDepotBill.Department = lnqInDepotBill.Department; lnqOldInDepotBill.FactUnitPrice = lnqInDepotBill.FactUnitPrice; lnqOldInDepotBill.FactPrice = -lnqInDepotBill.FactPrice; lnqOldInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqOldInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqOldInDepotBill.InDepotCount = -lnqInDepotBill.InDepotCount; lnqOldInDepotBill.Price = -lnqInDepotBill.Price; lnqOldInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqOldInDepotBill.Provider = lnqInDepotBill.Provider; lnqOldInDepotBill.Remark = lnqInDepotBill.Remark; lnqOldInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqOldInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqOldInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqOldInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); serverDetail.ProcessInDepotDetail(dataContxt, lnqOldInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqNewInDepotBill = new S_InDepotDetailBill(); lnqNewInDepotBill.ID = Guid.NewGuid(); lnqNewInDepotBill.InDepotBillID = lnqInDepotBill.InDepotBillID + "(对冲单据)"; lnqNewInDepotBill.BatchNo = lnqInDepotBill.BatchNo; lnqNewInDepotBill.BillTime = ServerTime.Time; lnqNewInDepotBill.Department = lnqInDepotBill.Department; lnqNewInDepotBill.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); lnqNewInDepotBill.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqNewInDepotBill.FillInPersonnel = lnqInDepotBill.FillInPersonnel; lnqNewInDepotBill.GoodsID = lnqInDepotBill.GoodsID; lnqNewInDepotBill.InDepotCount = lnqInDepotBill.InDepotCount; lnqNewInDepotBill.Price = lnqInDepotBill.Price; lnqNewInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqNewInDepotBill.Provider = lnqInDepotBill.Provider; lnqNewInDepotBill.Remark = lnqInDepotBill.Remark; lnqNewInDepotBill.StorageID = lnqInDepotBill.StorageID; lnqNewInDepotBill.UnitPrice = lnqInDepotBill.UnitPrice; lnqNewInDepotBill.FillInDate = lnqInDepotBill.FillInDate; lnqNewInDepotBill.AffrimPersonnel = lnqInDepotBill.AffrimPersonnel; serverDetail.ProcessInDepotDetail(dataContxt, lnqNewInDepotBill, null); } } else { lnqInDepotBill.FactPrice = Convert.ToDecimal(invoiceTable.Rows[i]["Price"]); lnqInDepotBill.FactUnitPrice = Convert.ToDecimal(invoiceTable.Rows[i]["UnitPrice"]); } } dataContxt.SubmitChanges(); } #endregion } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 删除发票记录 /// </summary> /// <param name="invoiceCode">发票号</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>删除成功返回True,删除失败返回False</returns> public bool DeleteInvoiceInfo(string invoiceCode, out string error) { error = null; string str = "0"; int count = 0; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; OrdinaryInDepotBillServer serverOrdinaryBill = new OrdinaryInDepotBillServer(); MaterialRejectBill serverMaterialRejectBill = new MaterialRejectBill(); string strSql = "select * from B_Invoice where InvoiceCode = '" + invoiceCode + "'"; DataTable dtInvoice = GlobalObject.DatabaseServer.QueryInfo(strSql); for (int i = 0; i <= dtInvoice.Rows.Count - 1; i++) { count = i; decimal dcOldUnitPrice = 0; if (!GlobalObject.GeneralFunction.IsNullOrEmpty(error)) { return(false); } str = "1"; #region 改变入库表的单价(普通入库或者报检入库) var varCheckOutInDepot = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varCheckOutInDepot.Count() != 0) { S_CheckOutInDepotBill lnqCheckOutInDepot = varCheckOutInDepot.Single(); lnqCheckOutInDepot.UnitInvoicePrice = 0; lnqCheckOutInDepot.InvoicePrice = 0; lnqCheckOutInDepot.HavingInvoice = false; dcOldUnitPrice = lnqCheckOutInDepot.UnitPrice; dataContxt.SubmitChanges(); } else { var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varOrdinaryGoods.Count() != 0) { S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single(); lnqOrdinaryGoods.InvoiceUnitPrice = 0; lnqOrdinaryGoods.InvoicePrice = 0; lnqOrdinaryGoods.HavingInvoice = false; dcOldUnitPrice = lnqOrdinaryGoods.UnitPrice; dataContxt.SubmitChanges(); int intFlag = serverOrdinaryBill.GetHavingInvoice(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; if (varOrdinaryBill.Count() != 0) { S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single(); lnqOrdinaryBill.InvoiceStatus = intFlag; dataContxt.SubmitChanges(); } } } else { var varRejectList = from a in dataContxt.S_MaterialListRejectBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varRejectList.Count() != 0) { S_MaterialListRejectBill lnqMaterialList = varRejectList.Single(); lnqMaterialList.InvoiceUnitPrice = 0; lnqMaterialList.InvoicePrice = 0; lnqMaterialList.HavingInvoice = false; dcOldUnitPrice = lnqMaterialList.UnitPrice; dataContxt.SubmitChanges(); int intFlag = serverMaterialRejectBill.SetHavingInvoiceReturn(dtInvoice.Rows[i]["Bill_ID"].ToString(), out error); if (intFlag == 4) { return(false); } else { var varRejectBill = from a in dataContxt.S_MaterialRejectBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; if (varRejectBill.Count() != 0) { S_MaterialRejectBill lnqMaterialBill = varRejectBill.Single(); lnqMaterialBill.InvoiceFlag = intFlag; dataContxt.SubmitChanges(); } } } else { var varOutsourcing = from a in dataContxt.S_CheckOutInDepotForOutsourcingBill where a.Bill_ID == dtInvoice.Rows[i]["Bill_ID"].ToString() && a.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && a.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select a; if (varOutsourcing.Count() != 0) { S_CheckOutInDepotForOutsourcingBill lnqOutsourcing = varOutsourcing.Single(); lnqOutsourcing.UnitInvoicePrice = 0; lnqOutsourcing.InvoicePrice = 0; lnqOutsourcing.HavingInvoice = false; dcOldUnitPrice = lnqOutsourcing.UnitPrice; dataContxt.SubmitChanges(); } } } } #endregion str = "2"; #region 改变入库明细表金额 var varInDepotDetail = from b in dataContxt.S_InDepotDetailBill where b.GoodsID == Convert.ToInt32(dtInvoice.Rows[i]["GoodsID"].ToString()) && b.InDepotBillID.Contains(dtInvoice.Rows[i]["Bill_ID"].ToString()) && b.BatchNo == dtInvoice.Rows[i]["BatchNo"].ToString() select b; if (varInDepotDetail.Count() != 0) { if (varInDepotDetail.Count() == 1) { S_InDepotDetailBill lnqInDepotDetailSingle = varInDepotDetail.Single(); lnqInDepotDetailSingle.InvoiceUnitPrice = 0; lnqInDepotDetailSingle.InvoicePrice = 0; lnqInDepotDetailSingle.FactUnitPrice = dcOldUnitPrice; lnqInDepotDetailSingle.FactPrice = Math.Round(dcOldUnitPrice * Convert.ToDecimal(lnqInDepotDetailSingle.InDepotCount), 2); } else { var varInDepotDetailList = from a in varInDepotDetail where a.InDepotBillID == dtInvoice.Rows[i]["Bill_ID"].ToString() select a; S_InDepotDetailBill lnqInDepotDetailData = varInDepotDetailList.Single(); lnqInDepotDetailData.InvoiceUnitPrice = 0; lnqInDepotDetailData.InvoicePrice = 0; lnqInDepotDetailData.FactUnitPrice = dcOldUnitPrice; lnqInDepotDetailData.FactPrice = Math.Round(dcOldUnitPrice * Convert.ToDecimal(lnqInDepotDetailData.InDepotCount), 2); var varData7 = from a in varInDepotDetail where a.InDepotBillID != dtInvoice.Rows[i]["Bill_ID"].ToString() select a; dataContxt.S_InDepotDetailBill.DeleteAllOnSubmit(varData7); } dataContxt.SubmitChanges(); } #endregion } var varInvoice = from a in dataContxt.B_Invoice where a.InvoiceCode == invoiceCode select a; if (varInvoice.Count() > 0) { dataContxt.B_Invoice.DeleteAllOnSubmit(varInvoice); dataContxt.SubmitChanges(); } return(true); } catch (Exception ex) { error = ex.Message + str + count.ToString(); return(false); } }
/// <summary> /// 回退单据 /// </summary> /// <param name="billID">单据号</param> /// <param name="lldID">领料单单号</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> private bool ReturnBill(string billID, string lldID, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { int intGoodsID = 0; string strBatchNo = ""; decimal dcCount = 0; decimal dcWastrel = 0; //报检单状态修改 var varData_A = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == billID select a; if (varData_A.Count() == 1) { S_CheckOutInDepotBill lnqCheck = varData_A.Single(); intGoodsID = Convert.ToInt32(lnqCheck.GoodsID); strBatchNo = lnqCheck.BatchNo.ToString(); dcCount = Convert.ToDecimal(lnqCheck.EligibleCount); dcWastrel = Convert.ToDecimal(lnqCheck.DeclareWastrelCount); lnqCheck.BillStatus = "等待入库"; } //库存记录的删除/修改 var varData_B = from a in dataContxt.S_Stock where a.GoodsID == intGoodsID && a.BatchNo == strBatchNo select a; if (varData_B.Count() == 1) { S_Stock lnqStock = varData_B.Single(); if (Convert.ToDecimal(lnqStock.ExistCount) == dcCount) { dataContxt.S_Stock.DeleteOnSubmit(lnqStock); } else { lnqStock.ExistCount = Convert.ToDecimal(lnqStock.ExistCount) - dcCount; } } //入库明细表记录删除 var varData_C = from a in dataContxt.S_InDepotDetailBill where a.InDepotBillID == billID && a.BatchNo == strBatchNo && a.GoodsID == intGoodsID select a; if (varData_C.Count() == 1) { dataContxt.S_InDepotDetailBill.DeleteOnSubmit(varData_C.Single()); } //领料单主表删除 var varData_D = from a in dataContxt.S_MaterialRequisition where a.Bill_ID == lldID && a.PurposeCode == UniversalFunction.GetPurpose(CE_PickingPurposeProperty.破坏性检测).Code select a; if (varData_D.Count() == 1) { dataContxt.S_MaterialRequisition.DeleteOnSubmit(varData_D.Single()); } //领料单此表删除 var varData_E = from a in dataContxt.S_MaterialRequisitionGoods where a.Bill_ID == lldID && a.GoodsID == intGoodsID && a.BatchNo == strBatchNo select a; if (varData_E.Count() == 1) { dataContxt.S_MaterialRequisitionGoods.DeleteOnSubmit(varData_E.Single()); } //出库明细表记录删除 var varData_F = from a in dataContxt.S_FetchGoodsDetailBill where a.FetchBIllID == lldID && a.BatchNo == strBatchNo && a.GoodsID == intGoodsID select a; if (varData_F.Count() == 1) { dataContxt.S_FetchGoodsDetailBill.DeleteOnSubmit(varData_F.Single()); } dataContxt.SubmitChanges(); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
/// <summary> /// 赋值账务信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <returns>返回账务信息对象</returns> public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_CheckOutInDepotBill bill) { View_HR_Personnel personnel = UniversalFunction.GetPersonnelInfo(dataContext, bill.DeclarePersonnelCode); S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.InDepotTime; detailBill.FillInPersonnel = bill.DeclarePersonnel; detailBill.Department = personnel.部门名称; detailBill.FactPrice = Math.Round(Convert.ToDecimal(bill.InDepotCount) * bill.UnitPrice, 2); detailBill.FactUnitPrice = bill.UnitPrice; detailBill.GoodsID = bill.GoodsID; detailBill.BatchNo = bill.BatchNo; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = bill.InDepotCount; detailBill.Price = Math.Round(Convert.ToDecimal(bill.InDepotCount) * bill.UnitPrice, 2); detailBill.UnitPrice = bill.UnitPrice; detailBill.OperationType = (int)CE_SubsidiaryOperationType.报检入库; detailBill.Provider = bill.Provider; detailBill.StorageID = bill.StorageID; detailBill.FillInDate = bill.Bill_Time; detailBill.AffrimPersonnel = bill.DepotManager; return(detailBill); }
/// <summary> /// 提交入库信息 /// </summary> /// <param name="billID">单据编号</param> /// <param name="inDepotInfo">入库信息, 只取其中入库部分</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool SubmitInDepotInfo(string billID, S_CheckOutInDepotBill inDepotInfo, out string error) { error = null; string mrBillNo = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.Connection.Open(); dataContxt.Transaction = dataContxt.Connection.BeginTransaction(); try { var result = from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == billID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的报检入库单!", billID); throw new Exception(error); } S_CheckOutInDepotBill bill = result.Single(); if (bill.BillStatus == CheckInDepotBillStatus.已入库.ToString()) { error = string.Format("入库单号为 [{0}] 单据状态为已入库", billID); throw new Exception(error); } bill.DepotManager = inDepotInfo.DepotManager; bill.ShelfArea = inDepotInfo.ShelfArea; bill.ColumnNumber = inDepotInfo.ColumnNumber; bill.LayerNumber = inDepotInfo.LayerNumber; bill.InDepotCount = inDepotInfo.InDepotCount; bill.Price = Math.Round(bill.UnitPrice * Convert.ToDecimal(inDepotInfo.InDepotCount), 2); bill.PlanPrice = Math.Round(bill.PlanUnitPrice * Convert.ToDecimal(inDepotInfo.InDepotCount), 2); bill.BillStatus = inDepotInfo.BillStatus; bill.RebackReason = ""; bill.InDepotTime = ServerTime.Time; // 添加信息到入库明细表 OpertaionDetailAndStock(dataContxt, bill); if (bill.BatchNo.Substring(bill.BatchNo.Length - 4, 4) == "Auto") { if (!InsertWebData(bill, out error)) { throw new Exception(error); } } dataContxt.SubmitChanges(); if ((int)bill.DeclareWastrelCount > 0 && bill.InDepotCount > 0) { if (!InsertIntoMaterialRequisition(dataContxt, bill, out mrBillNo, out error)) { throw new Exception(error); } } dataContxt.SubmitChanges(); dataContxt.Transaction.Commit(); // 检查一下入库明细表 return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { dataContxt.Transaction.Rollback(); if (mrBillNo != null) { ReturnBill(billID, mrBillNo, out error); } error = exce.Message; return(false); } }
/// <summary> /// 逐级回退单据 /// </summary> /// <param name="billID">单据号</param> /// <param name="rebackReason">回退原因</param> /// <param name="intStatusFlag">0:回退_质检电信息有误;1:回退_质检机信息有误</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool RebackBill(string billID, string rebackReason, int intStatusFlag, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.S_CheckOutInDepotBill where r.Bill_ID == billID select r; if (result.Count() == 0) { error = string.Format("找不到编号为 [{0}] 的报检入库单号", billID); return(false); } S_CheckOutInDepotBill bill = result.Single(); CheckInDepotBillStatus status = (CheckInDepotBillStatus)Enum.Parse(typeof(CheckInDepotBillStatus), bill.BillStatus); bool needReback = false; if (status == CheckInDepotBillStatus.等待确认到货数 || status == CheckInDepotBillStatus.回退_确认到货有误) { needReback = true; bill.BillStatus = CheckInDepotBillStatus.回退_采购单据有误.ToString(); bill.DepotManagerAffirmCount = 0; bill.DepotManager = ""; } else if (status == CheckInDepotBillStatus.等待质检机检验 || status == CheckInDepotBillStatus.等待质检电检验 || status == CheckInDepotBillStatus.回退_质检电信息有误 || status == CheckInDepotBillStatus.回退_质检机信息有误) { needReback = true; bill.BillStatus = CheckInDepotBillStatus.回退_确认到货有误.ToString(); bill.CheckoutJoinGoods_Time = null; bill.CheckoutReport_ID = ""; bill.EligibleCount = 0; bill.ConcessionCount = 0; bill.ReimbursementCount = 0; bill.DeclareWastrelCount = 0; bill.QualityInfo = ""; bill.Checker = ""; bill.QualityInputer = ""; } else if (status == CheckInDepotBillStatus.等待入库) { needReback = true; if (intStatusFlag == 0) { bill.BillStatus = CheckInDepotBillStatus.回退_质检电信息有误.ToString(); } else { bill.BillStatus = CheckInDepotBillStatus.回退_质检机信息有误.ToString(); } bill.InDepotCount = 0; bill.ShelfArea = ""; bill.ColumnNumber = ""; bill.LayerNumber = ""; } if (needReback) { try { bill.RebackReason = rebackReason; dataContxt.SubmitChanges(); return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { error = exce.Message; return(false); } } else { return(false); } }
/// <summary> /// 添加报检入库单 /// </summary> /// <param name="bill">单据信息</param> /// <param name="error">出错时返回错误信息</param> /// <returns>操作是否成功的标志</returns> public bool AddBill(S_CheckOutInDepotBill bill, out string error) { error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { if (bill.Bill_ID.ToString() == "系统自动生成") { string billID = GetNextBillNo(bill.CheckOutGoodsType); bill.Bill_ID = billID; bill.BatchNo = billID; if (UniversalFunction.GetStorageInfo_View(bill.StorageID).零成本控制) { throw new Exception("【零成本】库房,无法通过【报检入库单】入库"); } dataContxt.S_CheckOutInDepotBill.InsertOnSubmit(bill); } else { var varData = from a in dataContxt.S_CheckOutInDepotBill where a.Bill_ID == bill.Bill_ID select a; if (varData.Count() != 1) { error = "数据不唯一或者为空"; return(false); } else { S_CheckOutInDepotBill lnqBill = varData.Single(); lnqBill.OrderFormNumber = bill.OrderFormNumber; lnqBill.ArriveGoods_Time = bill.ArriveGoods_Time; // 到货日期 lnqBill.Bill_Time = bill.Bill_Time; // 报检日期 lnqBill.BillStatus = bill.BillStatus; lnqBill.Buyer = bill.Buyer; // 采购员签名 lnqBill.DeclarePersonnelCode = bill.DeclarePersonnelCode; // 报检员编码 lnqBill.DeclarePersonnel = bill.DeclarePersonnel; // 报检员签名 lnqBill.DeclareCount = bill.DeclareCount; // 报检数 lnqBill.Provider = bill.Provider; // 供应商编码 lnqBill.ProviderBatchNo = bill.ProviderBatchNo; // 供应商批次 lnqBill.GoodsID = bill.GoodsID; lnqBill.BatchNo = bill.BatchNo; // xsy, 没有废除OA前暂用 lnqBill.Remark = bill.Remark; lnqBill.CheckOutGoodsType = bill.CheckOutGoodsType; lnqBill.OnlyForRepairFlag = bill.OnlyForRepairFlag; lnqBill.UnitPrice = bill.UnitPrice; lnqBill.Price = bill.Price; lnqBill.PlanUnitPrice = bill.PlanUnitPrice; lnqBill.PlanPrice = bill.PlanPrice; lnqBill.TotalPrice = bill.TotalPrice; lnqBill.StorageID = bill.StorageID; lnqBill.Version = bill.Version; lnqBill.IsExigenceCheck = bill.IsExigenceCheck; lnqBill.InvoicePrice = bill.InvoicePrice; lnqBill.UnitInvoicePrice = bill.UnitInvoicePrice; if (UniversalFunction.GetStorageInfo_View(bill.StorageID).零成本控制) { throw new Exception("【零成本】库房,无法通过【报检入库单】入库"); } } } error = bill.BatchNo; if (GlobalObject.GeneralFunction.IsNullOrEmpty(bill.Bill_ID)) { throw new Exception("【单据号】获取失败,请重新再试"); } dataContxt.SubmitChanges(); return(true); //GetAllBill(out returnBill, out error); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <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="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); } }