//insert xe rửa public bool insertVehicleWash(vehicleWashDTO vel) { try { this.openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO VEHICLE_WASH (id, type)" + "VALUES (@id, @type)", this.getConnection); cmd.Parameters.Add("@id", SqlDbType.NChar).Value = vel.id; cmd.Parameters.Add("@type", SqlDbType.Int).Value = vel.type; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (Exception ex) { MessageBox.Show("Error: ", ex.Message); } finally { this.closeConnection(); } return(false); }
//end sinh btn wash private void btnWash_Click(object sender, EventArgs e) { string id = this.dgv.CurrentRow.Cells[0].Value.ToString(); int type = Convert.ToInt32(this.dgv.CurrentRow.Cells[1].Value); vehicleWashDTO vehicleWashDTO = new vehicleWashDTO(id, type); if (this.vehBUS.UpdateStatusVehicle(id, "WASH", 1) && this.vehicleWashBUS.insertVehicleWash(vehicleWashDTO)) { MessageBox.Show("Successfully"); this.fotherServices_Park_Load(sender, e); } else MessageBox.Show("Unsuccessfully"); }
private void btnRuaXe_Click(object sender, EventArgs e) { if (this.vehBUS.CheckID_Exited(this.txtID.Text.Trim())) { MessageBox.Show("ID xe đã tồn tại trong bãi xe", "Gửi Xe", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Warning); this.txtID.Text = ""; } else { if (this.picBox1.Image == null || this.picBox2.Image == null) { MessageBox.Show("Can't insert new vehicle if you don't upload your image", "Insert object", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (this.txtID.Text.Trim() == "") { MessageBox.Show("Can't insert new vehicle if you don't have id", "Insert object", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int type = this.cbLoaiXe.SelectedIndex; MemoryStream pic1 = new MemoryStream(); this.picBox1.Image.Save(pic1, this.picBox1.Image.RawFormat); MemoryStream pic2 = new MemoryStream(); this.picBox2.Image.Save(pic2, this.picBox2.Image.RawFormat); vehicleDTO vehDTO = new vehicleDTO(this.txtID.Text.Trim(), type, pic1, pic2, 0, 0, 1); vehicleWashDTO vehWashDTO = new vehicleWashDTO(this.txtID.Text.Trim(), type); if (this.vehBUS.insertVehicle(vehDTO) && this.vehWashBUS.insertVehicleWash(vehWashDTO)) { MessageBox.Show("Successfully~~"); } //thu phi //this.openForm_Sua(vehDTO, type); //end } } }
//insert public bool insertVehicleWash(vehicleWashDTO vehWashDTO) { return(this.vehWashDAL.insertVehicleWash(vehWashDTO)); }