コード例 #1
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");
        }
コード例 #2
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");
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        private void DeleteUnusedCodes()
        {
            var lstCodes = dbContext.tblUniqueCodes.Where(p => SqlFunctions.DateDiff("dd", p.creationdatetime, DateTime.Now) >= 2 && p.isused == false).ToList();

            if (lstCodes != null)
            {
                dbContext.tblUniqueCodes.RemoveRange(lstCodes);

                dbContext.SaveChanges();
            }
        }
コード例 #6
0
        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();
            }
        }
コード例 #7
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;

                dbContext.SaveChanges();
            }
            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);

                dbContext.SaveChanges();
            }

            return(true);
        }
コード例 #8
0
        protected void lnkResend_Click(object sender, EventArgs e)
        {
            string link = string.Empty, body = string.Empty, jono = string.Empty;

            LinkButton lnkResendRequest = (LinkButton)sender;

            jrcode = lnkResendRequest.CommandArgument.ToString().Trim();

            var verify = dbContext.tblAttachments.Where(x => x.jr_code == jrcode && x.typeofattachment.Trim() == "Admin" &&
                                                        x.IsPrepared == true && x.IsChecked == true && x.IsApproved == false).Count();

            if (verify >= 1)
            {
                link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/"
                       + ConfigurationManager.AppSettings["AttachmentApproverPage"];

                var asstr = (from data in dbContext.tblUsers
                             join approvers in dbContext.tblApprovers on data.EmpID equals approvers.EmpID
                             into UP
                             from approvers in UP.DefaultIfEmpty()
                             where approvers.OrderValue == 1
                             select new
                {
                    EmpID = data.EmpID,
                    EmailAdd = data.EmailAdd
                }
                             ).ToList();

                foreach (DataRow dr in ConvertToDataTable(asstr).Rows)
                {
                    body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                    body += "<br /><br />" + "I Have Prepared A Job Order Request Attachment/s For Your Checking and Approval.";

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

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

                    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 Attachment 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);
                    }
                }
            }
            else
            {
                var app = dbContext.tblRequests.Where(x => x.JR_Code == jrcode).FirstOrDefault();

                if (app != null)
                {
                    app.IsHold = false;

                    app.AttachementStatus = "PREPARED";

                    app.CreationDateTime = DateTime.Now;

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

                    dbContext.SaveChanges();
                }


                var accept = dbContext.tblAttachments.Where(x => x.jr_code == jrcode &&
                                                            x.typeofattachment.Trim() == "Admin").FirstOrDefault();

                if (accept != null)
                {
                    accept.PreparedBy = Session["FullName_FnameFirst"].ToString();

                    accept.IsPrepared = true;

                    accept.datecreated = DateTime.Now;

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

                    dbContext.SaveChanges();
                }

                link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/"
                       + ConfigurationManager.AppSettings["AttachmentNoterPage"];

                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.IsNoter == 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)
                {
                    body = "Dear Sir/Ma'am," + "<br /><br />" + "Good Day!";

                    body += "<br /><br />" + "I Have Prepared A Job Order Request Attachment/s For Your Checking and Approval.";

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

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

                    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 Attachment 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);
                    }
                }
            }
        }
コード例 #9
0
        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();
        }
コード例 #10
0
        private void Save(string appr)
        {
            if ((rdoInCharge.SelectedValue == "04" || rdoInCharge.SelectedValue == "05" || rdoInCharge.SelectedValue == "08") &&
                (ddlCheckJig.SelectedIndex == -1 || ddlCheckJig.SelectedIndex == 0))
            {
                Show("Select if jig is exists.");
            }
            else
            {
                string link = string.Empty, body = string.Empty;

                link = Environment.NewLine + "http://" + HttpContext.Current.Request.Url.Authority + "/"
                       + ConfigurationManager.AppSettings["NoterPage"];

                SqlCommand cmd = new SqlCommand("update tblRequest set " +
                                                "Is_Assessed=@Is_Assessed, " +
                                                "AssessedBy=@AssessedBy, " +
                                                "AssessedRemarks =@AssessedRemarks," +
                                                "DateAssessed=@Date, " +
                                                "Noter=@Noter, " +
                                                "IsHold=@IsHold," +
                                                "IsExistingJig=convert(bit, @IsExistingJig)," +
                                                "AssessmentRemarks=@AssessmentRemarks, " +
                                                "IsCancelled=@IsCancelled ," +
                                                "AssessmentCode = @AssessmentCode " +
                                                "where JR_Code=@JR_Code");

                cmd.CommandType = CommandType.Text;

                cmd.Parameters.AddWithValue("@AssessedBy", Session["FullName_LnameFirst"].ToString().Trim());
                cmd.Parameters.AddWithValue("@Noter", appr);

                if (ddlAssessment.SelectedValue.ToString().Trim() == "CP")
                {
                    cmd.Parameters.AddWithValue("@AssessedRemarks", "REJECTED");

                    cmd.Parameters.AddWithValue("@IsCancelled", true);
                }
                else
                {
                    cmd.Parameters.AddWithValue("@AssessedRemarks", "SIGNED");

                    cmd.Parameters.AddWithValue("@IsCancelled", false);
                }

                if (tbAssessmentRemarks.Text.Length == 0)
                {
                    cmd.Parameters.AddWithValue("@AssessmentRemarks", "N/A");
                }
                else
                {
                    cmd.Parameters.AddWithValue("@AssessmentRemarks", tbAssessmentRemarks.Text.Trim());
                }

                if (rdoInCharge.SelectedValue == "04" || rdoInCharge.SelectedValue == "05" || rdoInCharge.SelectedValue == "08")
                {
                    cmd.Parameters.AddWithValue("@IsExistingJig", string.IsNullOrEmpty(ddlCheckJig.SelectedValue.ToString().Trim()) ? DBNull.Value.ToString() : ddlCheckJig.SelectedValue.ToString().Trim());
                }
                else
                {
                    cmd.Parameters.AddWithValue("@IsExistingJig", DBNull.Value);
                }

                cmd.Parameters.AddWithValue("@JR_Code", jrcode);
                cmd.Parameters.AddWithValue("@Date", DateTime.Now.Date);
                cmd.Parameters.AddWithValue("@IsHold", false);
                cmd.Parameters.AddWithValue("@Is_Assessed", true);
                cmd.Parameters.AddWithValue("@AssessmentCode", ddlAssessment.SelectedValue.ToString().Trim());

                SqlHelper.ExecuteNonQuery(ClsConfig.JobRequestConnectionString, cmd);

                if (ddlAssessment.SelectedValue.ToString().Trim() != "CP")
                {
                    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.IsNoter == 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=" + Session["RCode"].ToString().Trim(), "Noter", dr["EmailAdd"].ToString().Trim(), Session["FullName_LnameFirst"].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 Checking and Approval.";

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

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

                        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();
                }

                Show("Record Successfully Assessed");
            }
        }