예제 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (Captcha1.IsValid == false)
            {
                litInfo.Text = "Invalid verification code! Please check.";
                Captcha1.Generate();
                Captcha1.Clear();
                txtPassword.Text = "";
                txtconpwd.Text   = "";
                RequiredFieldValidator2.ErrorMessage = "";
                return;
            }
            else
            {
                string saltedPasswordHash = txtPassword.Text;
                Captcha1.Generate();
                obj = new PPRDataBL();
                int designationid = 0;
                int department    = 0;
                if (ddl_NDesignation.SelectedValue == "99999")
                {
                    designationid = obj.insertDesignationDataBL(txtDesignation.Text);
                }
                if (ddlDeparment.SelectedValue == "99999" && txtOtherDepartment.Text != "")
                {
                    department = obj.insertDepartmentDataBL(ddlMinistry.SelectedValue, HttpUtility.HtmlEncode(txtOtherDepartment.Text));
                }

                int success = obj.sendPublicUserDataBL(ddlMinistry.SelectedValue, ddlDeparment.SelectedValue == "99999" && txtOtherDepartment.Text == "" ? ddlDeparment.SelectedValue : department.ToString(), ddl_NDesignation.SelectedValue == "99999" ? designationid.ToString() : ddl_NDesignation.SelectedValue, HttpUtility.HtmlEncode(txtloginId.Text)
                                                       , HttpUtility.HtmlEncode(saltedPasswordHash), HttpUtility.HtmlEncode(txt_NName.Text), HttpUtility.HtmlEncode(""), HttpUtility.HtmlEncode(txt_NAddress1.Text),
                                                       HttpUtility.HtmlEncode(txt_NAddress2.Text), HttpUtility.HtmlEncode(txt_NAddress3.Text), HttpUtility.HtmlEncode(txt_NTelephone.Text), HttpUtility.HtmlEncode(txt_NMobile.Text), HttpUtility.HtmlEncode(txt_NEmail.Text));
                SaveToPDF(HttpUtility.HtmlEncode(HttpUtility.HtmlEncode(txtloginId.Text)));
                if (success > 0)
                {
                    string      folderPath = Server.MapPath("~/writedata/UserRegisteration/");
                    string      FileName   = (folderPath + ViewState["UserRegisterationFile"].ToString());
                    MailUtility objm       = new MailUtility();
                    objm.SendUserDetailsMail(txt_NEmail.Text, "User Registration", txtloginId.Text, FileName, hdnPassCap.Value.ToString());
                    Captcha1.Clear();
                    reset();
                    string strScript = "<script>" + "alert('Data save successfully, Details send on your mail, You can login after verified by your admin.');";
                    strScript += "window.location='Login.aspx';";
                    strScript += "</script>";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Startup", strScript);
                    Session["UserEmail"] = null;
                    Session["LoginID"]   = null;
                }
                else
                {
                    Alert.show("User already exist please choose another user id");
                    Captcha1.Clear();
                }
            }
        }

        catch (Exception ex)
        {
            LogError(ex);
        }
    }