private void btn_ok_Click(object sender, EventArgs e) { List <Image> pics = new List <Image>(); foreach (PictureBox pic in panel_car_pics.Controls) { pics.Add(pic.Image); } //test if the fields is not null OracleDataBase db = new OracleDataBase(); Tables.Car car = new Tables.Car(txb_matricule.Text, txb_name.Text, txb_color.Text, type_car, Convert.ToDouble(txb_km.Text)); Tables.CarPictures carPictures = new Tables.CarPictures(txb_matricule.Text, pics); db.addCar(car, carPictures); //add client if note exist else update with comfirmation msg //get user detail by id for modify }
public void addCar(Tables.Car car, Tables.CarPictures carPics) { OracleConnection Connection = new OracleConnection(stringConnection); OracleCommand cmd = new OracleCommand("AddCar", Connection); cmd.CommandType = CommandType.StoredProcedure; //insert user cmd.Parameters.Add("Matricule_", OracleDbType.NVarchar2).Value = car.Matricule; cmd.Parameters.Add("VoitureName_", OracleDbType.NVarchar2).Value = car.VoitureName; cmd.Parameters.Add("Color_", OracleDbType.NVarchar2).Value = car.Color; cmd.Parameters.Add("Car_Type_", OracleDbType.NVarchar2).Value = car.Type; cmd.Parameters.Add("km_", OracleDbType.Int64).Value = car.Km; //insert user details //try execute the querys try { Connection.Open(); cmd.ExecuteNonQuery(); foreach (Image pic in carPics.Pics) { OracleCommand cmd2 = new OracleCommand("AddCarPictures", Connection); cmd2.CommandType = CommandType.StoredProcedure; cmd2.Parameters.Add("Matricule_", OracleDbType.NVarchar2).Value = carPics.Matricule; cmd2.Parameters.Add("pic_", OracleDbType.Blob).Value = ImageToByteArray(pic); cmd2.ExecuteNonQuery(); Thread.Sleep(5000); } Connection.Close(); } catch (SqlException ex) { MessageBox.Show(ex.Message); } }