public void RejectByChecker()
        {
            var app = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (app != null)
            {
                app.IsRejected = true;

                app.Checker = Session["FullName_FnameFirst"].ToString().Trim();

                app.CheckerRemarks = "REJECTED";

                app.DateChecked = DateTime.Now.Date;

                app.IsHold = false;

                app.RejectRemarks = tbRejectReasons.Text.Trim().Replace("\r\n", "<br />").Replace(" ", "&nbsp;").Replace("\t", "&nbsp;&nbsp;&nbsp;&nbsp;").Replace("'", "^");

                app.HoldBy = DBNull.Value.ToString();

                app.HoldRemarks = DBNull.Value.ToString();

                app.CreationDateTime = DateTime.Now;

                dbContext.Entry(app).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            SendRejectedEmail();

            string script = "window.onload = function() { CloseWindow(); };";

            ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", script, true);
        }
Beispiel #2
0
        private Boolean SaveEmailLogs(string url, string role, string emailadd, string emailfrom, string sentto, string code)
        {
            var logs = dbContext.tblEmailLogs.Where(x => x.UserRole == role && x.JR_Code == code).FirstOrDefault();

            if (logs != null)
            {
                logs.EmailUrl     = url;
                logs.UserRole     = role;
                logs.EmailAdd     = emailadd;
                logs.EmailFrom    = emailfrom;
                logs.SentTo       = sentto;
                logs.JR_Code      = code;
                logs.CreationDate = DateTime.Now;

                dbContext.Entry(logs).State = EntityState.Modified;
            }
            else
            {
                tblEmailLog tbl = new tblEmailLog()
                {
                    EmailUrl     = url,
                    UserRole     = role,
                    EmailAdd     = emailadd,
                    EmailFrom    = emailfrom,
                    SentTo       = sentto,
                    JR_Code      = code,
                    CreationDate = DateTime.Now
                };

                dbContext.tblEmailLogs.Add(tbl);
            }

            return(true);
        }
Beispiel #3
0
        protected void Cancel(object sender, EventArgs e)
        {
            var query = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (query != null)
            {
                query.IsCancelled = true;

                query.CreationDateTime = DateTime.Now;

                dbContext.Entry(query).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            RadNotification1.Text = "Requests Successfully Cancelled";

            RadNotification1.Title = "Notification";

            RadNotification1.TitleIcon = string.Empty;

            RadNotification1.ContentIcon = string.Empty;

            RadNotification1.Show();

            Response.Redirect("HomePage.aspx");
        }
Beispiel #4
0
        protected void btnaccept_Click(object sender, ImageClickEventArgs e)
        {
            var accept = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (accept != null)
            {
                accept.Is_JobAccepted = true;

                accept.CreationDateTime = DateTime.Now;

                dbContext.Entry(accept).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            divDetails.Visible = false;

            divRecords.Visible = true;

            jrcode = string.Empty;

            Session["RCode"] = null;

            gridRecords.Rebind();

            Show("Successfully Accepted");
        }
        protected void btnaccept_Click(object sender, ImageClickEventArgs e)
        {
            var accept = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (accept != null)
            {
                accept.FinalAcceptanceBy = Session["FullName_LnameFirst"].ToString().Trim();

                accept.AcceptRemarks = "SIGNED";

                accept.DateAccepted = DateTime.Now;

                accept.CreationDateTime = DateTime.Now;

                dbContext.Entry(accept).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            SendToAssesstor();

            divDetails.Visible = true;

            GetRequestDetails();

            Show("Successfully Accepted");
        }
        protected void btnaccept_Click(object sender, ImageClickEventArgs e)
        {
            if (!dpAccomplish.SelectedDate.HasValue)
            {
                Show("Please set date accomplish.");
            }
            //else if (gridAttachment2.MasterTableView.Items.Count == 0)
            //{
            //    Show("Please add an attachment.");
            //}
            else
            {
                var completed = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

                if (completed != null)
                {
                    completed.IsCompleted = true;

                    completed.CompletionRemarks = tbRemarks.Text.Trim();

                    completed.Completion_Date = dpAccomplish.SelectedDate.Value;

                    completed.CreationDateTime = DateTime.Now;

                    dbContext.Entry(completed).State = EntityState.Modified;

                    dbContext.SaveChanges();
                }

                EmailRequestor();

                Show("Request Has Been Successfully Finished");

                divDetails.Visible = false;

                divRecords.Visible = true;

                jrcode = string.Empty;

                Session["RCode"] = null;

                gridRecords.Rebind();
            }
        }
        protected void ChangeIncharge(object sender, EventArgs e)
        {
            string link = string.Empty, body = string.Empty;

            dbContext = new JobRequestDBEntities();

            var a = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

            if (a != null)
            {
                tblRequest tbldata = a as tblRequest;

                tbldata.Incharge_ID = incharge;

                dbContext.Entry(tbldata).State = EntityState.Modified;

                dbContext.SaveChanges();
            }

            link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/DirectAssessment.aspx";

            var asstr = (from data in dbContext.tblUsers
                         join inchargePerson in dbContext.tblInchargePersons on data.EmpID equals inchargePerson.EmpID
                         into UP
                         from inchargePerson in UP.DefaultIfEmpty()
                         where inchargePerson.Incharge_ID == rdoInCharge.SelectedValue && inchargePerson.IsAssesstor == true
                         select new
            {
                EmpID = data.EmpID,
                EmailAdd = data.EmailAdd,
                InchargeCode = inchargePerson.Incharge_ID,
                IsAssesstor = inchargePerson.IsAssesstor,
                IsNoter = inchargePerson.IsNoter
            }
                         ).ToList();

            foreach (DataRow dr in ConvertToDataTable(asstr).Rows)
            {
                Boolean ress;

                ress = SaveEmailLogs(link + "?EmpID=" + dr["EmpID"].ToString().Trim() + "&RCode=" + jrcode
                                     , "Assesstor", dr["EmailAdd"].ToString().Trim(), approverfullname_fnamefirst.ToString().Trim()
                                     , dr["EmpID"].ToString().Trim(), Session["RCode"].ToString().Trim());

                body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                body += "<br /><br />" + "I Have Prepared A Job Order Request For Your Assessment.";

                body += "<br /><br />" + "You may click the link below to redirect to main page. ";

                body += "<br /><br />" + link + "?EmpID=" + dr["EmpID"].ToString().Trim() + "&RCode=" + jrcode;

                body += "<br /><br />" + "Thank You.";

                body += "<br /><br />" + "Note: This is a system generated email. Please do not reply. Thank you";


                var rx = new Regex(@"(?<=\w)\w");

                var newString2 = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                using (MailMessage mm = new MailMessage())
                {
                    string sub = "Online Job Order Request: Requesting For Approval";

                    mm.Subject = sub.ToUpper();

                    mm.Body = body;

                    var newString = rx.Replace(Session["FullName_FnameFirst"].ToString(), new MatchEvaluator(m => m.Value.ToLowerInvariant()));

                    mm.From = new MailAddress(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),

                                              ConfigurationManager.AppSettings["MailSenderName"].ToString());

                    mm.To.Add(dr["EmailAdd"].ToString().Trim());

                    SmtpClient smtp = new SmtpClient();

                    smtp.Host = ConfigurationManager.AppSettings["MailServer"].ToString();

                    smtp.EnableSsl = true;

                    mm.IsBodyHtml = true;

                    NetworkCredential NetworkCred = new NetworkCredential(ConfigurationManager.AppSettings["MailSenderEmailAddress"].ToString(),
                                                                          ConfigurationManager.AppSettings["MailSenderEmailPassword"].ToString());

                    smtp.Credentials = NetworkCred;

                    smtp.Port = Convert.ToInt32(ConfigurationManager.AppSettings["SMTPPort"]);

                    ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate,
                                                                                       X509Chain chain, SslPolicyErrors sslPolicyErrors)
                    { return(true); };
                    smtp.Send(mm);
                }
            }

            dbContext.SaveChanges();

            SendToRequestor_Transferred();

            Show("Record Successfully Transferred");

            divRecords.Visible = true;

            gridRecords.Rebind();
        }