private void button1_Click(object sender, EventArgs e) { MainSite mainSite = new MainSite(); mainSite.Show(); this.Close(); }
//For Sign Out private void button2_Click(object sender, EventArgs e) { Form1.enter = false; MainSite mainSite = new MainSite(); mainSite.Show(); this.Close(); }
//For Sign In private void button1_Click(object sender, EventArgs e) { /* * textBox1----password * textBox2----username * comboBox1---role */ if (textBox1.Text.Trim() == "" || textBox2.Text.Trim() == "" || comboBox1.Text.Trim() == "") { enter = false; MessageBox.Show("Null Values exit, please select login type, enter username and password", "Wrong", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (!(comboBox1.Text.Trim() == "Customer" || comboBox1.Text.Trim() == "Seller" || comboBox1.Text.Trim() == "Employee")) { MessageBox.Show("Are you are customer or seller or employee??", "Invalid Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (textBox1.Text.Trim().Length <= 5) { //Password length>6 enter = false; MessageBox.Show("the length of password should be more than 5", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { x.set.Reset(); role = comboBox1.Text.Trim(); string sql = null; if (role == "Customer") { sql = "select * from customer where CustomerId='" + textBox2.Text.Trim() + "'and PassWord='******'"; } else if (role == "Employee") { if (textBox2.Text.Trim().Length != 6) { MessageBox.Show("the length of id should be equal to 6", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = "select * from employee where EmployeeId='" + textBox2.Text.Trim() + "'and PassWord='******'"; } } else { if (textBox2.Text.Trim().Length != 6) { MessageBox.Show("the length of id should be equal to 6", "Invalid Password", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { sql = "select * from seller where SellerId='" + textBox2.Text.Trim() + "'and PassWord='******'"; } } if (sql != null) { x.query(sql); if (x.set.Tables[0].Rows.Count >= 0) { enter = true; username = textBox2.Text; if (role == "Customer") { MainSite mainSite = new MainSite(); mainSite.Show(); } else if (role == "Employee") { Information info = new Information(); info.Show(); } else { Seller seller = new Seller(); seller.Show(); } enter = true; this.Close(); } else { enter = false; MessageBox.Show("Username Or Password is wrong", "Invalid Sign In", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void Information_Load(object sender, EventArgs e) { this.Controls.Add(this.pictureBox2); this.Controls.Add(this.button1); this.Controls.Add(this.button2); this.Controls.Add(this.button3); this.Controls.Add(this.button4); this.Controls.Add(this.button7); this.Controls.Add(this.button5); this.Controls.Add(this.button1); this.Controls.Add(this.button9); this.Controls.Add(this.panel3); this.Controls.Add(this.label1); this.Controls.Add(this.label2); this.Controls.Add(this.label3); this.Controls.Add(this.label4); this.Controls.Add(this.label5); this.Controls.Add(this.label6); this.Controls.Add(this.label7); this.Controls.Add(this.label8); this.Controls.Add(this.label11); this.Controls.Add(this.textBox1); this.Controls.Add(this.textBox2); this.Controls.Add(this.textBox3); this.Controls.Add(this.textBox4); this.Controls.Add(this.textBox5); this.Controls.Add(this.textBox6); this.Controls.Add(this.textBox7); this.Controls.Add(this.button8); this.panel3.Controls.Add(this.button6); this.panel3.Controls.Add(this.label9); this.panel3.Controls.Add(this.dataGridView1); this.button5.Visible = false; //Main Site this.button9.Visible = false; //Payment management this.panel3.Visible = false; this.button7.Visible = false; //Employee management checkInventory = checkSeller = false; x.set.Reset(); string sql = null; this.button3.Text = "Shopping Cart"; if (Form1.role == "Customer") { this.panel3.Visible = true; this.button4.Visible = false; // Inventory Button this.button7.Visible = false; // Employee Button this.button1.Visible = false; // Seller Button this.button5.Visible = true; // Main Site this.label3.Text = "Email:"; this.textBox4.ReadOnly = false; this.button9.Visible = true; this.label9.Text = "Order Informaiton"; this.button6.Text = "Select Order"; this.label5.Text = "Address:"; sql = "select CustomerId,PassWord,LastName,FirstName,PhoneNumber,EmailId,Address from customer where CustomerId='" + Form1.username + "'"; } else { this.button3.Text = "Main Page"; this.label3.Text = "Supervisor:"; this.textBox4.ReadOnly = true; this.textBox5.ReadOnly = true; this.label5.Text = "Role:"; sql = "select EmployeeId,PassWord,LastName,FirstName,PhoneNumber,SupervisorId,DesignationRole from employee where EmployeeId='" + Form1.username + "'"; this.button4.Visible = true; // Inventory Button; this.button7.Visible = false; // Employee Button this.button1.Visible = true; //Seller Button } x.query(sql); if (x.set.Tables[0].Rows.Count > 0) { this.button8.Visible = true; //Update DataTable view = x.set.Tables[0]; textBox6.Text = view.Rows[0][0].ToString(); //username textBox7.Text = view.Rows[0][1].ToString(); //password textBox1.Text = view.Rows[0][2].ToString(); //last name textBox2.Text = view.Rows[0][3].ToString(); //first name textBox3.Text = view.Rows[0][4].ToString(); //phone number textBox4.Text = view.Rows[0][5].ToString(); //supervsior textBox5.Text = view.Rows[0][6].ToString(); //address/role if (textBox5.Text.Trim() == "Supervisor") { this.button7.Visible = true; } } else { MessageBox.Show("No data", "Wrong", MessageBoxButtons.OK, MessageBoxIcon.Information); MainSite mainSite = new MainSite(); this.Close(); mainSite.Close(); } }