Exemplo n.º 1
0
        private void goBack_Click(object sender, EventArgs e)
        {
            SqlConnection  sqlConn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Hashika\Desktop\Spark-master\Spark\spark_database.mdf;Integrated Security=True");
            string         query   = "SELECT * FROM tbluser where username='******'";
            SqlDataAdapter data    = new SqlDataAdapter(query, sqlConn);
            DataTable      dtbl    = new DataTable();

            data.Fill(dtbl);
            if (dtbl.Rows.Count != 0)
            {
                int type = 0;
                foreach (DataRow row in dtbl.Rows)
                {
                    type = Convert.ToInt16(row["type"].ToString());
                }
                if (type == 1 | type == 2)
                {
                    //if it is cashier
                    this.Hide();
                    user userform = new user();
                    userform.setUsername(username);
                    userform.setDataGrid(this.checkoutDataGrid);
                    userform.ShowDialog();
                    this.Close();
                }
                else if (type == 4)
                {
                    //if it is special customer
                    this.Hide();
                    specialCustomer specialcustomer = new specialCustomer();
                    specialcustomer.setUsername(username);
                    specialcustomer.setDataGrid(this.checkoutDataGrid);
                    specialcustomer.ShowDialog();
                    this.Close();
                }
            }
        }
Exemplo n.º 2
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text.Trim();
            string password = txtPassword.Text.Trim();

            //setting ms sql connection
            SqlConnection  sqlConn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Maneesha\Desktop\Spark\Spark\spark_database.mdf;Integrated Security=True");
            string         query   = "SELECT * FROM tbluser where username='******'and password='******'";
            SqlDataAdapter data    = new SqlDataAdapter(query, sqlConn);
            DataTable      dtbl    = new DataTable();

            data.Fill(dtbl);
            if (dtbl.Rows.Count != 0)
            {
                int type = 0;
                foreach (DataRow row in dtbl.Rows)
                {
                    type = Convert.ToInt16(row["type"].ToString());
                }
                if (type == 1)
                {
                    this.Hide();
                    //go to the view userForm
                    user userForm = new user();
                    userForm.setUsername(username);
                    userForm.ShowDialog();
                    this.Close();
                }
                else if (type == 2)
                {
                    //go to supplier
                    this.Hide();
                    supplier supplierform = new supplier();
                    supplierform.setUsername(username);
                    supplierform.ShowDialog();
                    this.Close();
                }
                else if (type == 3)
                {
                    //go to admin
                    this.Hide();
                    admin admin = new admin();
                    admin.setUsername(username);
                    admin.ShowDialog();
                    this.Close();
                }
                else if (type == 4)
                {
                    //go to customer
                    this.Hide();
                    specialCustomer specialcustomer = new specialCustomer();
                    specialcustomer.setUsername(username);
                    specialcustomer.ShowDialog();
                    this.Close();
                }
            }
            else
            {
                this.checkCredentials.Visible = true;
            }
        }