Beispiel #1
0
        void CapNhatThongTheLoai(string MaTheLoai, string TenTheLoai)
        {
            TheLoaiBLL cls = new TheLoaiBLL(MaTheLoai, TenTheLoai);

            int kq = cls.CapNhat();

            switch (kq)
            {
            case 0:
            {
                MessageBox.Show("Cập Nhật Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HienThiThongTheLoai();
                break;
            }

            case 1:
            {
                MessageBox.Show("Cập Nhật Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            case 2:
            {
                MessageBox.Show("Không Có Mã thể loại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaTuaSach.Focus();
                break;
            }

            case 3:
            {
                MessageBox.Show("Có mã thể loại này trong tựa sách.không cập nhật  được", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
            }
        }
Beispiel #2
0
        void ThemThongTheLoai(string MaTheLoai, string TenTheLoai)
        {
            TheLoaiBLL cls = new TheLoaiBLL(MaTheLoai, TenTheLoai);

            int kq = cls.Them();

            switch (kq)
            {
            case 0:
            {
                MessageBox.Show("Thêm Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HienThiThongTheLoai();
                break;
            }

            case 1:
            {
                MessageBox.Show("Thêm Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            case 2:
            {
                MessageBox.Show("Mã thể loại đã tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaTheLoai.Focus();
                break;
            }
            }
        }
Beispiel #3
0
        void XoaTheLoai(string MaTheLoai)
        {
            TheLoaiBLL cls = new TheLoaiBLL(MaTheLoai);
            int        kq  = cls.Xoa();

            switch (kq)
            {
            case 0:
            {
                MessageBox.Show("Xóa Thành Công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                HienThiThongTheLoai();
                break;
            }

            case 1:
            {
                MessageBox.Show("Xóa Thất Bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                break;
            }

            case 2:
            {
                MessageBox.Show("Không Tồn Tại Mã thể loại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaTheLoai.Focus();
                break;
            }

            case 3:
            {
                MessageBox.Show("Không thể xóa.Mã thể loại này c1 trong bảng tựa sách", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaTheLoai.Focus();
                break;
            }
            }
        }
        private void loadData()
        {
            TheLoaiBLL     theLoaiBLL = new TheLoaiBLL();
            List <TheLoai> list       = theLoaiBLL.getListCategory();

            grd.DataSource = list;
            DataBind();
        }
        private void loadDropTheLoai()
        {
            List <TheLoai> dsTL = new TheLoaiBLL().getListCategory();

            dropTheLoai.DataSource     = dsTL;
            dropTheLoai.DataValueField = "MaTLoai";
            dropTheLoai.DataTextField  = "TenTLoai";
            DataBind();
        }
 protected void update(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "update")
     {
         messenger.Text = "vao";
         string     ma        = e.CommandArgument.ToString();
         TheLoaiBLL chucVuBLL = new TheLoaiBLL();
         Session["theloai"] = chucVuBLL.findById(ma);
         Response.Redirect("/Admin/Edit/SuaTheLoai.aspx");
     }
 }
        protected void btnSua_Click(object sender, EventArgs e)
        {
            lb1.Text = "";
            TheLoaiBLL theLoaiBLL = new TheLoaiBLL();
            TheLoai    category   = new TheLoai();

            category.MaTLoai  = txtMa.Text;
            category.TenTLoai = txtTen.Text;
            category.GhiChu   = txtGhiChu.Text;
            lb1.Text          = theLoaiBLL.suaTheLoai(category);
        }
Beispiel #8
0
        void HienThiTheLoaiTheoMa(string MaLoaiSach)
        {
            DataTable dt = new TheLoaiBLL().truyXuatDuLieuBang_TheLoai();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["MaLoaiSach"].ToString() == MaLoaiSach)
                    {
                        txtMaTheLoai.Text  = dr["MaLoaiSach"].ToString();
                        txtTenTheLoai.Text = dr["TenLoaiSach"].ToString();
                    }
                }
            }
        }
        protected void btnTimKiem_Click(object sender, EventArgs e)
        {
            lblTK.Text = "";
            string ten = txtTimKiem.Text;

            if (ten.Length > 0)
            {
                TheLoaiBLL     theLoaiBLL = new TheLoaiBLL();
                List <TheLoai> list       = theLoaiBLL.getListCategory("%" + ten + "%");
                lblTK.Text     = "Kết quả tìm kiếm: " + list.Count;
                grd.DataSource = list;
                DataBind();
            }
            else
            {
                loadData();
            }
        }
 protected void delete(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "delete")
     {
         try
         {
             string     ma         = (e.CommandArgument).ToString();
             TheLoaiBLL theloaiBLL = new TheLoaiBLL();
             theloaiBLL.delete(ma);
             loadData();
             messenger.Text = "Category deleted !@";
         }
         catch (Exception ex)
         {
             messenger.Text = "Err: " + ex.Message;
         }
     }
 }
Beispiel #11
0
        /// <summary>
        /// get tên thể loại bằng mã thể loại trong bảng thể loại
        /// </summary>
        /// <param name="MaTheLoai">mã thể loại</param>
        /// <returns>tên thể loại</returns>
        string GetTenTheLoai(string MaTheLoai)
        {
            string    tentheloai = "";
            DataTable dt         = new TheLoaiBLL().truyXuatDuLieuBang_TheLoai();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["MaLoaiSach"].ToString() == MaTheLoai)
                    {
                        tentheloai = dr["TenLoaiSach"].ToString();
                        break;
                    }
                }
            }

            return(tentheloai);
        }
Beispiel #12
0
        void HienThiThongTheLoai()
        {
            DataTable dt = new TheLoaiBLL().truyXuatDuLieuBang_TheLoai();


            if (dt.Rows.Count > 0)
            {
                lvwTheLoai.Items.Clear();
                int i = 1;
                foreach (DataRow dr in dt.Rows)
                {
                    ListViewItem li = lvwTheLoai.Items.Add(i.ToString());
                    li.SubItems.Add(dr["MaLoaiSach"].ToString());
                    li.SubItems.Add(dr["TenLoaiSach"].ToString());

                    li.Tag = dr["MaLoaiSach"].ToString();
                    i++;
                }
            }
        }
 protected void btnThem_Click(object sender, EventArgs e)
 {
     try
     {
         TheLoaiBLL theLoaiBLL = new TheLoaiBLL();
         TheLoai    category   = new TheLoai();
         category.MaTLoai  = txtMa.Text;
         category.TenTLoai = txtTen.Text;
         category.GhiChu   = txtGhiChu.Text;
         theLoaiBLL.create(category);
         messenger.Text = theLoaiBLL.create(category);
         loadData();
         clear();
         messenger.Text = "Category Inserted !";
     }
     catch (Exception ex)
     {
         messenger.Text = ex.Message;
     }
 }