private void btnXoa_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) == null) { XtraMessageBox.Show("Bạn chưa chọn dòng cần xóa! ", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { DialogResult thongbao = XtraMessageBox.Show("Bạn có chắc muốn xóa thể loại này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (thongbao == DialogResult.No) { XtraMessageBox.Show("Bạn đã hủy thao tác xóa ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (thongbao == DialogResult.Yes) { Theloai_DTO TL = new Theloai_DTO(); TL.MaLoai = txtMaLoai.Text; if (TheLoai_BUS.XoaTL(txtMaLoai.Text.Trim())) { frmTheLoai_Load(sender, e); XtraMessageBox.Show("Bạn đã xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
private void matudong() { string MaLoai = "TL001"; int dem = 0; while (TheLoai_BUS.TimTL_TheoMa(MaLoai) != null) { dem += 1; if (dem < 10) { MaLoai = "TL00" + dem.ToString(); } else if (dem < 100) { MaLoai = "TL0" + dem.ToString(); } else if (dem < 1000) { MaLoai = "TL" + dem.ToString(); } else { XtraMessageBox.Show("Không thể thêm nữa. Không đủ bộ nhớ!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } txtMaLoai.Text = MaLoai; }
private void BtnLUU_Click(object sender, EventArgs e) { if (stt == 1) { if (txtTenTheLoai.Text.Trim() == "") { XtraMessageBox.Show("Bạn chưa nhập thể loại sách", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Theloai_DTO TL = new Theloai_DTO(); TL.MaLoai = txtMaLoai.Text; TL.TenLoai = txtTenTheLoai.Text; if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) != null) { XtraMessageBox.Show("Mã loại không được trùng ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (TheLoai_BUS.ThemTL(TL)) { frmTheLoai_Load(sender, e); XtraMessageBox.Show("Bạn đã thêm thành công " + txtTenTheLoai.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (stt == 2) { if (txtMaLoai.Text.Trim() == "") { XtraMessageBox.Show("Bạn chưa chọn dòng cần sửa", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtTenTheLoai.Text.Trim() == "") { XtraMessageBox.Show("Thể loại sách không được rỗng", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Theloai_DTO TL = new Theloai_DTO(); TL.MaLoai = txtMaLoai.Text; TL.TenLoai = txtTenTheLoai.Text; if (TheLoai_BUS.TimTL_TheoMa(txtMaLoai.Text.Trim()) == null) { XtraMessageBox.Show("Mã loại không được sửa ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (TheLoai_BUS.SuaTL(TL)) { frmTheLoai_Load(sender, e); XtraMessageBox.Show("Bạn đã sửa thành công " + txtTenTheLoai.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Không sửa được", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }