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);
             }
         }
     }
 }
Example #2
0
        public static bool ThemTL(Theloai_DTO TL)
        {
            con = DataProvider.MoKetNoi();
            string sTruyVan = @"insert into TheLoai values(N'" + TL.MaLoai + "',N'" + TL.TenLoai + "')";
            bool   kq       = DataProvider.TruyVanKhongLayDuLieu(sTruyVan, con);

            DataProvider.DongKetNoi(con);
            return(kq);
        }
 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);
             }
         }
     }
 }
Example #4
0
        public static bool SuaTL(Theloai_DTO TL)
        {
            string sTruyVan = @"update TheLoai set TenLoai =N'" + TL.TenLoai + "' where MaLoai='" + TL.MaLoai + "'";

            con = DataProvider.MoKetNoi();
            bool kq = DataProvider.TruyVanKhongLayDuLieu(sTruyVan, con);

            DataProvider.DongKetNoi(con);
            return(kq);
        }
Example #5
0
        public static List <Theloai_DTO> TimTL(string dk, string giatri)
        {
            string sTruyVan = @"select * from THELOAI where " + dk + " like N'%" + giatri + "%'";

            con = DataProvider.MoKetNoi();
            DataTable          dt    = DataProvider.TruyVanLayDuLieu(sTruyVan, con);
            List <Theloai_DTO> lstTL = new List <Theloai_DTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Theloai_DTO TL = new Theloai_DTO();
                TL.MaLoai  = dt.Rows[i]["MaLoai"].ToString();
                TL.TenLoai = dt.Rows[i]["TenLoai"].ToString();
                lstTL.Add(TL);
            }
            DataProvider.DongKetNoi(con);
            return(lstTL);
        }
Example #6
0
        public static Theloai_DTO TimTL_TheoMa(string maloai)
        {
            string sTruyVan = @"select * from THELOAI where MaLoai='" + maloai + "'";

            con = DataProvider.MoKetNoi();
            DataTable dt = DataProvider.TruyVanLayDuLieu(sTruyVan, con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            Theloai_DTO TL = new Theloai_DTO();

            TL.MaLoai  = dt.Rows[0]["MaLoai"].ToString();
            TL.TenLoai = dt.Rows[0]["TenLoai"].ToString();
            DataProvider.DongKetNoi(con);
            return(TL);
        }
Example #7
0
        public static List <Theloai_DTO> LayDSTL()
        {
            string sTruyVan = "select * from THELOAI";

            con = DataProvider.MoKetNoi();
            DataTable dt = DataProvider.TruyVanLayDuLieu(sTruyVan, con);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }
            List <Theloai_DTO> lstTheLoai = new List <DTO.Theloai_DTO>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Theloai_DTO TL = new Theloai_DTO();
                TL.MaLoai  = dt.Rows[i]["MaLoai"].ToString();
                TL.TenLoai = dt.Rows[i]["TenLoai"].ToString();
                lstTheLoai.Add(TL);
            }
            DataProvider.DongKetNoi(con);
            return(lstTheLoai);
        }
Example #8
0
 public static bool SuaTL(Theloai_DTO TL)
 {
     return(TheLoai_DAO.SuaTL(TL));
 }
Example #9
0
 public static bool ThemTL(Theloai_DTO TL)
 {
     return(TheLoai_DAO.ThemTL(TL));
 }