Exemplo n.º 1
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            string strUser;
            string strUserType;
            string strPass;
            string sMsg = "";

            strUser = txtUserID.Text;
            strPass = txtPassword.Text;

            DataSet   o_FindUser     = new DataSet();
            DataSet   o_FindEmployee = new DataSet();
            Users     oUsers         = new Users();
            Employees oEmployees     = new Employees();

            try
            {
                o_FindUser     = oUsers.FindData(strUser, strPass);
                o_FindEmployee = oEmployees.FindData(o_FindUser.Tables["Logins"].Rows[0]["EmployeeID"].ToString());

                sMsg        = "Welcome " + o_FindEmployee.Tables ["Employees"].Rows[0]["FName"].ToString();
                strUserType = o_FindEmployee.Tables["Employees"].Rows[0]["EType"].ToString();

                switch (strUserType)
                {
                case "Admission":
                case "Admin":
                case "Nurse":
                case "Doctor":
                    frmMenu menuForm = new frmMenu();
                    menuForm.oCurrent.UserName = strUser;
                    menuForm.oCurrent.Type     = strUserType;
                    menuForm.Visible           = true;
                    menuForm.Activate();
                    menuForm.SelectUser();
                    break;
                }
            }

            catch
            {
                if (cnt == 0)
                {
                    sMsg = "User not in database. Please try again.";
                }
                if (cnt == 1)
                {
                    sMsg = "User not in database. One try left.";
                }
                if (cnt == 2)
                {
                    sMsg = "Application is closing. Please contact your supervisor.";
                }
                txtUserID.Text   = "";
                txtPassword.Text = "";
            }
            finally
            {
                MessageBox.Show(sMsg, "", MessageBoxButtons.OK);
                txtUserID.Text   = "";
                txtPassword.Text = "";
            }

            if (cnt > 2)
            {
                Application.Exit();
            }
        }
Exemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var sMsg = "";

            var user     = txtUserID.Text;
            var password = txtPassword.Text;

            var oUsers = new Users();

            try
            {
                var oFind = oUsers.FindData(user, password);

                sMsg = "Welcome " + oFind.Tables["Login"].Rows[0]["UserName"].ToString();

                switch (user)
                {
                case "Admissions":
                    var admitForm = new FrmAdmissions
                    {
                        Visible = true
                    };

                    admitForm.Activate();

                    break;

                case "Admin":
                case "Nurse":
                case "Doctor":
                    var menuForm = new frmMenu();

                    menuForm.oCurrent.UserName = user;

                    menuForm.Visible = true;

                    menuForm.Activate();

                    menuForm.SelectUser();

                    break;
                }
            }
            catch (Exception exception)
            {
                switch (Cnt)
                {
                case 0:
                    sMsg = "User not in database. Please try again.";
                    break;

                case 1:
                    sMsg = "User not in database. One try left.";
                    break;

                case 2:
                    sMsg = "Application is closing. Please contact your supervisor.";
                    break;
                }

                txtUserID.Text   = "";
                txtPassword.Text = "";
            }
            finally
            {
                MessageBox.Show(sMsg, "", MessageBoxButtons.OK);
                txtUserID.Text   = "";
                txtPassword.Text = "";
            }
        }
Exemplo n.º 3
0
        private void btnLogin_Click(object sender, System.EventArgs e)
        {
            string strUser;
            string strPass;
            string sMsg = "";

            strUser = txtUserID.Text;
            strPass = txtPassword.Text;

            DataSet ds_Find = new DataSet();
            Users   oUsers  = new Users();

            try
            {
                ds_Find = oUsers.FindData(strUser, strPass);
                sMsg    = "Welcome " + strUser;

                switch (strUser)
                {
                case "Admissions":
                    frmAdmissions admitForm = new frmAdmissions();
                    admitForm.Visible = true;
                    admitForm.Activate();
                    break;

                case "Admin":
                    frmMenu a_menuForm = new frmMenu();
                    a_menuForm.oCurrent.UserName = strUser;
                    a_menuForm.Visible           = true;
                    a_menuForm.Activate();
                    a_menuForm.SelectUser();
                    break;

                case "Nurse":
                    frmMenu n_menuForm = new frmMenu();
                    n_menuForm.oCurrent.UserName = strUser;
                    n_menuForm.Visible           = true;
                    n_menuForm.Activate();
                    n_menuForm.SelectUser();
                    break;

                case "Doctor":
                    frmMenu d_menuForm = new frmMenu();
                    d_menuForm.oCurrent.UserName = strUser;
                    d_menuForm.Visible           = true;
                    d_menuForm.Activate();
                    d_menuForm.SelectUser();
                    break;
                }
            }

            catch
            {
                if (cnt == 0)
                {
                    sMsg = "User not in database. Please try again.";
                }
                if (cnt == 1)
                {
                    sMsg = "User not in database. One try left.";
                }
                if (cnt == 2)
                {
                    sMsg = "Application is closing. Please contact your supervisor.";
                }
                txtUserID.Text   = "";
                txtPassword.Text = "";
            }
            finally
            {
                MessageBox.Show(sMsg, "", MessageBoxButtons.OK);
                txtUserID.Text   = "";
                txtPassword.Text = "";
            }

            if (cnt > 2)
            {
                Application.Exit();
            }
        }