Exemple #1
0
        private void manageToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            EditCust ed = new EditCust();

            ed.Show();
            ed.emp = this;
            this.Hide();
        }
 public void view(String cmd, AddSupplier ads = null, AddVehicle adv = null, AddOrder ado = null, View v = null, UpDe ud = null, Manage adm = null, EditCust edc = null, CustOrder C_Order = null)
 {
     using (Conn = new SqlConnection())
     {
         try
         {
             Conn.ConnectionString = "Server = (local);Database = Spare_parts;Trusted_Connection = true";
             SqlCommand Cmd = new SqlCommand(cmd, Conn);
             Conn.Open();
             SqlDataReader reader = Cmd.ExecuteReader();
             if (ads != null)
             {
                 while (reader.Read())
                 {
                     ads.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString());
                 }
             }
             else if (adv != null)
             {
                 while (reader.Read())
                 {
                     adv.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString());
                 }
             }
             else if (ado != null)
             {
                 while (reader.Read())
                 {
                     ado.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString());
                 }
             }
             else if (v != null)
             {
                 while (reader.Read())
                 {
                     v.parts(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString());
                 }
             }
             else if (ud != null)
             {
                 while (reader.Read())
                 {
                     ud.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString());
                 }
             }
             else if (edc != null)
             {
                 while (reader.Read())
                 {
                     edc.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString());
                 }
             }
             else if (adm != null)
             {
                 while (reader.Read())
                 {
                     adm.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString(), reader[7].ToString(), reader[8].ToString(), reader[9].ToString());
                 }
             }
             else
             {
                 while (reader.Read())
                 {
                     C_Order.Add(reader[0].ToString(), reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), reader[4].ToString(), reader[5].ToString(), reader[6].ToString());
                 }
             }
         }
         catch (SqlException)
         {
             MessageBox.Show("An error occured", "Error");
         }
     }
     Conn.Close();
 }
        public void getVehicle(AddItem ad = null, UpDe ud = null, AddCustomer adc = null, EditCust edc = null, string veh = null)
        {
            String cmd = "exec getVehicle ''";

            if (veh != null)
            {
                cmd = "exec getVehicle '" + veh + "'";
            }
            using (Conn = new SqlConnection())
            {
                try
                {
                    Conn.ConnectionString = "Server = (local);Database = Spare_parts;Trusted_Connection = true";
                    SqlCommand Cmd = new SqlCommand(cmd, Conn);
                    Conn.Open();
                    SqlDataReader reader = Cmd.ExecuteReader();
                    if (ad != null)
                    {
                        while (reader.Read())
                        {
                            ad.Veh(reader[0].ToString());
                        }
                    }
                    else if (ud != null)
                    {
                        while (reader.Read())
                        {
                            ud.Veh(reader[0].ToString());
                        }
                    }
                    else if (edc != null)
                    {
                        while (reader.Read())
                        {
                            edc.Veh(reader[0].ToString());
                        }
                    }
                    else
                    {
                        while (reader.Read())
                        {
                            adc.Veh(reader[0].ToString());
                        }
                    }
                }
                catch (SqlException)
                {
                    MessageBox.Show("An error occured", "Error");
                }
            }
            Conn.Close();
        }