protected void btnApprv_Click(object sender, EventArgs e) { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } bool isset = false; foreach (GridViewRow row in gvDept.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); IncomeProjection expPro = CommonBLL.GetIncomePro(recID); if (expPro != null && expPro.Status == (int)Utility.BudgetItemStatus.Pending_Approval) { expPro.Status = (int)Utility.BudgetItemStatus.Approved; expPro.ApprovedBy = usr.FullName; expPro.ApprovedDate = DateTime.Now; CommonBLL.UpdateIncomePro(expPro); isset = true; } } } if (isset) { BindGrid(); success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully approved."; return; } else { BindGrid(); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured some of selected record(s) could not be approved.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); } }
protected void gvDept_RowCommand(object sender, GridViewCommandEventArgs e) { try { if (e.CommandName == "del") { int index = int.Parse(e.CommandArgument.ToString()); // int key = Convert.ToInt32(gvDept.DataKeys[index].Value.ToString()); IncomeProjection estf = CommonBLL.GetIncomePro(index); CommonBLL.DeleteIncomePro(estf); BindGrid(); success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> Record deleted successfully!!."; return; } if (e.CommandName == "edt") { hid.Value = "Update"; dvID.Visible = false; btnSubmit.Text = "Update"; dvAdd.Visible = true; dvRentalIncome.Visible = false; //GridViewRow row = gvDept.SelectedRow; int index = int.Parse(e.CommandArgument.ToString()); IncomeProjection estf = CommonBLL.GetIncomePro(index); txtID.Text = estf.ID.ToString(); if (estf.IncomeTypeId.ToString() == forfeitedAsset || estf.IncomeTypeId.ToString() == rentalIncon) { dvProperty.Visible = true; dvDetail.Visible = false; ddlProperty.SelectedValue = estf.PropertyID.Value.ToString(); } else { dvDetail.Visible = true; dvProperty.Visible = false; txtDetail.Text = estf.Details; } txtTot.Text = estf.Amount.ToString(); ddlIncomeType.SelectedValue = estf.IncomeTypeId.ToString(); ddlMonth.SelectedValue = estf.Month.ToString(); } } 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 btnReturn_Click(object sender, EventArgs e) { try { AppUser usr = null; if (Session["user"] != null) { usr = (AppUser)Session["user"]; } else { Response.Redirect("../Login.aspx", false); return; } if (string.IsNullOrEmpty(txtcomment.Text)) { modalErr.Visible = true; modalErr.InnerText = "Comment is required!!!"; mpeAppr.Show(); return; } bool isset = false; AppUser budgetInputer = new AppUser(); foreach (GridViewRow row in gvDept.Rows) { if (((CheckBox)row.FindControl("chkRow")).Checked) { Label lbID = row.FindControl("lbRecID") as Label; int recID = int.Parse(lbID.Text); IncomeProjection expPro = CommonBLL.GetIncomePro(recID); if (expPro != null && expPro.Status == (int)Utility.BudgetItemStatus.Approved) { expPro.Status = (int)Utility.BudgetItemStatus.Returned_For_Correction; CommonBLL.UpdateIncomePro(expPro); budgetInputer = UserBLL.GetUserByUserName(expPro.AddeBy); isset = true; } } } if (isset) { BindGrid(); //sending mail string body = ""; string from = ConfigurationManager.AppSettings["exUser"].ToString(); string siteUrl = ConfigurationManager.AppSettings["siteUrl"].ToString(); string appLogo = ConfigurationManager.AppSettings["appLogoUrl"].ToString(); string hodEmail = UserBLL.GetApproverEmailByDept(budgetInputer.DepartmentID.Value); string subject = "Budget Item Correction Notification"; string FilePath = Server.MapPath("EmailTemplates/"); if (File.Exists(FilePath + "ReturnBudget.htm")) { FileStream f1 = new FileStream(FilePath + "ReturnBudget.htm", FileMode.Open); StreamReader sr = new StreamReader(f1); body = sr.ReadToEnd(); body = body.Replace("@add_appLogo", appLogo); body = body.Replace("@siteUrl", siteUrl); body = body.Replace("@BudgetElement", "Inflow Projection"); body = body.Replace("@add_Comment", txtcomment.Text); //Replace the values from DB or any other source to personalize each mail. f1.Close(); } string rst = ""; try { rst = Utility.SendMail(budgetInputer.Email, from, hodEmail, subject, body); } catch { } if (rst.Contains("Successful")) { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification has been sent to Initiator"; return; } else { success.Visible = true; success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>×</button>Selected Record(s) has been successfully Returned for correction.Notification could NOT be sent at this time"; return; } } else { BindGrid(); error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> An error occured. Either no record is selected OR some of selected record(s) could not be approved.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.Message); } }
protected void btnSubmit_Click(object sender, EventArgs e) { IncomeProjection income = 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); income = CommonBLL.GetIncomePro(Convert.ToInt32(txtID.Text)); if (income != 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; } income.Amount = tot; income.IncomeTypeId = int.Parse(ddlIncomeType.SelectedValue); if (ddlIncomeType.SelectedValue == forfeitedAsset) { income.PropertyID = int.Parse(ddlProperty.SelectedValue); } else { income.Details = txtDetail.Text; } income.DepartmentId = usr.DepartmentID; income.Status = (int)Utility.BudgetItemStatus.Pending_Approval; income.Month = month; income.BudgetYrID = budYr.ID; rst = CommonBLL.UpdateIncomePro(income); 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; income = new IncomeProjection(); int month = int.Parse(ddlMonth.SelectedValue); income.IncomeTypeId = int.Parse(ddlIncomeType.SelectedValue); income.DepartmentId = usr.DepartmentID; if (ddlIncomeType.SelectedValue == forfeitedAsset) { income.PropertyID = int.Parse(ddlProperty.SelectedValue); } else { income.Details = txtDetail.Text; } income.AddeBy = User.Identity.Name; income.DateAdded = DateTime.Now; income.Amount = tot; income.BudgetYrID = budYr.ID; income.Month = month; income.Status = (int)Utility.BudgetItemStatus.Pending_Approval; result = CommonBLL.AddIncomePro(income); if (result) { BindGrid(); txtTot.Text = ""; dvDetail.Visible = false; dvProperty.Visible = false; ddlIncomeType.SelectedValue = ""; ddlMonth.SelectedValue = ""; ddlProperty.SelectedValue = ""; txtDetail.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); } }
protected void ButtonSave_Click(object sender, EventArgs e) { try { SetRowData(); DataTable table = ViewState["CurrentTable"] as DataTable; usr = (AppUser)Session["user"]; budYr = (BudgetYear)Session["budgetYr"]; bool isSave = false; if (table != null) { foreach (DataRow row in table.Rows) { decimal amt = 0; int month = 0; int propID = 0; IncomeProjection income = new IncomeProjection(); string dlProp = row.ItemArray[1] as string; string txjan = row.ItemArray[2] as string; string txfeb = row.ItemArray[3] as string; string txmar = row.ItemArray[4] as string; string txapr = row.ItemArray[5] as string; string txmay = row.ItemArray[6] as string; string txjun = row.ItemArray[7] as string; string txjul = row.ItemArray[8] as string; string txaug = row.ItemArray[9] as string; string txsep = row.ItemArray[10] as string; string txoct = row.ItemArray[11] as string; string txnov = row.ItemArray[12] as string; string txdec = row.ItemArray[13] as string; if (dlProp != null) { propID = int.Parse(dlProp); } if (!string.IsNullOrEmpty(txjan)) { amt = decimal.Parse(txjan); month = 1; } if (!string.IsNullOrEmpty(txfeb)) { amt = decimal.Parse(txfeb); month = 2; } if (!string.IsNullOrEmpty(txmar)) { amt = decimal.Parse(txmar); month = 3; } if (!string.IsNullOrEmpty(txapr)) { amt = decimal.Parse(txapr); month = 4; } if (!string.IsNullOrEmpty(txmay)) { amt = decimal.Parse(txmay); month = 5; } if (!string.IsNullOrEmpty(txjun)) { amt = decimal.Parse(txjun); month = 6; } if (!string.IsNullOrEmpty(txjul)) { amt = decimal.Parse(txjul); month = 7; } if (!string.IsNullOrEmpty(txaug)) { amt = decimal.Parse(txaug); month = 8; } if (!string.IsNullOrEmpty(txsep)) { amt = decimal.Parse(txsep); month = 9; } if (!string.IsNullOrEmpty(txoct)) { amt = decimal.Parse(txoct); month = 10; } if (!string.IsNullOrEmpty(txnov)) { amt = decimal.Parse(txnov); month = 11; } if (!string.IsNullOrEmpty(txdec)) { amt = decimal.Parse(txdec); month = 12; } income.PropertyID = propID; income.IncomeTypeId = int.Parse(ddlIncomeType.SelectedValue); income.DepartmentId = usr.DepartmentID; income.AddeBy = User.Identity.Name; income.DateAdded = DateTime.Now; income.Amount = amt; income.BudgetYrID = budYr.ID; income.Month = month; income.Status = (int)Utility.BudgetItemStatus.Pending_Approval; bool result = CommonBLL.AddIncomePro(income); if (result) { isSave = true; } else { isSave = false; break; } } if (isSave) { BindGrid(); ViewState["CurrentTable"] = null; dvRentalIncome.Visible = false; ddlIncomeType.SelectedValue = ""; success.Visible = true; success.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button> All Record(s) has been added successfully!!."; return; } else { error.Visible = true; error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>×</button>An error occured while saving the inputted data.Kindly review your input and try again.If error persist contact Administrator!!."; return; } } } 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); } }