public static void Insert(Vehicle vehicle) { VehicleDAL.Insert(vehicle); Console.WriteLine("Inserted"); }
private void btnSaveMV_Click(object sender, EventArgs e) { if (ValidateFormMV()) { int id; int.TryParse(txtIdMV.Text, out id); // Getting data from UI vehicleBLL.ID = id; vehicleBLL.MotorizedVehicle = txtNameMV.Text; vehicleBLL.Unit = txtUnitMV.Text; genSetBLL.ID = id; genSetBLL.Generator_Set = ""; genSetBLL.Unit = ""; waterRescueBLL.ID = id; waterRescueBLL.WaterRescueKit = ""; waterRescueBLL.Unit = ""; extricationBLL.ID = id; extricationBLL.ExtricationKit = ""; extricationBLL.Unit = ""; ppeBLL.ID = id; ppeBLL.PersonalProtectiveGear = ""; ppeBLL.Unit = ""; firstAidKitBLL.ID = id; firstAidKitBLL.MedicalKit = ""; firstAidKitBLL.Unit = ""; othersBLL.ID = id; othersBLL.Others = ""; othersBLL.Unit = ""; equipmentBLL.Vehicle_no = id; equipmentBLL.Genset_no = id; equipmentBLL.WaterRescue_no = id; equipmentBLL.Extrication_no = id; equipmentBLL.PPE_no = id; equipmentBLL.FirstAid_no = id; equipmentBLL.Others_no = id; // Inserting data into Database bool success = vehicleDAL.Insert(vehicleBLL); genSetDAL.Insert(genSetBLL); waterRescueDAL.Insert(waterRescueBLL); extricationDAL.Insert(extricationBLL); ppeDAL.Insert(ppeBLL); firstAidKitDAL.Insert(firstAidKitBLL); othersDAL.Insert(othersBLL); equipmentDAL.Insert(equipmentBLL); // If the data is successfully inserted then the value of success will be true else it will be false if (success == true) { // Data successfully inserted MessageBox.Show("Motorized Vehicle Information successfully saved.", "Motorized Vehicle Information Save Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearMV(); txtNameMV.Focus(); } else { // Failed to insert data MessageBox.Show("Failed to add new motorized vehicle information.", "Motorized Vehicle Information Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } // Refreshing Data Grid View DataTable dt = vehicleDAL.Select(); dgvMotorizedVehicle.DataSource = dt; DataView dv = dt.DefaultView; dv.Sort = "vehicle_no"; DataTable sortedDT = dv.ToTable(); } }