//insert
        public bool insertcustomer_Vehicle(customer_VehicleDTO customer_VehicleDTO)
        {
            try
            {
                this.openConnection();

                SqlCommand cmd = new SqlCommand("INSERT INTO CUSTOMER_VEHICLE(id_Cus, id_Veh)" +
                                                "VALUES (@id_Cus, @id_Veh)", this.getConnection);
                cmd.Parameters.Add("@id_Cus", SqlDbType.NChar).Value = customer_VehicleDTO.id_Cus;
                cmd.Parameters.Add("@id_Veh", SqlDbType.NChar).Value = customer_VehicleDTO.id_Veh;

                if (cmd.ExecuteNonQuery() == 1)
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: ", ex.Message);
            }
            finally
            {
                this.closeConnection();
            }
            return(false);
        }
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            string id_Cus = this.cbIDCustomer.Text;
            string id_Veh = this.cbIDxe.Text;
            customer_VehicleDTO customer_VehicleDTO = new customer_VehicleDTO(id_Cus, id_Veh);

            try
            {
                if (this.customer_VehicleBUS.insertcustomer_Vehicle(customer_VehicleDTO))
                {
                    MessageBox.Show("Sở hữu xe thành công", "liên kết xe", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.flienKetVehicle_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Sở hữu xe không thành công", "liên kết xe", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: ", ex.Message);
            }
        }
Example #3
0
 //insert
 public bool insertcustomer_Vehicle(customer_VehicleDTO customer_VehicleDTO)
 {
     return(this.customer_VehicleDAL.insertcustomer_Vehicle(customer_VehicleDTO));
 }