protected void btnSearch_Click(object sender, EventArgs e) { try { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; var q = CommonBLL.GetExpenseProjectionList(budYr.ID); if (ddlExpTyp.SelectedValue != "") { int expTy = int.Parse(ddlExpTyp.SelectedValue); q = q.Where(p => p.ExpenseTypeID.Value == expTy); } if (User.IsInRole(AdminRole)) { if (ddlDeptFilter.SelectedValue != "") { int dep = int.Parse(ddlDeptFilter.SelectedValue); q = q.Where(p => p.DepartmentID == dep); } gvDept.DataSource = q.ToList(); gvDept.DataBind(); } else { gvDept.DataSource = q.Where(p => p.DepartmentID == usr.DepartmentID).ToList(); gvDept.DataBind(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
private void BindGrid() { BudgetYear byr = (BudgetYear)Session["budgetYr"]; gvCommon.DataSource = LookUpBLL.GetCapexItemList(byr.ID); gvCommon.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { error.Visible = false; success.Visible = false; dvAdd.Visible = false; dvAppr.Visible = false; try { if (Session["user"] != null) { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(deptApprRole) && budYr.IsActive == true) { dvAppr.Visible = true; } if (User.IsInRole(deptIniRole) && budYr.IsActive == true) { dvAdd.Visible = true; } if (User.IsInRole(AdminRole) && budYr.IsActive == true) { dvAdmin.Visible = true; } } else { Response.Redirect("Login.aspx", false); return; } if (!IsPostBack) { Utility.BindMonth(ddlMonth); if (usr.DepartmentID.Value.ToString() != GSSDeptId) { Utility.BindExpenseCategory(ddlCat); Utility.BindExpenseCategory(ddlExpTyp); } else { Utility.BindExpenseCategory(ddlCat, 1); Utility.BindExpenseCategory(ddlExpTyp, 1); } Utility.BindDept(ddlDeptFilter); lbDept.Text = usr.Department.Name.ToUpper(); lbyr.Text = budYr.Year; BindGrid(); if (User.IsInRole(AdminRole)) { ddlDeptFilter.Visible = true; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.InnerException); } }
private void BindProprtyList(DropDownList ddlist) { budYr = (BudgetYear)Session["budgetYr"]; ddlist.DataTextField = "Name"; ddlist.DataValueField = "ID"; ddlist.DataSource = LookUpBLL.GetPropertyLookup(budYr.ID); ddlist.DataBind(); }
protected void gvDept_RowDataBound(object sender, GridViewRowEventArgs e) { try { bool? nullable; CheckBox box = null; budYr = (BudgetYear)this.Session["budgetYr"]; if (e.Row.RowType == DataControlRowType.Header) { box = e.Row.FindControl("chkHeader") as CheckBox; if (base.User.IsInRole(this.deptApprRole) && ((nullable = budYr.IsActive).GetValueOrDefault() && nullable.HasValue)) { box.Visible = true; } } if (e.Row.RowType == DataControlRowType.DataRow) { int num; Label label = e.Row.FindControl("lbAmt") as Label; this.priceTotal += Convert.ToDecimal(label.Text); Label label2 = e.Row.FindControl("lbStatus") as Label; CheckBox box2 = e.Row.FindControl("chkRow") as CheckBox; ImageButton button = e.Row.FindControl("imgBtnEdit") as ImageButton; ImageButton button2 = e.Row.FindControl("imgBtnDel") as ImageButton; if (base.User.IsInRole(this.deptIniRole) && ((nullable = budYr.IsActive).GetValueOrDefault() && nullable.HasValue)) { num = 3; if ((label2.Text == num.ToString()) || (label2.Text == (num = 1).ToString())) { button2.Visible = true; button.Visible = true; } } if (base.User.IsInRole(this.deptApprRole) && ((nullable = budYr.IsActive).GetValueOrDefault() && nullable.HasValue)) { box2.Visible = true; num = 2; if ((label2.Text == num.ToString()) || (label2.Text == (num = 3).ToString())) { box2.Visible = false; } } } if (e.Row.RowType == DataControlRowType.Footer) { Label label3 = e.Row.FindControl("lbSumAmt") as Label; label3.Text = this.priceTotal.ToString("N"); } } catch (Exception exception) { this.error.Visible = true; this.error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + exception.InnerException); } }
private void BindGrid() { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(AdminRole)) { gvDept.DataSource = CommonBLL.GetDisbursementList(budYr.ID); gvDept.DataBind(); } else { gvDept.DataSource = CommonBLL.GetDisbursementList(budYr.ID, usr.DepartmentID.Value); gvDept.DataBind(); } }
private void BindGrid() { if (Session["budgetYr"] != null) { BudgetYear byr = (BudgetYear)Session["budgetYr"]; gvDir.DataSource = LookUpBLL.GetCapexTypeList(byr.ID); gvDir.DataBind(); } else { Response.Redirect("Login.aspx", false); return; } }
private void BindGrid() { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(AdminRole) || User.IsInRole(PBMgrRole) || User.IsInRole(PBOffRole) || User.IsInRole(EDRole) || User.IsInRole(MDRole)) { gvDept.DataSource = CommonBLL.GetATCRequestList(budYr.ID); gvDept.DataBind(); } else if (User.IsInRole(deptApprRole)) { gvDept.DataSource = CommonBLL.GetATCRequestList(budYr.ID, usr.DepartmentID.Value); gvDept.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { error.Visible = false; success.Visible = false; try { // hidEDPending.Value = ""; hidMDPending.Value = ""; // btnCorrect.Visible = false; // btnMD.Visible = false; //dvExco.Visible = false; if (Session["user"] != null) { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; } else { Response.Redirect("Login.aspx", false); return; } if (!IsPostBack) { lbDept.Text = usr.Department.Name.ToUpper(); lbyr.Text = budYr.Year; int budyrID = budYr.ID; int deptID = usr.DepartmentID.Value; if (User.IsInRole(AdminRole) || User.IsInRole(PBMgrRole) || User.IsInRole(PBOffRole)) { dvFilter.Visible = true; Utility.BindDept(ddlDept); List <Department> deptList = DepartmentBLL.GetDeptList(); } if (User.IsInRole(EDRole) || User.IsInRole(MDRole)) { dvFilter.Visible = true; Utility.BindDept(ddlDept); List <Department> deptList = DepartmentBLL.GetDeptList(); lbDept.Visible = false; } BindGrid(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }
public static SingletonThisBudgetYear Instance() { // Uses lazy initialization. // Note: this is not thread safe. if (_instance == null) { using (SSLsEntities db = new SSLsEntities()) { _instance = new SingletonThisBudgetYear(); BudgetYear data = db.BudgetYear.FirstOrDefault(w => w.Enable == true && w.IsCurrent == true); _instance.ThisYear = data; } } return(_instance); }
protected void Page_Load(object sender, EventArgs e) { this.error.Visible = false; this.success.Visible = false; this.dvAdd.Visible = false; this.dvAppr.Visible = false; try { if (this.Session["user"] != null) { bool?nullable; usr = (AppUser)this.Session["user"]; budYr = (BudgetYear)this.Session["budgetYr"]; if (base.User.IsInRole(this.deptApprRole) && ((nullable = budYr.IsActive).GetValueOrDefault() && nullable.HasValue)) { this.dvAppr.Visible = true; } if (base.User.IsInRole(this.deptIniRole) && ((nullable = budYr.IsActive).GetValueOrDefault() && nullable.HasValue)) { this.dvAdd.Visible = true; } } else { base.Response.Redirect("Login.aspx", false); return; } if (!base.IsPostBack) { Utility.BindMonth(this.ddlMonth); Utility.BindDisbursementList(this.ddlAsset); Utility.BindDept(this.ddlDeptFilter); this.lbDept.Text = usr.Department.Name.ToUpper(); this.lbyr.Text = budYr.Year; this.BindGrid(); if (base.User.IsInRole(this.AdminRole)) { this.dvAdminScr.Visible = true; } } } catch (Exception exception) { this.error.Visible = true; this.error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + exception.InnerException); } }
protected void Page_Load(object sender, EventArgs e) { error.Visible = false; success.Visible = false; dvAdd.Visible = false; //dvAppr.Visible = false; try { if (Session["user"] != null) { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(deptApprRole) && budYr.IsActive == true) { dvAppr.Visible = true; } if (User.IsInRole(deptIniRole) && budYr.IsActive == true) { dvSelect.Visible = true; } if (User.IsInRole(AdminRole) && budYr.IsActive == true) { dvAdmin.Visible = true; } } else { Response.Redirect("Login.aspx", false); return; } if (!IsPostBack) { Utility.BindMonth(ddlMonth); Utility.BindIncomeType(ddlIncomeType); Utility.BindIncomeType(ddlIncTyp); BindProprtyList(ddlProperty); lbDept.Text = usr.Department.Name.ToUpper(); lbyr.Text = budYr.Year; FirstGridViewRow(); BindGrid(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.InnerException); } }
protected void btnSearch_Click(object sender, EventArgs e) { try { if (ddlAstTyp.SelectedValue != "") { BudgetYear byr = (BudgetYear)Session["budgetYr"]; int astTypID = int.Parse(ddlAstTyp.SelectedValue); gvCommon.DataSource = LookUpBLL.GetCapexItemListLookUp(astTypID, byr.ID); gvCommon.DataBind(); } } catch { } }
protected void btnSearch_Click(object sender, EventArgs e) { try { budYr = (BudgetYear)Session["budgetYr"]; if (ddlDept.SelectedValue != "") { int deptId = int.Parse(ddlDept.SelectedValue); gvDept.DataSource = CommonBLL.GetATCRequestList(budYr.ID, deptId); gvDept.DataBind(); } } catch { } }
protected void Page_Load(object sender, EventArgs e) { error.Visible = false; success.Visible = false; dvAdd.Visible = false; dvAppr.Visible = false; try { if (Session["user"] != null) { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(deptApprRole) && budYr.IsActive == true) { dvAppr.Visible = true; } if (User.IsInRole(deptIniRole) && budYr.IsActive == true) { dvAdd.Visible = true; } if (User.IsInRole(AdminRole) && budYr.IsActive == true) { dvAdmin.Visible = true; } } else { Response.Redirect("Login.aspx", false); return; } if (!IsPostBack) { Utility.BindMonth(ddlMonth); Utility.BindReinvestmentType(ddlCat); Utility.BindReinvestmentType(ddlReinvestTyp); BindGrid(); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.InnerException); } }
protected void btnSearch_Click(object sender, EventArgs e) { try { if (ddlDeptFilter.SelectedValue != "") { int dept = int.Parse(ddlDeptFilter.SelectedValue); usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(AdminRole)) { gvDept.DataSource = CommonBLL.GetDisbursementList(budYr.ID, dept); gvDept.DataBind(); } } } catch { } }
protected void btnSearch_Click(object sender, EventArgs e) { try { bool isCatSet = false; bool isTypeSet = false; string cat = ""; int dept = 0; if (ddlCatFilter.SelectedValue != "") { cat = ddlCatFilter.SelectedValue; isCatSet = true; } usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (User.IsInRole(AdminRole)) { var q = CommonBLL.GetRestructureList(budYr.ID); if (isCatSet) { q = q.Where(p => p.LoanType == cat); } if (ddlDeptFilter.SelectedValue != "") { dept = int.Parse(ddlDeptFilter.SelectedValue); q = q.Where(p => p.DepartmentId == dept); } gvDept.DataSource = q.ToList(); gvDept.DataBind(); } else { var q = CommonBLL.GetRestructureList(budYr.ID, usr.DepartmentID.Value); if (isCatSet) { q = q.Where(p => p.LoanType == cat); } gvDept.DataSource = q.ToList(); gvDept.DataBind(); } } catch { } }
protected void gvDir_SelectedIndexChanged(object sender, EventArgs e) { try { hid.Value = "Update"; dvID.Visible = true; dvMsg.InnerText = "Update Budget Year :"; btnSubmit.Text = "Update"; string recID = ""; GridViewRow row = gvDir.SelectedRow; recID = (row.FindControl("lbID") as Label).Text; BudgetYear bYear = LookUpBLL.GetBudgetYear(int.Parse(recID)); if (bYear != null) { txtID.Text = recID; txtDept.Text = bYear.Year; if (bYear.StartDate.HasValue) { txtDate.Text = bYear.StartDate.Value.ToString("dd/MM/yyyy"); } if (bYear.EndDate.HasValue) { txtEDate.Text = bYear.EndDate.Value.ToString("dd/MM/yyyy"); } if (bYear.IsActive.HasValue && bYear.IsActive == true) { chkActive.Checked = true; } else { chkActive.Checked = false; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { if (Session["budgetYr"] != null) { BudgetYear byr = (BudgetYear)Session["budgetYr"]; Utility.BindCapexType(ddlDir, byr.ID); Utility.BindCapexType(ddlAstTyp, byr.ID); BindGrid(); } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }
public void SpendBudget(float fAmount, String strBudget, String strYear) { if (strBudget == null) { return; } if (!BudgetYear.Contains(strBudget)) { return; } Hashtable hashYearAmount = (Hashtable)BudgetYear[strBudget]; if (!hashYearAmount.Contains(strYear)) { return; } float fAvailable = (float)hashYearAmount[strYear]; hashYearAmount.Remove(strYear); fAvailable = fAvailable - fAmount; hashYearAmount.Add(strYear, fAvailable); }
/// <summary> /// Check if budget can support treatment. For targets and deficiency met. /// </summary> /// <param name="fAmount"></param> /// <param name="strBudget"></param> /// <param name="strYear"></param> /// <returns>The budget that is available</returns> public string IsBudgetAvailable(float fAmount, String strBudget, String strYear) { string[] budgets = strBudget.Split('|'); foreach (string budget in budgets) { string budgetCheck = budget.Trim(); //Budget not defined if (!BudgetYear.Contains(budgetCheck)) { continue; } Hashtable hashYearAmount = (Hashtable)BudgetYear[budgetCheck]; if (!hashYearAmount.Contains(strYear)) { continue; } float fAvailable = (float)hashYearAmount[strYear]; if (!BudgetYearOriginal.Contains(budgetCheck)) { continue; } Hashtable hashYearAmountOriginal = (Hashtable)BudgetYearOriginal[budgetCheck]; if (!hashYearAmountOriginal.Contains(strYear)) { continue; } float fOriginal = (float)hashYearAmountOriginal[strYear]; float fAfterSpending = fAvailable - fAmount; if (fAfterSpending >= 0) { return(budgetCheck); } } return(null); }
protected void btnAppr_Click(object sender, EventArgs e) { try { if (ddlBudgetYr.SelectedValue != "") { BudgetYear byr = new BudgetYear(); byr = LookUpBLL.GetBudgetYear(int.Parse(ddlBudgetYr.SelectedValue)); Session["budgetYr"] = byr; Response.Redirect("Default.aspx", false); return; } else { modalErr.Visible = true; modalErr.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> Kindly select Budget year and Proceed"; mpeAppr.Show(); } } catch (Exception ex) { } }
public void LoadBudgets() { string[] budgets = BudgetOrderString.Split(','); String strBudget; for (int i = 0; i < budgets.Length; i++) { strBudget = budgets[i]; m_listBudgetOrder.Add(strBudget); } String strSelect = "SELECT YEAR_,BUDGETNAME,AMOUNT FROM " + cgOMS.Prefix + "YEARLYINVESTMENT WHERE SIMULATIONID='" + this.InvestmentID + "' ORDER BY YEAR_"; DataSet ds = null; try { ds = DBMgr.ExecuteQuery(strSelect); } catch (Exception ex) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Loading YEARLYINVESTMENT table." + ex.Message)); return; } String strYear; String strAmount; MaximumYear = Int32.MinValue; foreach (DataRow row in ds.Tables[0].Rows) { strYear = row[0].ToString(); var year = Convert.ToInt32(strYear); if (year > MaximumYear) { MaximumYear = year; } strBudget = row[1].ToString(); strAmount = row[2].ToString(); if (BudgetYear.Contains(strBudget)) { Hashtable hashYearAmount = (Hashtable)BudgetYear[strBudget]; Hashtable hashYearAmountOriginal = (Hashtable)BudgetYearOriginal[strBudget]; m_hashBudgetYear.Remove(strBudget); m_hashBudgetYearOriginal.Remove(strBudget); if (strAmount == "") { hashYearAmount.Add(strYear, 0.0); hashYearAmountOriginal.Add(strYear, 0.0); } else { hashYearAmount.Add(strYear, float.Parse(strAmount)); hashYearAmountOriginal.Add(strYear, float.Parse(strAmount)); } BudgetYear.Add(strBudget, hashYearAmount); BudgetYearOriginal.Add(strBudget, hashYearAmountOriginal); } else { Hashtable hashYearAmount = new Hashtable(); Hashtable hashYearAmountOriginal = new Hashtable(); if (strAmount == "") { hashYearAmount.Add(strYear, 0.0); hashYearAmountOriginal.Add(strYear, 0.0); } else { hashYearAmount.Add(strYear, float.Parse(strAmount)); hashYearAmountOriginal.Add(strYear, float.Parse(strAmount)); } BudgetYear.Add(strBudget, hashYearAmount); BudgetYearOriginal.Add(strBudget, hashYearAmountOriginal); } } foreach (var budget in BudgetYear.Keys) { var hashYearAmount = (Hashtable)BudgetYear[budget]; var hashYearAmountOriginal = (Hashtable)BudgetYearOriginal[budget]; for (int year = MaximumYear + 1; year < MaximumYear + 101; year++) { hashYearAmount.Add(year.ToString(), hashYearAmount[MaximumYear.ToString()]); hashYearAmountOriginal.Add(year.ToString(), hashYearAmountOriginal[MaximumYear.ToString()]); } } }
//protected void btnLoad_Click(object sender, EventArgs e) //{ // try // { // string agrNo = txtobligor.Text.Trim(); // Obligor obl = Utility.GetObligor(agrNo); // if (obl != null) // { // lbName.Text = "Obligor's Name: " + obl.FullName.ToUpper(); // lbName.ForeColor = System.Drawing.Color.RoyalBlue; // btnSubmit.Enabled = true; // } // else // { // lbName.Text = "Not Found"; // lbName.ForeColor = System.Drawing.Color.Maroon; // btnSubmit.Enabled = false; // } // } // catch (Exception ex) // { // error.Visible = true; // error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; // Utility.WriteError("Error: " + ex.Message); // } //} protected void btnSubmit_Click(object sender, EventArgs e) { DisbursementProjection recpro = null; try { decimal num; int num2; usr = (AppUser)this.Session["user"]; budYr = (BudgetYear)this.Session["budgetYr"]; if (this.hid.Value == "Update") { num = 0M; num2 = int.Parse(this.ddlMonth.SelectedValue); recpro = CommonBLL.GetDisbursement(Convert.ToInt32(this.txtID.Text)); if (recpro != null) { if (!decimal.TryParse(this.txtTot.Text, out num)) { this.error.Visible = true; this.error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Amount must be numeric!!."; } else { recpro.Amount = new decimal?(num); recpro.AssetName = this.ddlAsset.SelectedItem.Text; recpro.DepartmentId = usr.DepartmentID; recpro.Status = 1; recpro.Month = new int?(num2); recpro.BudgetYrID = new int?(budYr.ID); if (CommonBLL.UpdateDisbursement(recpro)) { this.BindGrid(); this.success.Visible = true; this.success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; } } } else { this.error.Visible = true; this.error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { num = 0M; if (!decimal.TryParse(this.txtTot.Text, out num)) { this.error.Visible = true; this.error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Quantity must be numeric!!."; } else { recpro = new DisbursementProjection(); num2 = int.Parse(this.ddlMonth.SelectedValue); recpro.AssetName = this.ddlAsset.SelectedItem.Text; recpro.DepartmentId = usr.DepartmentID; recpro.AddedBy = base.User.Identity.Name; recpro.DateAdded = new DateTime?(DateTime.Now); recpro.Amount = new decimal?(num); recpro.BudgetYrID = new int?(budYr.ID); recpro.Month = new int?(num2); recpro.Status = 1; if (CommonBLL.AddDisbursement(recpro)) { this.BindGrid(); this.txtTot.Text = ""; this.ddlAsset.SelectedValue = ""; this.lbName.Text = ""; this.btnSubmit.Enabled = false; this.ddlMonth.SelectedValue = ""; this.success.Visible = true; this.success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; } else { this.error.Visible = true; this.error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } } catch (Exception exception) { this.error.Visible = true; this.error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + exception.Message); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ExpenseProjection expPro = null; try { usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; if (hid.Value == "Update") { bool rst = false; decimal tot = 0; int month = int.Parse(ddlMonth.SelectedValue); expPro = CommonBLL.GetExpensePRojection(Convert.ToInt32(txtID.Text)); if (expPro != null) { if (!decimal.TryParse(txtTot.Text, out tot)) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Amount must be numeric!!."; return; } expPro.Amount = tot; expPro.Details = txtDetails.Text; expPro.ExpenseTypeID = int.Parse(ddlCat.SelectedValue); expPro.DepartmentID = usr.DepartmentID; expPro.Status = (int)Utility.BudgetItemStatus.Pending_Approval; expPro.MonthYr = month; expPro.BudgetYrID = budYr.ID; rst = CommonBLL.UpdateExpenseProjection(expPro); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { decimal tot = 0; if (!decimal.TryParse(txtTot.Text, out tot)) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Amount must be numeric!!."; return; } bool result = false; expPro = new ExpenseProjection(); int month = int.Parse(ddlMonth.SelectedValue); expPro.ExpenseTypeID = int.Parse(ddlCat.SelectedValue); expPro.DepartmentID = usr.DepartmentID; expPro.Details = txtDetails.Text; expPro.AddedBy = User.Identity.Name; expPro.DateAdded = DateTime.Now; expPro.Amount = tot; expPro.BudgetYrID = budYr.ID; expPro.MonthYr = month; expPro.Status = (int)Utility.BudgetItemStatus.Pending_Approval; result = CommonBLL.AddExpenseProjection(expPro); if (result) { BindGrid(); txtTot.Text = ""; txtDetails.Text = ""; ddlCat.SelectedValue = ""; ddlMonth.SelectedValue = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }
protected void gvDept_RowDataBound(object sender, GridViewRowEventArgs e) { try { CheckBox chkheader = null; budYr = (BudgetYear)Session["budgetYr"]; if (e.Row.RowType == DataControlRowType.Header) { chkheader = e.Row.FindControl("chkHeader") as CheckBox; if (User.IsInRole(deptApprRole) && budYr.IsActive == true) { chkheader.Visible = true; } if (User.IsInRole(AdminRole) && budYr.IsActive == true) { chkheader.Visible = true; } } if (e.Row.RowType == DataControlRowType.DataRow) { Label st = e.Row.FindControl("lbStatus") as Label; CheckBox ck = e.Row.FindControl("chkRow") as CheckBox; Label lbAmt = e.Row.FindControl("lbAmt") as Label; priceTotal += Convert.ToDecimal(lbAmt.Text); ImageButton imgEdit = e.Row.FindControl("imgBtnEdit") as ImageButton; ImageButton imgDel = e.Row.FindControl("imgBtnDel") as ImageButton; if (User.IsInRole(deptIniRole) && budYr.IsActive == true) { if (st.Text == ((int)Utility.BudgetItemStatus.Rejected).ToString() || st.Text == ((int)Utility.BudgetItemStatus.Pending_Approval).ToString() || st.Text == ((int)Utility.BudgetItemStatus.Returned_For_Correction).ToString()) { imgDel.Visible = true; imgEdit.Visible = true; } } if (User.IsInRole(deptApprRole) && budYr.IsActive == true) { ck.Visible = true; if (st.Text == ((int)Utility.BudgetItemStatus.Approved).ToString() || st.Text == ((int)Utility.BudgetItemStatus.Rejected).ToString()) { //ck.Enabled = false; ck.Visible = false; } } if (User.IsInRole(AdminRole) && budYr.IsActive == true) { if (st.Text == ((int)Utility.BudgetItemStatus.Approved).ToString()) { ck.Visible = true; } if (st.Text == ((int)Utility.BudgetItemStatus.Returned_For_Correction).ToString()) { ck.Visible = false; } } } if (e.Row.RowType == DataControlRowType.Footer) { Label lbSumAmt = e.Row.FindControl("lbSumAmt") as Label; lbSumAmt.Text = priceTotal.ToString("N"); } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { if (hid.Value == "Update") { CapexType exp = null; bool rst = false; exp = LookUpBLL.GetCapexType(Convert.ToInt32(txtID.Text)); if (exp != null) { exp.Name = txtDept.Text.ToUpper(); // exp.GLCode = txtcode.Text; if (chkActive.Checked) { exp.isActive = true; } else { exp.isActive = false; } rst = LookUpBLL.UpdateCapexType(exp); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { BudgetYear byr = (BudgetYear)Session["budgetYr"]; bool result = false; CapexType exp = new CapexType(); exp.Name = txtDept.Text.ToUpper(); exp.BudgetYearID = byr.ID; // exp.GLCode = txtcode.Text; if (chkActive.Checked) { exp.isActive = true; } else { exp.isActive = false; } result = LookUpBLL.AddCapexType(exp); if (result) { BindGrid(); txtDept.Text = ""; //txtcode.Text = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button> An error occurred. kindly try again!!!"; Utility.WriteError("Error: " + ex.Message); } }
public void MoveBudgetAcross(string budget, string year, Priorities priority) { //Get next budget. var nextBudget = GetNextBudget(budget); //Add what is left from current budget (and priority) to the the next budget. string budgetCheck = budget.Trim(); Hashtable hashYearAmount; Hashtable hashYearAmountOriginal; float available = 0; float original = 0; //Budget not defined try { if (!BudgetYear.Contains(budgetCheck)) { return; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking budget year. " + e.Message)); throw e; } try { hashYearAmount = (Hashtable)BudgetYear[budgetCheck]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving budget year. " + e.Message)); throw e; } try { if (!hashYearAmount.Contains(year)) { return; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking year amount. " + e.Message)); throw e; } try { available = (float)hashYearAmount[year]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving year amount. " + e.Message)); throw e; } try { if (!BudgetYearOriginal.Contains(budgetCheck)) { return; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking budget year original. " + e.Message)); throw e; } try { hashYearAmountOriginal = (Hashtable)BudgetYearOriginal[budgetCheck]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving budget year original. " + e.Message)); throw e; } try { if (!hashYearAmountOriginal.Contains(year)) { return; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking year amount original. " + e.Message)); throw e; } try { original = (float)hashYearAmountOriginal[year]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving year amount original. " + e.Message)); throw e; } if (original <= 0) { return; } var percent = (1 - available / original) * 100; try { var percentLimit = (float)priority.BudgetPercent[budgetCheck]; if (percent < percentLimit) { var difference = percentLimit - percent; var budgetToMove = original * difference / 100; hashYearAmount[year] = (float)hashYearAmount[year] - budgetToMove; hashYearAmount = (Hashtable)BudgetYear[nextBudget]; hashYearAmount[year] = (float)hashYearAmount[year] + budgetToMove; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving budget year original. " + e.Message)); throw e; } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { budYr = (BudgetYear)Session["budgetYr"]; if (hid.Value == "Update") { Customer ast = null; bool rst = false; ast = LookUpBLL.GetCustomer(Convert.ToInt32(txtID.Text)); if (ast != null) { ast.FullName = txtOblg.Text; ast.Code = txtAgr.Text; ast.CustomerTypeID = int.Parse(ddlDir.SelectedValue); // ast.BudgetYearID = budYr.ID; rst = LookUpBLL.UpdateCustomer(ast); if (rst != false) { BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record updated successfully!!."; return; } } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not updated. Kindly try again. If error persist contact Administrator!!."; } } else { bool result = false; Customer ast = new Customer(); ast.FullName = txtOblg.Text; ast.CustomerTypeID = int.Parse(ddlDir.SelectedValue); ast.Code = txtAgr.Text; // ast.BudgetYearID = budYr.ID; result = LookUpBLL.AddCustomer(ast); if (result) { BindGrid(); txtOblg.Text = ""; txtAgr.Text = ""; ddlDir.SelectedValue = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>Record could Not added. Kindly try again. If error persist contact Administrator!!."; } } } catch (Exception ex) { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Kindly try again. If error persist contact Administrator!!."; Utility.WriteError("Error: " + ex.InnerException); } }
/// <summary> /// Check if budget can support treatment. Checks for each priority. /// </summary> /// <param name="fAmount"></param> /// <param name="strBudget"></param> /// <param name="strYear"></param> /// <param name="hashAttributeValue"></param> /// <param name="priority"></param> /// <param name="limits">Limits where treatments are split over multiple years</param> /// <returns></returns> public string IsBudgetAvailable(float fAmount, string strBudget, String strYear, Hashtable hashAttributeValue, Priorities priority, List <ISplitTreatmentLimit> limits, string budgetLimitType, out string budgetHash, out ISplitTreatmentLimit splitTreatmentLimit, out string reasonNoBudget) { reasonNoBudget = ""; string noBudgetAvailable = ""; splitTreatmentLimit = limits[0]; //Check priority. If not possible just return null. if (!(priority.IsAllSections || priority.Criteria.IsCriteriaMet(hashAttributeValue))) { budgetHash = ""; reasonNoBudget = "Priority (" + priority.PriorityLevel + ") criteria not met for year " + strYear; return(noBudgetAvailable); } string[] possibleBudgets; foreach (var limit in limits) { if (limit.Amount > fAmount) { splitTreatmentLimit = limit; break; } } budgetHash = ""; try { possibleBudgets = strBudget.Split('|'); for (int i = 0; i < possibleBudgets.Length; i++) { possibleBudgets[i] = possibleBudgets[i].Trim(); } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Budget is null." + e.Message)); throw e; } //If there are no budget criteria, then ignore. The list is enforced. var budgets = new List <string>(); if (SimulationMessaging.BudgetCriterias.Count > 0) { var listAvailableBudget = new List <BudgetCriteria>(); foreach (var budgetCriteria in SimulationMessaging.BudgetCriterias) { if (budgetCriteria.Criteria.IsCriteriaMet(hashAttributeValue)) { listAvailableBudget.Add(budgetCriteria); } } foreach (var budget in possibleBudgets) { var available = listAvailableBudget.Find(b => b.BudgetName == budget); if (available != null && !budgets.Contains(available.BudgetName)) { budgets.Add(available.BudgetName); } } } else { foreach (var budget in possibleBudgets) { budgets.Add(budget); } } if (budgets.Count == 0) { reasonNoBudget = "Budget (" + strBudget + ") did not meet budget criteria."; } foreach (string budget in budgets) { string budgetCheck = budget.Trim(); Hashtable hashYearAmount; Hashtable hashYearAmountOriginal; float fAvailable; float fOriginal; float fAfterSpending; float fPercent; //Budget not defined try { if (!BudgetYear.Contains(budgetCheck)) { continue; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking budget year. " + e.Message)); throw e; } try { hashYearAmount = (Hashtable)BudgetYear[budgetCheck]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving budget year. " + e.Message)); throw e; } try { if (!BudgetYearOriginal.Contains(budgetCheck)) { continue; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Checking budget year original. " + e.Message)); throw e; } bool currentBudgetAvailable = true; if (budgetLimitType.ToLower() == "unlimited")//If the budget is available (possible budget) and is unlimited... we are good. { return(budgetCheck); } //Starting here need to loop through year amounts. var year = Convert.ToInt32(strYear); for (int i = 0; i < splitTreatmentLimit.Percentages.Count; i++) { var currentYearAmount = fAmount * splitTreatmentLimit.Percentages[i] / 100; var currentYear = year + i; //Priority must be all years, match the current year or the current year must be greater than maximum year and the Maximum year must be a priority. if (!(priority.IsAllYears || priority.Years == currentYear || (currentYear > MaximumYear && priority.Years == MaximumYear))) { reasonNoBudget = "Priority is not set for year " + currentYear; return(null); } try { //This occurs when a split treament goes past then end. if (!hashYearAmount.Contains(currentYear.ToString())) { continue; } //Not past end of analysis. fAvailable = (float)hashYearAmount[currentYear.ToString()]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving year amount. " + e.Message)); throw e; } //This gets a hash of all years and the amount of budgets originally available. try { hashYearAmountOriginal = (Hashtable)BudgetYearOriginal[budgetCheck]; //This occurs when a split treament goes pas then end. if (!hashYearAmountOriginal.ContainsKey(currentYear.ToString())) { continue; } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving budget year original. " + e.Message)); throw e; } try { if (!hashYearAmountOriginal.Contains(currentYear.ToString())) { continue; } fOriginal = (float)hashYearAmountOriginal[currentYear.ToString()]; } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Retrieving year amount original. " + e.Message)); throw e; } fAfterSpending = fAvailable - currentYearAmount; if (fOriginal <= 0) { continue; } fPercent = (1 - fAfterSpending / fOriginal) * 100; try { float fPercentLimit = (float)priority.BudgetPercent[budgetCheck]; var original = (float)priority.BudgetPercent[budgetCheck] * fOriginal / 100; budgetHash = currentYearAmount.ToString("#,##0.##") + "/" + fAmount.ToString("#,##0.##") + "/" + fAvailable.ToString("#,##0.##") + "/" + original.ToString("#,##0.##"); //if (fPercent < fPercentLimit) return budgetCheck; if (fPercent > fPercentLimit) { currentBudgetAvailable = false; reasonNoBudget = "Percent after spending greater than priority limit " + fPercent.ToString("f2") + "/" + fPercentLimit.ToString("f2") + " for year(" + currentYear + ")"; return(noBudgetAvailable); } } catch (Exception e) { SimulationMessaging.AddMessage(new SimulationMessage("Error: Evaluating priority. " + e.Message)); throw e; } } //To be true here, there must be money available for each year. if (currentBudgetAvailable) { return(budgetCheck); } } return(noBudgetAvailable); }