protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && IsValidate())
            {
                if (chkAgree.Checked)
                {
                    Response.Cookies.Clear();
                    ManageUserSVC.ManageUserClient Client = new ManageUserSVC.ManageUserClient();

                    DataSet Dscus = Client.GetCustomerInfo(Guid.Parse(Session["CustomerID"].ToString()));
                    if (Dscus != null && Dscus.Tables[0].Rows.Count > 0)
                    {
                        if (Dscus.Tables[0].Rows[0]["SecurityCode"].ToString().Equals(txtSecCode.Text) && Dscus.Tables[0].Rows[0]["EmailID"].ToString().Equals(txtEmailID.Text))
                        {
                            Guid   CertyID   = Guid.NewGuid();
                            String Encrypted = Crypto.Encrypt(CertyID.ToString(), true);
                            string CertyNo   = "CE" + Guid.NewGuid().ToString().GetHashCode().ToString("x");

                            string        url         = System.Configuration.ConfigurationManager.AppSettings["HostingPrefix"];
                            StringBuilder strMailBody = new StringBuilder();
                            //header

                            strMailBody.Append("<p>&nbsp;</p>");
                            strMailBody.Append("<div style=" + c + "margin-left: auto;height:500px;margin-right: auto;position: absolute;text-align: center;top: 0;width: 100%;z-index: 999;" + c + ">");
                            strMailBody.Append("<div style=" + c + "background: url('" + url + "images/image.png') repeat-x scroll 0 0 transparent;height: 75px; width:798px;  position: relative;top: 0;z-index: 999;" + c + ">" + "<br/>");

                            //body
                            strMailBody.Append("<p>&nbsp;</p><table style='font-family: Tahoma;' border='0' cellpadding='0' cellspacing='0' width='600'><tbody><tr><td><table style='font-family: Tahoma;' border='0' cellpadding='0' cellspacing='0' width='600'>");
                            strMailBody.Append("<tbody><tr style='font-family: Tahoma; font-size: 15px; color: rgb(33, 33, 33); text-align: left; ' valign='top'><td style='padding:35px 20px'>");
                            strMailBody.Append(Dscus.Tables[0].Rows[0]["FirstName"].ToString() + " " + Dscus.Tables[0].Rows[0]["LastName"].ToString() + ",<br/><br/>");

                            strMailBody.Append("Your Certificate of Insurance has been generated.<br /><br />");
                            //strMailBody.Append("<b>" + "To view your Certificate of Insurance please click <a href='" + url + "iwed1eamrqqgvxybdda1ed4g.pdf?ching=" + Encrypted + "' target='_blank'>here</a><br /><br />");
                            strMailBody.Append("To view your Certificate of Insurance please click <a href='" + url + "ViewDoc.ashx?" + Crypto.ArgumentEncrypt("ching") + "=" + Encrypted + "&" + Crypto.ArgumentEncrypt("type") + "=" + Crypto.Encrypt("certy", true) + "' target='_blank'>here</a><br /><br />");
                            //strMailBody.Append("If you are having trouble with the above link please copy and paste the following link into your browser:<br /><br />");
                            //strMailBody.Append(url + "ViewDoc.ashx?" + Crypto.ArgumentEncrypt("ching") + "=" + Encrypted + "&" + Crypto.ArgumentEncrypt("type") + "=" + Crypto.Encrypt("certy",true) + "<br/><br/>");
                            strMailBody.Append("Sincerely,<br/>");
                            strMailBody.Append("dscoverage.ca<br/>");

                            strMailBody.Append("</tr></tbody></table>");
                            //footer

                            strMailBody.Append("<div style=" + c + "background: url('" + url + "images/footer-b.jpg') no-repeat scroll 0 0 transparent;color: #939393;font-size: 10px;height: 60px;line-height: 44px;overflow: hidden;padding: 0 20px;width: 760px;margin-top: 5px;" + c + ">" + "<p style='float: left;color: white;'>Copyright © " + DateTime.Now.Year.ToString() + " <a href='https://dscoverage.ca' target='_blank' style='color:white;font-weight: bolder;'>dscoverage.ca</a>, Inc. All Rights Reserved.</p></div>");
                            DateTime Eventfrom = DateTime.ParseExact(txtEventFrom.Text, "MM/dd/yyyy", System.Globalization.CultureInfo.GetCultureInfo("en-US"));
                            DateTime Eventto   = DateTime.ParseExact(txtEventTo.Text, "MM/dd/yyyy", System.Globalization.CultureInfo.GetCultureInfo("en-US"));
                            //DateTime Eventfrom = Convert.ToDateTime(txtEventFrom.Text);
                            //DateTime Eventto = Convert.ToDateTime(txtEventTo.Text);

                            Client.InsertCertificate(CertyID, DateTime.Now, CertyNo, Eventfrom, Eventto, txtAdditional.Text, txtHodrName.Text, txtHodrAddress.Text,
                                                     Guid.Parse(Session["CustomerID"].ToString()), null, chkWaiver.Checked);

                            byte[] buffer = dowload(url.Replace("https://", "http://") + "Certificate.aspx?" + Crypto.ArgumentEncrypt("ching") + "=" + Encrypted);

                            string Subject = ConfigurationManager.AppSettings["GenerateCerificate"].ToString();
                            bool   Sent    = CommonFunction.SendEmail(txtEmailID.Text.Trim(), strMailBody.ToString(), Subject);
                            Session["sent"] = Sent;
                            if (Sent)
                            {
                                //File.WriteAllBytes("D:\\Testssss.pdf", buffer);
                                Client.UpdateCertificate(CertyID, buffer);
                                Response.Redirect("Home.aspx?" + Crypto.ArgumentEncrypt("get") + "=" + Crypto.ArgumentEncrypt("yes"));
                            }
                        }
                        else
                        {
                            lblError.Text = "Invalid Email or Password! Please Enter valid Email Id and Password.";
                        }
                    }
                }
                else
                {
                    lblError.Text = "Please Read Terms And Conditions.";
                }
            }
        }