private void buttonConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                labelReturnMsg.Text = null;

                if (textBoxNewPassword.Text == staticUserPassword)
                {
                    labelReturnMsg.Text = Constants.msgPasswordEqualsToPrevious;
                }
                else if (string.IsNullOrEmpty(textBoxNewPassword.Text))
                {
                    labelReturnMsg.Text = Constants.msgNewPasswordBlank;
                }
                else if (string.IsNullOrEmpty(textBoxConfirmPassword.Text))
                {
                    labelReturnMsg.Text = Constants.msgConfirmPasswordBlank;
                }
                else if (textBoxNewPassword.Text != textBoxConfirmPassword.Text)
                {
                    labelReturnMsg.Text = Constants.msgNewAndConfirmPasswordNotEquals;
                }
                else
                {
                    LoginValidationWSIntegration.LoginValidationWS loginWS = new LoginValidationWSIntegration.LoginValidationWS();
                    loginWS.passwordFormatValidation(textBoxNewPassword.Text);
                    loginWS.passwordFormatValidation(textBoxConfirmPassword.Text);

                    UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                    int resultQuery = userWS.updateUser(staticUserName, textBoxNewPassword.Text, staticUserLevelDescription, staticUserID);
                    if (resultQuery < 1)
                    {
                        labelReturnMsg.Text = Constants.msgErrorBusinessToUser;
                    }
                    else
                    {
                        staticUserPassword = textBoxNewPassword.Text;
                        this.Close();
                    }
                }
            }
            catch (SoapException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelReturnMsg.ForeColor = System.Drawing.Color.Red;
                labelReturnMsg.Text      = ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelReturnMsg.ForeColor = System.Drawing.Color.Red;
                labelReturnMsg.Text      = Constants.msgErrorSystemToUser;
            }
        }
Beispiel #2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                labelReturnMsg.Text = null;

                if ((string.IsNullOrEmpty(textBoxUserName.Text)) && (string.IsNullOrEmpty(textBoxPassword.Text)))
                {
                    labelReturnMsg.Text = Constants.msgNamePasswordBlank;
                }
                else if (string.IsNullOrEmpty(textBoxUserName.Text))
                {
                    labelReturnMsg.Text = Constants.msgUserNameBlank;
                }
                else if (string.IsNullOrEmpty(textBoxPassword.Text))
                {
                    labelReturnMsg.Text = Constants.msgPasswordBlank;
                }
                else
                {
                    LoginValidationWSIntegration.LoginValidationWS loginWS = new LoginValidationWSIntegration.LoginValidationWS();
                    loginWS.passwordFormatValidation(textBoxPassword.Text);

                    UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                    DataTable dataTableUserLogin    = userWS.UserLogin(textBoxUserName.Text, textBoxPassword.Text);

                    if (dataTableUserLogin.Rows.Count == 0)
                    {
                        labelReturnMsg.Text = Constants.msgNoMatchesFound;
                    }
                    else
                    {
                        //pass to Myform the informations of the user
                        staticUserID               = Convert.ToInt32(dataTableUserLogin.Rows[0][Constants.fieldID]);
                        staticUserName             = dataTableUserLogin.Rows[0][Constants.fieldName].ToString();
                        staticUserLevelCode        = Convert.ToInt32(dataTableUserLogin.Rows[0][Constants.fieldLevelCode]);
                        staticUserLevelDescription = dataTableUserLogin.Rows[0][Constants.fieldLevelDescription].ToString();
                        staticUserPassword         = textBoxPassword.Text;

                        if (staticUserLevelCode == Constants.userCode)
                        {
                            System.Threading.Thread threadChangePasswordForm = new System.Threading.Thread(new System.Threading.ThreadStart(OpenChangePasswordForm));
                            threadChangePasswordForm.Start();
                            System.Threading.Thread threadLybraryBaseForm = new System.Threading.Thread(new System.Threading.ThreadStart(OpenLybraryTemplateForm));
                            threadLybraryBaseForm.Start();
                            this.Close();
                        }
                        else
                        {
                            System.Threading.Thread threadLybraryBaseForm = new System.Threading.Thread(new System.Threading.ThreadStart(OpenLybraryTemplateForm));
                            threadLybraryBaseForm.Start();
                            this.Close();
                        }
                    }
                }
            }
            catch (SoapException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelReturnMsg.ForeColor = System.Drawing.Color.Red;
                labelReturnMsg.Text      = ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelReturnMsg.ForeColor = System.Drawing.Color.Red;
                labelReturnMsg.Text      = Constants.msgErrorSystemToUser;
            }
        }