//insert vafp table VEHICLE_FIX public bool insertVehicle_FIX(vehicleFixDTO velFIX) { try { this.openConnection(); SqlCommand cmd = new SqlCommand("INSERT INTO VEHICLE_FIX (id, service)" + "VALUES (@id, @service)", this.getConnection); cmd.Parameters.Add("@id", SqlDbType.NChar).Value = velFIX.id; cmd.Parameters.Add("@service", SqlDbType.NChar).Value = velFIX.service; if (cmd.ExecuteNonQuery() == 1) { return(true); } } catch (Exception ex) { MessageBox.Show("Error: ", ex.Message); } finally { this.closeConnection(); } return(false); }
private void btnAdd_Click(object sender, EventArgs e) { try { if (this.cbDichVu.SelectedIndex != -1) { string id = this.dgvFix.CurrentRow.Cells[0].Value.ToString(); string service = this.cbDichVu.Text; vehicleFixDTO vehFixDTO = new vehicleFixDTO(id, service); if (this.vehFixBUS.VerifyIDandService_Existed(id, service) == false) { if (this.vehFixBUS.insertVehicle_FIX(vehFixDTO)) { MessageBox.Show("Thêm dịch vụ sửa thành công", "Info Vehicle", MessageBoxButtons.OK, MessageBoxIcon.Information); this.cbTypeFilter.SelectedIndex = 3; DataTable table = this.vehFixBUS.getVehicleFix_info_all(); if (table != null) { this.designDataGridView(table, 3, 4); this.lbCount.Text = "Số Lượng Xe: " + this.dgvFix.Rows.Count; } else { this.dgvFix.DataSource = null; } } else { MessageBox.Show("Thêm dịch vụ sửa không thành công", "Info Vehicle", MessageBoxButtons.OK, MessageBoxIcon.Error); this.dgvFix.DataSource = null; } } else { MessageBox.Show("Xe đã và đang sử dụng dịch vụ này.\nVui lòng chọn lại", "Info Vehicle", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { } }
//insert public bool insertVehicle_FIX(vehicleFixDTO vehFixDTO) { return(this.vehFixDAL.insertVehicle_FIX(vehFixDTO)); }