void SetInfo() { if (_Lnq_BillInfo != null) { lbBillStatus.Text = _Service_Flow.GetNowBillStatus(_Lnq_BillInfo.BillNo); txtBillNo.Text = _Lnq_BillInfo.BillNo; txtVoucherNo.Text = _Lnq_BillInfo.VoucherNo; dtpFinanceTime.Value = Convert.ToDateTime(_Lnq_BillInfo.FinanceTime); txtSettlementCompany.Text = UniversalFunction.GetProviderInfo(_Lnq_BillInfo.Provider).供应商名称; txtSettlementCompany.Tag = _Lnq_BillInfo.Provider; } else { lbBillStatus.Text = CE_CommonBillStatus.新建单据.ToString(); _Lnq_BillInfo = new Bus_PurchasingMG_AccountBill(); txtBillNo.Text = this.FlowInfo_BillNo; _Lnq_BillInfo.BillNo = txtBillNo.Text; dtpFinanceTime.Value = ServerTime.Time; } _List_ViewDetail = _Service_Account.GetListViewDetailInfo(_Lnq_BillInfo.BillNo); _List_Invoice = _Service_Account.GetListInvoiceInfo(_Lnq_BillInfo.BillNo); RefreshDataGridView(_List_ViewDetail, _List_Invoice); }
public override void LoadFormInfo() { try { m_billNoControl = new BillNumberControl(CE_BillTypeEnum.供应商应付账款.ToString(), _Service_Account); _Lnq_BillInfo = _Service_Account.GetSingleBillInfo(this.FlowInfo_BillNo); SetInfo(); } catch (Exception ex) { MessageDialog.ShowErrorMessage(ex.Message); } }
/// <summary> /// 操作流程以外的业务 /// </summary> /// <param name="billNo">单据号</param> public void OperatarUnFlowBusiness(string billNo) { IFinancialDetailManagement serverDetail = ServerModule.ServerModuleFactory.GetServerModule <IFinancialDetailManagement>(); IFlowServer serviceFlow = FlowControlService.ServerModuleFactory.GetServerModule <IFlowServer>(); string billStatus = serviceFlow.GetNextBillStatus(billNo); if (billStatus == null) { throw new Exception("单据状态为空,请重新确认"); } if (billStatus != CE_CommonBillStatus.单据完成.ToString()) { return; } DepotManagementDataContext dataContxt = CommentParameter.DepotDataContext; dataContxt.Connection.Open(); dataContxt.Transaction = dataContxt.Connection.BeginTransaction(); try { List <View_Bus_PurchasingMG_AccountBill_Detail> lstDetail = GetListViewDetailInfo(billNo); Bus_PurchasingMG_AccountBill billInfo = GetSingleBillInfo(billNo); foreach (View_Bus_PurchasingMG_AccountBill_Detail detailInfo in lstDetail) { //插一条原始的负记录(红冲单据) S_InDepotDetailBill lnqRedInDepotBill = new S_InDepotDetailBill(); lnqRedInDepotBill.ID = Guid.NewGuid(); lnqRedInDepotBill.InDepotBillID = detailInfo.单据号 + "(红冲单据)"; lnqRedInDepotBill.BatchNo = detailInfo.挂账年月; lnqRedInDepotBill.BillTime = (DateTime)billInfo.FinanceTime; lnqRedInDepotBill.Department = ""; lnqRedInDepotBill.FactUnitPrice = Math.Round((decimal)detailInfo.协议单价 / (1 + (decimal)detailInfo.税率 / 100), 6); lnqRedInDepotBill.FactPrice = -Math.Round(lnqRedInDepotBill.FactUnitPrice * (decimal)detailInfo.实付数量, 2); lnqRedInDepotBill.InDepotCount = -detailInfo.实付数量; lnqRedInDepotBill.FillInPersonnel = BasicInfo.LoginID; lnqRedInDepotBill.GoodsID = (int)detailInfo.GoodsID; lnqRedInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务红冲; lnqRedInDepotBill.Provider = billInfo.Provider; lnqRedInDepotBill.Remark = billInfo.Remark + " " + detailInfo.备注; lnqRedInDepotBill.StorageID = "00"; lnqRedInDepotBill.UnitPrice = lnqRedInDepotBill.FactUnitPrice; lnqRedInDepotBill.Price = lnqRedInDepotBill.FactPrice; lnqRedInDepotBill.FillInDate = ServerTime.Time; lnqRedInDepotBill.AffrimPersonnel = BasicInfo.LoginID; serverDetail.ProcessInDepotDetail(dataContxt, lnqRedInDepotBill, null); //插一条新的正记录(对冲单据) S_InDepotDetailBill lnqHedgeInDepotBill = new S_InDepotDetailBill(); lnqHedgeInDepotBill.ID = Guid.NewGuid(); lnqHedgeInDepotBill.InDepotBillID = detailInfo.单据号 + "(对冲单据)"; lnqHedgeInDepotBill.BatchNo = detailInfo.挂账年月; lnqHedgeInDepotBill.BillTime = (DateTime)billInfo.FinanceTime; lnqHedgeInDepotBill.Department = ""; lnqHedgeInDepotBill.FactUnitPrice = (decimal)detailInfo.发票金额 / (decimal)detailInfo.实付数量; lnqHedgeInDepotBill.FactPrice = (decimal)detailInfo.发票金额; lnqHedgeInDepotBill.InDepotCount = detailInfo.实付数量; lnqHedgeInDepotBill.FillInPersonnel = BasicInfo.LoginID; lnqHedgeInDepotBill.GoodsID = (int)detailInfo.GoodsID; lnqHedgeInDepotBill.OperationType = (int)GlobalObject.CE_SubsidiaryOperationType.财务对冲; lnqHedgeInDepotBill.Provider = billInfo.Provider; lnqHedgeInDepotBill.Remark = billInfo.Remark + " " + detailInfo.备注; lnqHedgeInDepotBill.StorageID = "00"; lnqHedgeInDepotBill.UnitPrice = lnqHedgeInDepotBill.FactUnitPrice; lnqHedgeInDepotBill.Price = lnqHedgeInDepotBill.FactPrice; lnqHedgeInDepotBill.FillInDate = ServerTime.Time; lnqHedgeInDepotBill.AffrimPersonnel = BasicInfo.LoginID; serverDetail.ProcessInDepotDetail(dataContxt, lnqHedgeInDepotBill, null); var varAccountInfo = from a in dataContxt.Bus_PurchasingMG_Account where a.Provider == billInfo.Provider && a.YearMonth == detailInfo.挂账年月 && a.GoodsID == Convert.ToInt32(detailInfo.GoodsID) select a; if (varAccountInfo.Count() != 1) { throw new Exception("找不到对应的【挂账单】"); } varAccountInfo.Single().InvoiceCount += (decimal)detailInfo.实付数量; varAccountInfo.Single().InvoicePrice += (decimal)detailInfo.发票金额; dataContxt.SubmitChanges(); } dataContxt.Transaction.Commit(); } catch (Exception ex) { dataContxt.Transaction.Rollback(); throw new Exception(ex.Message); } }
/// <summary> /// 保存信息 /// </summary> /// <param name="billInfo">单据信息</param> /// <param name="invoiceInfo">发票信息列表</param> /// <param name="detailInfo">明细信息列表</param> public void SaveInfo(Bus_PurchasingMG_AccountBill billInfo, List <Bus_PurchasingMG_AccountBill_Invoice> invoiceInfo, List <View_Bus_PurchasingMG_AccountBill_Detail> detailInfo) { try { using (DepotManagementDataContext ctx = CommentParameter.DepotDataContext) { ctx.Connection.Open(); using (ctx.Transaction = ctx.Connection.BeginTransaction()) { var varData = from a in ctx.Bus_PurchasingMG_AccountBill where a.BillNo == billInfo.BillNo select a; if (varData.Count() == 1) { Bus_PurchasingMG_AccountBill lnqBill = varData.Single(); lnqBill.Provider = billInfo.Provider; lnqBill.Remark = billInfo.Remark; lnqBill.VoucherNo = billInfo.VoucherNo; lnqBill.FinanceTime = billInfo.FinanceTime; } else if (varData.Count() == 0) { ctx.Bus_PurchasingMG_AccountBill.InsertOnSubmit(billInfo); } else { throw new Exception("单据数据不唯一"); } var varInvoice = from a in ctx.Bus_PurchasingMG_AccountBill_Invoice where a.BillNo == billInfo.BillNo select a; ctx.Bus_PurchasingMG_AccountBill_Invoice.DeleteAllOnSubmit(varInvoice); ctx.SubmitChanges(); if (invoiceInfo != null && invoiceInfo.Count > 0) { foreach (Bus_PurchasingMG_AccountBill_Invoice item in invoiceInfo) { Bus_PurchasingMG_AccountBill_Invoice lnqTemp = new Bus_PurchasingMG_AccountBill_Invoice(); lnqTemp.F_Id = Guid.NewGuid().ToString(); lnqTemp.BillNo = billInfo.BillNo; lnqTemp.InvoiceTime = item.InvoiceTime; lnqTemp.InvoiceNo = item.InvoiceNo; ctx.Bus_PurchasingMG_AccountBill_Invoice.InsertOnSubmit(lnqTemp); } } var varDetail = from a in ctx.Bus_PurchasingMG_AccountBill_Detail where a.BillNo == billInfo.BillNo select a; ctx.Bus_PurchasingMG_AccountBill_Detail.DeleteAllOnSubmit(varDetail); ctx.SubmitChanges(); foreach (View_Bus_PurchasingMG_AccountBill_Detail item in detailInfo) { Bus_PurchasingMG_AccountBill_Detail lnqTemp = new Bus_PurchasingMG_AccountBill_Detail(); lnqTemp.F_Id = Guid.NewGuid().ToString(); lnqTemp.BillNo = billInfo.BillNo; lnqTemp.AccountCount = item.实付数量; lnqTemp.AccountPrice = item.发票金额; lnqTemp.GoodsID = item.GoodsID; lnqTemp.Remark = item.备注; lnqTemp.YearMonth = item.挂账年月; lnqTemp.YGCount = item.应付数量; lnqTemp.YGUnitPrice = item.协议单价; lnqTemp.TaxRate = item.税率; ctx.Bus_PurchasingMG_AccountBill_Detail.InsertOnSubmit(lnqTemp); } ctx.SubmitChanges(); ctx.Transaction.Commit(); } } } catch (Exception) { throw; } }
private bool 供应商应付账款_Form_CommonProcessSubmit(CustomFlowForm form, string advise) { try { Bus_PurchasingMG_AccountBill lnqBillInfo = form.ResultInfo as Bus_PurchasingMG_AccountBill; List <Bus_PurchasingMG_AccountBill_Invoice> invoiceInfo = form.ResultList[0] as List <Bus_PurchasingMG_AccountBill_Invoice>; List <View_Bus_PurchasingMG_AccountBill_Detail> detailInfo = form.ResultList[1] as List <View_Bus_PurchasingMG_AccountBill_Detail>; this.OperationType = GeneralFunction.StringConvertToEnum <CE_FlowOperationType>(form.ResultList[2].ToString()); this.BillNo = lnqBillInfo.BillNo; switch (this.OperationType) { case CE_FlowOperationType.提交: string billStatus = _Service_Flow.GetNextBillStatus(this.BillNo); if (billStatus == CE_CommonBillStatus.单据完成.ToString()) { string operationUser = _Service_Flow.GetBusinessOperationInfo(this.BillNo). Where(k => k.FlowID == 103). OrderByDescending(k => k.OperationTime). First().OperationPersonnel; if (operationUser == BasicInfo.LoginID) { throw new Exception("【新建人】与【审核人】不能为同一个人"); } } _Service_Account.SaveInfo(lnqBillInfo, invoiceInfo, detailInfo); _Service_Account.OperatarUnFlowBusiness(lnqBillInfo.BillNo); break; case CE_FlowOperationType.暂存: _Service_Account.SaveInfo(lnqBillInfo, invoiceInfo, detailInfo); break; case CE_FlowOperationType.回退: break; case CE_FlowOperationType.未知: break; default: break; } if (!_Service_Account.IsExist(lnqBillInfo.BillNo)) { MessageDialog.ShowPromptMessage("数据为空,保存失败,如需退出,请直接X掉界面"); return(false); } return(true); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); return(false); } }
private bool 供应商应付账款明细_PanelGetDataInfo(CE_FlowOperationType flowOperationType) { try { if (flowOperationType == CE_FlowOperationType.提交) { if (!CheckData_Submit()) { return(false); } if (dtpFinanceTime.Value.Day > 26) { if (MessageDialog.ShowEnquiryMessage("【账单日期】大于26日,点击【是】将提交单据,点击【否】将退出?") == DialogResult.No) { return(false); } } } else if (flowOperationType == CE_FlowOperationType.暂存) { if (!CheckData_Hold()) { return(false); } } _Lnq_BillInfo = new Bus_PurchasingMG_AccountBill(); _Lnq_BillInfo.BillNo = txtBillNo.Text; _Lnq_BillInfo.Provider = txtSettlementCompany.Tag.ToString(); _Lnq_BillInfo.VoucherNo = txtVoucherNo.Text; _Lnq_BillInfo.FinanceTime = dtpFinanceTime.Value; List <View_Bus_PurchasingMG_AccountBill_Detail> listTemp = new List <View_Bus_PurchasingMG_AccountBill_Detail>(); foreach (DataGridViewRow dgvr in customDataGridView1.Rows) { View_Bus_PurchasingMG_AccountBill_Detail detailTemp = new View_Bus_PurchasingMG_AccountBill_Detail(); detailTemp.图号型号 = dgvr.Cells["图号型号"].Value == null ? "" : dgvr.Cells["图号型号"].Value.ToString(); detailTemp.物品名称 = dgvr.Cells["物品名称"].Value == null ? "" : dgvr.Cells["物品名称"].Value.ToString(); detailTemp.规格 = dgvr.Cells["规格"].Value == null ? "" : dgvr.Cells["规格"].Value.ToString(); detailTemp.GoodsID = Convert.ToInt32(dgvr.Cells["GoodsID"].Value); detailTemp.单据号 = txtBillNo.Text; detailTemp.发票金额 = Convert.ToDecimal(dgvr.Cells["发票金额"].Value); detailTemp.应付金额 = Convert.ToDecimal(dgvr.Cells["应付金额"].Value); detailTemp.应付数量 = Convert.ToDecimal(dgvr.Cells["应付数量"].Value); detailTemp.实付数量 = Convert.ToDecimal(dgvr.Cells["实付数量"].Value); detailTemp.协议单价 = Convert.ToDecimal(dgvr.Cells["协议单价"].Value); detailTemp.税率 = Convert.ToInt32(dgvr.Cells["税率"].Value); detailTemp.备注 = dgvr.Cells["备注"].Value.ToString(); detailTemp.挂账年月 = dgvr.Cells["挂账年月"].Value.ToString(); listTemp.Add(detailTemp); } this.FlowInfo_BillNo = txtBillNo.Text; this.ResultInfo = _Lnq_BillInfo; this.ResultList = new List <object>(); this.ResultList.Add(_List_Invoice); this.ResultList.Add(listTemp); this.ResultList.Add(flowOperationType); this.KeyWords = "【供应商】:" + _Lnq_BillInfo.Provider; return(true); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); return(false); } }