protected void lnkbtnSave_OnClick(object sender, EventArgs e) { if (chkTermsCondi.Checked) { lnkbtnOTPSend.Visible = false; txtMobileOtp.Text = ""; RegisterDAL obj = new RegisterDAL(); if (obj.IsExists(txtemailid.Text.Trim())) { lblMainSuccessMsg.Visible = true; lblMainSuccessMsg.Text = "User Email id already exists, Please select another Email id"; } else { Random generator = new Random(); Int64 OTP = generator.Next(100000, 999999); ViewState["OTP"] = OTP; lblSuccessMsg.ForeColor = System.Drawing.Color.Green; string Message = "Dear Customer,Your One Time Password is " + OTP + ".Please enter OTP to proceed.Thank you,Team COGXIM"; string Subject = "OTP Varification."; string EmailBody = string.Empty; string OwnerName = txtOwnerName.Text.Trim(); RegisterDAL objtblRegister = new RegisterDAL(); tblEmailTemplate EmailTemplates = objtblRegister.SelectUserMailTemplates("OTP"); EmailBody = EmailTemplates.Body.ToString(); EmailBody = EmailBody.Replace("$$UserName$$", OwnerName); EmailBody = EmailBody.Replace("$$OTP$$", ViewState["OTP"].ToString()); if (SendMailMessage(txtemailid.Text.Trim(), "", "", Subject, EmailBody)) { // Sending mail to user } if (SendMsgForOTP(txtMobileNumber.Text.Trim(), Message)) { multivwRegstr.ActiveViewIndex = 1; lblSuccessMsg.Visible = true; lblSuccessMsg.Text = "Your OTP is send to your mobile number and Email also, Please enter OTP to proceed complete registration"; } else { lblSuccessMsg.Text = "Fetal error!, Please contact to support."; } } } }
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"); } }