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(); } } } }
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 Init() { IList <Addr_OrganizeCity> citys = Addr_OrganizeCityBLL.GetModelList ("Level=2 AND ID NOT IN (SELECT OrganizeCity FROM MCS_FNA.dbo.FNA_BudgetSource WHERE AccountMonth=" + ddl_AccountMonth.SelectedValue + ") ORDER BY SuperID,Code"); foreach (Addr_OrganizeCity city in citys) { FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL(); bll.Model.AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue); bll.Model.OrganizeCity = city.ID; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["DepartmentBudget"] = "0"; bll.Add(); } }
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(); }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in gv_List.Rows) { #region 保存作业区可用费用 FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL((int)gv_List.DataKeys[row.RowIndex].Value); if (bll.Model.ApproveFlag == 1) continue; TextBox tbx = null; decimal fee = 0; tbx = (TextBox)row.FindControl("tbBaseVolume"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.BaseVolume = fee; } else { tbx.Focus(); MessageBox.Show(this, "基础销量必须不能小于0"); return; } tbx = (TextBox)row.FindControl("tbPlanVolume"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.PlanVolume = fee; } else { tbx.Focus(); MessageBox.Show(this, "计划销量不能小于0"); return; } tbx = (TextBox)row.FindControl("tbBaseBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.BaseBudget = fee; } else { tbx.Focus(); MessageBox.Show(this, "费用预算额度不能小于0"); return; } tbx = (TextBox)row.FindControl("tbRetentionBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.RetentionBudget = fee; } else { tbx.Focus(); MessageBox.Show(this, "自留费用不能小于0"); return; } bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); tbx = (TextBox)row.FindControl("tbDepartmentBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0 && fee <= (bll.Model.BaseBudget + bll.Model.OverFullBudget)) { bll.Model["DepartmentBudget"] = fee.ToString(); bll.Update(); } else { tbx.Focus(); MessageBox.Show(this, "市场部预算额度不能小于0"); return; } #endregion } BindGrid(); }
private void Init() { IList<Addr_OrganizeCity> citys = Addr_OrganizeCityBLL.GetModelList ("Level=2 AND ID NOT IN (SELECT OrganizeCity FROM MCS_FNA.dbo.FNA_BudgetSource WHERE AccountMonth=" + ddl_AccountMonth.SelectedValue + ") ORDER BY SuperID,Code"); foreach (Addr_OrganizeCity city in citys) { FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL(); bll.Model.AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue); bll.Model.OrganizeCity = city.ID; bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["DepartmentBudget"] = "0"; bll.Add(); } }
protected void btnSave_Click(object sender, EventArgs e) { foreach (GridViewRow row in gv_List.Rows) { #region 保存作业区可用费用 FNA_BudgetSourceBLL bll = new FNA_BudgetSourceBLL((int)gv_List.DataKeys[row.RowIndex].Value); if (bll.Model.ApproveFlag == 1) { continue; } TextBox tbx = null; decimal fee = 0; tbx = (TextBox)row.FindControl("tbBaseVolume"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.BaseVolume = fee; } else { tbx.Focus(); MessageBox.Show(this, "基础销量必须不能小于0"); return; } tbx = (TextBox)row.FindControl("tbPlanVolume"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.PlanVolume = fee; } else { tbx.Focus(); MessageBox.Show(this, "计划销量不能小于0"); return; } tbx = (TextBox)row.FindControl("tbBaseBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.BaseBudget = fee; } else { tbx.Focus(); MessageBox.Show(this, "费用预算额度不能小于0"); return; } tbx = (TextBox)row.FindControl("tbRetentionBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0) { bll.Model.RetentionBudget = fee; } else { tbx.Focus(); MessageBox.Show(this, "自留费用不能小于0"); return; } bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); tbx = (TextBox)row.FindControl("tbDepartmentBudget"); if (tbx != null && decimal.TryParse(tbx.Text, out fee) && fee >= 0 && fee <= (bll.Model.BaseBudget + bll.Model.OverFullBudget)) { bll.Model["DepartmentBudget"] = fee.ToString(); bll.Update(); } else { tbx.Focus(); MessageBox.Show(this, "市场部预算额度不能小于0"); return; } #endregion } 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; } }