private void Add_Button_Click(object sender, RoutedEventArgs e) { try { int id; if (txtBranchID.Text == "") { id = 0; } else { id = int.Parse(txtBranchID.Text); } if (id > 1000) { throw new Exception("Inaccurate id number."); } string name = textBoxName.Text; if (name == "") { throw new Exception("Lacking Name."); } string address = textBoxAddress.Text; if (address == "") { throw new Exception("Lacking Address."); } long phoneNum = long.Parse(textBoxPhoneNum.Text); if (textBoxPhoneNum.Text.Length != 10) { throw new Exception("Inaccurate PhoneNum."); } string manager = textBoxManager.Text; if (manager == "") { throw new Exception("Lacking Manager."); } int employee = int.Parse(textBoxEmployees.Text); if (employee < 1) { throw new Exception("Inaccurate Employees"); } int deliveryFree = int.Parse(textBoxDelivery.Text); if (deliveryFree < 0) { throw new Exception("Inaccurate Delivery."); } branchHechser hechser = (branchHechser)comboBoxHechser.SelectedItem; if ((int)hechser < 0) { throw new Exception("Lacking Hechser."); } BE.Branch currentBranch = new BE.Branch(name, address, phoneNum, manager, employee, deliveryFree, hechser, id); bl.addBranch(currentBranch); dataGridBranch.Items.Refresh(); MessageBox.Show("You have added the Branch with the id: " + currentBranch.branchID.ToString()); //Clear the form: txtBranchID.Text = ""; textBoxAddress.Text = ""; textBoxDelivery.Text = ""; textBoxEmployees.Text = ""; textBoxManager.Text = ""; textBoxName.Text = ""; textBoxPhoneNum.Text = ""; comboBoxHechser.SelectedItem = null; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Branch(string branchName, string branchAddress, long branchPhoneNum, string branchManager, int branchEmployee, int branchDeliveryFree, branchHechser branchHechserBranch, int branchID = 0) { this.branchID = branchID; this.branchName = branchName; this.branchAddress = branchAddress; this.branchPhoneNum = branchPhoneNum; this.branchManager = branchManager; this.branchEmployee = branchEmployee; this.branchDeliveryFree = branchDeliveryFree; this.branchHechserBranch = branchHechserBranch; accessGranted = true; branchManagerPassword = "******"; }