public void BindGrid() { string condition = " AccountMonth = " + ddl_AccountMonth.SelectedValue; #region 组织查询条件 //管理片区及所有下属管理片区 if (tr_OrganizeCity.SelectValue != "1") { if (new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue)).Model.Level == 1) { condition += " AND OrganizeCity IN (SELECT ID FROM MCS_SYS.dbo.Addr_OrganizeCity WHERE Level=2 AND SuperID=" + tr_OrganizeCity.SelectValue + ")"; } else { condition += " AND OrganizeCity = " + tr_OrganizeCity.SelectValue; } } #endregion gv_List.BindGrid(FNA_BudgetSourceBLL.GetModelList(condition)); foreach (GridViewRow row in gv_List.Rows) { TextBox tbx = (TextBox)row.FindControl("tbDepartmentBudget"); if (tbx != null) { FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL((int)gv_List.DataKeys[row.RowIndex].Value); if (!string.IsNullOrEmpty(bll.Model["DepartmentBudget"])) { tbx.Text = bll.Model["DepartmentBudget"]; Label lab = (Label)row.FindControl("LabTotalBudget"); decimal fee = decimal.Parse(gv_List.DataKeys[row.RowIndex]["BaseBudget"].ToString()) + decimal.Parse(gv_List.DataKeys[row.RowIndex]["OverFullBudget"].ToString()) - decimal.Parse(bll.Model["DepartmentBudget"].ToString()); lab.Text = fee.ToString(); } } } }
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; } }