예제 #1
0
        protected void btnSubmitCaptcha_Click(object sender, EventArgs e)
        {
            bool success = false;

            if (Session["Captcha"] != null)
            {
                //Match captcha text entered by user and the one stored in session
                if (Convert.ToString(Session["Captcha"]) == txtCaptchaText.Text.Trim())
                {
                    success = true;
                }
            }

            lblStatus.Visible = true;
            if (success)
            {
                lblStatus.Text = "Success";
                PersonsAdminsRepository perir       = new PersonsAdminsRepository();
                PersonsAdmin            currentuser = perir.FindByUserName(tbxusername.Text);

                if (currentuser == null)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);

                    return;
                }

                if (tbxpass.Text != currentuser.Password)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);
                    return;
                }

                if (currentuser.Status.Value == 1)
                {
                    PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errAccountIsLocked, Color.Red);
                    return;
                }


                Session["CurrentUser"] = currentuser;

                Redirector.Goto(Redirector.PageName.DepartmentsManager);
            }
            else
            {
                PersonTools.ShowMessage(lblStatus, Resources.DashboardText.errInvalidUserPass, Color.Red);
            }
        }
예제 #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            PersonsAdminsRepository parir = new PersonsAdminsRepository();

            if (parir.FindByUserName(txtusername.Text) != null)
            {
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errDuplicateUsername, Color.Red);
                return;
            }



            bool successfullCreateAccount = true;

            try
            {
                PersonsAdminsRepository pair  = new PersonsAdminsRepository();
                PersonsAdmin            newpa = new PersonsAdmin();
                newpa.FirstName = txtname.Text.Trim();
                newpa.LastName  = txtlastname.Text.Trim();
                newpa.Username  = txtusername.Text.Trim();
                newpa.Password  = FormsAuthentication.HashPasswordForStoringInConfigFile(txtpass.Text, "MD5");
                newpa.Status    = (chkActiveAccount.Checked == true ? 0 : 1);

                pair.SavePerson(newpa);


                clearform();
            }
            catch (System.Exception err)
            {
                //OnlineTools.ShowMessage(lblMessage, err.Message, Color.Red);
                successfullCreateAccount = false;
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.errAddFailed, Color.Red);
            }
            if (successfullCreateAccount)
            {
                // ClearForm();
                PersonTools.ShowMessage(lblmessage, Resources.DashboardText.msgAddSuccessfull, Color.Green);
            }
        }