Пример #1
0
        private void button2_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");
            }

            Zookeeper zookeeper1 = new Zookeeper(employee1.ID, employee1.Fname, employee1.Lname, employee1.Birthdate);

            try
            {
                zookeeper1.Speciality = txtSpeciality.Text;
                zookeeper1.Zone       = Int32.Parse(txtZone.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            InsertZookeerperCmd(zookeeper1);
        }
Пример #2
0
        private void InsertZookeerperCmd(Zookeeper Z)
        {
            if (!verifySGBDConnection())
            {
                return;
            }

            SqlCommand cmd = new SqlCommand("insert into zoodb.zookeeper (emp_ID, specialty, zone) VALUES (@emp_ID, @specialty, @zone)", cn);

            cmd.Parameters.AddWithValue("@emp_ID", Int32.Parse(txtID.Text.ToString()));
            cmd.Parameters.AddWithValue("@specialty", txtSpeciality.Text.ToString());
            cmd.Parameters.AddWithValue("@zone", Int32.Parse(txtZone.Text.ToString()));


            cmd.ExecuteNonQuery();


            cn.Close();
            string            message = "Zookeeper added";
            string            caption = "added";
            MessageBoxButtons buttons = MessageBoxButtons.OK;
            DialogResult      result;

            // Displays the MessageBox.
            result = MessageBox.Show(message, caption, buttons);
        }
Пример #3
0
        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();
        }