コード例 #1
0
 private void buttonListAllUsers_Click(object sender, EventArgs e)
 {
     try
     {
         radioInsert.Checked       = false;
         radioUpdate.Checked       = false;
         radioDelete.Checked       = false;
         comboBoxUserLevel.Enabled = false;
         UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
         dataGridViewListUsers.DataSource = userWS.GetAllUser();
         dataGridViewListUsers.Columns[Constants.fieldID].Visible        = false;
         dataGridViewListUsers.Columns[Constants.fieldLevelCode].Visible = false;
     }
     catch (SoapException ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         labelSystemMessage.ForeColor = System.Drawing.Color.Red;
         labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
     }
     catch (Exception ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         labelSystemMessage.ForeColor = System.Drawing.Color.Red;
         labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
     }
 }
コード例 #2
0
 private void UserForm_Load(object sender, EventArgs e)
 {
     try
     {
         UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
         dataGridViewListUsers.DataSource = userWS.GetAllUser();
         dataGridViewListUsers.Columns[Constants.fieldID].Visible        = false;
         dataGridViewListUsers.Columns[Constants.fieldLevelCode].Visible = false;
     }
     catch (SoapException ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         labelSystemMessage.ForeColor = System.Drawing.Color.Red;
         labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
     }
     catch (Exception ex)
     {
         //Error log simulate
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.GetBaseException().ToString());
         labelSystemMessage.ForeColor = System.Drawing.Color.Red;
         labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
     }
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        private void buttonSearchStudent_Click(object sender, EventArgs e)
        {
            try
            {
                radioInsert.Checked       = false;
                radioUpdate.Checked       = false;
                radioDelete.Checked       = false;
                comboBoxUserLevel.Enabled = false;
                labelSystemMessage.Text   = Constants.msgLabelDefault;

                if (textBoxNameForSearch.Text == "")
                {
                    labelSystemMessage.Text = Constants.msgUserNameBlank;
                }
                else
                {
                    UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();

                    dataGridViewListUsers.DataSource = userWS.GetUsersByName(textBoxNameForSearch.Text);
                    dataGridViewListUsers.Columns[Constants.fieldID].Visible        = false;
                    dataGridViewListUsers.Columns[Constants.fieldLevelCode].Visible = false;

                    if (dataGridViewListUsers.RowCount == 0)
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgNoMatchesFound;
                    }
                }
            }
            catch (SoapException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }
コード例 #5
0
        private void buttonSaveUserModification_Click(object sender, EventArgs e)
        {
            try
            {
                labelSystemMessage.Text = null;

                if (textBoxUserName.Text == null)
                {
                    labelSystemMessage.Text = Constants.msgUserNameBlank;
                }
                else
                {
                    UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                    int returnOperation             = userWS.updateUser(textBoxUserName.Text, staticUserPassword, comboBoxUserLevel.Text, staticUserID);
                    if (returnOperation < 1)
                    {
                        labelSystemMessage.Text = Constants.msgNoRecordUpdated;
                    }
                    else
                    {
                        labelSystemMessage.Text = Constants.msgOperationCompleted;
                        staticUserName          = textBoxUserName.Text;
                    }
                }
            }
            catch (SoapException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
        private void buttonExecute_Click(object sender, EventArgs e)
        {
            try
            {
                labelSystemMessage.ForeColor = System.Drawing.Color.Black;
                labelSystemMessage.Text      = Constants.msgLabelDefault;

                if (radioInsert.Checked)
                {
                    if (textBoxName.Text.Length == 0)
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgValidInformation;
                    }
                    else
                    {
                        int resultOperation             = 0;
                        UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                        resultOperation = userWS.InsertUser(textBoxName.Text, comboBoxUserLevel.Text);

                        if (resultOperation == 0)
                        {
                            labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                            labelSystemMessage.Text      = Constants.msgErrorBusinessToUser;
                        }
                        else
                        {
                            labelSystemMessage.Text = Constants.msgOperationCompleted;
                            this.UserMaintenanceForm_Load(sender, e);
                            dataGridViewListUsers.DataSource = null;
                        }
                    }
                }
                else if (radioUpdate.Checked)
                {
                    if ((textBoxName.Text.Length == 0) ||
                        (dataGridViewListUsers.DataSource == null && dataGridViewListUsers.SelectedRows.Count == 0))
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgSelectRecord;
                    }
                    else
                    {
                        int resultOperation             = 0;
                        UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                        int iDColumnIndex = (int)AppEnum.TabUserModel.ID;
                        int informationID = (int)dataGridViewListUsers.SelectedRows[0].Cells[iDColumnIndex].Value;

                        resultOperation = userWS.updateUserWithoutPassword(textBoxName.Text, comboBoxUserLevel.Text, informationID);

                        if (resultOperation == 0)
                        {
                            labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                            labelSystemMessage.Text      = Constants.msgErrorBusinessToUser;
                        }
                        else
                        {
                            labelSystemMessage.ForeColor     = System.Drawing.Color.Black;
                            labelSystemMessage.Text          = Constants.msgOperationCompleted;
                            dataGridViewListUsers.DataSource = null;
                        }
                    }
                }
                else if (radioDelete.Checked)
                {
                    if ((textBoxName.Text.Length == 0) ||
                        (dataGridViewListUsers.DataSource == null && dataGridViewListUsers.SelectedRows.Count == 0))
                    {
                        labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                        labelSystemMessage.Text      = Constants.msgSelectRecord;
                    }
                    else
                    {
                        int resultOperation             = 0;
                        UserWSIntegration.UserWS userWS = new UserWSIntegration.UserWS();
                        int iDColumnIndex = (int)AppEnum.TabUserModel.ID;
                        int informationID = (int)dataGridViewListUsers.SelectedRows[0].Cells[iDColumnIndex].Value;

                        resultOperation = userWS.deleteUser(informationID);

                        if (resultOperation == 0)
                        {
                            labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                            labelSystemMessage.Text      = Constants.msgErrorBusinessToUser;
                        }
                        else
                        {
                            labelSystemMessage.ForeColor     = System.Drawing.Color.Black;
                            labelSystemMessage.Text          = Constants.msgOperationCompleted;
                            dataGridViewListUsers.DataSource = null;
                        }
                    }
                }
                else
                {
                    labelSystemMessage.Text = Constants.msgSelectRecord;
                }
            }
            catch (SoapException ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorBusinessToUser + ex.Message;
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                labelSystemMessage.ForeColor = System.Drawing.Color.Red;
                labelSystemMessage.Text      = Constants.msgErrorSystemToUser;
            }
        }