Пример #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Plot         pl     = new Plot();
            int          plotid = int.Parse(txtPlotID.Text);
            DialogResult dr     = MessageBox.Show("Are you sure?", "There is no going back", MessageBoxButtons.YesNo);

            if (dr == DialogResult.Yes)
            {
                pl.deletePlot(plotid);
                ClientForm cf = new ClientForm(userid, farmid, plotid);
                cf.Show();
                this.Hide();
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string    username = txtUsername.Text;
            string    password = txtPassword.Text;
            User      us       = new User();
            DataTable details  = new DataTable();
            bool      allowed  = false;

            details = us.returnDetails();
            foreach (DataRow item in details.Rows)
            {
                if (item["UserName"].ToString() == username)
                {
                    if (item["UserPassword"].ToString() == password)
                    {
                        allowed = true;
                        if (allowed)
                        {
                            if (int.Parse(item["RoleID"].ToString()) == 1)
                            {
                                ScientificForm sf = new ScientificForm(int.Parse(item["UserID"].ToString()), 0, 0);
                                sf.Show();
                                this.Hide();
                            }
                            else if (int.Parse(item["RoleID"].ToString()) == 2)
                            {
                                ClientForm cf = new ClientForm(int.Parse(item["UserID"].ToString()), 0, 0);
                                cf.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("Invalid role. Contact support");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Login credentials are incorrect");
                        }
                    }
                    else
                    {
                        allowed = false;
                    }
                }
            }
        }
Пример #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Plot   pl          = new Plot();
            int    farmid      = int.Parse(txtFarmID.Text);
            int    plantid     = int.Parse(txtPlant.Text);
            string user        = txtUser.Text;
            string performance = txtPerformance.Text;

            pl.insertPlot(farmid, plantid, user, performance);
            DialogResult ds = MessageBox.Show("Successful", "Return to Client Form?", MessageBoxButtons.OK);

            if (ds == DialogResult.OK)
            {
                ClientForm cf = new ClientForm(userid, farmid, plotid);
                cf.Show();
                this.Hide();
            }
        }
Пример #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            User us       = new User();
            int  clientid = int.Parse(txtClientID.Text);

            if (userid == clientid)
            {
                DialogResult dr = MessageBox.Show("Are you sure?", "There is no going back", MessageBoxButtons.YesNo);
                if (dr == DialogResult.Yes)
                {
                    us.deleteUser(clientid);
                    ClientForm cf = new ClientForm(userid, farmid, plotid);
                    cf.Show();
                    this.Hide();
                }
            }
            else
            {
                MessageBox.Show("You cannot delete someone else");
            }
        }
Пример #5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            User   us        = new User();
            int    roleid    = int.Parse(txtRoleID.Text);
            string username  = txtUsername.Text;
            string password  = txtPassword.Text;
            string confirm   = txtConfirmPassword.Text;
            string vatID     = txtIDNum.Text;
            string contact   = txtContactNumber.Text;
            string email     = txtEmail.Text;
            string address   = txtAddress.Text;
            int    theuserid = userid;

            if (password == confirm)
            {
                if (theuserid == int.Parse(txtClientID.Text))
                {
                    us.updateUser(roleid, username, password, vatID, contact, email, address, theuserid);
                    DialogResult ds = MessageBox.Show("Successful", "Return to Client Form?", MessageBoxButtons.OK);
                    if (ds == DialogResult.OK)
                    {
                        ClientForm cf = new ClientForm(userid, farmid, plotid);
                        cf.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("You cannot update someone else");
                }
            }
            else
            {
                MessageBox.Show("Your passwords do not match");
            }
        }