Ejemplo n.º 1
0
        /// <summary>
        /// login check code for user and password
        /// then return true value if it's correct
        /// show the right control panel and save logs
        /// </summary>
        public static bool UserLogin()
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("accounts").Where("Username", UserName).And("Password", UserPassword);
                MySqlReader r = new MySqlReader(cmd);
                if (r.Read())
                {
                    State = (States.AccountState)r.ReadByte("State");
                    switch (State)
                    {
                    case States.AccountState.Manager:
                    {
                        SaveLogin();
                        Console.WriteLine(UserName + " login as admin ha, i should go back to work then");
                        return(true);
                    }

                    case States.AccountState.Employee:
                    {
                        SaveLogin();
                        Console.WriteLine(UserName + " what's up fellow worker");
                        return(true);
                    }

                    default:
                        MessageBox.Show("من انت؟ هل تعمل فى هذه الصيدليه؟");
                        Console.WriteLine("User states is unknown");
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("أسم المستخدم و/او كلمه المرور خطأ");
                    return(false);
                }
            }
            catch (Exception ll)
            {
                Console.WriteLine("Error while logging in");
                Core.SaveException(ll);
                return(false);
            }
            finally
            {
                UserPassword = null;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// login check code
        /// </summary>
        public static bool UserLogin()
        {
            try
            {
                MySqlCommand cmd = new MySqlCommand(MySqlCommandType.SELECT);
                cmd.Select("accounts").Where("Username", UserName).And("Password", UserPassword);
                MySqlReader r = new MySqlReader(cmd);
                if (r.Read())
                {
                    State = (States.AccountState)r.ReadByte("State");
                    switch (State)
                    {
                    case States.AccountState.Manager:
                    {
                        Manager ma = new Manager();
                        ma.Show();
                        SaveLogin();
                        return(true);
                    }

                    case States.AccountState.Employee:
                    {
                        CPanal gui = new CPanal();
                        gui.Show();
                        SaveLogin();
                        return(true);
                    }

                    default:
                        MessageBox.Show("من انت؟ هل تعمل فى هذه الصيدليه؟");
                        return(false);
                    }
                }
                else
                {
                    MessageBox.Show("أسم المستخدم و/او كلمه المرور خطأ");
                    return(false);
                }
            }
            catch (Exception ll)
            {
                Program.SaveException(ll);
                return(false);
            }
        }