Exemple #1
0
        private void Authorize_Click(object sender, EventArgs e)
        {
            try
            {
                KreationService.Log log = null;

                log = new KreationService.Log();

                log.Username = UserName.Text;
                log.Password = PassWord.Text;
                log.type     = Type.Text;
                log.branch   = bid.Text;
                int q = client.add_Ac(log);
                if (q > 0)
                {
                    MetroMessageBox.Show(this, "User Added", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    MetroMessageBox.Show(this, "Adding Incomplete", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            load_gridview();
            dataGridView1.Update();
            dataGridView1.Refresh();

            UserName.Text = string.Empty;
            PassWord.Text = string.Empty;
            Type.Text     = string.Empty;
            bid.Text      = string.Empty;
        }
Exemple #2
0
        private void Sign_Click(object sender, EventArgs e)
        {
            KreationService.Log login = null;

            login = new KreationService.Log();
            try
            {
                login          = new KreationService.Log();
                AcceptButton   = Sign;
                login.Username = UserName.Text; /*assign textbox to string to pass server*/
                login.Password = Password.Text;
                login.type     = comboBox_Type.Text;
                login.branch   = comboBox_Branch.Text;

                String avl = client.login(login);/* Pass string to server and get return value then assign it to var */
                if (avl != login.type)
                {
                    MessageBox.Show("Retry, Incorrect Password or username");
                }

                else
                {
                    if (login.type == "Admin")
                    {
                        this.Hide();
                        Admin a = new Admin(login.Username);
                        a.ShowDialog();
                        this.Close();
                    }

                    else if (login.type == "Accountant" && login.branch == "Borella")
                    {
                        this.Hide();
                        Accountant ac = new Accountant(login.Username);
                        ac.ShowDialog();
                        this.Close();
                    }

                    else if (login.type == "Accountant" && login.branch == "Bamba")
                    {
                        this.Hide();
                        BAccountant bac = new BAccountant(login.Username);
                        bac.ShowDialog();
                        this.Close();
                    }

                    else if (login.type == "Accountant" && login.branch == "Wattala")
                    {
                        this.Hide();
                        WAccountant wac = new WAccountant(login.Username);
                        wac.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Guest" && login.branch == "Borella")
                    {
                        this.Hide();
                        Guest g = new Guest();
                        g.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Guest" && login.branch == "Bamba")
                    {
                        this.Hide();
                        BGuest bg = new BGuest();
                        bg.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Guest" && login.branch == "Wattala")
                    {
                        this.Hide();
                        WGuest wg = new WGuest();
                        wg.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Emp" && login.branch == "Borella")
                    {
                        this.Hide();
                        POS p = new POS(login.Username);
                        p.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Emp" && login.branch == "Bamba")
                    {
                        this.Hide();
                        BPOS p = new BPOS(login.Username);
                        p.ShowDialog();
                        this.Close();
                    }
                    else if (login.type == "Emp" && login.branch == "Wattala")
                    {
                        this.Hide();
                        WPOS p = new WPOS(login.Username);
                        p.ShowDialog();
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }