/// <summary> /// thêm hình thức kiểm tra từ texbox /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnThemHTKT_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbTenHTKT.Text) || string.IsNullOrEmpty(tbMaHTKT.Text) || string.IsNullOrEmpty(tbHesoHTKT.Text)) { MessageBox.Show("Thêm thất bại,phải điền đầy đủ thông tin !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { HinhThucKiemTraBLL mhbll = new HinhThucKiemTraBLL(); if (mhbll.ThemHinhThucKiemTra(tbMaHTKT.Text, tbTenHTKT.Text, Int32.Parse(tbHesoHTKT.Text)) == true) { MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); //cap nhat du lieu len giao dien LoadHinhThucKiemtra(); } else { MessageBox.Show("Thêm thất bại,Hình thức kiểm tra này đã có !!!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnLuu_Click(object sender, EventArgs e) { #region KiemTraRangBuoc try { int heso = Int32.Parse(tbHeSo.Text); if (heso < 1) { MessageBox.Show("Hệ số phải là số nguyên dương!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch { MessageBox.Show("Hệ số phải là số nguyên dương!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endregion HinhThucKiemTraBLL htktbll = new HinhThucKiemTraBLL(); ErrorType result; //them if (this.ten == null) { result = htktbll.ThemHinhThucKiemTra(tbMa.Text, tbTenHTKT.Text, tbHeSo.Text); } else //sua { result = htktbll.SuaHinhThucKiemTra(tbMa.Text, tbTenHTKT.Text, tbHeSo.Text); } switch ((int)result) { case (int)ErrorType.KI_TU_RONG: MessageBox.Show("Thất bại, bạn phải điền đầy đủ thông tin để thực hiện!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case (int)ErrorType.DA_TON_TAI: MessageBox.Show("Không thể thêm, hình thức kiểm tra này đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); break; case (int)ErrorType.THAT_BAI: MessageBox.Show("Thất bại, Xin kiểm tra lại kết nối CSDL!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); break; default: string infor; if (this.ten == null) { infor = "Thêm thành công!"; } else { infor = "Sửa thành công !"; } MessageBox.Show(infor, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); tbHeSo.Text = ""; tbMa.Text = ""; tbTenHTKT.Text = ""; break; } }