protected void LoginBtn_Click(object sender, EventArgs e)
    {
        //#region CSV Updation For User
        //DataSet dsUser = new DataSet();
        //DataAccessEntities oEntities = new DataAccessEntities();
        //oEntities.Email = "";
        //oEntities.MRNumber = txtLoginUsername.Text;
        //oEntities.UserName = "";
        //dsUser = objBusinessLogic.GetUserNameByMRNumber(oEntities);
        //string visitorId = string.Empty;
        //string AvailableMR = string.Empty;
        //if (dsUser != null && dsUser.Tables[0].Rows.Count > 0)
        //{
        //    visitorId = dsUser.Tables[0].Rows[0]["UserName"].ToString();
        //    Messege = dsUser.Tables[0].Rows[0]["Messege"].ToString();
        //    AvailableMR = dsUser.Tables[0].Rows[0]["AvailableMR"].ToString();
        //    Session["IsMR"] = Convert.ToString(AvailableMR);
        //}
        //#endregion


        if (Session["AppointmentDetail"] != null)
        {
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());
            if (IsNum == true)
            {
                UserInfo objUser = new UserInfo();
                objUser.Username = txtLoginUsername.Text.Trim();
                UserMembership objMembership = new UserMembership(objUser);
                objMembership.Username = txtLoginUsername.Text.Trim();
                objMembership.Password = txtLoginPassword.Text;
                objUser.Membership     = objMembership;

                PortalSettings  po          = new PortalSettings();
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                if (objUserInfo != null)
                {
                    UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    Response.Redirect("/Payment.aspx");
                }
                else
                {
                    if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                    {
                        lblLoginError.CssClass = "errorText";

                        lblLoginError.Visible = true;

                        lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                        return;
                    }

                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct password!";
                    return;
                }
            }
            else
            {
                Session["AppointmentDetail"] = null;
                lblLoginError.CssClass       = "errorText";
                lblLoginError.Visible        = true;
                lblLoginError.Text           = "Please Enter MR Number To Login!";
                return;
            }
        }
        else if (Session["ConsultationAppointment"] != null)
        {
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());
            if (IsNum == true)
            {
                UserInfo objUser = new UserInfo();
                objUser.Username = txtLoginUsername.Text.Trim();
                UserMembership objMembership = new UserMembership(objUser);
                objMembership.Username = txtLoginUsername.Text.Trim();
                objMembership.Password = txtLoginPassword.Text;
                objUser.Membership     = objMembership;

                PortalSettings  po          = new PortalSettings();
                UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                if (objUserInfo != null)
                {
                    UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    Response.Redirect("/Payment.aspx");
                }
                else
                {
                    if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                    {
                        lblLoginError.CssClass = "errorText";

                        lblLoginError.Visible = true;

                        lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                        return;
                    }

                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct password!";
                    return;
                }
            }
            else
            {
                Session["ConsultationAppointment"] = null;
                lblLoginError.CssClass             = "errorText";
                lblLoginError.Visible = true;
                lblLoginError.Text    = "Please Enter MR Number To Login!";
                return;
            }
        }
        else
        {
            JaslokMailer      objMailer     = new JaslokMailer();
            List <Parameters> lstParameters = new List <Parameters>();
            string            lsEmailStatus = string.Empty;
            PatIndex          objPatIndex   = new PatIndex();
            bool IsNum = IsNumber(txtLoginUsername.Text.Trim().ToString());

            if (IsNum == false)
            {
                // check for visitor id and MRNO
                string  MRNumber;
                string  Username;
                DataSet ds = objBusinessLogic.GetMRNumberByUserName(txtLoginUsername.Text.Trim());

                if (ds.Tables[0].Rows.Count > 0)
                {
                    MRNumber = ds.Tables[0].Rows[0]["MRNumber"].ToString();
                    Username = ds.Tables[0].Rows[0]["Username"].ToString();
                }
                else
                {
                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please enter correct Id and Password!";
                    return;
                }
                if (string.IsNullOrEmpty(MRNumber) && !string.IsNullOrEmpty(Username))
                {
                    //loginStatus = UserLoginStatus.LOGIN_SUCCESS;


                    UserInfo objUser = new UserInfo();
                    objUser.Username = txtLoginUsername.Text.Trim();
                    UserMembership objMembership = new UserMembership(objUser);
                    objMembership.Username = txtLoginUsername.Text.Trim();
                    objMembership.Password = txtLoginPassword.Text;
                    objUser.Membership     = objMembership;

                    PortalSettings  po          = new PortalSettings();
                    UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                    UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                    if (objUserInfo != null)
                    {
                        UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);

                        Session["IsVisitor"] = true;

                        Response.Redirect("/redirect");

                        //Response.Redirect("/redirect");
                    }
                    else
                    {
                        if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                        {
                            lblLoginError.CssClass = "errorText";

                            lblLoginError.Visible = true;

                            lblLoginError.Text = "You are not authorized to access Jaslok Portal. Authenticate your mobile number by clicking \"Please verify\" link below";

                            return;
                        }

                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Please enter correct password!";
                        return;
                    }
                }

                if (!string.IsNullOrEmpty(MRNumber))
                {
                    lblLoginError.CssClass = "errorText";
                    lblLoginError.Visible  = true;
                    lblLoginError.Text     = "Please Enter MR Number To Login!";
                    return;
                }
            }
            if (IsNum == true)
            {
                // check for Mr Number in db
                bool check = objBusinessLogic.IsExistMrNo(txtLoginUsername.Text.Trim());

                if (check == true)
                {
                    UserInfo objUser = new UserInfo();
                    objUser.Username = txtLoginUsername.Text.Trim();
                    UserMembership objMembership = new UserMembership(objUser);
                    objMembership.Username = objUser.Username.Trim();
                    objMembership.Password = txtLoginPassword.Text;
                    objUser.Membership     = objMembership;


                    PortalSettings  po          = new PortalSettings();
                    UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                    UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                    if (objUserInfo != null)
                    {
                        UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);



                        if (!string.IsNullOrEmpty(hdnRedirectUrl.Value))
                        {
                            if (hdnRedirectUrl.Value.ToLower() == "patientregistration")
                            {
                                Response.Redirect("/");
                            }
                            else
                            {
                                Response.Redirect("/" + hdnRedirectUrl.Value);
                            }
                        }
                        else
                        {
                            Response.Redirect("/redirect");
                        }
                    }
                    else
                    {
                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Please enter correct password!";
                        return;
                    }

                    //UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);
                    //Response.Redirect("/redirect");
                }
                // If User enters MRNo. which we do not have
                else
                {
                    var PatientDetails = objPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtLoginUsername.Text.Trim());


                    if (PatientDetails.MRNO != null && PatientDetails.WEBPWD != null)
                    {
                        DataSet dsVal = InsertUpdateUserDetails(PatientDetails.MRNO, PatientDetails.PatFName, PatientDetails.PatLName, PatientDetails.PatEmail, PatientDetails.WEBPWD, PatientDetails.PatMobile, PatientDetails.PatSex, PatientDetails.PatAddr1, PatientDetails.PatAge);


                        if (dsVal.Tables[0].Rows.Count == 1)
                        {
                            // loginStatus = UserLoginStatus.LOGIN_SUCCESS;

                            Session["IsVisitor"] = null;
                            UserInfo objUser = new UserInfo();
                            objUser.Username = txtLoginUsername.Text.Trim();
                            UserMembership objMembership = new UserMembership(objUser);
                            objMembership.Username = txtLoginUsername.Text.Trim();
                            objMembership.Password = txtLoginPassword.Text;
                            objUser.Membership     = objMembership;

                            PortalSettings  po          = new PortalSettings();
                            UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
                            UserInfo        objUserInfo = UserController.ValidateUser(0, objMembership.Username, txtLoginPassword.Text, "DNN", "", po.PortalName, this.Request.UserHostAddress, ref loginStatus);
                            if (objUserInfo != null)
                            {
                                UserController.UserLogin(0, objUser, Request.ServerVariables["SERVER_NAME"], this.Request.UserHostAddress, true);


                                //if (!string.IsNullOrEmpty(hdnRedirectUrl.Value))
                                //{
                                //    Response.Redirect("/" + hdnRedirectUrl.Value);
                                //}
                                //else
                                Response.Redirect("/redirect");
                            }
                            else
                            {
                                lblLoginError.CssClass = "errorText";
                                lblLoginError.Visible  = true;
                                lblLoginError.Text     = "Please enter correct password!";
                                return;
                            }
                        }
                    }
                    else
                    {
                        lblLoginError.CssClass = "errorText";
                        lblLoginError.Visible  = true;
                        lblLoginError.Text     = "Login Failed! You are not authorized to access Jaslok Portal!";
                    }
                }
            }
        }
    }
    protected void btnForgotPasword_Click(object sender, EventArgs e)
    {
        JaslokMailer      objMailer     = new JaslokMailer();
        List <Parameters> lstParameters = new List <Parameters>();
        string            lsEmailStatus = string.Empty;

        if (!IsNumber(txtForgotPasswordUserName.Text))
        {
            MembershipUser objUser = Membership.GetUser(txtForgotPasswordUserName.Text.Trim());
            if (objUser != null)
            {
                UserInfo objInfo = new UserInfo();
                objInfo = UserController.GetUserByName(objUser.UserName);
                string lsmobileNumber = objInfo.Profile.GetPropertyValue("PhoneNumber");
                string lsPassword;
                lsPassword = objUser.GetPassword();
                //sendmail(objUser.Email, lsPassword);
                if (!string.IsNullOrEmpty(lsmobileNumber))
                {
                    CommonFn.SendSMS(lsmobileNumber.Replace("-", ""), "Your password is: " + lsPassword);
                }
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text
                });
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Password", ShortCodeValue = lsPassword
                });
                lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, objInfo.Email, null);
                if (string.IsNullOrEmpty(lsEmailStatus))
                {
                    lblForgotPassError.Text     = "Password has been sent to your email address.";
                    lblForgotPassError.CssClass = "successText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                else
                {
                    lblForgotPassError.Text     = "Problem in sending email";
                    lblForgotPassError.CssClass = "errorText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                txtForgotPasswordUserName.Text = "";
                //lblGeneratedPassword.Text = lsPassword;
            }
            else
            {
                lblForgotPassError.CssClass    = "errorText";
                lblForgotPassError.Text        = "Username does not exist.";
                txtForgotPasswordUserName.Text = "";
                divLoginForm.Attributes.Add("style", "display:none;");
                divForgotPassword.Attributes.Add("style", "display:block;");
            }
        }
        else
        {
            PatIndex objPatIndex    = new PatIndex();
            var      PatientDetails = objPatIndex.GetPatientDetails("JEEVAPG", "JEEVAPG@16", txtForgotPasswordUserName.Text.Trim());

            if (PatientDetails.WEBPWD != null)
            {
                if (!string.IsNullOrEmpty(PatientDetails.WEBPWD))
                {
                    CommonFn.SendSMS(PatientDetails.PatMobile.Replace("-", ""), "Your password is: " + PatientDetails.WEBPWD);
                }
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Username", ShortCodeValue = txtForgotPasswordUserName.Text
                });
                lstParameters.Add(new Parameters {
                    ShortCodeName = "Password", ShortCodeValue = PatientDetails.WEBPWD
                });
                lsEmailStatus = objMailer.SendEmail("forgotpassword", lstParameters, PatientDetails.PatEmail, null);
                if (string.IsNullOrEmpty(lsEmailStatus))
                {
                    lblForgotPassError.Text     = "Password has been sent to your email address.";
                    lblForgotPassError.CssClass = "successText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                else
                {
                    lblForgotPassError.Text     = "Problem in sending email";
                    lblForgotPassError.CssClass = "errorText";
                    divLoginForm.Attributes.Add("style", "display:none;");
                    divForgotPassword.Attributes.Add("style", "display:block;");
                }
                txtForgotPasswordUserName.Text = "";
            }
            else
            {
                lblForgotPassError.Text     = "MRNumber not found, Please enter valid MRNumber.";
                lblForgotPassError.CssClass = "errorText";
                divLoginForm.Attributes.Add("style", "display:none;");
                divForgotPassword.Attributes.Add("style", "display:block;");
            }
        }
    }
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            spnStatus.Visible = true;

            lblMsg.Visible = false;
            string secret_key   = "ed70df7a017654499542ff0a5515812824b74142";
            string data         = "";
            string txnId        = Request["TxId"];
            string txnStatus    = Request["TxStatus"];
            string amount       = Request["amount"];
            string pgTxnId      = Request["pgTxnNo"];
            string issuerRefNo  = Request["issuerRefNo"];
            string authIdCode   = Request["authIdCode"];
            string firstName    = Request["firstName"];
            string lastName     = Request["lastName"];
            string pgRespCode   = Request["pgRespCode"];
            string zipCode      = Request["addressZip"];
            string resSignature = Request["signature"];

            bool flag = true;
            if (txnId != null)
            {
                data += txnId;
            }
            if (txnStatus != null)
            {
                data += txnStatus;
            }
            if (amount != null)
            {
                data += amount;
            }
            if (pgTxnId != null)
            {
                data += pgTxnId;
            }
            if (issuerRefNo != null)
            {
                data += issuerRefNo;
            }
            if (authIdCode != null)
            {
                data += authIdCode;
            }
            if (firstName != null)
            {
                data += firstName;
            }
            if (lastName != null)
            {
                data += lastName;
            }
            if (pgRespCode != null)
            {
                data += pgRespCode;
            }
            if (zipCode != null)
            {
                data += zipCode;
            }

            System.Security.Cryptography.HMACSHA1 myhmacsha1 = new System.Security.Cryptography.HMACSHA1(Encoding.ASCII.GetBytes(secret_key));

            System.IO.MemoryStream stream = new System.IO.MemoryStream(Encoding.ASCII.GetBytes(data));
            string signature = BitConverter.ToString(myhmacsha1.ComputeHash(stream)).Replace("-", "").ToLower();

            if (resSignature != null && !signature.Equals(resSignature))
            {
                flag = false;
            }
            if (flag == true)
            {
                //Response.Write("Thank You for using citrus payment Your Unique Transaction Status:" + Convert.ToString(txnStatus));
                if (Session["Bed"] != null || Session["Surgery"] != null || Session["AppointmentDetail"] != null || Session["HealthCheck-upComprehensive"] != null || Session["OutstandingBillPayment"] != null || Session["permenantRegistration"] != null || Session["ConsultationAppointment"] != null)
                {
                    DataAccessEntities sessionData = new DataAccessEntities();
                    if (Session["Bed"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["Bed"];
                    }
                    else if (Session["Surgery"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["Surgery"];
                    }
                    else if (Session["AppointmentDetail"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["AppointmentDetail"];
                    }
                    else if (Session["HealthCheck-upComprehensive"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["HealthCheck-upComprehensive"];
                    }
                    else if (Session["OutstandingBillPayment"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["OutstandingBillPayment"];
                    }
                    else if (Session["permenantRegistration"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["permenantRegistration"];
                    }
                    else if (Session["ConsultationAppointment"] != null)
                    {
                        sessionData = (DataAccessEntities)Session["ConsultationAppointment"];
                    }

                    //double Damount = Convert.ToDouble(amount);

                    sessionData.Tranrefid  = Convert.ToString(issuerRefNo);
                    sessionData.Transtatus = Convert.ToString(txnStatus);
                    sessionData.Amount     = Convert.ToInt32(Session["Amount"]);
                    sessionData.UserId     = user.UserID;

                    lblUserName.Text    = user.DisplayName;
                    lblMNo.Text         = user.Username; //= Convert.ToString(user.UserID);
                    lblTxtnId.Text      = sessionData.Transactionid = Convert.ToString(txnId);
                    lblPaidAgainst.Text = sessionData.FacilityName;
                    lblDateTime.Text    = Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy"));
                    lblAmount.Text      = Convert.ToString(Session["Amount"]) + ".00 INR";

                    if (txnStatus != null)
                    {
                        PatIndex objDeposit = new PatIndex();
                        if (Session["Bed"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["Bed"] = null;
                                Response.Redirect("/Bed-Booking");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, sessionData.Category, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "BedBookingPayment");
                            Session["Bed"] = null;
                        }

                        else if (Session["Surgery"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["Surgery"] = null;
                                Response.Redirect("/surgery-booking");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, sessionData.Category, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "SurgeryBookingPayment");
                            Session["Surgery"] = null;
                        }
                        else if (Session["HealthCheck-upComprehensive"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["HealthCheck-upComprehensive"] = null;
                                Response.Redirect("/health-check-up-comprehensive");
                            }
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            string _categoryName = sessionData.Category;
                            if (_categoryName == "Male" || _categoryName == "Female")
                            {
                                _categoryName = "Package B (" + sessionData.Category + ")";
                            }
                            ServiceBookingSendEmail(user.DisplayName, user.Email, sessionData.FacilityName, _categoryName, lblDateTime.Text, Convert.ToString(Session["Amount"]) + ".00 INR", "HealthCheckPayment");
                            Session["HealthCheck-upComprehensive"] = null;
                        }
                        else if (Session["OutstandingBillPayment"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["OutstandingBillPayment"] = null;
                                Response.Redirect("/outstandingbillpayment");
                            }

                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }

                            objBusinessLogic.SavePaymentBedSurgery(sessionData);
                            OutStandingSendEmail(sessionData.FacilityName, Convert.ToString(Session["Amount"]) + ".00 INR", "OutstandingPayment");
                            Session["OutstandingBillPayment"] = null;
                        }
                        else if (Session["permenantRegistration"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["permenantRegistration"] = null;
                                Response.Redirect("/");
                            }
                            Session["permenantRegistration"] = null;
                            lblMsg.Visible = true;



                            string Gender = user.Profile.GetPropertyValue("Gender");
                            if (Gender == "Male")
                            {
                                Gender = "M";
                            }
                            else
                            {
                                Gender = "F";
                            }
                            string Age         = user.Profile.GetPropertyValue("Age");
                            string Address     = user.Profile.GetPropertyValue("Address");
                            string PhoneNumber = user.Profile.GetPropertyValue("PhoneNumber");

                            string[] X = PhoneNumber.Split('-');
                            PhoneNumber = X[1];

                            string Username;
                            string Fname;
                            string Lname;
                            string Email;

                            if (user.Username.Length > 20)
                            {
                                Username = user.Username.Substring(0, 20);
                            }
                            else
                            {
                                Username = user.Username;
                            }

                            if (user.FirstName.Length > 30)
                            {
                                Fname = user.FirstName.Substring(0, 30);
                            }
                            else
                            {
                                Fname = user.FirstName;
                            }

                            if (user.LastName.Length > 30)
                            {
                                Lname = user.LastName.Substring(0, 30);
                            }
                            else
                            {
                                Lname = user.LastName;
                            }
                            if (user.Email.Length > 50)
                            {
                                Email = user.Email.Substring(0, 50);
                            }
                            else
                            {
                                Email = user.Email;
                            }
                            if (Address.Length > 30)
                            {
                                Address = Address.Substring(0, 30);
                            }

                            if (PhoneNumber.Length > 12)
                            {
                                PhoneNumber = PhoneNumber.Substring(0, 12);
                            }


                            var PatientDetails = objPatIndex.UpdateorInsertPatient(user.Username, user.FirstName, user.LastName, Gender, Age, "01/01/2000", Address, Address, Address, PhoneNumber, Email);

                            if (!string.IsNullOrEmpty(PatientDetails.WEBPWD))
                            {
                                DataSet ds = objBusinessLogic.IsExistMRNumber(PatientDetails.MRNO);
                                if (ds.Tables[0].Rows.Count > 0)
                                {
                                    Clear();
                                    lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                    lblMsg.Text      = "You Are Allready Registered As A permanent User!";
                                }
                                else
                                {
                                    bool IsUserExist = objBusinessLogic.IsUserExist(PatientDetails.MRNO);
                                    if (!IsUserExist)
                                    {
                                        if (PatientDetails.PatSex == "M")
                                        {
                                            PatientDetails.PatSex = "Male";
                                        }
                                        else
                                        {
                                            PatientDetails.PatSex = "Female";
                                        }
                                        DataSet dsVal = InsertUpdateUserDetails(PatientDetails.MRNO, PatientDetails.PatFName, PatientDetails.PatLName, PatientDetails.PatEmail, PatientDetails.WEBPWD, PatientDetails.PatMobile, PatientDetails.PatSex, PatientDetails.PatAddr1, PatientDetails.PatAge);
                                        lblMNo.Text = PatientDetails.MRNO;


                                        var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                                        if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                                        {
                                            sessionData.JeevaStatus = detaisl.MRNO;
                                        }

                                        objBusinessLogic.SavePaymentBedSurgery(sessionData);


                                        if (dsVal.Tables[0].Rows.Count > 0)
                                        {
                                            // SendMail & MSG

                                            try
                                            {
                                                PermanentUserSendEmail(PatientDetails.PatFName, PatientDetails.PatEmail, PatientDetails.MRNO, PatientDetails.WEBPWD, PhoneNumber, "PermanentRegistration");
                                                lblMsg.Text      = "You are now the permanent user! Please login with your MR Number that has been sent to your registered mobile number";
                                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#008000");
                                            }
                                            catch (Exception ex)
                                            {
                                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                                lblMsg.Text      = "SMS Service is stoped Due to technical problem!";
                                            }
                                            UserController.DeleteUser(ref user, false, false);
                                            UserController.RemoveUser(user);
                                            if (user.UserID != -1)
                                            {
                                                secure.SignOut();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Clear();
                                        lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                        lblMsg.Text      = "UserName allready exist!";
                                    }
                                }
                            }
                            else
                            {
                                Clear();
                                lblMsg.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FF0000");
                                lblMsg.Text      = "You are already register as a permanent user, Please login with MR Number";
                            }
                        }
                        else if (Session["ConsultationAppointment"] != null || Session["AppointmentDetail"] != null)
                        {
                            if (txnStatus == "CANCELED")
                            {
                                Session["ConsultationAppointment"] = null;
                                Session["AppointmentDetail"]       = null;
                                Response.Redirect("/");
                            }
                            sessionData.FacilityName = "Appointment";
                            var detaisl = objPatIndex.SaveDeposit(lblTxtnId.Text, lblMNo.Text, Convert.ToDouble(Session["Amount"]), Convert.ToString(DateTime.Now.ToString("dd/MM/yyyy")), sessionData.FacilityName);

                            if (detaisl != null && !string.IsNullOrEmpty(detaisl.MRNO))
                            {
                                sessionData.JeevaStatus = detaisl.MRNO;
                            }
                            sessionData.FacilityName = "Consultation Appointment";
                            objBusinessLogic.SavePaymentBookAppointment(sessionData);
                            AppointmentSendEmail(Convert.ToString(sessionData.PhoneNo), Convert.ToString(sessionData.MobileNo), Convert.ToString(sessionData.Location), Convert.ToString(sessionData.Address), Convert.ToString(sessionData.TimeDate), Convert.ToString(Session["Amount"]) + ".00 INR", Convert.ToString(sessionData.Description), sessionData.dName, "ConsultationAppointment");
                            Session["ConsultationAppointment"] = null;
                            Session["AppointmentDetail"]       = null;
                        }
                    }
                    else
                    {
                        plcDivSucces.Visible          = false;
                        plcDivError.Visible           = true;
                        spnStatus.Attributes["Class"] = "highlight";
                        spnStatus.InnerText           = "Payment Fail !";
                    }
                    Session["Amount"] = null;
                }
                else
                {
                    plcDivSucces.Visible          = false;
                    plcDivError.Visible           = true;
                    spnStatus.Attributes["Class"] = "highlight";
                    spnStatus.InnerText           = "Payment Fail !";
                }
            }
            else
            {
                Response.Write("Citrus Response Signature and Our (Merchant)Signature Mis - Match");
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }