/// <summary> /// 构造函数 /// </summary> /// <param name="operateMode">操作模式</param> /// <param name="billNo">普通入库单号</param> public 普通入库物品清单(CE_BusinessOperateMode operateMode, string billNo) { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true); UpdateStyles(); m_operateMode = operateMode; m_billNo = billNo; m_billInfo = ServerModuleFactory.GetServerModule <IOrdinaryInDepotBillServer>().GetBill(billNo); if (m_operateMode == CE_BusinessOperateMode.仓库核实) { btnAdd.Enabled = false; btnDelete.Enabled = false; btnDeleteAll.Enabled = false; } else { txtShelf.ReadOnly = true; txtColumn.ReadOnly = true; txtLayer.ReadOnly = true; if (m_operateMode == CE_BusinessOperateMode.查看) { toolStrip1.Visible = false; } } m_queryResult = m_goodsServer.GetGoodsViewInfo(m_billNo); RefreshDataGridView(m_queryResult); StapleInfo.InitUnitComboBox(cmbUnit); // 添加数据定位控件 m_dataLocalizer = new UserControlDataLocalizer(dataGridView1, this.Name, UniversalFunction.SelectHideFields(this.Name, dataGridView1.Name, BasicInfo.LoginID)); panelTop.Controls.Add(m_dataLocalizer); m_dataLocalizer.Dock = DockStyle.Bottom; if (BasicInfo.ListRoles.Contains(CE_RoleEnum.采购账务管理员.ToString()) || BasicInfo.ListRoles.Contains(CE_RoleEnum.会计.ToString())) { label19.Visible = true; label20.Visible = true; numUnitPrice.Visible = true; numPrice.Visible = true; } else { label19.Visible = false; label20.Visible = false; numUnitPrice.Visible = false; numPrice.Visible = false; } }
/// <summary> /// 提交工装验证信息 /// </summary> /// <param name="billInfo">取单据中工装验证信息部分</param> /// <param name="returnInfo">添加完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作结果</returns> public bool SubmitMachineValidationInfo(S_OrdinaryInDepotBill billInfo, out IQueryResult returnInfo, out string error) { returnInfo = null; error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { var result = from r in dataContxt.S_OrdinaryInDepotBill where r.Bill_ID == billInfo.Bill_ID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的普通入库单!", billInfo.Bill_ID); return(false); } S_OrdinaryInDepotBill updateBill = result.Single(); updateBill.MachineValidationID = billInfo.MachineValidationID; updateBill.MachineManager = billInfo.MachineManager; updateBill.AllowInDepot = billInfo.AllowInDepot; updateBill.BillStatus = billInfo.BillStatus; dataContxt.SubmitChanges(); return(GetAllBill(out returnInfo, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 提交入库信息 /// </summary> /// <param name="inDepotInfo">入库信息, 只取其中入库部分</param> /// <param name="returnInfo">添加完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作结果</returns> public bool SubmitInDepotInfo(S_OrdinaryInDepotBill inDepotInfo, out IQueryResult returnInfo, out string error) { returnInfo = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from r in dataContxt.S_OrdinaryInDepotBill where r.Bill_ID == inDepotInfo.Bill_ID select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的普通入库单!", inDepotInfo.Bill_ID); return(false); } S_OrdinaryInDepotBill bill = result.Single(); if (bill.BillStatus == CheckInDepotBillStatus.已入库.ToString()) { error = string.Format("入库单号为 [{0}] 单据状态为已入库", inDepotInfo.Bill_ID); return(false); } bill.DepotManager = inDepotInfo.DepotManager; bill.BillStatus = inDepotInfo.BillStatus; bill.InDepotDate = ServerTime.Time; // 添加信息到入库明细表 OpertaionDetailAndStock(dataContxt, bill); //更新工装库存状态 IDepotTypeForPersonnel serverDepot = ServerModuleFactory.GetServerModule <IDepotTypeForPersonnel>(); if (serverDepot.GetDepotInfo(bill.Depot).DepotName == GlobalObject.CE_GoodsType.工装.ToString() && bill.Bill_Time > Convert.ToDateTime("2012-4-21") && !UpdateFrockStockStatus(dataContxt, bill.Bill_ID, out error)) { return(false); } // 正式使用单据号 m_assignBill.UseBillNo(dataContxt, "普通入库单", bill.Bill_ID); dataContxt.SubmitChanges(); return(GetAllBill(out returnInfo, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
private void 修改单据ToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSelectedRow()) { return; } if (lblBillStatus.Text != OrdinaryInDepotBillStatus.新建单据.ToString()) { MessageDialog.ShowPromptMessage("您现在不是处于新建单据状态,无法进行此操作"); return; } if (!CheckUserOperation(dataGridView1.SelectedRows[0])) { return; } if (!CheckDataItem()) { return; } S_OrdinaryInDepotBill bill = new S_OrdinaryInDepotBill(); bill.Bill_ID = txtBill_ID.Text; bill.Bill_Time = ServerModule.ServerTime.Time; //bill.OrderBill_ID = txtOrderFormNumber.Text; bill.Depot = txtMaterialType.Tag as string; bill.Checker = txtChecker.Tag as string; bill.NeedMachineManager = chkNeedMachineManager.Checked; bill.NeedQualityAffirmance = chkQualityAffirmance.Checked; bill.Remark = txtRemark.Text; bill.StorageID = UniversalFunction.GetStorageID(cmbStorage.Text); if (txtOrderFormNumber.Text != dataGridView1.SelectedRows[0].Cells["订单号"].Value.ToString()) { if (m_goodsServer.IsExist(txtBill_ID.Text)) { MessageDialog.ShowPromptMessage("已经设置了物品清单时不允许再修改订单号, 您可以删除物品清单中的所有物品后再进行此操作!"); return; } } if (!m_billServer.UpdateBill(bill, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } RefreshDataGridView(m_queryResult); PositioningRecord(bill.Bill_ID); }
/// <summary> /// 更新指定单据物品类别 /// </summary> /// <param name="billNo">单据编号</param> /// <param name="depotType">物品类别</param> /// <param name="returnInfo">操作完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool UpdateGoodsType(string billNo, string depotType, out IQueryResult returnInfo, out string error) { returnInfo = null; error = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; OrdinaryInDepotGoodsBill serverOrdinaryBill = new OrdinaryInDepotGoodsBill(); var result = from r in dataContxt.S_OrdinaryInDepotBill where r.Bill_ID == billNo select r; if (result.Count() == 0) { error = string.Format("找不到入库单号为 [{0}] 的普通入库单!", billNo); return(false); } S_OrdinaryInDepotBill bill = result.Single(); bill.Depot = depotType; IQueryable <S_OrdinaryInDepotGoodsBill> goodsBill = serverOrdinaryBill.GetGoodsInfo(billNo); foreach (var item in goodsBill) { View_F_GoodsPlanCost goodsPlanCost = m_serverBasicGoods.GetGoodsInfoView(item.GoodsID); if (goodsPlanCost != null)// && goodsPlanCost.日期 == ServerTime.Time.Date) { if (goodsPlanCost.录入员编码 != bill.BuyerCode) { error = string.Format("图号型号:{0}, 物品名称:{1}, 规格:{2} 的物品信息在基础物品信息表中由 {3} 创建而不是当前采购员录单时自动创建,无法进行修改,如要更改请与系统管理员联系", goodsPlanCost.图号型号, goodsPlanCost.物品名称, goodsPlanCost.规格, goodsPlanCost.录入员编码); return(false); } //m_serverBasicGoods.UpdateGoodsType(dataContxt, item.GoodsID, depotType); } } dataContxt.SubmitChanges(); return(GetAllBill(out returnInfo, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
private void 提交验证信息ToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSelectedRow()) { return; } OrdinaryInDepotBillStatus status = (OrdinaryInDepotBillStatus)Enum.Parse( typeof(OrdinaryInDepotBillStatus), dataGridView1.SelectedRows[0].Cells["单据状态"].Value.ToString()); if (status != OrdinaryInDepotBillStatus.等待工装验证) { MessageDialog.ShowPromptMessage("请选择等待工装验证的记录后再进行此操作"); return; } if (txtMachineValidationID.Text.Trim() == "") { txtMachineValidationID.Focus(); MessageDialog.ShowPromptMessage("请输入工装验证报告编号后再进行此操作"); return; } string billNo = txtBill_ID.Text; S_OrdinaryInDepotBill bill = new S_OrdinaryInDepotBill(); bill.Bill_ID = billNo; bill.MachineValidationID = txtMachineValidationID.Text; bill.MachineManager = BasicInfo.LoginID; bill.AllowInDepot = chkAllowInDepot.Checked; bill.BillStatus = OrdinaryInDepotBillStatus.等待入库.ToString(); if (!m_billServer.SubmitMachineValidationInfo(bill, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } MessageDialog.ShowPromptMessage("成功提交,等待仓管入库!"); StringBuilder sb = new StringBuilder(); sb.AppendFormat("【订单号】:{0} 【物品申请人】:{1} ※※※ 等待【仓管员】处理", txtOrderFormNumber.Text, txtProposer.Text); PassFlowMessage(sb.ToString(), m_billMessageServer.GetRoleStringForStorage(cmbStorage.Text)); RefreshDataGridView(m_queryResult); PositioningRecord(billNo); }
/// <summary> /// 变更金额_普通入库单 /// </summary> /// <param name="dataContxt">数据上下文</param> /// <param name="detailInfo">结算单明细</param> void ChangePrice_S_OrdinaryInDepotGoodsBill(DepotManagementDataContext dataContxt, View_Business_Settlement_ProcurementStatementDetail detailInfo) { IOrdinaryInDepotBillServer serviceOrdinaryBill = ServerModule.ServerModuleFactory.GetServerModule <IOrdinaryInDepotBillServer>(); string error = ""; var varOrdinaryGoods = from a in dataContxt.S_OrdinaryInDepotGoodsBill where a.Bill_ID == detailInfo.入库单号 && a.GoodsID == detailInfo.物品ID && a.BatchNo == detailInfo.批次号 select a; //普通入库单单价修改 if (varOrdinaryGoods.Count() != 0) { S_OrdinaryInDepotGoodsBill lnqOrdinaryGoods = varOrdinaryGoods.Single(); lnqOrdinaryGoods.InvoiceUnitPrice = detailInfo.发票单价; lnqOrdinaryGoods.InvoicePrice = detailInfo.发票金额; lnqOrdinaryGoods.HavingInvoice = true; dataContxt.SubmitChanges(); int intFlag = serviceOrdinaryBill.GetHavingInvoice(dataContxt, detailInfo.入库单号, out error); if (intFlag == 4) { throw new Exception(error); } else { var varOrdinaryBill = from a in dataContxt.S_OrdinaryInDepotBill where a.Bill_ID == detailInfo.入库单号 select a; if (varOrdinaryBill.Count() != 0) { S_OrdinaryInDepotBill lnqOrdinaryBill = varOrdinaryBill.Single(); lnqOrdinaryBill.InvoiceStatus = intFlag; dataContxt.SubmitChanges(); } } } }
private void 物品入库ToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSelectedRow()) { return; } if (dataGridView1.SelectedRows[0].Cells["单据状态"].Value.ToString() != OrdinaryInDepotBillStatus.等待入库.ToString()) { MessageDialog.ShowPromptMessage("请选择等待入库的记录后再进行此操作!"); return; } if (MessageDialog.ShowEnquiryMessage("您确定已经核实好物品清单了吗?") == DialogResult.No) { return; } string billNo = txtBill_ID.Text; S_OrdinaryInDepotBill inDepotInfo = new S_OrdinaryInDepotBill(); inDepotInfo.Bill_ID = billNo; inDepotInfo.DepotManager = BasicInfo.LoginID; inDepotInfo.BillStatus = CheckInDepotBillStatus.已入库.ToString(); inDepotInfo.InDepotDate = ServerTime.Time; if (!m_billServer.SubmitInDepotInfo(inDepotInfo, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } StringBuilder sb = new StringBuilder(); sb.AppendFormat("{0} 号单据已经入库, ", billNo); EndFlowMessage(sb.ToString()); RefreshDataGridView(m_queryResult); PositioningRecord(billNo); MessageDialog.ShowPromptMessage("成功将零件入库!"); }
/// <summary> /// 修改单据 /// </summary> /// <param name="bill">单据信息</param> /// <param name="returnInfo">修改完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作是否成功的标志</returns> public bool UpdateBill(S_OrdinaryInDepotBill bill, out IQueryResult returnInfo, out string error) { error = null; returnInfo = null; try { DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; var result = from c in dataContxt.S_OrdinaryInDepotBill where c.Bill_ID == bill.Bill_ID select c; if (result.Count() > 0) { S_OrdinaryInDepotBill updateBill = result.Single(); updateBill.Bill_Time = bill.Bill_Time; //updateBill.OrderBill_ID = bill.OrderBill_ID; updateBill.Invoice_ID = bill.Invoice_ID; updateBill.Cess = bill.Cess; updateBill.Provider = bill.Provider; updateBill.Proposer = bill.Proposer; updateBill.Designer = bill.Designer; updateBill.NeedQualityAffirmance = bill.NeedQualityAffirmance; updateBill.NeedMachineManager = bill.NeedMachineManager; updateBill.Depot = bill.Depot; updateBill.Checker = bill.Checker; updateBill.Remark = bill.Remark; dataContxt.SubmitChanges(); return(GetAllBill(out returnInfo, out error)); } error = string.Format("找不到 {0} 单据, 无法进行此操作", bill.Bill_ID); return(false); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <summary> /// 赋值库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回库存信息</returns> public S_Stock AssignStockInfo(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill, S_OrdinaryInDepotGoodsBill item) { S_Stock lnqStock = new S_Stock(); lnqStock.GoodsID = item.GoodsID; lnqStock.ProviderBatchNo = item.ProviderBatchNo; lnqStock.BatchNo = item.BatchNo; lnqStock.Provider = bill.Provider; lnqStock.StorageID = bill.StorageID; lnqStock.ShelfArea = item.ShelfArea; lnqStock.ColumnNumber = item.ColumnNumber; lnqStock.LayerNumber = item.LayerNumber; lnqStock.ExistCount = (decimal)item.Amount; lnqStock.UnitPrice = item.UnitPrice; lnqStock.Price = 0; return(lnqStock); }
/// <summary> /// 根据单据信息操作账务信息与库存信息 /// </summary> /// <param name="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> void OpertaionDetailAndStock(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill) { OrdinaryInDepotGoodsBill serverOrdinaryBill = new OrdinaryInDepotGoodsBill(); IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); var result = from r in dataContext.S_OrdinaryInDepotGoodsBill where r.Bill_ID == bill.Bill_ID select r; foreach (var item in result) { S_InDepotDetailBill detailInfo = serverOrdinaryBill.AssignDetailInfo(dataContext, bill, item); S_Stock stockInfo = serverOrdinaryBill.AssignStockInfo(dataContext, bill, item); if (detailInfo == null || stockInfo == null) { throw new Exception("获取账务信息或者库存信息失败"); } serverDetail.ProcessInDepotDetail(dataContext, detailInfo, stockInfo); } }
/// <summary> /// 添加普通入库单 /// </summary> /// <param name="bill">单据信息</param> /// <param name="returnInfo">添加完毕后查询数据库的返回结果</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <returns>操作结果</returns> public bool AddBill(S_OrdinaryInDepotBill bill, out IQueryResult returnInfo, out string error) { returnInfo = null; error = null; DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; try { string strSql = @"select Provider from B_OrderFormInfo where OrderFormNumber = '" + bill.OrderBill_ID + "' "; DataTable dt = GlobalObject.DatabaseServer.QueryInfo(strSql); if (dt.Rows.Count == 0) { error = "订单号有问题,请核实"; return(false); } if (GlobalObject.GeneralFunction.IsNullOrEmpty(bill.Bill_ID)) { throw new Exception("【单据号】获取失败,请重新再试"); } bill.Provider = dt.Rows[0][0].ToString(); dataContxt.S_OrdinaryInDepotBill.InsertOnSubmit(bill); dataContxt.SubmitChanges(); return(GetAllBill(out returnInfo, out error)); } catch (Exception exce) { error = exce.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); } }
private void 设置物品清单ToolStripMenuItem_Click(object sender, EventArgs e) { string billNo = txtBill_ID.Text; try { this.dataGridView1.CellEnter -= new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEnter); if (lblBillStatus.Text != MaterialRequisitionBillStatus.新建单据.ToString()) { MessageDialog.ShowPromptMessage("您现在不是处于新建单据状态,无法进行此操作"); return; } if (!CheckDataItem()) { return; } // 如果此单据存在则检查选择行 if (m_billServer.IsExist(txtBill_ID.Text)) { if (!CheckSelectedRow()) { return; } if (!CheckUserOperation(dataGridView1.SelectedRows[0])) { return; } } else { S_OrdinaryInDepotBill bill = new S_OrdinaryInDepotBill(); bill.Bill_ID = txtBill_ID.Text; bill.Bill_Time = dateTime_BillTime.Value; // 入库日期 bill.OrderBill_ID = txtOrderFormNumber.Text; // 订单号 bill.Cess = Convert.ToInt32(txtProvider.Tag); bill.NeedQualityAffirmance = chkQualityAffirmance.Checked; // 需质检确认 bill.NeedMachineManager = chkNeedMachineManager.Checked; bill.AskDepartment = txtAskDepartment.Text; if (bill.NeedMachineManager) { bill.DeviceType = cmbDeviceType.Text; } bill.QualityEligibilityFlag = false; bill.MachineValidationID = ""; bill.BuyerCode = BasicInfo.LoginID; // 采购员编码 bill.Proposer = txtProposer.Tag as string; bill.Checker = "0000"; bill.MachineManager = "0000"; bill.DepotManager = "0000"; bill.StorageID = UniversalFunction.GetStorageID(cmbStorage.Text); if (txtDesigner.Text == "") { bill.Designer = "0000"; } else { bill.Designer = txtDesigner.Tag as string; } bill.Provider = txtProvider.Text; // 供应商编码 bill.Depot = txtMaterialType.Tag as string; // 仓库名就是材料类别 bill.Remark = txtRemark.Text; bill.BillStatus = OrdinaryInDepotBillStatus.新建单据.ToString(); if (!m_billServer.AddBill(bill, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } } 普通入库物品清单 form = new 普通入库物品清单(CE_BusinessOperateMode.修改, txtBill_ID.Text); form.ShowDialog(); if (!m_goodsServer.IsExist(txtBill_ID.Text)) { if (MessageDialog.ShowEnquiryMessage("您没有设置物品清单,是否要删除已经创建的单据?") == DialogResult.Yes) { if (!m_billServer.DeleteBill(txtBill_ID.Text, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); } else { RefreshDataGridView(m_queryResult); } } } } finally { this.dataGridView1.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellEnter); } RefreshDataGridView(m_queryResult); PositioningRecord(billNo); }
private void 质量验收ToolStripMenuItem_Click(object sender, EventArgs e) { if (!CheckSelectedRow()) { return; } OrdinaryInDepotBillStatus status = (OrdinaryInDepotBillStatus)Enum.Parse( typeof(OrdinaryInDepotBillStatus), dataGridView1.SelectedRows[0].Cells["单据状态"].Value.ToString()); if (status != OrdinaryInDepotBillStatus.等待质检) { MessageDialog.ShowPromptMessage("请选择等待质检的记录后再进行此操作"); return; } if (!radYes.Checked && !radNo.Checked) { MessageDialog.ShowPromptMessage("请选择质量是否合格后再进行此操作"); return; } string billNo = txtBill_ID.Text; S_OrdinaryInDepotBill bill = new S_OrdinaryInDepotBill(); bill.Bill_ID = billNo; bill.QualityEligibilityFlag = radYes.Checked; bill.Checker = BasicInfo.LoginID; bill.MassCheckDate = ServerTime.Time; if (chkNeedMachineManager.Checked) { bill.BillStatus = OrdinaryInDepotBillStatus.等待工装验证.ToString(); } else { bill.BillStatus = OrdinaryInDepotBillStatus.等待入库.ToString(); } if (!m_billServer.SubmitQualityInfo(bill, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } StringBuilder sb = new StringBuilder(); if (chkNeedMachineManager.Checked) { sb.AppendFormat("【订单号】:{0} 【物品申请人】:{1} ※※※ 等待【工装管理员】处理", txtOrderFormNumber.Text, txtProposer.Text); PassFlowMessage(sb.ToString(), CE_RoleEnum.工装管理员); MessageDialog.ShowPromptMessage("成功提交,等待工装验证!"); } else { sb.AppendFormat("【订单号】:{0} 【物品申请人】:{1} ※※※ 等待【仓管员】处理", txtOrderFormNumber.Text, txtProposer.Text); PassFlowMessage(sb.ToString(), m_billMessageServer.GetRoleStringForStorage(cmbStorage.Text)); MessageDialog.ShowPromptMessage("成功提交,等待仓管入库!"); } RefreshDataGridView(m_queryResult); PositioningRecord(billNo); }
/// <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="dataContext">数据上下文</param> /// <param name="bill">单据信息</param> /// <param name="item">明细信息</param> /// <returns>返回账务信息</returns> public S_InDepotDetailBill AssignDetailInfo(DepotManagementDataContext dataContext, S_OrdinaryInDepotBill bill, S_OrdinaryInDepotGoodsBill item) { IPersonnelInfoServer personnelServer = ServerModuleFactory.GetServerModule <IPersonnelInfoServer>(); S_InDepotDetailBill detailBill = new S_InDepotDetailBill(); View_HR_Personnel personnel = UniversalFunction.GetPersonnelInfo(dataContext, bill.BuyerCode); View_F_GoodsPlanCost basicGoodsInfo = UniversalFunction.GetGoodsInfo(dataContext, item.GoodsID); detailBill.ID = Guid.NewGuid(); detailBill.BillTime = (DateTime)bill.InDepotDate; detailBill.FillInPersonnel = personnel.姓名; detailBill.Department = personnel.部门名称; detailBill.FactPrice = Math.Round((item.UnitPrice * (decimal)item.Amount), 2); detailBill.FactUnitPrice = item.UnitPrice; detailBill.GoodsID = item.GoodsID; detailBill.BatchNo = item.BatchNo; detailBill.InDepotBillID = bill.Bill_ID; detailBill.InDepotCount = item.Amount; detailBill.Price = Math.Round((item.UnitPrice * (decimal)item.Amount), 2); detailBill.UnitPrice = item.UnitPrice; detailBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.普通入库; detailBill.Provider = bill.Provider; detailBill.StorageID = bill.StorageID; detailBill.AffrimPersonnel = UniversalFunction.GetPersonnelInfo(bill.DepotManager).姓名; detailBill.FillInDate = bill.Bill_Time; return(detailBill); }
private void btnAdd_Click(object sender, EventArgs e) { if (!CheckDataItem()) { return; } S_OrdinaryInDepotBill lnqBill = m_serverBill.GetBill(m_billNo); S_OrdinaryInDepotGoodsBill goods = new S_OrdinaryInDepotGoodsBill(); View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(txtCode.Text, txtName.Text, txtSpec.Text, numUnitPrice.Value); if (planCost == null) { return; } goods.Bill_ID = m_billNo; goods.ProviderBatchNo = txtProviderBatchNo.Text; if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号)) { goods.BatchNo = m_goodsServer.GetNewBatchNo(); } else { goods.BatchNo = ""; } goods.Amount = numGoodsAmount.Value; goods.UnitPrice = numUnitPrice.Value; goods.Price = decimal.Round(goods.UnitPrice * numGoodsAmount.Value, 2); goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price); goods.ShelfArea = ""; goods.ColumnNumber = ""; goods.LayerNumber = ""; goods.Remark = txtRemark.Text; goods.TestingSingle = lnklbSingleBill.Text; goods.GoodsID = planCost.序号; foreach (DataGridViewRow row in dataGridView1.Rows) { if (row.Cells["图号型号"].Value.ToString() == txtCode.Text && row.Cells["物品名称"].Value.ToString() == txtName.Text && row.Cells["规格"].Value.ToString() == txtSpec.Text && row.Cells["供方批次号"].Value.ToString() == txtProviderBatchNo.Text) { MessageDialog.ShowPromptMessage("已经存在相同的物品信息列不允许再进行重复添加!"); return; } } if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error)) { if (m_error.Contains("不能在具有唯一索引")) { m_error = "此物品清单中的物品(同种物品、同一批号)可能已经在其他普通入库单中增加,不允许再重复入库!"; } MessageDialog.ShowErrorMessage(m_error); return; } RefreshDataGridView(m_queryResult); PositioningRecord(planCost.图号型号, planCost.物品名称, planCost.规格); }
private void btnAutoGenerate_Click(object sender, EventArgs e) { if (dataGridView1.Rows.Count > 0) { MessageDialog.ShowPromptMessage("请删除此清单中的所有物品后再进行此操作!"); return; } IOrderFormGoodsServer orderFormGoodsServer = ServerModuleFactory.GetServerModule <IOrderFormGoodsServer>(); IQueryable <View_B_OrderFormGoods> goodsGroup = null; if (!orderFormGoodsServer.GetOrderFormGoods( BasicInfo.ListRoles, BasicInfo.LoginID, m_billInfo.OrderBill_ID, out goodsGroup, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } S_OrdinaryInDepotBill lnqBill = m_serverBill.GetBill(m_billNo); IOrderFormInfoServer serviceOrderForm = ServerModuleFactory.GetServerModule <IOrderFormInfoServer>(); View_B_OrderFormInfo orderInfo = serviceOrderForm.GetOrderFormInfo(m_billInfo.OrderBill_ID); foreach (var item in goodsGroup) { if (item.订货数量 == 0) { continue; } S_OrdinaryInDepotGoodsBill goods = new S_OrdinaryInDepotGoodsBill(); View_F_GoodsPlanCost planCost = GetBasicGoodsInfo(item.图号型号, item.物品名称, item.规格, 0); if (planCost == null) { return; } goods.GoodsID = planCost.序号; goods.Bill_ID = m_billNo; goods.ProviderBatchNo = ""; if (m_serverGoodsShelfLife.IsShelfLife(planCost.序号)) { goods.BatchNo = m_goodsServer.GetNewBatchNo(); } else { goods.BatchNo = ""; } goods.Amount = item.订货数量; IBargainGoodsServer serviceBargainGoods = ServerModuleFactory.GetServerModule <IBargainGoodsServer>(); goods.UnitPrice = serviceBargainGoods.GetGoodsUnitPrice(orderInfo.订单号, goods.GoodsID, orderInfo.供货单位); goods.Price = decimal.Round(goods.UnitPrice * item.订货数量, (int)2); goods.AmountInWords = CalculateClass.GetTotalPrice(goods.Price); goods.Remark = txtRemark.Text; if (!m_goodsServer.AddGoods(m_billNo, goods, out m_queryResult, out m_error)) { MessageDialog.ShowErrorMessage(m_error); return; } } btnRefresh_Click(sender, e); }
/// <summary> /// 回退单据 /// </summary> /// <param name="djh">单据号</param> /// <param name="billStatus">单据状态</param> /// <param name="returnBill">返回回退后查询到的单据信息</param> /// <param name="error">出错时返回错误信息,无错时返回null</param> /// <param name="rebackReason">回退原因</param> /// <returns>回退成功返回True,回退失败返回False</returns> public bool ReturnBill(string djh, string billStatus, out IQueryResult returnBill, out string error, string rebackReason) { returnBill = null; error = null; try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.S_OrdinaryInDepotBill where a.Bill_ID == djh select a; string strMsg = ""; if (varData.Count() == 1) { S_OrdinaryInDepotBill lnqMRequ = varData.Single(); switch (billStatus) { case "新建单据": strMsg = string.Format("{0}号普通入库单已回退,请您重新处理单据; 回退原因为" + rebackReason, djh); m_billMessageServer.PassFlowMessage(djh, strMsg, lnqMRequ.BuyerCode, false); lnqMRequ.BillStatus = "新建单据"; lnqMRequ.Checker = "0000"; lnqMRequ.MachineManager = "0000"; if (!m_serverFrockStandingBook.DeleteFrockOrdinaryInDepotBill(ctx, djh, out error)) { return(false); } break; case "等待质检": strMsg = string.Format("{0}号普通入库单已回退,请您重新处理单据; 回退原因为" + rebackReason, djh); m_billMessageServer.PassFlowMessage(djh, strMsg, UniversalFunction.GetPersonnelCode(lnqMRequ.Checker), false); lnqMRequ.BillStatus = "等待质检"; lnqMRequ.Checker = "0000"; break; case "等待工装验证": strMsg = string.Format("{0}号普通入库单已回退,请您重新处理单据; 回退原因为" + rebackReason, djh); m_billMessageServer.PassFlowMessage(djh, strMsg, UniversalFunction.GetPersonnelCode(lnqMRequ.MachineManager), false); lnqMRequ.BillStatus = "等待工装验证"; lnqMRequ.MachineManager = "0000"; break; default: break; } ctx.SubmitChanges(); } else { error = "数据不唯一或者为空"; return(false); } return(GetAllBill(out returnBill, out error)); } catch (Exception exce) { error = exce.Message; return(false); } }
/// <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); } }