/// <summary> /// 获取资金帐号 /// </summary> /// <param name="bankAccountsId">付款帐号Id</param> /// <returns></returns> public BankAccountInfo GetBankAccounts(Guid bankAccountsId) { if (bankAccountsId == Guid.Empty) { return(new BankAccountInfo()); } return(_bankAccounts.GetBankAccounts(bankAccountsId)); }
//费用申报(lmshop_CostReport) protected void EditCostReportModel(CostReportInfo model, PersonnelInfo personnelInfo) { model.ReportNo = new CodeManager().GetCode(CodeType.RE); model.ReportKind = (int)CostReportKind.FeeIncome; model.AssumeBranchId = string.IsNullOrEmpty(ddl_AssumeBranch.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeBranch.SelectedValue); model.AssumeGroupId = string.IsNullOrEmpty(ddl_AssumeGroup.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeGroup.SelectedValue); model.AssumeShopId = string.IsNullOrEmpty(ddl_AssumeShop.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeShop.SelectedValue); model.CostsVarieties = string.IsNullOrEmpty(Hid_CostsClass.Value) ? -1 : int.Parse(Hid_CostsClass.Value); model.GoodsCode = string.Empty; model.CompanyClassId = string.IsNullOrEmpty(ddl_CompanyClass.SelectedValue) ? Guid.Empty : new Guid(ddl_CompanyClass.SelectedValue); model.CompanyId = string.IsNullOrEmpty(ddl_FeeType.SelectedValue) ? Guid.Empty : new Guid(ddl_FeeType.SelectedValue); model.UrgentOrDefer = int.Parse(rbl_UrgentOrDefer.SelectedValue); model.UrgentReason = model.UrgentOrDefer.Equals(1) ? txt_UrgentReason.Text : string.Empty; model.ReportName = txt_ReportName.Text; model.StartTime = DateTime.Parse(txt_StartTime.Text); model.EndTime = DateTime.Parse(txt_EndTime.Text); model.PayCompany = txt_PayCompany.Text; model.ReportCost = Math.Abs(Decimal.Parse(txt_ReportCost.Text)); model.RealityCost = model.ReportCost; model.ApplyForCost = model.ReportCost; model.ActualAmount = model.ReportCost; model.CostType = int.Parse(rbl_CostType.SelectedValue); model.Deposit = 2; if (model.CostType.Equals(2)) { model.BankAccountName = txt_BankName.Text.Trim() + "," + txt_SubBankName.Text.Trim(); } model.InvoiceType = (int)CostReportInvoiceType.WaitCheck; model.PayBankAccountId = string.IsNullOrEmpty(rcb_PayBankAccount.SelectedValue) ? Guid.Empty : new Guid(rcb_PayBankAccount.SelectedValue); //结算账号 model.AssumeFilialeId = string.IsNullOrEmpty(Hid_AssumeFiliale.Value) ? Guid.Empty : new Guid(Hid_AssumeFiliale.Value); //结算公司 model.ReportMemo = txt_ReportMemo.Text; model.ReportFilialeId = personnelInfo.FilialeId; model.ReportBranchId = personnelInfo.BranchId; model.ReportPersonnelId = personnelInfo.PersonnelId; model.State = (int)CostReportState.Auditing; if (string.IsNullOrEmpty(Request.QueryString["ReportId"])) { model.ReportDate = DateTime.Now; } model.Memo = WebControl.RetrunUserAndTime("[【费用收入】:" + txt_ReportMemo.Text + ";]"); model.IsLastTime = true; model.IsSystem = false; model.ApplyNumber = 1; model.IsEnd = false; if (!string.IsNullOrEmpty(rcb_PayBankAccount.SelectedValue)) { var bankAccountInfo = _bankAccounts.GetBankAccounts(new Guid(rcb_PayBankAccount.SelectedValue)); if (bankAccountInfo != null && bankAccountInfo.IsMain) { model.IsOut = true; } else { model.IsOut = false; } } }
/// <summary> /// 返回资金流Model /// </summary> /// <param name="model"></param> /// <param name="personnelInfo"></param> /// <param name="flag">true:有手续费;false:无手续费;</param> /// <returns></returns> public WasteBookInfo AddWasteBookInfo(CostReportInfo model, PersonnelInfo personnelInfo, bool flag) { decimal income; if (flag && model.Poundage > 0) { income = model.Poundage; } else { income = model.RealityCost; } string auditingMan = _personnelManager.GetName(personnelInfo.PersonnelId); string reportMan = _personnelManager.GetName(model.ReportPersonnelId); var dateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); var wasteBookTradeCode = _codeManager.GetCode(CodeType.RD); int wasteBookType; string strMan, strDes; if (income > 0) { wasteBookType = (int)WasteBookType.Decrease; strMan = "收款"; strDes = "减少"; } else { wasteBookType = (int)WasteBookType.Increase; strMan = "付款"; strDes = "增加"; } bool isDeposit = (model.ReportKind == (int)CostReportKind.FeeIncome && !string.IsNullOrEmpty(model.DepositNo)); var wasteBookDescription = string.Format("[费用申报(申报编号:{0};费用名称:{1};申报人:{2};" + strMan + "单位:{3};完成打款人:{4};手续费:{5};交易流水号:{6};资金" + strDes + ",{7}" + (isDeposit ? "【押金回收】" : "") + ")]", model.ReportNo, model.ReportName, reportMan, model.PayCompany, auditingMan, model.Poundage.ToString("#0.00"), model.TradeNo, dateTime); var bankInfo = _bankAccountsDao.GetBankAccounts(model.PayBankAccountId); var wasteBookInfo = new WasteBookInfo( Guid.NewGuid(), model.PayBankAccountId, wasteBookTradeCode, wasteBookDescription, -income, //金额 (Int32)AuditingState.Yes, wasteBookType, model.AssumeFilialeId) { LinkTradeCode = model.ReportNo, LinkTradeType = (int)WasteBookLinkTradeType.CostReport, BankTradeCode = string.Empty, State = (int)WasteBookState.Currently, IsOut = bankInfo.IsMain }; return(wasteBookInfo); }
/// <summary> /// 绑定银行 /// </summary> /// <returns></returns> protected void BindBankDataBound(object sender, EventArgs eventArgs) { var ddlBank = sender as DropDownList; if (ddlBank != null) { ddlBank.Items.Clear(); if (BankIds.Count > 0) { foreach (var bankInfo in BankIds.Distinct().Select(id => _bankAccounts.GetBankAccounts(id)).Where(bankInfo => bankInfo.IsUse)) { ddlBank.Items.Add(new ListItem(bankInfo.BankName + "-" + bankInfo.AccountsName, bankInfo.BankAccountsId.ToString())); } } ddlBank.Items.Insert(0, new ListItem("全部", Guid.Empty.ToString())); ddlBank.SelectedValue = Guid.Empty.ToString(); } }
protected void Rg_BankWebSite_UpdateCommand(object sender, GridCommandEventArgs e) { var editedItem = (GridEditableItem)e.Item; if (editedItem != null) { var oldBankAccountsId = new Guid(((Label)editedItem.FindControl("lbOldBankAccountsId")).Text); var bankinfo = _bankAccountsWrite.GetBankAccounts(oldBankAccountsId); if (bankinfo.IsMain) { RAM.Alert("系统提示:该资金帐号为主账号不允许编辑!"); return; } var bankAccountsId = new Guid(((DropDownList)editedItem.FindControl("DDL_Bank")).SelectedValue); var sourceName = ((Label)editedItem.FindControl("lbFromSourceNameE")).Text; BankAccountInfo bwInfo; if (sourceName == "-") { bwInfo = new BankAccountInfo { BankAccountsId = bankAccountsId, TargetId = new Guid(RTVWebSite.SelectedNode.Value), }; } else { var selectSalePlatformInfo = CacheCollection.SalePlatform.Get(TargetId); if (selectSalePlatformInfo != null) { bwInfo = new BankAccountInfo { BankAccountsId = bankAccountsId, TargetId = new Guid(RTVWebSite.SelectedNode.Value), }; } else { RAM.Alert("只可编辑未绑定的账户!"); return; } } try { BankAccountInfo isinfo = _bankAccountDaoWrite.Get(bwInfo); if (isinfo == null) { _bankAccountDaoWrite.Update(oldBankAccountsId, bwInfo); BankAccount.Instance.Remove(); } else { RAM.Alert("修改该资金账户已存在!"); return; } } catch { RAM.Alert("修改该资金账户失败!"); return; } if (CacheCollection.SalePlatform.Get(bwInfo.TargetId) != null || CacheCollection.Filiale.IsB2CFiliale(bwInfo.TargetId)) { try { B2CSao.RemoveBankAccountBinding(bwInfo.TargetId, oldBankAccountsId); B2CSao.AddBankAccountBinding(bwInfo.TargetId, bwInfo.BankAccountsId); } catch (Exception exp) { RAM.Alert("同步失败,错误信息:" + exp.Message); } } } }
protected void PayAndReceive(CostReportInfo model) { bool execute = false; //是否执行完成操作 bool need = false; //是否需要完成 decimal realityCost = model.RealityCost; //当是预借款最后一次时,判断金额大小之后,RealityCost的值已经被改变,故此处需要用一个变量提前暂存 var bankAccountInfo = _bankAccounts.GetBankAccounts(model.PayBankAccountId); #region 结算账号 string payBankAccount = bankAccountInfo == null ? "暂无结算" : (bankAccountInfo.BankName + "【" + bankAccountInfo.AccountsName + "】"); #endregion if (model.CostType.Equals(1) || (model.CostType.Equals(2) && (bankAccountInfo != null && !bankAccountInfo.IsFinish))) { //在申请页面完成 need = true; } if (model.ReportKind == (int)CostReportKind.Before) { //预借款 BeforeLoan(model, need, payBankAccount, out execute); } else if (model.ReportKind == (int)CostReportKind.Later) { //凭证报销 VoucherPay(model, need, payBankAccount); } else if (model.ReportKind == (int)CostReportKind.FeeIncome) { execute = true; //费用收入 FeeIncome(model, payBankAccount); } if (bankAccountInfo != null && bankAccountInfo.IsMain) { model.IsOut = true; } else { model.IsOut = false; } #region 保存数据 using (var ts = new TransactionScope(TransactionScopeOption.Required)) { try { _costReport.UpdateReport(model); if (execute || need) { _costReport.UpdatePayCostAndExecuteDate(model.ReportId, realityCost); _utility.UpdateFieldByPk("lmShop_CostReportAmount", "IsPay", new object[] { true }, "ReportId", model.ReportId.ToString()); _utility.UpdateFieldByPk("lmShop_CostReportBill", "IsPay", new object[] { true }, "ReportId", model.ReportId.ToString()); model.RealityCost = realityCost; string errorMessage; bool result = ExecuteFinishHandle(model, Personnel, out errorMessage); if (!result) { throw new Exception(errorMessage); } } //添加操作日志 _operationLogManager.Add(Personnel.PersonnelId, Personnel.RealName, model.ReportId, model.ReportNo, OperationPoint.CostDeclare.AuditDeclare.GetBusinessInfo(), 1, ""); ts.Complete(); } catch { MessageBox.Show(this, "保存失败!"); } finally { ts.Dispose(); } } #endregion }
//初始化页面数据 protected void LoadReportData(CostReportInfo model) { rbl_ReportKind.SelectedValue = model.ReportKind.ToString(); ddl_AssumeBranch.SelectedValue = model.AssumeBranchId.Equals(Guid.Empty) ? string.Empty : model.AssumeBranchId.ToString(); ddl_AssumeGroup.SelectedValue = model.AssumeGroupId.Equals(Guid.Empty) ? string.Empty : model.AssumeGroupId.ToString(); ddl_AssumeShop.SelectedValue = model.AssumeShopId.Equals(Guid.Empty) ? string.Empty : model.AssumeShopId.ToString(); txt_GoodsCode.Text = model.GoodsCode; if ((model.ReportKind.Equals((int)CostReportKind.Before) && model.IsLastTime) || model.ReportKind.Equals((int)CostReportKind.Later)) { if (model.CostsVarieties.Equals(0)) { CompanyClass.Visible = ImgCompanyClass.Visible = true; } else if (model.CostsVarieties.Equals(1)) { GoodsCode.Visible = txtGoodsCode.Visible = true; } } txt_CompanyClass.Text = Cost.ReadInstance.GetCompanyName(model.CompanyClassId, model.CompanyId); rbl_UrgentOrDefer.SelectedValue = model.UrgentOrDefer.ToString(); txt_UrgentReason.Text = model.UrgentReason; txt_ReportName.Text = model.ReportName + (model.ApplyNumber > 1 ? " " + WebControl.ConvertToChnName(model.ApplyNumber) + "期" : string.Empty); if (model.ReportKind.Equals((int)CostReportKind.Before)) { lit_ReportName.Text = "借款内容"; } txt_StartTime.Text = model.StartTime.ToString("yyyy年MM月"); txt_EndTime.Text = model.EndTime.ToString("yyyy年MM月"); txt_PayCompany.Text = model.PayCompany; //“申报类型”是费用收入时,“收款人”变成“付款人” if (model.ReportKind.Equals((int)CostReportKind.FeeIncome)) { lit_PayCompany.Text = "付款"; } else { #region 预借款、凭证报销、已扣款核销 有“票据类型” BillType.Visible = true; txt_InvoiceTitle.ToolTip = txt_InvoiceTitle.Text = model.InvoiceTitle; rbl_InvoiceType.SelectedValue = string.Format("{0}", model.InvoiceType); if (model.InvoiceType.Equals((int)CostReportInvoiceType.Invoice) || model.InvoiceType.Equals((int)CostReportInvoiceType.VatInvoice)) { InvoiceType.InnerText = "发票"; InvoiceTitle.InnerHtml = "发票抬头:"; BillNo.InnerText = "发票号码"; BillCode.Visible = true; TaxAmount.InnerText = "含税金额"; if (model.InvoiceType.Equals((int)CostReportInvoiceType.Invoice)) { NoTaxAmount.Visible = Tax.Visible = false; } else if (model.InvoiceType.Equals((int)CostReportInvoiceType.VatInvoice)) { NoTaxAmount.Visible = Tax.Visible = true; } } else if (model.InvoiceType.Equals((int)CostReportInvoiceType.Voucher)) { InvoiceType.InnerText = "收据"; InvoiceTitle.InnerHtml = "收据抬头:"; BillNo.InnerText = "收据号码"; BillCode.Visible = false; TaxAmount.InnerText = "金额"; NoTaxAmount.Visible = Tax.Visible = false; } #endregion } if (model.ReportKind.Equals((int)CostReportKind.Before)) { lit_ReportCost.Text = "预估申报"; } txt_ReportCost.Text = WebControl.RemoveDecimalEndZero(Math.Abs(model.ReportCost)); Lit_CapitalAmount.Text = Math.Abs(model.ReportCost).ToString(CultureInfo.InvariantCulture); rbl_CostType.SelectedValue = model.CostType.ToString(); if (model.CostType.Equals(2))//转账 { if (!string.IsNullOrEmpty(model.BankAccountName)) { txt_BankName.Text = model.BankAccountName.Split(',')[0]; txt_SubBankName.Text = model.BankAccountName.Split(',')[1]; } if (model.ReportKind.Equals((int)CostReportKind.Before) || model.ReportKind.Equals((int)CostReportKind.Later)) { txt_BankAccount.Text = model.BankAccount; BankName.Visible = txtBankName.Visible = SubBankName.Visible = txtSubBankName.Visible = BankAccount.Visible = txtBankAccount.Visible = true; } else if (model.ReportKind.Equals((int)CostReportKind.Paying) || model.ReportKind.Equals((int)CostReportKind.FeeIncome)) { BankName.Visible = txtBankName.Visible = SubBankName.Visible = txtSubBankName.Visible = true; } } if (model.ReportKind.Equals((int)CostReportKind.Before) || model.ReportKind.Equals((int)CostReportKind.Later)) { lit_BankName.Text = lit_SubBankName.Text = "收款"; } else if (model.ReportKind.Equals((int)CostReportKind.Paying) || model.ReportKind.Equals((int)CostReportKind.FeeIncome)) { lit_BankName.Text = lit_SubBankName.Text = "付款"; PayBankAccountAndAssumeFiliale.Visible = true; if (!model.PayBankAccountId.Equals(Guid.Empty)) { var bankAccountInfo = _bankAccounts.GetBankAccounts(model.PayBankAccountId); string payBankAccount = bankAccountInfo.BankName + "【" + bankAccountInfo.AccountsName + "】"; txt_PayBankAccount.ToolTip = txt_PayBankAccount.Text = payBankAccount; txt_AssumeFiliale.Text = CacheCollection.Filiale.GetFilialeNameAndFilialeId(model.PayBankAccountId).Split(',')[0]; } } //押金回收生成的“凭证报销”和“费用收入”有押金编号,此处要显示 if (!string.IsNullOrEmpty(model.DepositNo)) { DepositNo.Visible = txtDepositNo.Visible = true; txt_DepositNo.Text = model.DepositNo; } txt_ReportMemo.Text = model.ReportMemo; #region 广告使用图片(广告费=>推广费用) if (!model.InvoiceId.Equals(Guid.Empty)) { var costReportInvoice = _costReportInvoice.GetInvoice(model.InvoiceId); if (costReportInvoice != null && !costReportInvoice.InvoiceId.Equals(Guid.Empty)) { PreA.HRef = costReportInvoice.ImagePath; PreA.Visible = true; UploadImgName.Text = costReportInvoice.ImagePath.Substring(costReportInvoice.ImagePath.LastIndexOf('/') + 1); } } #endregion #region 差旅费 if (((model.ReportKind.Equals((int)CostReportKind.Before) && model.IsLastTime) || model.ReportKind == (int)CostReportKind.Later) && !model.CompanyId.Equals(Guid.Empty) && model.CompanyId.Equals(new Guid(CostReport_TravelExpenses))) { //获取差旅费 CostReportTravelInfoList = _costReportTravel.GetlmShop_CostReportTravelByReportId(model.ReportId); if (CostReportTravelInfoList.Any()) { LoadTravelData(CostReportTravelInfoList); } //获取起讫 CostReportTerminiInfoList = _costReportTermini.GetmShop_CostReportTerminiByReportId(model.ReportId); if (CostReportTerminiInfoList.Any()) { RepeaterTerminiDataBind(); } txt_CompanyClass.Style["color"] = "red"; txt_CompanyClass.Style["font-weight"] = "bold"; MessageBox.AppendScript(this, "$(\"#TraveA\").show();$(\"#TraveDetail\").show();$(\"input[id$='Hid_Travel']\").val(\"0\");"); } #endregion if (model.ReportKind.Equals((int)CostReportKind.Before)) { if (!model.PayCost.Equals(0)) { IsLastTime.Visible = true; rb_IsLastTime.SelectedValue = model.IsLastTime.ToString(); if (bool.Parse(rb_IsLastTime.SelectedValue)) { #region 是否终结 rbIsEndTitle.Visible = rbIsEnd.Visible = true; rb_IsEnd.SelectedValue = model.IsEnd.ToString(); #endregion } } #region 申请金额 //获取申请金额 CostReportAmountInfoList = _costReportAmount.GetmShop_CostReportAmountByReportId(model.ReportId).Where(p => !p.IsSystem).ToList(); if (CostReportAmountInfoList.Any()) { RepeaterAmountDataBind(); Amount.Visible = true; } #endregion } if (string.IsNullOrEmpty(model.DepositNo) && (model.ReportKind.Equals((int)CostReportKind.FeeIncome) || model.CompanyClassId.Equals(new Guid(CostReport_DepositMargins)))) { Amount.Visible = false; } #region 票据类型相关 //获取票据 CostReportBillInfoList = _costReportBill.Getlmshop_CostReportBillByReportId(model.ReportId); if (CostReportBillInfoList.Any()) { RepeaterBillDataBind(); Bill.Visible = true; } #endregion #region 是否有权限更改“申报部门” var isEnabled = GetPowerOperationPoint("SetAssume"); ddl_AssumeBranch.Enabled = isEnabled; ddl_AssumeGroup.Enabled = isEnabled; ddl_AssumeShop.Enabled = isEnabled; #endregion Hid_ReportPersonnelId.Value = model.ReportPersonnelId.ToString(); }
//付款 protected void btn_Pay_Click(object sender, EventArgs e) { #region 验证数据 var errorMsg = CheckData(); if (!string.IsNullOrEmpty(errorMsg)) { MessageBox.Show(this, errorMsg); return; } #endregion CostReportInfo model = _costReport.GetReportByReportId(new Guid(Request.QueryString["ReportId"])); if (model.State != (int)CostReportState.WaitVerify) { MessageBox.Show(this, "该单据状态已更新,不允许此操作!"); return; } var bankAccountInfo = _bankAccounts.GetBankAccounts(new Guid(rcb_PayBankAccount.SelectedValue)); #region 结算账号 string payBankAccount = bankAccountInfo == null ? "暂无结算" : (bankAccountInfo.BankName + "【" + bankAccountInfo.AccountsName + "】"); #endregion //费用收入(押金) FeeIncome(model, payBankAccount); #region 额外可修改的项 UpdateItem(model); #endregion model.AssumeBranchId = string.IsNullOrEmpty(ddl_AssumeBranch.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeBranch.SelectedValue); model.AssumeGroupId = string.IsNullOrEmpty(ddl_AssumeGroup.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeGroup.SelectedValue); model.AssumeShopId = string.IsNullOrEmpty(ddl_AssumeShop.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeShop.SelectedValue); model.PayBankAccountId = string.IsNullOrEmpty(rcb_PayBankAccount.SelectedValue) ? Guid.Empty : new Guid(rcb_PayBankAccount.SelectedValue); model.AssumeFilialeId = string.IsNullOrEmpty(ddl_AssumeFiliale.SelectedValue) ? Guid.Empty : new Guid(ddl_AssumeFiliale.SelectedValue); model.Poundage = string.IsNullOrEmpty(txt_Poundage.Text) ? 0 : decimal.Parse(txt_Poundage.Text); model.TradeNo = txt_TradeNo.Text; model.AuditingMemo = txt_AuditingMemo.Text; if (bankAccountInfo != null && bankAccountInfo.IsMain) { model.IsOut = true; } else { model.IsOut = false; } #region 保存数据 using (var ts = new TransactionScope(TransactionScopeOption.Required)) { try { _costReport.UpdateReport(model); _costReport.UpdatePayCostAndExecuteDate(model.ReportId, model.ReportCost); string errorMessage; bool result = ExecuteFinishHandle(model, Personnel, out errorMessage); if (!result) { throw new Exception(errorMessage); } //添加操作日志 _operationLogManager.Add(Personnel.PersonnelId, Personnel.RealName, model.ReportId, model.ReportNo, OperationPoint.CostDeclare.AuditDeclare.GetBusinessInfo(), 1, ""); ts.Complete(); MessageBox.AppendScript(this, "setTimeout(function(){ CloseAndRebind(); }, " + GlobalConfig.PageAutoRefreshDelayTime + ");"); } catch { MessageBox.Show(this, "保存失败!"); } finally { ts.Dispose(); } } #endregion }