private void btnAddCustomer_Click(object sender, EventArgs e) { if (tbxAreaCode.Text.Length == 3) { if (tbxPhoneNo.Text.Length == 7) { if (String.IsNullOrEmpty(tbxFirstname.Text) == false) { if (String.IsNullOrEmpty(tbxLastname.Text) == false) { if (String.IsNullOrEmpty(tbxEmail.Text) == false) { try { firstname = tbxFirstname.Text; lastname = tbxLastname.Text; email = tbxEmail.Text; phoneno = Int64.Parse(tbxAreaCode.Text + tbxPhoneNo.Text); string query = $"insert into customer values('{lastname}','{firstname}','{email}',{phoneno});"; Filler.InserterDeleter(query); DataViewControl dvc = new DataViewControl(); this.Hide(); dvc.tabControl1.SelectedTab = dvc.customerPage; dvc.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Please Enter Email"); } } else { MessageBox.Show("Please Enter Last Name"); } } else { MessageBox.Show("Please Enter First Name"); } } else { MessageBox.Show("Please Enter Valid Phone Number"); } } else { MessageBox.Show("Please Enter Valid Phone Number"); } }
private void btnExit_Click(object sender, EventArgs e) { DataViewControl dvc = new DataViewControl(); this.Hide(); dvc.tabControl1.SelectedTab = dvc.customerPage; dvc.ShowDialog(); this.Close(); }
private void btnAddSale_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are You Sure", "Warning", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { try { string vin = this.inventoryGrid.CurrentRow.Cells[0].Value.ToString(); Int64 telephone = Int64.Parse(this.customerGrid.CurrentRow.Cells[2].Value.ToString()); price = decimal.Parse(tbxPrice.Text); string query = "select inventoryID " + "from inventory " + $"where vin = '{vin}';"; DataTable idtbl = Filler.DataTableFiller(query); foreach (DataRow row in idtbl.Rows) { inventoryID = int.Parse(row["inventoryID"].ToString().Trim()); } string query2 = "select customerID " + "from customer " + $"where telephone = {telephone};"; DataTable cdtbl = Filler.DataTableFiller(query2); foreach (DataRow row in cdtbl.Rows) { customerID = int.Parse(row["customerID"].ToString().Trim()); } string salesquery = $"insert into sales values({inventoryID},{customerID},{price}); " + $"update inventory set sold = 1 where inventoryID = {inventoryID};"; Filler.InserterDeleter(salesquery); DataViewControl dvc = new DataViewControl(); this.Hide(); dvc.tabControl1.SelectedTab = dvc.salesPage; dvc.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else if (dialogResult == DialogResult.No) { } }
private void btnLogIn_Click(object sender, EventArgs e) { string username = tbxUsername.Text; string password = tbxPassword.Text; string queryUsername = $"select username, password from account " + $"where username = '******';"; DataTable Usernamedtbl = Filler.DataTableFiller(queryUsername); if (Usernamedtbl.Rows.Count == 0) { MessageBox.Show("User Not Found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { foreach (DataRow row in Usernamedtbl.Rows) { if (row["password"].ToString().Trim() != Encryption.sha256(password)) { MessageBox.Show("Incorrect Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { DataViewControl dvc = new DataViewControl(); this.Hide(); dvc.ShowDialog(); dvc.Dispose(); this.Close(); } } } }
private void btnAddCar_Click(object sender, EventArgs e) { if (tbxVin.Text.Length == 17) { if (String.IsNullOrEmpty(tbxMake.Text) == false) { if (String.IsNullOrEmpty(tbxModel.Text) == false) { if (String.IsNullOrEmpty(tbxTrim.Text) == false) { if (String.IsNullOrEmpty(tbxColor.Text) == false) { try { vin = tbxVin.Text; year = int.Parse(cbxYear.Text); make = tbxMake.Text; model = tbxModel.Text; trim = tbxTrim.Text; color = tbxColor.Text; mileage = int.Parse(tbxMileage.Text); string query = $"insert into inventory values('{vin}','{color}','{make}','{model}','{trim}',{year},{mileage},0);"; Filler.InserterDeleter(query); DataViewControl dvc = new DataViewControl(); this.Hide(); dvc.tabControl1.SelectedTab = dvc.inventoryPage; dvc.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Please Enter Color"); } } else { MessageBox.Show("Please Enter Trim"); } } else { MessageBox.Show("Please Enter Model"); } } else { MessageBox.Show("Please Enter Make"); } } else { MessageBox.Show("Please Enter Valid Vin"); } }