protected void btnThem_Click(object sender, EventArgs e) { TheLoai tl = new TheLoai(); if (txtMaTheLoai.Text == "") { Response.Write("<script language='javascript'>alert('" + "Bạn chưa nhập mã thể loại!" + "')</script>"); txtMaTheLoai.Focus(); } else { if (txtTenTheLoai.Text == "") { Response.Write("<script language='javascript'>alert('" + "Bạn chưa nhập tên thể loại!" + "')</script>"); txtTenTheLoai.Focus(); } else { tl.MaTheLoai = txtMaTheLoai.Text; tl.TenTheLoai = txtTenTheLoai.Text; Response.Write("<script language=''javascript>alert('" + " Thêm thành công! " + "')</script>"); tlbll.ThemTheLoai(tl); Page_Load(sender, e); txtMaTheLoai.Text = ""; txtTenTheLoai.Text = ""; } } }
void LuuTheLoai() { if (txbTLMaTheLoai.Text == "") { return; } TheLoaiDAO tttheloai = new TheLoaiDAO() { MaTheLoai = txbTLMaTheLoai.Text, TenTheLoai = txbTLTenTheLoai.Text }; if (theloai.KiemTraTheLoai(tttheloai.MaTheLoai)) { theloai.SuaTheLoai(tttheloai); } else { theloai.ThemTheLoai(tttheloai); } MessageBox.Show("Lưu thể loại thành công!"); LoadDtgvTheLoai(); }