Ejemplo n.º 1
0
        protected void lnkbtnContinoue_OnClick(object sender, EventArgs e)
        {
            if (ViewState["OTP"] != null)
            {
                string OTP = ViewState["OTP"].ToString();
                if (OTP == txtMobileOtp.Text.Trim())
                {
                    string strMsg = string.Empty;

                    RegisterDAL objtblRegister  = new RegisterDAL();
                    Int64       intWorkCompIdno = 0;
                    string      CompName        = txtCompanyName.Text.Trim();
                    string      OwnerName       = txtOwnerName.Text.Trim();
                    string      LastName        = txtOwnerLast.Text.Trim();
                    //string Address1 = txtAdrs1.Text.Trim();
                    //string Address2 = txtAdrs2.Text.Trim();
                    //Int64 CityIdno = Convert.ToInt64(ddlCity.SelectedValue);
                    //Int64 StateIdno = Convert.ToInt64(ddlState.SelectedValue);
                    //string PinNo = Convert.ToString(txtpincode.Text.Trim());
                    string EmailId      = txtemailid.Text.Trim();
                    string PhneNum      = txtMobileNumber.Text.Trim();
                    string OwnMobileNum = txtMobileNumber.Text.Trim();

                    string Ipaddress = Request.UserHostAddress.ToString();

                    intWorkCompIdno = objtblRegister.Insert(CompName, OwnerName, LastName, EmailId, PhneNum, OwnMobileNum, Ipaddress, false);

                    if (intWorkCompIdno > 0)
                    {
                        #region ClientSMS & SMStoSir
                        string Clientsms = "Dear " + OwnerName + ", thank you for regsitering with us. We have received your request and we shall email you the login details very shortly.";

                        if (SendMsgForOTP(OwnMobileNum, Clientsms))
                        {
                            // sending sms to client
                        }

                        string Message = "Dear Sir, " + OwnerName + ", [" + OwnMobileNum + "], has submitted registration request for Web Transport.";
                        string MobNum  = "9829068896";;  // here num to send sms
                        if (SendMsgForOTP(MobNum, Message))
                        {
                            // sending sms to punitsir
                        }
                        #endregion

                        #region MailToClient & MailToAdmin
                        string           Subject        = "Registration";
                        string           EmailBody      = string.Empty;
                        tblEmailTemplate EmailTemplates = objtblRegister.SelectUserMailTemplates("Register");
                        EmailBody = EmailTemplates.Body.ToString();
                        EmailBody = EmailBody.Replace("$$UserName$$", OwnerName);

                        if (SendMailMessage(txtemailid.Text.Trim(), "", "", Subject, EmailBody))
                        {
                            // Sending mail to user
                        }

                        string           AdminEmailBody       = string.Empty;
                        tblEmailTemplate AdminstrSQLForTmplts = objtblRegister.SelectUserMailTemplates("Mail To Admin");
                        AdminEmailBody = AdminstrSQLForTmplts.Body.ToString();
                        AdminEmailBody = AdminEmailBody.Replace("$$UserName$$", OwnerName).Replace("$$MobileNum$$", OwnMobileNum).ToString();
                        string MailTo = "*****@*****.**"; // to add more mailid use ; keyword
                        if (SendMailMessage(MailTo, "", "", Subject, AdminEmailBody))
                        {
                            // Sending mail to Punit sir
                        }
                        #endregion
                        multivwRegstr.ActiveViewIndex = 0;
                        ClearControls();
                        lblMainSuccessMsg.Visible = true;
                        lblMainSuccessMsg.Text    = "Thank you for registration with us, we will revert back you soon.";
                    }
                    else
                    {
                        multivwRegstr.ActiveViewIndex = 0;
                        lblMainSuccessMsg.Visible     = true;
                        lblMainSuccessMsg.Text        = "Record already exists.";
                    }
                }
                else
                {
                    lblSuccessMsg.Visible   = true;
                    lblSuccessMsg.ForeColor = System.Drawing.Color.Red;
                    lblSuccessMsg.Text      = "OTP code does not match";

                    lnkbtnOTPSend.Visible = true;
                }
            }
            else
            {
                Response.Redirect("NewRegister.aspx");
            }
        }