private void btnLuu_Click(object sender, EventArgs e) { //GetDuLieu nhap DateTime Ngay = DateTime.MinValue; string GhiChu = ""; string TenKhachHang = ""; int MaDonViVe = 0; string MaSoThe = ""; try { Ngay = calNgayPhatHanh.Value; TenKhachHang = StringTools.TrimSpace(txtTenKhachHang.Text); MaDonViVe = Convert.ToInt32(cboCongTy.SelectedValue.ToString()); GhiChu = StringTools.TrimSpace(txtGhiChu.Text); MaSoThe = StringTools.TrimSpace(txtMaSoThe.Text); } catch (Exception ex) { new MessageBox.MessageBoxBA().Show("Có lỗi dữ liệu nhập. Bạn cần kiểm tra lại."); return; } if (g_ThemMoi) // chen mới { DataTable dt = The.GetChiTietThe(MaSoThe, MaDonViVe, calNgayPhatHanh.Value.Year); if ((dt != null) && (dt.Rows.Count > 0)) { new MessageBox.MessageBoxBA().Show("Đã tồn tại mã thẻ.Bạn cần kiểm tra lại."); return; } bool bSuccess = The.Insert(MaSoThe, Ngay, TenKhachHang, GhiChu, MaDonViVe); if (bSuccess) { LoadDSTheHuy(); new MessageBox.MessageBoxBA().Show("Thêm mới thành công."); UnLockControl(); } else { new MessageBox.MessageBoxBA().Show("Lỗi thêm mới."); } LockControl(); return; } else { } }