private void btnAditoftruck_Click(object sender, EventArgs e) { if (txtLicencePlate.Text.Equals("") || txtWeightofTruck.Text.Equals("")) { MessageBox.Show("Vui lòng điền đầy đủ thông tin"); } else { bool isCheck = truckBO.isExistLicencePlate(txtLicencePlate.Text.Trim()); if (!isCheck) { MessageBox.Show("Biển số xe đã tồn tại vui lòng kiểm tra lại"); txtLicencePlate.ResetText(); txtWeightofTruck.ResetText(); } else { Truck truck = new Truck(); truck.MSKH = SplitMSKH(txtMSKHofTruck.Text); truck.LicencePlate = txtLicencePlate.Text; truck.Weight = int.Parse(txtWeightofTruck.Text); truckBO.Add(truck); RefreshTruckNoRemoveMSKH(); loadDataDGoftruck(); } } }
private void btnSaveTruck_Click_1(object sender, EventArgs e) { if (txtLicencePlate.Text != string.Empty && double.Parse(txtTruckofWeight.Text) > 0) { bool check = truckBO.Add(new Data.Truck { MSKH = int.Parse(txtMSKH.Text.Substring(2)), LicencePlate = txtLicencePlate.Text, Weight = double.Parse(txtTruckofWeight.Text) }); if (check == true) { MessageBox.Show("Thêm thành công "); btnSaveTruck.Visible = false; txtAll.Focus(); } else { MessageBox.Show("Thêm thất bại"); } } else { MessageBox.Show("Không hợp lệ!"); } }