private void BindBudgetInfo() { tr_BudgetInfo.Visible = true; int month = (int)ViewState["AccountMonth"]; int organizecity = (int)ViewState["OrganizeCity"]; int feetype = (int)ViewState["FeeType"]; lb_BudgetAmount.Text = FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, feetype).ToString("0.###"); lb_BudgetBalance.Text = FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype).ToString("0.###"); lb_SubmitTotalCost.Text = FNA_FeeApplyBLL.GetApplyTotalCost(month, organizecity, feetype).ToString("0.###"); if (decimal.Parse(lb_BudgetAmount.Text) != 0) { lb_TotalPercent.Text = (decimal.Parse(lb_SubmitTotalCost.Text) / decimal.Parse(lb_BudgetAmount.Text)).ToString("0.##%"); } hl_ViewBudget.NavigateUrl = "~/SubModule/FNA/Budget/BudgetBalance.aspx?OrganizeCity=" + organizecity.ToString() + "&AccountMonth=" + month.ToString(); if (feetype == ConfigHelper.GetConfigInt("GiftFeeType")) { if ((int)ViewState["GiftFeeClassify"] == 0) { MessageBox.ShowAndRedirect(this, "赠品费用请至赠品专项费用申请页面申请!", "FeeApply_GiftFeeApply.aspx"); return; } GetGiftAmountBalance(); } }
void BindBudget(int month, int organizecity, int feetype) { lb_Balance.Text = FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype).ToString("0.##"); int city = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", organizecity, 1); lb_DepartmentBalance.Text = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false).ToString(); }
private void BindBudgetInfo(int city, int month, int client, int feetype, int productbrand, int giftclassify) { decimal totalbudget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); lb_TotalBudget.Text = totalbudget.ToString("0.##"); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); ViewState["SalesVolume"] = 0m; if (giftamounts.Count > 0) { decimal available = giftamounts[0].AvailableAmount + giftamounts[0].PreBalance - giftamounts[0].DeductibleAmount;; decimal balance = giftamounts[0].BalanceAmount; ViewState["SalesVolume"] = giftamounts[0].SalesVolume; lb_AvailableAmount.Text = available.ToString("0.##"); lb_BalanceAmount.Text = balance.ToString("0.##"); //2012-3-27 暂时只取赠品额度,不取预算 //lb_BalanceAmount.Text = (totalbudget > balance ? balance : totalbudget).ToString("0.##"); } else { lb_AvailableAmount.Text = "0"; lb_BalanceAmount.Text = "0"; } hl_ViewBudget.NavigateUrl = "~/SubModule/FNA/Budget/BudgetBalance.aspx?OrganizeCity=" + city.ToString(); }
private void BindBudgetInfo(int city, int month, int client, int feetype, int productbrand, int giftclassify, int receiver) { lb_OrganizeCityName.Text = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", city); lb_ClientName.Text = client == 0 ? "" : new CM_ClientBLL(client).Model.FullName; lb_Receiver.Text = (receiver == 0 || receiver == null) ? "" : new CM_ClientBLL(receiver).Model.FullName; decimal totalbudget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); lb_TotalBudget.Text = totalbudget.ToString("0.##"); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); if (giftamounts.Count > 0) { decimal available = giftamounts[0].AvailableAmount + giftamounts[0].PreBalance - giftamounts[0].DeductibleAmount; decimal balance = giftamounts[0].BalanceAmount; ViewState["SalesVolume"] = giftamounts[0].SalesVolume; lb_AvailableAmount.Text = available.ToString("0.##"); lb_BalanceAmount.Text = balance.ToString("0.##"); //2012-3-27 暂时只取赠品额度,不取预算 //lb_BalanceAmount.Text = (totalbudget > balance ? balance : totalbudget).ToString("0.##"); } else { lb_AvailableAmount.Text = "0"; lb_BalanceAmount.Text = "0"; } hl_ViewBudget.NavigateUrl = "~/SubModule/FNA/Budget/BudgetBalance.aspx?OrganizeCity=" + city.ToString(); }
private bool Save() { #region 判断是否超过可用预算合计值 TextBox tbx = null; decimal sumBuget = 0, fee = 0; foreach (GridViewRow row in gv_List.Rows) { int feetype = (int)gv_List.DataKeys[row.RowIndex]["FeeType"]; tbx = (TextBox)row.FindControl("tbx_BudgetAmount"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { if (feetype == 20) { if (fee > decimal.Parse(lb_RetentionBudget.Text)) { tbx.Focus(); MessageBox.Show(this, "自留费用不超过可用自留费用!"); return(false); } } else { string[] outbudgets = ConfigHelper.GetConfigString("OutSumBudgetFeeType").Split(','); if (!outbudgets.Contains(feetype.ToString())) { sumBuget += fee; } } } else { tbx.Focus(); MessageBox.Show(this, "费用预算额度格式必须为数字值,且不能小于0!"); return(false); } } if (sumBuget > decimal.Parse(lb_SumBudget.Text)) { tbx.Focus(); MessageBox.Show(this, "分配的总费用不能大于总可用预算合计值!当前合计值:" + sumBuget.ToString("0.##") + ",可用费用值:" + lb_SumBudget.Text); return(false); } #endregion foreach (GridViewRow row in gv_List.Rows) { FNA_BudgetBLL bll = new FNA_BudgetBLL((int)gv_List.DataKeys[row.RowIndex]["ID"]); if (bll.Model.ApproveFlag == 2) { bll.Model.BudgetAmount = decimal.Parse(((TextBox)row.FindControl("tbx_BudgetAmount")).Text); bll.Model.Remark = ((TextBox)row.FindControl("tbx_Remark")).Text; bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); } } return(true); }
private decimal GetGiftAmountBalance() { decimal giftamountbalance = 0; int month = 0, city = 0, feetype = 0, client = 0, productbrand = 0, giftclassify = 0; feetype = (int)ViewState["GiftFeeType"]; int.TryParse(ddl_ApplyMonth.SelectedValue, out month); int.TryParse(tr_OrganizeCity.SelectValue, out city); int.TryParse(select_Client.SelectValue, out client); int.TryParse(ddl_Brand.SelectedValue, out productbrand); int.TryParse(rbl_GiftClassify.SelectedValue, out giftclassify); IList <ORD_GiftApplyAmount> giftamounts = ORD_GiftApplyAmountBLL.GetModelList( string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, productbrand, giftclassify)); if (giftamounts.Count > 0) { decimal budget = FNA_BudgetBLL.GetUsableAmount(month, city, feetype, false); decimal balance = giftamounts[0].BalanceAmount; giftamountbalance = budget > balance ? balance : budget; } lb_GiftAmountBalance.Text = giftamountbalance.ToString("0.0#"); return(giftamountbalance); }
protected decimal GetAssignedBudget(int OrganizeCity, int AccountMonth) { if (ConfigHelper.GetConfigString("OutSumBudgetFeeType") != "") { return(FNA_BudgetBLL.GetModelList("OrganizeCity=" + OrganizeCity.ToString() + " AND AccountMonth=" + AccountMonth.ToString() + " AND FeeType NOT IN (" + ConfigHelper.GetConfigString("OutSumBudgetFeeType") + ") ").Sum(p => p.BudgetAmount)); } else { return(FNA_BudgetBLL.GetModelList("OrganizeCity=" + OrganizeCity.ToString() + " AND AccountMonth=" + AccountMonth.ToString()).Sum(p => p.BudgetAmount)); } }
public void BindGrid() { if (tr_OrganizeCity.SelectValue == "0") { return; } DataTable dt = FNA_BudgetBLL.GetAssignInfo(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_AccountMonth.SelectedValue), int.Parse(ddl_CityLevel.SelectedValue)); DataTable dt_Matrix = MatrixTable.Matrix(dt, new string[] { "OrganizeCity", "区域名称" }, "FeeTypeName", "BudgetAmount", true, true); gv_List.DataSource = dt_Matrix; gv_List.DataBind(); }
private void BindBudgetInfo() { tbl_BudgetInfo.Visible = true; int month = (int)ViewState["AccountMonth"]; int organizecity = (int)ViewState["OrganizeCity"]; int feetype = (int)ViewState["FeeType"]; lb_BudgetAmount.Text = (FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, feetype) + FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, 0)).ToString("0.###"); lb_BudgetBalance.Text = (FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype) + FNA_BudgetBLL.GetUsableAmount(month, organizecity, 0)).ToString("0.###"); }
protected void bt_Submit_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { bt_OK_Click(null, null); FNA_BudgetTransferApplyBLL bll = new FNA_BudgetTransferApplyBLL((int)ViewState["ID"]); #region 判断源预算余额是否够调拨 decimal balance = FNA_BudgetBLL.GetUsableAmount(bll.Model.FromAccountMonth, bll.Model.FromOrganizeCity, bll.Model.FromFeeType); if (balance < bll.Model.TransferAmount) { MessageBox.Show(this, "对不起,源预算余额不够调拨!源余额为" + balance.ToString("0.##")); return; } #endregion #region 发起工作流 NameValueCollection dataobjects = new NameValueCollection(); dataobjects.Add("ID", ViewState["ID"].ToString()); dataobjects.Add("OrganizeCity", bll.Model.ToOrganizeCity.ToString()); dataobjects.Add("AccountMonth", bll.Model.ToAccountMonth.ToString()); dataobjects.Add("FromFeeType", bll.Model.FromFeeType.ToString()); dataobjects.Add("ToFeeType", bll.Model.ToFeeType.ToString()); dataobjects.Add("TransferAmount", bll.Model.TransferAmount.ToString("0.##")); #region 组合审批任务主题 string title = TreeTableBLL.GetFullPathName("MCS_SYS.dbo.Addr_OrganizeCity", bll.Model.ToOrganizeCity) + " 申请扩增预算额度,扩增额度:" + bll.Model.TransferAmount.ToString("0.##"); #endregion int TaskID = EWF_TaskBLL.NewTask("FNA_BudgetTransferApplyFlow", (int)Session["UserID"], title, "~/SubModule/FNA/Budget/BudgetTransferApplyDetail.aspx?ID=" + ViewState["ID"].ToString(), dataobjects); if (TaskID <= 0) { MessageBox.Show(this, "对不起,工作流发起失败,请与管理员联系!"); return; } bll.Submit((int)Session["UserID"], TaskID); new EWF_TaskBLL(TaskID).Start(); //直接启动流程 #endregion MessageBox.ShowAndRedirect(this, "预算扩增提交成功!", Page.ResolveClientUrl("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString())); } }
private void BindFeeRateInfo() { tr_FeeRateInfo.Visible = true; int month = (int)ViewState["AccountMonth"]; int organizecity = (int)ViewState["OrganizeCity"]; int feetype = (int)ViewState["FeeType"]; decimal forcastvolume = SVM_SalesForcastBLL.GetTotalVolume(month, organizecity, true); decimal balance = FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype); decimal totalcost = FNA_FeeApplyBLL.GetApplyTotalCost(month, organizecity, feetype); lb_ForcastVolume.Text = forcastvolume.ToString("0.###"); lb_BudgetBalance1.Text = balance.ToString("0.###"); lb_SubmitTotalCost1.Text = totalcost.ToString("0.###"); if (forcastvolume != 0) { lb_FeeRate.Text = ((totalcost - balance) / forcastvolume).ToString("0.##%"); } }
protected void btnApprove_Click(object sender, EventArgs e) { foreach (GridViewRow row in gv_List.Rows) { CheckBox cb = (CheckBox)row.FindControl("CheckBox1"); if (cb.Checked) { FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL((int)gv_List.DataKeys[row.RowIndex].Value); bll.Model.ApproveFlag = 1; bll.Update(); FNA_BudgetBLL budget = new FNA_BudgetBLL(); budget.Model.AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue); budget.Model.ApproveFlag = 1; budget.Model.OrganizeCity = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID; budget.Model.BudgetAmount = decimal.Parse(bll.Model["DepartmentBudget"]); budget.Model.FeeType = 0; budget.Model.BudgetType = 1; budget.Model.InsertStaff = (int)Session["UserID"]; budget.Model.InsertTime = DateTime.Now; budget.Add(); } } BindGrid(); }
private void BindGrid() { //权限判断 if (!Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1511, "ApproveBudget")) { btnApprove.Visible = false; } IList <FNA_BudgetSource> sourcelists = FNA_BudgetSourceBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " and AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND ApproveFlag=1"); if (sourcelists.Count == 0) { MessageBox.ShowAndRedirect(this, "对不起当前作业区可用费用计算表还未填写或未审核!", "BudgetSource.aspx"); return; } IList <FNA_Budget> budgets = FNA_BudgetBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " AND AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND BudgetType=1"); lb_PlanVolume.Text = sourcelists[0].PlanVolume.ToString("0.##"); lb_SumBudget.Text = (sourcelists[0].BaseBudget + sourcelists[0].OverFullBudget - decimal.Parse(sourcelists[0]["DepartmentBudget"])).ToString("0.##"); lb_RetentionBudget.Text = sourcelists[0].RetentionBudget.ToString("0.##"); lb_DepartmentBudget.Text = sourcelists[0]["DepartmentBudget"]; string[] outbudgets = ConfigHelper.GetConfigString("OutSumBudgetFeeType").Split(','); lb_AssignBalance.Text = (sourcelists[0].BaseBudget + sourcelists[0].OverFullBudget - decimal.Parse(sourcelists[0]["DepartmentBudget"]) - budgets.Sum(p => outbudgets.Contains(p.FeeType.ToString()) ? 0 : p.BudgetAmount)).ToString("0.##"); #region 初始化预算分配 Dictionary <string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("FNA_FeeType", true); foreach (Dictionary_Data item in dic.Values) { if (budgets.FirstOrDefault(p => p.FeeType == int.Parse(item.Code)) == null) { FNA_BudgetBLL bll = new FNA_BudgetBLL(); bll.Model.AccountMonth = (int)ViewState["AccountMonth"]; bll.Model.OrganizeCity = (int)ViewState["OrganizeCity"]; bll.Model.BudgetType = 1; bll.Model.FeeType = int.Parse(item.Code); if (bll.Model.FeeType == 20) { bll.Model.BudgetAmount = decimal.Parse(lb_RetentionBudget.Text); } else { bll.Model.BudgetAmount = 0; } bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Add(); } } #endregion budgets = FNA_BudgetBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " and AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND BudgetType=1").OrderBy(p => p.FeeType).ToList(); gv_List.BindGrid(budgets); if (budgets.FirstOrDefault(p => p.ApproveFlag == 2) == null) { btnSave.Visible = false; btnApprove.Visible = false; cbx_CheckAll.Visible = false; } }
protected void bt_Submit_Click(object sender, EventArgs e) { if ((int)ViewState["ID"] != 0) { if (gv_List.Rows.Count == 0) { MessageBox.Show(this, "对不起, 必须添加相应的费用明细!"); return; } bt_Save_Click(null, null); FNA_FeeApplyBLL bll = new FNA_FeeApplyBLL((int)ViewState["ID"]); if (bll.Model.State != 1) { MessageBox.Show(this, "对不起,该申请单不为草稿状态,不能提交!"); return; } if (bll.Model.Client == 0 && !cbx_NoInsteadPayClient.Checked) { MessageBox.Show(this, "请正确选择费用代垫客户,如果确认无代垫客户,请勾选【确认无代垫客户】复选框!"); return; } if (cbx_NoInsteadPayClient.Checked && bll.Model.Client != 0) { MessageBox.Show(this, "您已选择了费用代垫客户,又请勾选【确认无代垫客户】复选框,两者只能选择其一,请确认!"); return; } #region 判断预算额度余额是否够申请 if (((Dictionary_Data)ViewState["DicFeeType"]).Description == "BudgetControl") { decimal _balance = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, bll.Model.FeeType); decimal _applycost = decimal.Parse(lb_TotalCost.Text); lb_BudgetAmount.Text = _balance.ToString("0.###"); if (bll.Model.FeeType == ConfigHelper.GetConfigInt("GiftFeeType")) { _balance = GetGiftAmountBalance(); } if (_balance < _applycost) { MessageBox.Show(this, "对不起,您当前的预算余额不够申请该项费用!"); return; } } #endregion #region 发起工作流 NameValueCollection dataobjects = new NameValueCollection(); dataobjects.Add("ID", ViewState["ID"].ToString()); dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString()); dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString()); dataobjects.Add("TotalFee", lb_TotalCost.Text); dataobjects.Add("BorrowFee", lb_BorrowTotal.Text); dataobjects.Add("FeeType", bll.Model.FeeType.ToString()); dataobjects.Add("AccountTitleType", bll.Model["AccountTitle2"]); #region 组合审批任务主题 string title = bll.Model["Title"] + ",申请备案号:" + bll.Model.SheetCode + ",总费用:" + lb_TotalCost.Text; #endregion string AppCode = "FNA_FeeApplyFlow"; if (EWF_Flow_AppBLL.GetModelList("Code='" + AppCode + "_" + bll.Model.FeeType.ToString() + "' AND EnableFlag='Y'").Count > 0) { AppCode = AppCode + "_" + bll.Model.FeeType.ToString(); } if (bll.Model["AccountTitle2"] == "81")//导购管理费 { AppCode = "FNA_FeeApplyFlow_8"; } int TaskID = EWF_TaskBLL.NewTask(AppCode, (int)Session["UserID"], title, "~/SubModule/FNA/FeeApply/FeeApplyDetail3.aspx?ID=" + ViewState["ID"].ToString(), dataobjects); if (TaskID <= 0) { MessageBox.Show(this, "对不起,工作流发起失败,请与管理员联系!"); return; } new EWF_TaskBLL(TaskID).Start(); //直接启动流程 #endregion bll.Submit((int)Session["UserID"], TaskID); MessageBox.ShowAndRedirect(this, "费用申请提交成功!", "FeeApplyList.aspx?FeeType=" + ViewState["FeeType"].ToString() + "&AccountMonth=" + ViewState["AccountMonth"].ToString()); } }
private void BindGrid() { int month = int.Parse(ddl_Month.SelectedValue); int organizecity = int.Parse(tr_OrganizeCity.SelectValue); int level = int.Parse(ddl_Level.SelectedValue); int feetype = int.Parse(ddl_FeeType.SelectedValue); int state = int.Parse(ddl_State.SelectedValue); int flag = int.Parse(ddl_Flag.SelectedValue); if (MCSTabControl1.SelectedIndex == 0) { #region 显示汇总单数据源 Dictionary_Data dicFeeType = null; if (feetype > 0) { dicFeeType = DictionaryBLL.GetDicCollections("FNA_FeeType")[feetype.ToString()]; } DataTable dtSummary_Sub; DataTable dtSummary = FNA_FeeApplyBLL.GetSummaryTotal(month, organizecity, level, feetype, state, flag, int.Parse(Session["UserID"].ToString())); if (dtSummary.Rows.Count == 0) { gv_List.DataBind(); return; } else { dtSummary_Sub = FNA_FeeApplyBLL.GetSummaryTotal_Sub(month, organizecity, level, feetype, state, flag, int.Parse(Session["UserID"].ToString())); } #region 矩阵化数据表,扩展表数据列 dtSummary.Columns.Add(new DataColumn("ID", Type.GetType("System.Int32"))); if (level < 10) { foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["OrganizeCity"]; } dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "ApplyCost", true, true); } else { if (level == 10) { //按经销商查看 #region 将经销商的ID赋至表ID列 foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["经销商ID"] == DBNull.Value ? 0 : row["经销商ID"]; row["经销商名称"] = row["经销商名称"] == DBNull.Value ? "无" : row["经销商名称"]; } #endregion dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "经销商名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "ApplyCost", true, true); } else if (level == 20) { //按门店查看 #region 将门店的ID赋至表ID列 foreach (DataRow row in dtSummary.Rows) { row["ID"] = row["客户ID"] == DBNull.Value ? 0 : row["客户ID"]; row["客户名称"] = row["客户名称"] == DBNull.Value ? "无" : row["客户名称"]; } #endregion dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "ID", "管理片区名称", "客户名称" }, new string[] { "FeeTypeName", "AccountTitleName" }, "ApplyCost", true, true); } } dtSummary = MatrixTable.ColumnSummaryTotal(dtSummary, new int[] { 1 }, new string[] { "sales" }); dtSummary.Columns["合计"].ColumnName = "费用合计"; dtSummary.Columns.Add("本月费用合计", Type.GetType("System.Decimal")); dtSummary.Columns.Add("预计销量", Type.GetType("System.Decimal")); dtSummary.Columns.Add("上月销量", Type.GetType("System.Decimal")); dtSummary.Columns.Add("平均销量", Type.GetType("System.Decimal")); dtSummary.Columns.Add("预计费点", Type.GetType("System.String")); if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) { dtSummary.Columns.Add("预算总额", Type.GetType("System.Decimal")); dtSummary.Columns.Add("其中扩增额", Type.GetType("System.Decimal")); dtSummary.Columns.Add("预算余额", Type.GetType("System.Decimal")); dtSummary.Columns.Add("终结费用", Type.GetType("System.Decimal")); } if (dicFeeType != null && dicFeeType.Description == "FeeRateControl") { dtSummary.Columns.Add("上月余额", Type.GetType("System.Decimal")); } #endregion decimal sumTotalVolume = 0, sumAvgVolume = 0, sumSalesForcast = 0, sumHappenApplyCost = 0; decimal sumTotalBudget = 0, sumExtBudget = 0, sumPreMonthBudgetBalance = 0, sumUsableAmount = 0, sumCancelCost = 0; int premonth = month - 1; if (premonth >= AC_AccountMonthBLL.GetCurrentMonth()) { premonth = AC_AccountMonthBLL.GetCurrentMonth() - 1; } foreach (DataRow row in dtSummary.Rows) { int id = 0; if (int.TryParse(row["ID"].ToString(), out id) && id > 0) { string filter = "ID=" + id; bool includechild = false; if (level < 10 && new Addr_OrganizeCityBLL(id).Model.Level >= level) { includechild = true; } #region 计算销量数据 decimal happenApplyCost = 0, forcast = 0, preSales = 0, aVGSales = 0, feeRate = 0; DataRow[] drows = dtSummary_Sub.Select(filter); if (drows.Length > 0) { decimal.TryParse(drows[0]["HappenApplyCost"].ToString(), out happenApplyCost); decimal.TryParse(drows[0]["Forcast"].ToString(), out forcast); decimal.TryParse(drows[0]["PreSales"].ToString(), out preSales); decimal.TryParse(drows[0]["AVGSales"].ToString(), out aVGSales); decimal.TryParse(drows[0]["FeeRate"].ToString(), out feeRate); } row["本月费用合计"] = happenApplyCost.ToString("0.##"); row["上月销量"] = preSales.ToString("0.##"); row["平均销量"] = aVGSales.ToString("0.##"); row["预计销量"] = forcast.ToString("0.##"); row["预计费点"] = feeRate.ToString("0.##%"); sumHappenApplyCost += (decimal)row["本月费用合计"]; sumTotalVolume += (decimal)row["上月销量"]; sumAvgVolume += (decimal)row["平均销量"]; sumSalesForcast += (decimal)row["预计销量"]; #endregion #region 预算总额及余额 if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) { row["预算总额"] = (FNA_BudgetBLL.GetSumBudgetAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetSumBudgetAmount(month, id, 0, includechild)); sumTotalBudget += (decimal)row["预算总额"]; row["其中扩增额"] = (FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, feetype, includechild) + FNA_BudgetExtraApplyBLL.GetExtraAmount(month, id, 0, includechild)); sumExtBudget += (decimal)row["其中扩增额"]; row["预算余额"] = (FNA_BudgetBLL.GetUsableAmount(month, id, feetype, includechild) + FNA_BudgetBLL.GetUsableAmount(month, id, 0, includechild)); sumUsableAmount += (decimal)row["预算余额"]; row["终结费用"] = (FNA_FeeApplyBLL.GetCancelCost(month, id, feetype, includechild) + FNA_FeeApplyBLL.GetCancelCost(month, id, 0, includechild)); sumCancelCost += (decimal)row["终结费用"]; } #endregion //#region 计算预计费点 //if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10) //{ // row["上月余额"] = FNA_BudgetBLL.GetUsableAmount(month - 1, id, feetype, includechild); // sumPreMonthBudgetBalance += (decimal)row["上月余额"]; // if ((decimal)row["预计销量"] != 0) // row["预计费点"] = (((decimal)row["费用合计"] - (decimal)row["上月余额"]) / (decimal)row["预计销量"]).ToString("0.00%"); //} //else if ((decimal)row["预计销量"] != 0) // row["预计费点"] = ((decimal)row["费用合计"] / (decimal)row["预计销量"]).ToString("0.00%"); //#endregion } #region 求合计行 if (id == 0) { row["本月费用合计"] = sumHappenApplyCost.ToString("0.##"); row["上月销量"] = sumTotalVolume.ToString("0.##"); row["平均销量"] = sumAvgVolume.ToString("0.##"); row["预计销量"] = sumSalesForcast.ToString("0.##"); #region 预算总额及余额 if (dicFeeType != null && dicFeeType.Description == "BudgetControl" && level < 10) { row["预算总额"] = sumTotalBudget.ToString("0.##"); row["其中扩增额"] = sumExtBudget.ToString("0.##"); row["预算余额"] = sumUsableAmount.ToString("0.##"); row["终结费用"] = sumCancelCost.ToString("0.##"); } #endregion #region 预计费点 if (sumSalesForcast != 0) { if (dicFeeType != null && dicFeeType.Description == "FeeRateControl" && level < 10) { row["上月余额"] = sumPreMonthBudgetBalance; row["预计费点"] = (((decimal)row["费用合计"] - sumPreMonthBudgetBalance) / sumSalesForcast).ToString("0.##%"); } else { row["预计费点"] = ((decimal)row["费用合计"] / sumSalesForcast).ToString("0.##%"); } } #endregion } #endregion } gv_List.DataSource = dtSummary; gv_List.DataBind(); if (dtSummary.Columns.Count >= 24) { gv_List.Width = new Unit(dtSummary.Columns.Count * 55); } else { gv_List.Width = new Unit(100, UnitType.Percentage); } MatrixTable.GridViewMatric(gv_List); if (level == 20) { //按终端门店显示时,将上下行相同管理片区合并 MatrixTable.GridViewMergSampeValueRow(gv_List, 0); MatrixTable.GridViewMergSampeValueRow(gv_List, 1); } #region 是否可以批量审批 if (state != 1 || level >= 10) { gv_List.Columns[0].ItemStyle.Width = new Unit(1); foreach (GridViewRow row in gv_List.Rows) { row.FindControl("bt_Approved").Visible = false; row.FindControl("bt_UnApproved").Visible = false; } } else { gv_List.Columns[0].ItemStyle.Width = new Unit(68); } #endregion #endregion } else { string condition = "1=1"; #region 组织明细记录的查询条件 //管理片区及所有下属管理片区 if (tr_OrganizeCity.SelectValue == "0") { #region 绑定用户可管辖的管理片区 Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]); tr_OrganizeCity.DataSource = staff.GetStaffOrganizeCity(); if (tr_OrganizeCity.DataSource.Select("ID = 1").Length > 0) { tr_OrganizeCity.RootValue = "0"; tr_OrganizeCity.SelectValue = "1"; } else { tr_OrganizeCity.RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); tr_OrganizeCity.SelectValue = staff.Model.OrganizeCity.ToString(); } if ((int)ViewState["OrganizeCity"] > 0) { tr_OrganizeCity.SelectValue = ViewState["OrganizeCity"].ToString(); } #endregion } if (tr_OrganizeCity.SelectValue != "1") { Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue)); string orgcitys = orgcity.GetAllChildNodeIDs(); if (orgcitys != "") { orgcitys += ","; } orgcitys += tr_OrganizeCity.SelectValue; condition += " AND FNA_FeeApply.OrganizeCity IN (" + orgcitys + ")"; } //会计月条件 condition += " AND FNA_FeeApply.AccountMonth = " + ddl_Month.SelectedValue; //费用类型 if (ddl_FeeType.SelectedValue != "0") { condition += " AND FNA_FeeApply.FeeType = " + ddl_FeeType.SelectedValue; } int accounttile = 0; int.TryParse(tr_AccountTitle.SelectValue, out accounttile); decimal _cost = 0; decimal.TryParse(tbx_ApplyCost.Text, out _cost); //费用科目 if (accounttile > 1) { DataTable dt = TreeTableBLL.GetAllChildByNodes("MCS_PUB.dbo.AC_AccountTitle", "ID", "SuperID", accounttile.ToString()); string ids = ""; foreach (DataRow dr in dt.Rows) { ids += dr["ID"].ToString() + ","; } ids += accounttile.ToString(); if (_cost == 0) { condition += " AND FNA_FeeApply.ID IN (SELECT ApplyID FROM MCS_FNA.dbo.FNA_FeeApplyDetail WHERE AccountTitle IN(" + ids + ") AND FNA_FeeApplyDetail.ApplyID=FNA_FeeApply.ID)"; } else { condition += " AND FNA_FeeApply.ID IN (SELECT ApplyID FROM MCS_FNA.dbo.FNA_FeeApplyDetail WHERE AccountTitle IN(" + ids + ") AND (ApplyCost+AdjustCost)" + ddl_ApplyCostOP.SelectedValue + " " + _cost.ToString() + " AND FNA_FeeApplyDetail.ApplyID=FNA_FeeApply.ID)"; } } else if (_cost != 0)//金额判断 { condition += " AND FNA_FeeApply.ID IN (SELECT ApplyID FROM MCS_FNA.dbo.FNA_FeeApplyDetail WHERE (ApplyCost+AdjustCost)" + ddl_ApplyCostOP.SelectedValue + " " + _cost.ToString() + " AND FNA_FeeApplyDetail.ApplyID=FNA_FeeApply.ID)"; } //审批状态 if (ddl_State.SelectedValue == "0") { condition += " AND FNA_FeeApply.State IN (2,3) "; } else if (ddl_State.SelectedValue == "1") { condition += @" AND FNA_FeeApply.State = 2 AND FNA_FeeApply.ApproveTask IN (SELECT EWF_Task_Job.Task FROM MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)"; } else if (ddl_State.SelectedValue == "2") { condition += " AND FNA_FeeApply.State = 3 "; } else if (ddl_State.SelectedValue == "3") { AC_AccountMonth m = new AC_AccountMonthBLL(month).Model; condition += @" AND FNA_FeeApply.State IN (2,3) AND FNA_FeeApply.ApproveTask IN (SELECT EWF_Task_Job.Task FROM MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND EWF_Task_JobDecision.DecisionTime BETWEEN DATEADD(month,-1,'" + m.BeginDate.ToString("yyyy-MM-dd") + @"') AND DATEADD(month,3,'" + m.BeginDate.ToString("yyyy-MM-dd") + @"'))"; } #endregion gv_ListDetail.ConditionString = condition; gv_ListDetail.BindGrid(); btn_Approve.Visible = state == 1; btn_UnApprove.Visible = state == 1; gv_ListDetail.Columns[gv_ListDetail.Columns.Count - 1].Visible = state == 1; } }
protected void bt_Transfer_Click(object sender, EventArgs e) { int frommonth = int.Parse(ddl_FromMonth.SelectedValue); int fromcity = int.Parse(tr_FromOrganizeCity.SelectValue); int tomonth = int.Parse(ddl_ToMonth.SelectedValue); int tocity = int.Parse(tr_ToOrganizeCity.SelectValue); if (frommonth != tomonth) { MessageBox.Show(this, "调拨的月份必须相同!"); return; } if (fromcity == 0 || tocity == 0) { MessageBox.Show(this, "请正确选择要调拨预算的源及目的管理片区!"); return; } if (new Addr_OrganizeCityBLL(fromcity).Model.Level > new Addr_OrganizeCityBLL(tocity).Model.Level) { MessageBox.Show(this, "源管理片区的级别不能低于目的管理片区的级别!如需调回金额,请在调拨金额中输入负数。"); return; } if (!new Addr_OrganizeCityBLL(fromcity).GetAllChildNodeIDs().Split(new char[] { ',' }).Contains(tocity.ToString())) { MessageBox.Show(this, "目的管理单元并不是源管理单元的直接或间接下级,不可以调拨!"); return; } if (fromcity == tocity && frommonth == tomonth) { MessageBox.Show(this, "源与目的管理片区及月份不能完全相同!"); return; } int budgettype = 3; //调拨预算 decimal amount = 0; #region 判断调拨金额是否在可用余额之内 foreach (GridViewRow row in gv_FromBalance.Rows) { int id = (int)gv_FromBalance.DataKeys[row.RowIndex]["ID"]; int feetype = (int)gv_FromBalance.DataKeys[row.RowIndex]["FeeType"]; if (decimal.TryParse(((TextBox)row.FindControl("tbx_TransferAmount")).Text, out amount)) { if (amount > 0) { if (FNA_BudgetBLL.GetUsableAmount(frommonth, fromcity, feetype) - amount < 0) { ((TextBox)row.FindControl("tbx_TransferAmount")).Focus(); MessageBox.Show(this, "对不起,调拨金额必须小于源管理片区的可用预算余额!"); return; } } else { if (FNA_BudgetBLL.GetUsableAmount(tomonth, tocity, feetype) + amount < 0) { ((TextBox)row.FindControl("tbx_TransferAmount")).Focus(); MessageBox.Show(this, "对不起,目的管理片区的可用余额不够调拨金额!"); return; } } } else { ((TextBox)row.FindControl("tbx_TransferAmount")).Focus(); MessageBox.Show(this, "对不起,调拨金额必须为数字格式!"); return; } } #endregion foreach (GridViewRow row in gv_FromBalance.Rows) { int feetype = (int)gv_FromBalance.DataKeys[row.RowIndex]["FeeType"]; if (decimal.TryParse(((TextBox)row.FindControl("tbx_TransferAmount")).Text, out amount)) { if (amount != 0) { FNA_BudgetBLL.Transfer(frommonth, fromcity, feetype, tomonth, tocity, feetype, amount, budgettype, (int)Session["UserID"], ((TextBox)row.FindControl("tbx_Remark")).Text); } } } LoadFromUsableBudget(); LoadToUsableBudget(); MessageBox.Show(this, "预算调配成功!"); }
void BindToBudget(int month, int organizecity, int feetype) { lb_ToBalance.Text = FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype).ToString("0.##"); }
protected void bt_Submit_Click(object sender, EventArgs e) { if (!Save()) { return; } if ((int)ViewState["ID"] != 0) { ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]); Session["SubmitOrderApplyID"] = (int)ViewState["ID"]; if (bll.Model.State > 1) { Response.Redirect("OrderApplyList.aspx"); } if (bll.Items.Count == 0) { MessageBox.ShowAndRedirect(this, "对不起,定单申请明细不能为空!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } if (bll.Model.AccountMonth < AC_AccountMonthBLL.GetCurrentMonth()) { MessageBox.Show(this, "对不起,该订单申请月份已不是当前月份,已不可提交,请删除该单后重新申请赠品!"); return; } decimal totalcost = bll.Items.Sum(m => m.BookQuantity * m.Price); if (bll.Model.Type == 2) { //促销品申请 #region 判断预算额度余额是否够申请 ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(bll.Model.PublishID).Model; int productbrand = 0, giftclassify = 0; int.TryParse(publish["ProductBrand"], out productbrand); int.TryParse(publish["GiftClassify"], out giftclassify); decimal _budgetbalance = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, publish.FeeType); decimal _productbalance = ORD_GiftApplyAmountBLL.GetBalanceAmount(bll.Model.AccountMonth, bll.Model.Client, productbrand, giftclassify); decimal _balance = _productbalance; //2012-3-27 暂时限定赠品额度,不限定预算 //decimal _balance = (_budgetbalance > _productbalance ? _productbalance : _budgetbalance); string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' }); if (_balance < totalcost && !nolimitbrand.Contains(publish["ProductBrand"])) { if (bll.Model["GiftClassify"] == "2" && _balance > 0 && ORD_OrderApplyBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + bll.Model["ProductBrand"] + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)=" + bll.Model["GiftClassify"]).Count == 0) { //判断是否可以申请最低金额赠品1件 decimal MinApplyAmount = 0, MaxApplyAmount = 0; ORD_ApplyPublishBLL _publishbll = new ORD_ApplyPublishBLL(bll.Model.PublishID); _publishbll.GetMinApplyAmount(out MinApplyAmount, out MaxApplyAmount); if (_balance > 0 && _balance < MinApplyAmount) { if (bll.Items.Count > 1) { MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品"); return; } else { int applyproduct = bll.Items[0].Product; ORD_ApplyPublishDetail applydetail = _publishbll.Items.FirstOrDefault(p => p.Product == applyproduct); if (applydetail != null && applydetail.MinQuantity < bll.Items[0].BookQuantity) { MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品"); return; } } } else { MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } } else { MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString()); return; } } #endregion #region 发起工作流 NameValueCollection dataobjects = new NameValueCollection(); dataobjects.Add("ID", ViewState["ID"].ToString()); dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString()); dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString()); dataobjects.Add("FeeType", publish.FeeType.ToString()); dataobjects.Add("ProductBrand", publish["ProductBrand"]); dataobjects.Add("GiftClassify", publish["GiftClassify"]); dataobjects.Add("TotalFee", totalcost.ToString()); int TaskID = EWF_TaskBLL.NewTask("CuXiaoPin_Apply", (int)Session["UserID"], "促销品申请申请流程", "~/SubModule/Logistics/Order/OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString() + "&Type=2", dataobjects); new EWF_TaskBLL(TaskID).Start(); #endregion bll.Submit((int)Session["UserID"], TaskID); Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString()); } else { //产品申请申请 bll.Submit((int)Session["UserID"], 0); Response.Redirect("OrderApplyList.aspx"); } } }
private void BindGrid() { //权限判断 if (!Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1511, "ApproveBudget")) { btnApprove.Visible = false; } IList<FNA_BudgetSource> sourcelists = FNA_BudgetSourceBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " and AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND ApproveFlag=1"); if (sourcelists.Count == 0) { MessageBox.ShowAndRedirect(this, "对不起当前作业区可用费用计算表还未填写或未审核!", "BudgetSource.aspx"); return; } IList<FNA_Budget> budgets = FNA_BudgetBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " AND AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND BudgetType=1"); lb_PlanVolume.Text = sourcelists[0].PlanVolume.ToString("0.##"); lb_SumBudget.Text = (sourcelists[0].BaseBudget + sourcelists[0].OverFullBudget - decimal.Parse(sourcelists[0]["DepartmentBudget"])).ToString("0.##"); lb_RetentionBudget.Text = sourcelists[0].RetentionBudget.ToString("0.##"); lb_DepartmentBudget.Text = sourcelists[0]["DepartmentBudget"]; string[] outbudgets = ConfigHelper.GetConfigString("OutSumBudgetFeeType").Split(','); lb_AssignBalance.Text = (sourcelists[0].BaseBudget + sourcelists[0].OverFullBudget - decimal.Parse(sourcelists[0]["DepartmentBudget"]) - budgets.Sum(p => outbudgets.Contains(p.FeeType.ToString()) ? 0 : p.BudgetAmount)).ToString("0.##"); #region 初始化预算分配 Dictionary<string, Dictionary_Data> dic = DictionaryBLL.GetDicCollections("FNA_FeeType", true); foreach (Dictionary_Data item in dic.Values) { if (budgets.FirstOrDefault(p => p.FeeType == int.Parse(item.Code)) == null) { FNA_BudgetBLL bll = new FNA_BudgetBLL(); bll.Model.AccountMonth = (int)ViewState["AccountMonth"]; bll.Model.OrganizeCity = (int)ViewState["OrganizeCity"]; bll.Model.BudgetType = 1; bll.Model.FeeType = int.Parse(item.Code); if (bll.Model.FeeType == 20) bll.Model.BudgetAmount = decimal.Parse(lb_RetentionBudget.Text); else bll.Model.BudgetAmount = 0; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Add(); } } #endregion budgets = FNA_BudgetBLL.GetModelList("OrganizeCity=" + ViewState["OrganizeCity"].ToString() + " and AccountMonth=" + ViewState["AccountMonth"].ToString() + " AND BudgetType=1").OrderBy(p => p.FeeType).ToList(); gv_List.BindGrid(budgets); if (budgets.FirstOrDefault(p => p.ApproveFlag == 2) == null) { btnSave.Visible = false; btnApprove.Visible = false; cbx_CheckAll.Visible = false; } }
protected void bt_OK_Click(object sender, EventArgs e) { FNA_BudgetExtraApplyBLL _bll; if ((int)ViewState["ID"] != 0) { //修改 _bll = new FNA_BudgetExtraApplyBLL((int)ViewState["ID"]); } else { //新增 _bll = new FNA_BudgetExtraApplyBLL(); _bll.Model.AccountMonth = AC_AccountMonthBLL.GetCurrentMonth(); } pl_detail.GetData(_bll.Model); //_bll.Model["SheetCode"] = FNA_BudgetExtraApplyBLL.GenerateSheetCode(_bll.Model.OrganizeCity);在存储过程中实现 #region 判断必填项 if (_bll.Model.OrganizeCity == 0) { MessageBox.Show(this, "必须正确选择管理片区!"); return; } if (_bll.Model.FeeType == 0) { MessageBox.Show(this, "必须正确选择费用类型!"); return; } if (_bll.Model["ExtraType"] == "0") { MessageBox.Show(this, "必须正确选择扩增费用类别!"); return; } #endregion #region 判断上级直至部经理手中有无预算 decimal sumbudget = 0; Addr_OrganizeCityBLL city = new Addr_OrganizeCityBLL(_bll.Model.OrganizeCity); DataTable dt = city.GetFullPath(); for (int i = 0; i < dt.Rows.Count; i++) { Addr_OrganizeCity c = new Addr_OrganizeCityBLL((int)dt.Rows[i]["ID"]).Model; if (c == null || c.ID == 1 || c.ID == _bll.Model.OrganizeCity || c.Level == 1) { continue; //忽略总部 } sumbudget += FNA_BudgetBLL.GetUsableAmount(_bll.Model.AccountMonth, c.ID, _bll.Model.FeeType); } if (sumbudget > _bll.Model.ExtraAmount) { MessageBox.Show(this, "对不起,您的上级领导预算余额大于您要扩增的金额,请与领导沟通申请要求分配预算给您,而无需提交扩增预算流程!"); return; } #endregion if ((int)ViewState["ID"] != 0) { //修改 _bll.Model.UpdateStaff = (int)Session["UserID"]; if (_bll.Update() == 0) { if (sender != null) { MessageBox.ShowAndRedirect(this, "修改成功!", "BudgetExtraApplyDetail.aspx?ID=" + ViewState["ID"].ToString()); } } } else { //新增 _bll.Model.ApproveFlag = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; ViewState["ID"] = _bll.Add(); bt_Submit.Visible = true; if ((int)ViewState["ID"] > 0) { if (sender != null) { MessageBox.ShowAndRedirect(this, "新增成功!", "BudgetExtraApplyDetail.aspx?ID=" + ViewState["ID"].ToString()); } } } }
private bool Save() { #region 判断是否超过可用预算合计值 TextBox tbx = null; decimal sumBuget = 0, fee = 0; foreach (GridViewRow row in gv_List.Rows) { int feetype = (int)gv_List.DataKeys[row.RowIndex]["FeeType"]; tbx = (TextBox)row.FindControl("tbx_BudgetAmount"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { if (feetype == 20) { if (fee > decimal.Parse(lb_RetentionBudget.Text)) { tbx.Focus(); MessageBox.Show(this, "自留费用不超过可用自留费用!"); return false; } } else { string[] outbudgets = ConfigHelper.GetConfigString("OutSumBudgetFeeType").Split(','); if (!outbudgets.Contains(feetype.ToString())) { sumBuget += fee; } } } else { tbx.Focus(); MessageBox.Show(this, "费用预算额度格式必须为数字值,且不能小于0!"); return false; } } if (sumBuget > decimal.Parse(lb_SumBudget.Text)) { tbx.Focus(); MessageBox.Show(this, "分配的总费用不能大于总可用预算合计值!当前合计值:" + sumBuget.ToString("0.##") + ",可用费用值:" + lb_SumBudget.Text); return false; } #endregion foreach (GridViewRow row in gv_List.Rows) { FNA_BudgetBLL bll = new FNA_BudgetBLL((int)gv_List.DataKeys[row.RowIndex]["ID"]); if (bll.Model.ApproveFlag == 2) { bll.Model.BudgetAmount = decimal.Parse(((TextBox)row.FindControl("tbx_BudgetAmount")).Text); bll.Model.Remark = ((TextBox)row.FindControl("tbx_Remark")).Text; bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); } } return true; }