private void Button3_Click(object sender, EventArgs e) { Employee employee1 = new Employee(); try { employee1 = new Employee(Int32.Parse(txtID.Text.ToString()), txtfname.Text, txtlname.Text, txtbirthdate.Text); } catch (Exception ex) { MessageBox.Show("Select Employee from left list"); } Cashier cashier1 = new Cashier(employee1.ID, employee1.Fname, employee1.Lname, employee1.Birthdate); try { cashier1.ShopID = Int32.Parse(txtShopID.Text.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } InsertCashierCmd(cashier1); }
private void InsertCashierCmd(Cashier Z) { if (!verifySGBDConnection()) { return; } SqlCommand cmd = new SqlCommand("insert into zoodb.cashier (emp_ID, shop_ID) VALUES (@emp_ID, @shop_ID)", cn); cmd.Parameters.AddWithValue("@emp_ID", Int32.Parse(txtID.Text.ToString())); cmd.Parameters.AddWithValue("@shop_ID", txtShopID.Text.ToString()); cmd.ExecuteNonQuery(); cn.Close(); string message = "cashier added"; string caption = "added"; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; LoadToolStripMenuItem_Click(null, null); // Displays the MessageBox. result = MessageBox.Show(message, caption, buttons); }
private void LoadEmployees(Int32 emp, List <int> list) { if (!verifySGBDConnection()) { return; } SqlCommand cmd1 = new SqlCommand("SELECT * FROM zoodb.getEmployeeJob(@ID)", cn); cmd1.Parameters.AddWithValue("@ID", emp); SqlDataReader reader1 = cmd1.ExecuteReader(); while (reader1.Read()) { list.Add(Int32.Parse(reader1["emp_ID"].ToString())); Employee E = new Employee(); E.ID = emp; E.Fname = reader1["Fname"].ToString(); E.Lname = reader1["Lname"].ToString(); E.Birthdate = reader1["Birthdate"].ToString(); Zookeeper Z = new Zookeeper(E.ID, E.Fname, E.Lname, E.Birthdate); Z.Speciality = reader1["specialty"].ToString(); Z.Zone = Int32.Parse(reader1["zone"].ToString()); listBox1.Items.Add(E.ID + " " + E.Fname + " " + E.Lname + " Zookeeper"); } cn.Close(); if (!verifySGBDConnection()) { return; } SqlCommand cmd = new SqlCommand("SELECT * FROM zoodb.getEmployeeJob2(@ID)", cn); cmd.Parameters.AddWithValue("@ID", emp); SqlDataReader reader = cmd.ExecuteReader(); List <Employee> employeelist = new List <Employee>(); while (reader.Read()) { list.Add(Int32.Parse(reader["emp_ID"].ToString())); Employee E = new Employee(); E.ID = emp; E.Fname = reader["Fname"].ToString(); E.Lname = reader["Lname"].ToString(); E.Birthdate = reader["Birthdate"].ToString(); Cashier C = new Cashier(E.ID, E.Fname, E.Lname, E.Birthdate); C.ShopID = Int32.Parse(reader["shop_ID"].ToString()); listBox1.Items.Add(E.ID + " " + E.Fname + " " + E.Lname + " Cashier"); } cn.Close(); currentEmployee = 0; ShowEmployee(); }