Example #1
0
 protected void btnMDFinal_Click(object sender, EventArgs e)
 {
     try
     {
         AppUser usr = null;
         if (Session["user"] != null)
         {
             usr = (AppUser)Session["user"];
         }
         else
         {
             Response.Redirect("../Login.aspx", false);
             return;
         }
         int deptID = int.Parse(ddlDept.SelectedValue);
         List <DeptBudgetItem> budMenuLst = LookUpBLL.GetDeptMenuItem(deptID).ToList();
         if (budMenuLst.Count() > 0)
         {
             foreach (DeptBudgetItem dm in budMenuLst)
             {
                 if (dm.Code == "CA")//for capex
                 {
                     Utility.UpdateBudgetCapex((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
                 if (dm.Code == "DI")
                 {
                     Utility.UpdateBudgetDirect((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
                 if (dm.Code == "ID")
                 {
                     Utility.UpdateBudgetIndirect((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
                 if (dm.Code == "MO")
                 {
                     Utility.UpdateBudgetMovable((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
                 if (dm.Code == "RE")
                 {
                     Utility.UpdateBudgetRevenue((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
                 if (dm.Code == "SA")
                 {
                     Utility.UpdateBudgetExistingSf((int)Utility.BudgetItemStatus.MD_Approved, deptID, usr.FullName, 2);
                 }
             }
             BudgetYear           budYr            = (BudgetYear)Session["budgetYr"];
             List <TrackApproval> getTrackApproval = null;
             getTrackApproval = LookUpBLL.GetTrackApproval(deptID, budYr.ID).ToList();
             if (getTrackApproval != null && getTrackApproval.Count() > 0)
             {
                 TrackApproval appTrack = getTrackApproval.FirstOrDefault();
                 appTrack.status   = (int)Utility.BudgetItemStatus.MD_Approved;
                 appTrack.ActionBy = usr.FullName;
                 LookUpBLL.UpdateApprovalStatus(appTrack);
                 dvExco.Visible    = false;
                 success.Visible   = true;
                 success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Budget has been successfully approved.";
                 return;
             }
             else
             {
                 LookUpBLL.AddApprovaltrack(new TrackApproval()
                 {
                     BudgetYr = budYr.ID, DepartmentID = deptID, ActionBy = usr.FullName, dateApproved = DateTime.Now, status = (int)Utility.BudgetItemStatus.MD_Approved
                 });
                 dvExco.Visible    = false;
                 success.Visible   = true;
                 success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Budget has been successfully approved.";
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> An error occured. Kindly try again. If error persist contact Administrator!!.";
         Utility.WriteError("Error: " + ex.Message);
     }
 }
Example #2
0
 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();
         int  deptID = int.Parse(ddlDept.SelectedValue);
         List <DeptBudgetItem> budMenuLst = LookUpBLL.GetDeptMenuItem(deptID).ToList();
         if (budMenuLst.Count() > 0)
         {
             foreach (DeptBudgetItem dm in budMenuLst)
             {
                 if (dm.Code == "CA")//for capex
                 {
                     Utility.UpdateBudgetCapex((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
                 if (dm.Code == "DI")
                 {
                     Utility.UpdateBudgetDirect((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
                 if (dm.Code == "ID")
                 {
                     Utility.UpdateBudgetIndirect((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
                 if (dm.Code == "MO")
                 {
                     Utility.UpdateBudgetMovable((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
                 if (dm.Code == "RE")
                 {
                     Utility.UpdateBudgetRevenue((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
                 if (dm.Code == "SA")
                 {
                     Utility.UpdateBudgetExistingSf((int)Utility.BudgetItemStatus.Returned_For_Correction, deptID, usr.FullName, 4);
                 }
             }
             BudgetYear           budYr            = (BudgetYear)Session["budgetYr"];
             List <TrackApproval> getTrackApproval = null;
             getTrackApproval = LookUpBLL.GetTrackApproval(deptID, budYr.ID).ToList();
             if (getTrackApproval != null && getTrackApproval.Count() > 0)
             {
                 TrackApproval appTrack = getTrackApproval.FirstOrDefault();
                 appTrack.status   = (int)Utility.BudgetItemStatus.Returned_For_Correction;
                 appTrack.ActionBy = usr.FullName;
                 LookUpBLL.UpdateApprovalStatus(appTrack);
                 dvExco.Visible = false;
                 //success.Visible = true;
                 //success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Budget has been successfully returned to HOD.";
                 //return;
             }
             else
             {
                 LookUpBLL.AddApprovaltrack(new TrackApproval()
                 {
                     BudgetYr = budYr.ID, DepartmentID = deptID, ActionBy = usr.FullName, dateApproved = DateTime.Now, status = (int)Utility.BudgetItemStatus.Returned_For_Correction
                 });
                 dvExco.Visible = false;
                 //success.Visible = true;
                 //success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Budget has been successfully approved.";
                 //return;
             }
             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 = Utility.GetUsersEmailAdd(deptApprRole, deptID);
             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", ddlDept.SelectedItem.Text + " Department");
                 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'>&times;</button>Action was successful. Notification has been sent to HOD";
                 return;
             }
             else
             {
                 success.Visible   = true;
                 success.InnerHtml = "<button type='button' class='close' data-dismiss='alert'>&times;</button>Action was successful.Notification could NOT be sent at this time";
                 return;
             }
         }
         else
         {
             BindGrid();
             error.Visible   = true;
             error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> An error occured. kindly try again.If error persist contact Administrator!!.";
         }
     }
     catch (Exception ex)
     {
         error.Visible   = true;
         error.InnerHtml = " <button type='button' class='close' data-dismiss='alert'>&times;</button> An error occured. Kindly try again. If error persist contact Administrator!!.";
         Utility.WriteError("Error: " + ex.Message);
     }
 }