Esempio n. 1
0
        private void adminEditButton_Click(object sender, EventArgs e)
        {
            if (dataGridAdmin.SelectedRows.Count == 1 && dataGridAdmin.Rows.Count > 0)
            {
                User user = null;
                //CurrentRow nie bedzie nigdy nullem bo jest pierwsze wybrane
                //bedzie nullem! trzeba sprawdzic
                int    userIndex = dataGridAdmin.CurrentRow.Index;
                string username  = dataGridAdmin.Rows[userIndex].Cells[0].Value.ToString();
                user = CommonFacade.GetUserByUsername(username);

                AdminEditForm adminEditForm = new AdminEditForm("Edit user", "Confirm", true, user);
                adminEditForm.ShowDialog(this);

                RefreshGrid();
            }
            else
            {
                MessageBox.Show("Select user !", "Select row ...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Esempio n. 2
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            //data from BizzLayer

            //User userSearchCriteria = new User();
            //userSearchCriteria.user_name = loginTextBox.Text;
            //IQueryable<User> resultRecords = UserFacade.GetUser(userSearchCriteria);
            User user = CommonFacade.GetUserByUsername(loginTextBox.Text);

            //próba dobicia sie do stringa z haslem
            if (user != null)
            {
                string passwordLogin = CryptoService.MD5Hash(passwordTextBox.Text);
                //var passwordSQL = resultRecords.FirstOrDefault().password;
                if (object.Equals(user.password, passwordLogin))
                {
                    if (user.retire_date == null ||
                        user.retire_date.Value < DateTime.Now.Date)
                    {
                        if (user.roles == "DOC")
                        {
                            int idDoctor = DoctorFacade.GetDoctorIdByUsername(user.user_name);
                            doctor = new Doctor(idDoctor);
                            doctor.ShowDialog();
                        }
                        else if (user.roles == "REG")
                        {
                            registrarForm = new RegistrarMainForm(loginTextBox.Text);
                            registrarForm.ShowDialog(this);
                        }
                        else if (user.roles == "LABM")
                        {
                            laboratory_mw = new Laboratory_MW(user.roles, loginTextBox.Text);
                            laboratory_mw.ShowDialog(this);
                        }
                        else if (user.roles == "LABW")
                        {
                            laboratory_mw = new Laboratory_MW(user.roles, loginTextBox.Text);
                            laboratory_mw.ShowDialog(this);
                        }
                        else if (user.roles == "ADM")
                        {
                            adminForm = new Admin();
                            adminForm.ShowDialog(this);
                        }
                    }
                    else
                    {
                        //MessageBox.Show("Can't access account because of retire date. Contact administrator");
                        MessageBox.Show("Can't access account because of retire date. Contact administrator", "Contact administrator ...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    //MessageBox.Show("Wrong login or password");
                    MessageBox.Show("Wrong login or password ! \nPlease check CapsLock and try again or contact administrator", "Wrong login or password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                //MessageBox.Show("Wrong login");
                MessageBox.Show("Wrong login or password", "Wrong login or password", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }