Пример #1
0
 public QtyForm(PosForm frmpos)
 {
     InitializeComponent();
     connect = new MySqlConnection();
     connect.ConnectionString = dbconnect.DataConnection();
     fpos = frmpos;
 }
Пример #2
0
 public ChangePasswordForm(PosForm frm)
 {
     InitializeComponent();
     connect = new MySqlConnection();
     connect.ConnectionString = dbconnect.DataConnection();
     f = frm;
 }
Пример #3
0
 public LookUpForm(PosForm frm)
 {
     InitializeComponent();
     connect = new MySqlConnection();
     connect.ConnectionString = dbconnect.DataConnection();
     posform         = frm;
     this.KeyPreview = true;
 }
Пример #4
0
 public SettleForm(PosForm fp)
 {
     InitializeComponent();
     connect = new MySqlConnection();
     connect.ConnectionString = dbconnect.DataConnection();
     fpos            = fp;
     this.KeyPreview = true;
 }
Пример #5
0
 public SeniorReceipt(PosForm frm)
 {
     InitializeComponent();
     connect = new MySqlConnection();
     connect.ConnectionString = dbconnect.DataConnection();
     f = frm;
     this.KeyPreview = true;
 }
Пример #6
0
        public DiscountForm(PosForm form)
        {
            InitializeComponent();
            connect = new MySqlConnection();
            connect.ConnectionString = dbconnect.DataConnection();

            f = form;
            this.KeyPreview = true;
        }
Пример #7
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            string _username = "", _role = "", _name = "";

            try
            {
                bool found = false;
                connect.Open();
                command = new MySqlCommand("SELECT * FROM users_tbl where username = @username AND password = @password", connect);
                command.Parameters.AddWithValue("@username", usertxt.Text);
                command.Parameters.AddWithValue("@password", passtxt.Text);
                DataReader = command.ExecuteReader();
                DataReader.Read();
                if (DataReader.HasRows)
                {
                    found     = true;
                    _username = DataReader["username"].ToString();
                    _role     = DataReader["role"].ToString();
                    _name     = DataReader["name"].ToString();
                }
                else
                {
                    found = false;
                }
                DataReader.Close();
                connect.Close();

                if (found == true)
                {
                    if (_role == "Cashier")
                    {
                        MessageBox.Show("Welcome " + _name + "!", "Access Granted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        usertxt.Text = "";
                        passtxt.Text = "";
                        this.Hide();
                        PosForm pf = new PosForm(this);
                        pf.usernamelbl.Text = _username;
                        pf.cashierlbl.Text  = _name + " | " + _role;
                        pf.ShowDialog();
                    }
                    else if (_role == "Administrator")
                    {
                        MessageBox.Show("Welcome " + _name + "!", "Access Granted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        usertxt.Text = "";
                        passtxt.Text = "";
                        this.Hide();
                        AdminPage frm = new AdminPage();
                        frm.nametxt.Text     = _name;
                        frm.usernametxt.Text = _username;
                        frm.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Invalid username" + _name + "!", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    usertxt.Text = "";
                    passtxt.Text = "";
                }
            }
            catch (Exception ex)
            {
                connect.Close();
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }