コード例 #1
0
        public static List <CTMuonTra_DTO> LayDSCTMuonTra()
        {
            string sTruyVan = "select * from CTMuonTra";

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

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

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CTMuonTra_DTO CTMT = new CTMuonTra_DTO();
                CTMT.ID        = int.Parse(dt.Rows[i]["ID"].ToString());
                CTMT.MaMuonTra = dt.Rows[i]["MaMuonTra"].ToString();
                CTMT.MaSach    = dt.Rows[i]["TenSach"].ToString();
                CTMT.DaTra     = dt.Rows[i]["DaTra"].ToString();
                CTMT.NgayTra   = dt.Rows[i]["NgayTra"].ToString();
                CTMT.GhiChu    = dt.Rows[i]["GhiChu"].ToString();
                lstCTMuonTra.Add(CTMT);
            }
            DataProvider.DongKetNoi(con);
            return(lstCTMuonTra);
        }
コード例 #2
0
 private void cboDieuKien_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboDieuKien.Text == "Mã mượn trả")
     {
         CTMuonTra_DTOBindingSource.DataSource = CTMuonTra_BUS.LayDSMT();
         this.reportViewer1.RefreshReport();
         List <CTMuonTra_DTO> lst = CTMuonTra_BUS.LayDSMT();
         cboDanhSach.DataSource = lst;
         CTMuonTra_DTO CT = new CTMuonTra_DTO();
         CT.MaMuonTra = "TC";
         CT.MaMuonTra = "Tất cả";
         lst.Insert(0, CT);
         cboDanhSach.DisplayMember = "MaMuonTra";
     }
     else if (cboDieuKien.Text == "Tình trạng")
     {
         CTMuonTra_DTOBindingSource.DataSource = CTMuonTra_BUS.LayDSMT();
         this.reportViewer1.RefreshReport();
         List <CTMuonTra_DTO> lst = CTMuonTra_BUS.LayDSMT();
         cboDanhSach.DataSource = lst;
         CTMuonTra_DTO CT = new CTMuonTra_DTO();
         CT.DaTra = "TC";
         CT.DaTra = "Tất cả";
         lst.Insert(0, CT);
         cboDanhSach.DisplayMember = "DaTra";
     }
 }
コード例 #3
0
        public static bool ThemCTMuonTra(CTMuonTra_DTO CTMT)
        {
            con = DataProvider.MoKetNoi();
            string sTruyVan = @"insert into CTMuonTra values(N'" + CTMT.MaMuonTra + "',N'" + CTMT.MaSach + "',N'" + CTMT.DaTra + "',N'" + CTMT.NgayTra + "',N'" + CTMT.GhiChu + "')";
            bool   kq       = DataProvider.TruyVanKhongLayDuLieu(sTruyVan, con);

            DataProvider.DongKetNoi(con);
            return(kq);
        }
コード例 #4
0
        private void BtnLuu_Click(object sender, EventArgs e)
        {
            if (flag == 1)
            {
                CTMuonTra_DTO CT = new CTMuonTra_DTO();
                CT.MaMuonTra = cboMaMuonTra.Text;
                CT.MaSach    = cboMaSach.Text;
                if (CK0.Checked == true)
                {
                    CT.DaTra   = CK0.Text;
                    CT.NgayTra = textBox1.Text;
                }
                else
                {
                    CT.DaTra   = CK1.Text;
                    CT.NgayTra = dtpNgayMuon.Text;
                }
                CT.GhiChu = txtGhiChu.Text;

                if (CTMuonTra_BUS.ThemCTMuonTra(CT))
                {
                    frmCTMuonTra_Load(sender, e);
                    MessageBox.Show("Thêm thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Không thêm được", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else if (flag == 2)
            {
                CTMuonTra_DTO CT = new CTMuonTra_DTO();
                CT.ID        = int.Parse(ID.Text);
                CT.MaMuonTra = cboMaMuonTra.Text;
                CT.MaSach    = cboMaSach.Text;
                if (CK0.Checked == true)
                {
                    CT.DaTra   = CK0.Text;
                    CT.NgayTra = textBox1.Text;
                }
                else
                {
                    CT.DaTra   = CK1.Text;
                    CT.NgayTra = dtpNgayMuon.Text;
                }
                CT.GhiChu = txtGhiChu.Text;
                if (CTMuonTra_BUS.SuaCTMuonTra(CT))
                {
                    frmCTMuonTra_Load(sender, e);
                    MessageBox.Show("Sửa thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Không sửa được", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #5
0
        public static bool SuaCTMuonTra(CTMuonTra_DTO CTMT)
        {
            string sTruyVan = @"update CTMuonTra set MaMuonTra =N'" + CTMT.MaMuonTra + "',TenSach = N'" + CTMT.MaSach + "' , DaTra = N'" + CTMT.DaTra + "' , NgayTra = N'" + CTMT.NgayTra + "', GhiChu = N'" + CTMT.GhiChu + "'  where ID='" + CTMT.ID + "'";

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

            DataProvider.DongKetNoi(con);
            return(kq);
        }
コード例 #6
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            CTMuonTra_DTO CT = new CTMuonTra_DTO();

            CT.ID = int.Parse(ID.Text);
            if (CTMuonTra_BUS.XoaCTMuonTra(ID.Text))
            {
                frmCTMuonTra_Load(sender, e);
                MessageBox.Show("Xóa thành công ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #7
0
        public static List <CTMuonTra_DTO> TimKiem(string dk, string giatri)
        {
            string sTruyVan = @"select * from CTMuonTra where " + dk + " like N'%" + giatri + "%'";

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

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                CTMuonTra_DTO CTMT = new CTMuonTra_DTO();
                CTMT.ID        = int.Parse(dt.Rows[i]["ID"].ToString());
                CTMT.MaMuonTra = dt.Rows[i]["MaMuonTra"].ToString();
                CTMT.MaSach    = dt.Rows[i]["TenSach"].ToString();
                CTMT.DaTra     = dt.Rows[i]["DaTra"].ToString();
                CTMT.NgayTra   = dt.Rows[i]["NgayTra"].ToString();
                CTMT.GhiChu    = dt.Rows[i]["GhiChu"].ToString();
                lst.Add(CTMT);
            }
            DataProvider.DongKetNoi(con);
            return(lst);
        }
コード例 #8
0
 public static bool SuaCTMuonTra(CTMuonTra_DTO CTMT)
 {
     return(CTMuonTra_DAO.SuaCTMuonTra(CTMT));
 }
コード例 #9
0
 public static bool ThemCTMuonTra(CTMuonTra_DTO CTMT)
 {
     return(CTMuonTra_DAO.ThemCTMuonTra(CTMT));
 }