private void metroTextButtonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                hmsDataContext DBcon = new hmsDataContext();
                Login_         log   = new Login_();
                log = DBcon.Login_s.SingleOrDefault(x => x.LoginUserName == metroTextBox1.Text && x.LoginPassword == metroTextBox2.Text);

                if (log.Profile == "ADMIN" && log.LoginUserName == "admin" && metroTextBox1.Text == log.LoginUserName && metroTextBox2.Text == log.LoginPassword)
                {
                    user = metroTextBox1.Text;
                    FormMain.ActiveForm.Hide();
                    new FormAdmin().Show();
                    metroTextBox1.Clear();
                    metroTextBox2.Clear();
                }
                if (log.Profile != "ADMIN")
                {
                    if (log.Profile == "DOCTOR" && metroTextBox1.Text == log.LoginUserName && metroTextBox2.Text == log.LoginPassword)
                    {
                        user = metroTextBox1.Text;
                        FormMain.ActiveForm.Hide();
                        new FormDoctor().Show();
                        metroTextBox1.Clear();
                        metroTextBox2.Clear();
                    }
                }
                if (log.Profile != "ADMIN" && log.Profile != "DOCTOR")
                {
                    if (log.Profile == "ACCOUNTANT" && metroTextBox1.Text == log.LoginUserName && metroTextBox2.Text == log.LoginPassword)
                    {
                        user = metroTextBox1.Text;
                        FormMain.ActiveForm.Hide();
                        new FormAccountant().Show();
                        metroTextBox1.Clear();
                        metroTextBox2.Clear();
                    }
                }
                if (log.Profile != "ADMIN" && log.Profile != "DOCTOR" && log.Profile != "ACCOUNTANT")
                {
                    if (log.Profile == "RECEPTIONIST" && metroTextBox1.Text == log.LoginUserName && metroTextBox2.Text == log.LoginPassword)
                    {
                        user = metroTextBox1.Text;
                        FormMain.ActiveForm.Hide();
                        new FormReceptionist().Show();
                        metroTextBox1.Clear();
                        metroTextBox2.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "Incorrect Username or Password", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                metroTextBox1.Clear();
                metroTextBox2.Clear();
            }
        }
Exemple #2
0
        private void metroTextButtonAddDoctorConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                hmsDataContext dbcon = new hmsDataContext();
                Doctor_        dc    = new Doctor_();
                Login_         lg    = new Login_();
                Salary_        sl    = new Salary_();
                Department     dp    = new Department();

                dc.DoctorName     = metroTextBox1.Text;
                dc.DoctorEmail    = metroTextBox3.Text;
                dc.DoctorAddress  = metroTextBox6.Text;
                dc.DoctorPhone    = metroTextBox7.Text;
                dc.DoctorUsername = metroTextBox9.Text;
                dc.DoctorProfile  = metroComboBox1.Text;
                dc.DoctorGender   = metroComboBox2.Text;
                dc.DoctorAge      = metroTextBox5.Text;
                dc.DoctorSalary   = metroTextBox8.Text;

                lg.LoginPassword = metroTextBox10.Text;
                lg.LoginUserName = metroTextBox9.Text;
                lg.Profile       = metroComboBox1.Text;

                sl.Name    = metroTextBox1.Text;
                sl.Salary  = metroTextBox8.Text;
                sl.Profile = metroComboBox1.Text;
                dc.DoctorDepartmentName = metroComboBox3.Text;
                dbcon.Doctor_s.InsertOnSubmit(dc);
                dbcon.Login_s.InsertOnSubmit(lg);
                dbcon.Salary_s.InsertOnSubmit(sl);
                dbcon.SubmitChanges();
                // MessageBox.Show("Succesfully saved!!");
                MetroMessageBox.Show(this, "Succesfully Saved.", "Congratulation!!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                metroTextBox1.Clear();
                metroTextBox3.Clear();
                metroTextBox5.Clear();
                metroTextBox6.Clear();
                metroTextBox7.Clear();
                metroTextBox8.Clear();
                metroTextBox9.Clear();
                metroTextBox10.Clear();
                metroComboBox1.SelectedItem = null;
                metroComboBox2.SelectedItem = null;
                metroComboBox3.SelectedItem = null;
            }

            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "Username already exist.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                metroTextBox9.Clear();
                // metroTextBox2.Clear();
            }
        }
Exemple #3
0
        private void metroTextButtonAddAccountantConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                hmsDataContext dbcon = new hmsDataContext();
                Accountant_    ac    = new Accountant_();
                Login_         lg    = new Login_();
                Salary_        sl    = new Salary_();

                ac.AccountantName     = metroTextBox1.Text;
                ac.AccountantAddress  = metroTextBox3.Text;
                ac.AccountantPhone    = metroTextBox4.Text;
                ac.AccountantUsername = metroTextBox6.Text;
                ac.AccountantProfile  = metroComboBox1.Text;
                ac.AccountantSalary   = metroTextBox5.Text;

                lg.LoginPassword = metroTextBox7.Text;
                lg.LoginUserName = metroTextBox6.Text;
                lg.Profile       = metroComboBox1.Text;

                sl.Name    = metroTextBox1.Text;
                sl.Salary  = metroTextBox5.Text;
                sl.Profile = metroComboBox1.Text;

                dbcon.Salary_s.InsertOnSubmit(sl);
                dbcon.Login_s.InsertOnSubmit(lg);
                dbcon.Accountant_s.InsertOnSubmit(ac);
                dbcon.SubmitChanges();

                // MessageBox.Show("Succesfully saved!!");
                MetroMessageBox.Show(this, "Succesfully Saved.", "Congratulation!!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                metroTextBox1.Clear();
                metroTextBox3.Clear();
                metroTextBox4.Clear();
                metroTextBox5.Clear();
                metroTextBox6.Clear();
                metroTextBox7.Clear();
                metroComboBox1.SelectedItem = null;
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "Username already exist.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                metroTextBox6.Clear();
            }
        }
Exemple #4
0
        private void metroTextButtonLogin_Click(object sender, EventArgs e)
        {
            Login_ log = new Login_();

            try
            {
                log = DBcon.Login_s.SingleOrDefault(x => x.LoginUserName == metroTextBox1.Text && x.LoginPassword == metroTextBox2.Text);
                if (log != null)
                {
                    user = log.LoginUserName;
                    this.Hide();
                    metroTextBox1.Clear();
                    metroTextBox2.Clear();
                    var profile = log.Profile.ToString();
                    if (profile == "ADMIN")
                    {
                        var adminForm = new FormAdmin();
                        adminForm.Show();
                    }
                    else if (profile == "DOCTOR")
                    {
                        var doctorForm = new FormDoctor();
                        doctorForm.Show();
                    }
                    else if (profile == "ACCOUNTANT")
                    {
                        var accform = new FormAccountant();
                        accform.Show();
                    }
                    else if (profile == "RECEPTIONIST")
                    {
                        var recform = new FormReceptionist();
                        recform.Show();
                    }
                }
                else
                {
                    MetroMessageBox.Show(this, "Incorrect Login Details", "Login Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, ex.Message, "Critical Error", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }
        private void metroTextButtonReceptionistChangePassword_Click(object sender, EventArgs e)
        {
            hmsDataContext dbcon = new hmsDataContext();

            if (dbcon.Login_s.Any(x => x.LoginUserName == FormMain.user && x.LoginPassword == metroTextBox2.Text) == true)
            {
                if (metroTextBox7.Text.Length < 6)
                {
                    MetroMessageBox.Show(this, "Please, select a password with at least 6 characters.", "Warning!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation);
                }
                else if (metroTextBox7.Text != metroTextBox1.Text)
                {
                    MetroMessageBox.Show(this, "Password doesn't match.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
                }
                else
                {
                    Login_ lg = new Login_();
                    lg = dbcon.Login_s.SingleOrDefault(x => x.LoginUserName == FormMain.user);

                    if (lg != null)
                    {
                        lg.LoginUserName = metroLabel10.Text;
                        lg.LoginPassword = metroTextBox1.Text;
                        dbcon.SubmitChanges();
                        //MetroMessageBox.Show(this, "Your password has been changed successfully. Please login with your new password.", "Congratulation!!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        //this.Dispose();
                        //FormReceptionist.ActiveForm.Dispose();
                        //new FormMain().Show();
                        MetroMessageBox.Show(this, "Your password has been changed successfully. Please restart the application and login with your new password.", "Congratulation!!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        Application.Exit();
                    }
                }
            }
            else
            {
                MetroMessageBox.Show(this, "Your password is incorrect.", "Halt!!!", MessageBoxButtons.RetryCancel, MessageBoxIcon.Error);
            }
        }