private void btnSua_Click(object sender, EventArgs e) { if (txtMaThuMuc.Text == "") { MessageBox.Show("Mã Thư Mục Trống ! "); } else if (txtTenThuMuc.Text == "") { MessageBox.Show("Tên Thư Mục Trống !"); } else { try { ThuMuc tm = new ThuMuc(txtMaThuMuc.Text, txtTenThuMuc.Text); if (bs_tm.Sua(tm)) { MessageBox.Show("Đã Sửa ! "); } else { MessageBox.Show("Không có mã đó ! "); } } catch (Exception) { MessageBox.Show("Không có mã đó ! "); } } frmThuMuc_Load(sender, e); }
private void btnThem_Click(object sender, EventArgs e) { if (txtMaThuMuc.Text == "") { MessageBox.Show("Mã thư mục trống"); } else if (txtTenThuMuc.Text == "") { MessageBox.Show("Tên thư mục trống !"); } else { ThuMuc tm = new ThuMuc(txtMaThuMuc.Text, txtTenThuMuc.Text); try { if (bs_tm.Them(tm)) { // MessageBox.Show("Đã thêm"); } else { MessageBox.Show("Mã trùng "); } } catch (Exception) { throw; } } frmThuMuc_Load(sender, e); }
public bool Sua(ThuMuc tm) { try { conn.Open(); cmdSua = "update ThuMuc set tenthumuc = '" + tm.TenThuMuc + "' where mathumuc = '" + tm.MaThuMuc + "' "; SqlCommand cmd = new SqlCommand(cmdSua, conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { throw; } finally { conn.Close(); } return(false); }
public bool Them(ThuMuc tm) { try { conn.Open(); cmdThem = "insert into ThuMuc values ('" + tm.MaThuMuc + "',N'" + tm.TenThuMuc + "')"; SqlCommand cmd = new SqlCommand(cmdThem, conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { throw; } finally { conn.Close(); } return(false); }
public bool Sua(ThuMuc tm) { return(dal_tm.Sua(tm)); }
public bool Them(ThuMuc tm) { return(dal_tm.Them(tm)); }