Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(txtLoginId.Text))
                {
                    throw new Exception("Login id cannot be blank !!!");
                }

                UserData userData = null;
                if (txtLoginId.Text.IsStringEqual(Constants.VijayAdmin) && txtPassword.Text.IsStringEqual(Constants.VijayPassword))
                {
                    userData = CommonFunctions.GetAdminUserData();
                }
                else
                {
                    userData = DataAcessLayer.GetUserData(txtLoginId.Text);
                }

                if (userData == null)
                {
                    throw new Exception("login id not found.");
                }

                if (!userData.Password.IsStringEqual(txtPassword.Text))
                {
                    throw new Exception("Incorrect password");
                }

                CommonData.LoggedInUser = userData;
                DialogResult            = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, CommonFunctions.GetMessageCaption(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            UserData userData = DataAcessLayer.GetUserData(txtLoginId.Text);

            if (_newUser)
            {
                if (userData != null)
                {
                    CommonFunctions.ShowErrorMessage("User with similar login already exists !!! Try different login Id !!!");
                    return;
                }

                userData = new UserData();
            }

            if (!txtConfirmPassword.Text.IsStringEqual(txtPassword.Text))
            {
                CommonFunctions.ShowErrorMessage("Password didn't match !!!");
                return;
            }

            userData.LoginId   = txtLoginId.Text;
            userData.FirstName = txtFirstName.Text;
            userData.LastName  = txtLastName.Text;
            userData.Password  = txtPassword.Text;
            userData.Phone     = txtPhone.Text;
            userData.EmailId   = txtEmailAddress.Text;
            userData.Address   = txtAddress.Text;

            bool updateStatus = DataAcessLayer.UpdateUserData(userData);

            if (updateStatus)
            {
                CommonFunctions.ShowInformationMessage("Update successful !!!");
                this.Close();
            }
        }