Esempio n. 1
0
        private void lblHome_Click(object sender, EventArgs e)
        {
            CustHomeForm home = new CustHomeForm(usersTable);

            home.Show();
            this.Hide();
        }
        private void edit()
        {
            if (isChecked())
            {
                Users users = setUsers();

                int affectedRowCount = dataAccess.Insert <Users>(users, true);

                DataTable userTable = dataAccess.GetData <Users>($"where UserName = '******' and Password = '******'");
                if (affectedRowCount > 0)
                {
                    Customers customer = setCustomers();

                    affectedRowCount = dataAccess.Insert <Customers>(customer, true);

                    if (affectedRowCount > 0)
                    {
                        MessageBox.Show("Profile Edited Successfull");
                        CustHomeForm customerHome = new CustHomeForm(this.userTable);
                        customerHome.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Unable to save.");
                    }
                }
                else
                {
                    MessageBox.Show("Unable to save.");
                }
            }
        }
Esempio n. 3
0
        private void Action_According_Dialog_Result_1(DialogResult dialogResult)
        {
            if (dialogResult == DialogResult.Yes)
            {
                Product newproduct = setProduct();

                int rowsAffected = dataAccess.Insert <Product>(newproduct, true);
                if (rowsAffected > 0)
                {
                    MessageBox.Show($"Your Requested Submitted Successfully");
                    CustHomeForm ch = new CustHomeForm(UsersTable);
                    ch.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Something Went Wrong!!!");
                }
            }
            else
            {
                MessageBox.Show("Please be sure before confirming");
            }
        }
        private void login()
        {
            if (isEmpty())
            {
                DataTable userTable;
                userTable = dataAccess.GetData <Users>($"where UserName = '******' and Password = '******'");

                if (userTable.Rows.Count > 0)
                {
                    if (userTable.Rows[0].Field <int>("UserType") == (int)Users.UserTypeEnum.Admin)
                    {
                        AdminHomeForm adminHome = new AdminHomeForm(userTable);
                        adminHome.Show();
                        this.Hide();
                    }
                    else if (userTable.Rows[0].Field <int>("UserType") == (int)Users.UserTypeEnum.Employee)
                    {
                        if (userTable.Rows[0].Field <bool>("Information_given"))
                        {
                            DataTable employeeTable = dataAccess.GetData <Employee>($"where User_id = '{userTable.Rows[0].Field<int>("id")}'");
                            if (employeeTable.Rows[0].Field <int>("Designation") == (int)Employee.DesignationEnum.Manager)
                            {
                                EmpHomeForm employeeHome = new EmpHomeForm(userTable);
                                employeeHome.Show();
                                this.Hide();
                            }
                            else
                            {
                                MessageBox.Show("You are not a manager So you can't Login to the home page!!!");
                            }
                        }
                        else
                        {
                            EmpRegistration employeeRegistration = new EmpRegistration(userTable);
                            employeeRegistration.Show();
                            this.Hide();
                        }
                    }
                    else if (userTable.Rows[0].Field <int>("UserType") == (int)Users.UserTypeEnum.Customer)
                    {
                        DataTable customerTable = dataAccess.GetData <Customers>($"where User_Id = '{userTable.Rows[0].Field<int>("Id")}'");
                        if (customerTable.Rows[0].Field <bool>("Is_verified"))
                        {
                            CustHomeForm customeerHome = new CustHomeForm(userTable);
                            customeerHome.Show();
                            this.Hide();
                        }
                        else
                        {
                            MessageBox.Show("Please wait for verification");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("UserName or Password is not correct!!!");
                    errorProvider1.SetError(txtUserName, "User Name maybe wrong!!!");
                    errorProvider1.SetError(txtPassword, "Password Maybe wrong!!!");
                }
            }
        }