Beispiel #1
0
        // insert  bool ,dto (có chưa bảng qi định dto )

        public bool themDocGia(docgiaDTO dgDTO)
        {
            string query = string.Format("insert into [docgia] values (@mathe,@hoten,@email,@ngaysinh,@ngaydk,@diachi,@loaidocgia,@tongtienno)");

            SqlParameter[] param = new SqlParameter[8];
            param[0]       = new SqlParameter("@mathe", SqlDbType.Int);
            param[0].Value = Convert.ToString(dgDTO.MaThe);
            param[1]       = new SqlParameter("@hoten", SqlDbType.NVarChar);
            param[1].Value = Convert.ToString(dgDTO.HoTen);
            param[2]       = new SqlParameter("@email", SqlDbType.NVarChar);
            param[2].Value = Convert.ToString(dgDTO.Email);
            param[3]       = new SqlParameter("@ngaysinh", SqlDbType.DateTime);
            param[3].Value = Convert.ToString(dgDTO.NgaySinh);
            param[4]       = new SqlParameter("@ngaydk", SqlDbType.DateTime);
            param[4].Value = Convert.ToString(dgDTO.Ngaydk);
            param[5]       = new SqlParameter("@diachi", SqlDbType.NVarChar);
            param[5].Value = Convert.ToString(dgDTO.DiaChi);
            param[6]       = new SqlParameter("@loaidocgia", SqlDbType.Int);
            param[6].Value = Convert.ToString(dgDTO.Loaidocgia);
            param[7]       = new SqlParameter("@tongtienno", SqlDbType.Int);
            param[7].Value = Convert.ToString(dgDTO.Tongtienno);

            conn.excuteNonQuery2(query, param);


            return(true);
        }
Beispiel #2
0
        // update  bool ,dto
        public bool suaDocGia(docgiaDTO dgDTO, int mathe)
        {
            string query = string.Format("update [docgia] set mathe=@mathe, hoten=@hoten,email=@email,ngaysinh=@ngaysinh,ngaydk=@ngaydk,diachi=@diachi, tongtienno=@tongtienno,loaidocgia=@loaidocgia where mathe=@mathe ");

            SqlParameter[] param = new SqlParameter[8];
            param[0]       = new SqlParameter("@mathe", SqlDbType.Int);
            param[0].Value = Convert.ToString(mathe);
            param[1]       = new SqlParameter("@hoten", SqlDbType.NVarChar);
            param[1].Value = Convert.ToString(dgDTO.HoTen);
            param[2]       = new SqlParameter("@email", SqlDbType.NVarChar);
            param[2].Value = Convert.ToString(dgDTO.Email);
            param[3]       = new SqlParameter("@ngaysinh", SqlDbType.DateTime);
            param[3].Value = Convert.ToString(dgDTO.NgaySinh);
            param[4]       = new SqlParameter("@ngaydk", SqlDbType.DateTime);
            param[4].Value = Convert.ToString(dgDTO.Ngaydk);
            param[5]       = new SqlParameter("@diachi", SqlDbType.NVarChar);
            param[5].Value = Convert.ToString(dgDTO.DiaChi);
            param[6]       = new SqlParameter("@tongtienno", SqlDbType.Int);
            param[6].Value = Convert.ToString(dgDTO.Tongtienno);
            param[7]       = new SqlParameter("@loaidocgia", SqlDbType.Int);
            param[7].Value = Convert.ToString(dgDTO.Loaidocgia);
            conn.excuteNonQuery2(query, param);


            return(true);
        }
        // danh sach pheiu thu
        public bool danhsachPhieuThu(List <phieuthutienDTO> listPTTDTO)
        {
            string query = string.Format("select* from [phieuthutienphat] ");

            SqlParameter[] parm = new SqlParameter[1];
            // khong can nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@mathe", SqlDbType.Int);
            parm[0].Value = dg.MaThe;

            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                phieuthutienDTO pttDTO = new phieuthutienDTO();



                pttDTO.Ngaythu    = DateTime.Parse(dr["ngaythu"].ToString());
                pttDTO.Tienthu    = Int32.Parse(dr["tienthu"].ToString());
                pttDTO.Mathe      = Int32.Parse(dr["mathe"].ToString());
                pttDTO.Maphieuthu = Int32.Parse(dr["maphieuthu"].ToString());

                listPTTDTO.Add(pttDTO);
            }



            return(true);
        }
        public bool danhsachLoaiDG(List <loaidocgiaDTO> listLoaiDGDTO)
        {
            string query = string.Format("select* from [cacloaidocgia] ");

            SqlParameter[] parm = new SqlParameter[1];

            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@masach", SqlDbType.Int);
            parm[0].Value = dg.MaThe;


            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                loaidocgiaDTO cacloaiDGDTO = new loaidocgiaDTO();

                cacloaiDGDTO.Cacloai = Int32.Parse(dr["loaidg"].ToString());

                listLoaiDGDTO.Add(cacloaiDGDTO);
            }



            return(true);
        }
        // hien thi list dto

        public bool danhsachCTPT(List <ctptDTO> listctptDTO)
        {
            string query = string.Format("select* from [ct_phieumuon] ");

            SqlParameter[] parm = new SqlParameter[1];

            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@masach", SqlDbType.Int);
            parm[0].Value = dg.MaThe;

            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                ctptDTO ctphieutraDTO = new ctptDTO();

                ctphieutraDTO.Mapt         = Int32.Parse(dr["mapt"].ToString());
                ctphieutraDTO.Masach       = Int32.Parse(dr["masach"].ToString());
                ctphieutraDTO.Songaydamuon = Int32.Parse(dr["songaydamuon"].ToString());
                ctphieutraDTO.Tienphatsach = Int32.Parse(dr["tienphatsach"].ToString());

                listctptDTO.Add(ctphieutraDTO);
            }



            return(true);
        }
Beispiel #6
0
 public frmPhieuThuTienPhat(docgiaDTO docgia, Form parent)
 {
     InitializeComponent();
     this.docgia   = docgia;
     this.mainForm = parent;
     initPhieuThuTienPhat();
 }
Beispiel #7
0
        public bool danhsachPM(List <phieumuonDTO> listPMDTO)
        {
            string query = string.Format("select* from [phieumuon] ");

            SqlParameter[] parm = new SqlParameter[1];
            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@masach", SqlDbType.Int);
            parm[0].Value = dg.MaThe;


            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                phieumuonDTO pmDTO = new phieumuonDTO();

                pmDTO.Mapm     = int.Parse(dr["mapm"].ToString());
                pmDTO.Ngaymuon = DateTime.Parse(dr["ngaymuon"].ToString());
                pmDTO.Mathe    = int.Parse(dr["mathe"].ToString());


                listPMDTO.Add(pmDTO);
            }


            return(true);
        }
        public bool danhsachloaisach(List <loaisachDTO> list)
        {
            string query = string.Format("select* from [cacloaisach] order by loaisach  asc ");

            SqlParameter[] parm = new SqlParameter[1];

            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@masach", SqlDbType.Int);
            parm[0].Value = dg.MaThe;

            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                loaisachDTO loaisach = new loaisachDTO();

                loaisach.Theloaisach = dr["loaisach"].ToString();

                list.Add(loaisach);
            }

            return(true);
        }
        /// <summary>
        /// Mượn sách
        /// </summary>
        /// <param name="bandoc">bạn đọc mượn</param>
        /// <param name="sachs">danh sách sách mượn , thông tin đúng </param>
        /// <returns></returns>
        public bool MuonSach(docgiaDTO bandoc, List <sachDTO> sachs)
        {
            sachDAL      sachDAL             = new sachDAL();
            quydinhDAL   quyDinhDAL          = new quydinhDAL();
            phieumuonDAL phieuMuonDAL        = new phieumuonDAL();
            ctpmDAL      chiTietPhieuMuonDAL = new ctpmDAL();

            List <sachDTO>      cacSachdangmuon   = new List <sachDTO>();
            quydinhDTO          cacQuyDinh        = new quydinhDTO();
            List <phieumuonDTO> danhsachphieuMuon = new List <phieumuonDTO>();
            List <DateTime>     danhsachngaymuon  = new List <DateTime>();

            sachDAL.SachDangMuon(bandoc.MaThe, cacSachdangmuon, danhsachngaymuon);

            quyDinhDAL.listquydinh(cacQuyDinh);
            phieuMuonDAL.danhsachPM(danhsachphieuMuon);

            //kiểm tra số luọng sách mươn
            if (cacSachdangmuon.Count + sachs.Count > cacQuyDinh.Sosachduocmuon)
            {
                BUS_notification.mess = "Không thể mượn sách vượt quá số lượng cho phép";
                return(false);
            }

            //thêm phiếu mượn
            phieumuonDTO phieumuonDTO = new phieumuonDTO();

            phieumuonDTO.Mapm     = danhsachphieuMuon.Count + 1;
            phieumuonDTO.Mathe    = bandoc.MaThe;
            phieumuonDTO.Ngaymuon = DateTime.Now;
            if (!phieuMuonDAL.themPhieuMuon(phieumuonDTO))
            {
                BUS_notification.mess = "Không thể thêm phiếu mượn";
                return(false);
            }

            //thêm chi tiết phiếu mượn
            foreach (sachDTO sach in sachs)
            {
                ctpmDTO ctpm = new ctpmDTO();
                ctpm.Mapm   = phieumuonDTO.Mapm;
                ctpm.Masach = sach.Masach;
                if (!chiTietPhieuMuonDAL.themCTPM(ctpm))
                {
                    BUS_notification.mess = "Có sự cố trong khi mượn sách " + sach.Tensach;
                    return(false);
                }
                else
                {
                    QuanLiSachBUS sachBUS = new QuanLiSachBUS();
                    sachBUS.MuonSach(sach);
                }

                //thêm vao bang gia han cho sach
                GiaHanSachBUS ghsax = new GiaHanSachBUS();
                ghsax.TaoSoLanmuonsach(sach.Masach);
            }
            return(true);
        }
Beispiel #10
0
 public frmThongTinBanDoc(docgiaDTO docgia, Form parent)
 {
     InitializeComponent();
     this.docgia   = docgia;
     this.mainForm = parent;
     initThongTinBanDoc(docgia);
     initDanhSachSachDangMuon(docgia);
 }
 public void loadDanhSachBanDoc()
 {
     listDocGia = quanLiBanDocBUS.DanhSachDocGia();
     if (listDocGia.Count > 0)
     {
         docgia = listDocGia[0];
         anhXaThongTinBanDoc(0);
     }
 }
 public frmPhieuMuon(docgiaDTO docgia)
 {
     InitializeComponent();
     this.docgia = docgia;
     initFormPhieuMuon(docgia);
     this.DialogResult = DialogResult.Cancel;
     listSachCoSan     = quanLiSach.DanhSachSachCoSan();
     initComboBoxListItems();
     cbTimSachTheoMa.Select();
 }
        /// <summary>
        /// Ánh xạ thông tin bạn đọc
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvThongTinBanDoc_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView data = (DataGridView)sender;

            if (data.RowCount > 0)
            {
                indexBanDoc = data.SelectedRows[0].Index;
                docgia      = listDocGia[indexBanDoc];
                anhXaThongTinBanDoc(indexBanDoc);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Sửa Đọc Giả
        /// </summary>
        /// <param name="docgia"></param>
        /// <returns></returns>
        public bool SuaDocGia(docgiaDTO docgia)
        {
            docgiaDAL dgDAL = new docgiaDAL();

            if (dgDAL.isDocGia(docgia.MaThe))
            {
                return(dgDAL.suaDocGia(docgia, docgia.MaThe));
            }
            BUS_notification.mess = "Không tồn tại mã thẻ";
            return(false);
        }
Beispiel #15
0
        /// <summary>
        /// Thêm đọc giả
        /// </summary>
        /// <param name="docgia"></param>
        /// <returns></returns>
        public bool ThemDocGia(docgiaDTO docgia)
        {
            docgiaDAL dgDAL = new docgiaDAL();

            if (dgDAL.isDocGia(docgia.MaThe))
            {
                BUS_notification.mess = "Đã tạo thẻ với số CMND này. Vui lòng chọn số CMND khác";
                return(false);
            }
            return(dgDAL.themDocGia(docgia));
        }
Beispiel #16
0
 private void initThongTinBanDoc(docgiaDTO docgia)
 {
     txbTenBanDoc.Text         = docgia.HoTen;
     txbCMNDBanDoc.Text        = docgia.MaThe.ToString();
     dtpNgaySinhBanDoc.Value   = docgia.NgaySinh;
     txbEmailBanDoc.Text       = docgia.Email;
     txbDiaChiBanDoc.Text      = docgia.DiaChi;
     cbLoaiDocGia.Text         = QuanLiBanDocBUS.LoaiDocGia[docgia.Loaidocgia];
     txbTongTienNoBanDoc.Text  = docgia.Tongtienno.ToString();
     dtpNgayTaoTheBanDoc.Value = docgia.Ngaydk;
 }
Beispiel #17
0
 private void initDanhSachSachDangMuon(docgiaDTO docgia)
 {
     pnDanhSachSachDangMuon.Controls.Clear();
     listDongThongTinSach.Clear();
     listngaymuon.Clear();
     listSachDocGiaDangMuon = quanLiSachBUS.DanhSachDocGiaDangMuon(docgia, listngaymuon);
     for (int i = 0; i < listSachDocGiaDangMuon.Count; i++)
     {
         initDongThongTinSach(listSachDocGiaDangMuon[i], listngaymuon[i]);
     }
 }
Beispiel #18
0
        /// <summary>
        /// M thêm code vô đây
        /// , rep :ok gái
        /// </summary>
        /// <param name="docgia"></param>
        /// <returns></returns>
        public bool XoaDocGia(docgiaDTO docgia)
        {
            docgiaDAL doxgiaDAL = new docgiaDAL();

            if (!doxgiaDAL.isDocGia(docgia.MaThe))
            {
                BUS_notification.mess = "Không tồn tại mã thẻ";
                return(false);
            }

            return(doxgiaDAL.xoaDocGia(docgia.MaThe));
        }
Beispiel #19
0
 public frmPhieuTra(docgiaDTO docgia, List <ctptDTO> listCTPT)
 {
     InitializeComponent();
     this.docgia   = docgia;
     this.listCTPT = listCTPT;
     foreach (ctptDTO ctpt in listCTPT)
     {
         tongTienPhat += ctpt.Tienphatsach;
         initDongPhieuTra(ctpt);
     }
     initFormPhieuTra(docgia);
 }
 public void loadDanhSachBanDoc(int index)
 {
     listDocGia = quanLiBanDocBUS.DanhSachDocGia();
     dgvThongTinBanDoc.DataSource = listDocGia.Select(o => new { Column1 = o.MaThe, Column2 = o.HoTen, Column3 = o.Email, Column4 = o.NgaySinh }).ToList();
     if (listDocGia.Count > 0)
     {
         dgvThongTinBanDoc.Rows[0].Selected     = false;
         dgvThongTinBanDoc.Rows[index].Selected = true;
         dgvThongTinBanDoc.CurrentCell          = dgvThongTinBanDoc.Rows[index].Cells[0];
         anhXaThongTinBanDoc(index);
         indexBanDoc = index;
         docgia      = listDocGia[indexBanDoc];
     }
 }
        // tim kiem doc gia theo ten
        public bool timkiemDG(string Searchstr, List <docgiaDTO> ldgDTO)
        {
            //****** ưu tiên chuỗi đầu tien hơn


            // tìm vs chuỗi vào có dấu
            // thêm vào list
            // tạo một list tạm
            // chuyển tất cả các tên trong list thành không dấu vào list tạm
            // chuyển searchstr thành ko dấu
            // tim trong list ko dấu vs str ko dau

            // add

            //string searchStr2=ConvertToUnSign(Searchstr);

            string query = string.Format("select * from [docgia] where hoten like @hoten");

            SqlParameter[] param = new SqlParameter[1];
            param[0]       = new SqlParameter("@hoten", SqlDbType.NVarChar);
            param[0].Value = Convert.ToString("%" + Searchstr + "%");

            DataTable dtb = new DataTable();

            dtb = conn.excuteNonQuery(query, param);

            foreach (DataRow dr in dtb.Rows)
            {
                docgiaDTO tdgDTO = new docgiaDTO();

                tdgDTO.MaThe      = Int32.Parse(dr["mathe"].ToString());
                tdgDTO.HoTen      = dr["hoten"].ToString();
                tdgDTO.Email      = dr["email"].ToString();
                tdgDTO.Loaidocgia = Int32.Parse(dr["loaidocgia"].ToString());
                tdgDTO.NgaySinh   = DateTime.Parse(dr["ngaysinh"].ToString());
                tdgDTO.Ngaydk     = DateTime.Parse(dr["ngaydk"].ToString());
                tdgDTO.DiaChi     = dr["diachi"].ToString();
                tdgDTO.Tongtienno = Int32.Parse(dr["tongtienno"].ToString());

                ldgDTO.Add(tdgDTO);
            }


            if (dtb.Rows.Count > 0)
            {
                return(true);
            }

            return(false);
        }
Beispiel #22
0
        private void btnThemBanDoc_Click(object sender, EventArgs e)
        {
            int loaiDocGia = 0;
            int tuoi       = 0;

            if (txbTenBanDoc.Text != "" && txbEmailBanDoc.Text != "" && txbDiaChiBanDoc.Text != "" && txbCMNDBanDoc.Text != "" && dtpNgaySinhBanDoc.Text != "")
            {
                QuanLiBanDocBUS quanLiBanDocBUS = new QuanLiBanDocBUS();
                tuoi = DateTime.Now.Year - dtpNgaySinhBanDoc.Value.Year;
                if (tuoi < 18)
                {
                    loaiDocGia = 0;
                }
                else if (tuoi >= 18 && tuoi <= 22)
                {
                    loaiDocGia = 1;
                }
                else if (tuoi > 22)
                {
                    loaiDocGia = 2;
                }

                docgiaDTO dgDTO = new docgiaDTO(int.Parse(txbCMNDBanDoc.Text), txbTenBanDoc.Text, txbDiaChiBanDoc.Text, txbEmailBanDoc.Text, dtpNgaySinhBanDoc.Value, DateTime.Now, 0, loaiDocGia);
                if (quanLiBanDocBUS.ThemDocGia(dgDTO))
                {
                    MessageBox.Show("Đã thêm bạn đọc thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    int index = 0;
                    for (int i = 0; i < quanLiBanDocBUS.DanhSachDocGia().Count; i++)
                    {
                        if (int.Parse(txbCMNDBanDoc.Text) == quanLiBanDocBUS.DanhSachDocGia()[i].MaThe)
                        {
                            index = i;
                        }
                    }

                    refresh();
                    (mainForm as frmManHinhChinh).loadDanhSachBanDoc(index);
                }
                else
                {
                    MessageBox.Show(BUS_notification.mess, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #23
0
        private void btnLapPhieuTra_Click(object sender, EventArgs e)
        {
            refreshError();

            for (int i = 0; i < listDongThongTinSach.Count; i++)
            {
                if (listDongThongTinSach[i].chkChonSach.CheckState == CheckState.Checked)
                {
                    listSachDocGiaMuonTra.Add(listSachDocGiaDangMuon[i]);
                    if (listDongThongTinSach[i].cbTinhTrangSach.SelectedItem.ToString() == QuanLiSachBUS.DanhSachTrangThaiSach[0])
                    {
                        listSachDocGiaDangMuon[i].Trangthai = 0;
                    }
                    else
                    {
                        listSachDocGiaDangMuon[i].Trangthai = 2;
                    }
                }
            }

            if (listSachDocGiaMuonTra.Count == 0)
            {
                lbError.Text = "Vui lòng chọn sách để tạo phiếu trả";
            }
            else
            {
                try
                {
                    frmPhieuTra f = new frmPhieuTra(docgia, quanLiMuonTraMatBUS.TraSach(docgia, listSachDocGiaMuonTra));
                    f.ShowDialog();
                    listSachDocGiaMuonTra.Clear();
                    docgia = quanLiBanDocBUS.TimDocGia(docgia.MaThe.ToString(), docgia.HoTen)[0];
                    initThongTinBanDoc(docgia);
                    initDanhSachSachDangMuon(docgia);
                    chkChonSach.CheckState = CheckState.Unchecked;
                    sttErrorLabel.Text     = "Tạo phiếu trả thành công";
                }
                catch (Exception error)
                {
                    sttErrorLabel.Text = "Tạo phiếu trả thất bại. Vui lòng thử lại";
                    Console.WriteLine(error.ToString());
                }
            }
        }
Beispiel #24
0
        /// Danh sách các tựa sách mà đọc giả đang lượng
        /// </summary>
        /// <param name="docgia"></param>
        /// <returns></returns>
        public List <sachDTO> DanhSachDocGiaDangMuon(docgiaDTO docgia, List <DateTime> listngaymuon)
        {
            docgiaDAL docGiaDAL = new docgiaDAL();
            sachDAL   saxDAL    = new sachDAL();

            List <sachDTO> listsach = new List <sachDTO>();

            //List<DateTime> listngaymuon = new List<DateTime>();

            if (!docGiaDAL.isDocGia(docgia.MaThe))
            {
                BUS_notification.mess = "Không tồn tại đọc giả";
                return(new List <sachDTO>());
            }

            if (!saxDAL.SachDangMuon(docgia.MaThe, listsach, listngaymuon))
            {
                return(new List <sachDTO>());
            }
            return(listsach);
        }
Beispiel #25
0
        //hien thi danh sach
        public bool tatcaSach(List <sachDTO> lsachDTO)
        {
            string query = string.Format("select* from [sach] ");

            SqlParameter[] parm = new SqlParameter[1];
            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            parm[0]       = new SqlParameter("@masach", SqlDbType.Int);
            parm[0].Value = dg.MaThe;


            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                sachDTO sDTO = new sachDTO();

                sDTO.Masach    = int.Parse(dr["masach"].ToString());
                sDTO.Tensach   = dr["tensach"].ToString();
                sDTO.Theloai   = dr["Theloai"].ToString();
                sDTO.Tacgia    = dr["tacgia"].ToString();
                sDTO.Nxb       = dr["nxb"].ToString();
                sDTO.Ngaynhap  = DateTime.Parse(dr["ngaynhap"].ToString());
                sDTO.Ngayxb    = DateTime.Parse(dr["ngayxb"].ToString());
                sDTO.Giatri    = int.Parse(dr["giatri"].ToString());
                sDTO.Trangthai = int.Parse(dr["trangthai"].ToString());

                lsachDTO.Add(sDTO);
            }



            return(true);
        }
Beispiel #26
0
        // hien thi list dto

        public bool danhsachDG(List <docgiaDTO> listDGDTO)
        {
            string query = string.Format("select* from [docgia] ");

            SqlParameter[] parm = new SqlParameter[1];
            docgiaDTO      dg   = new docgiaDTO();

            parm[0]       = new SqlParameter("@mathe", SqlDbType.Int);
            parm[0].Value = dg.MaThe;

            DataTable datatable = new DataTable();

            datatable = conn.excuteNonQuery(query, parm);

            //gan value trong datatable vao DTO

            foreach (DataRow dr in datatable.Rows)
            {
                docgiaDTO tdgDTO = new docgiaDTO();

                tdgDTO.MaThe      = Int32.Parse(dr["mathe"].ToString());
                tdgDTO.HoTen      = dr["hoten"].ToString();
                tdgDTO.Email      = dr["email"].ToString();
                tdgDTO.Loaidocgia = Int32.Parse(dr["loaidocgia"].ToString());
                tdgDTO.NgaySinh   = DateTime.Parse(dr["ngaysinh"].ToString());
                tdgDTO.Ngaydk     = DateTime.Parse(dr["ngaydk"].ToString());
                tdgDTO.DiaChi     = dr["diachi"].ToString();
                tdgDTO.Tongtienno = Int32.Parse(dr["tongtienno"].ToString());

                listDGDTO.Add(tdgDTO);
            }



            return(true);
        }
        // hien thi list dto

        public bool listquydinh(quydinhDTO qdDTO)
        {
            string query = string.Format("select * from quydinh ");

            SqlParameter[] param = new SqlParameter[1];
            DataTable      dt    = new DataTable();
            // ko can thiet nhung phai co
            docgiaDTO dg = new docgiaDTO();

            param[0]       = new SqlParameter("@masach", SqlDbType.Int);
            param[0].Value = dg.MaThe;
            dt             = conn.excuteNonQuery(query, param);

            qdDTO.Tuoimax                   = int.Parse(dt.Rows[0]["tuoimax"].ToString());
            qdDTO.Tuoimin                   = int.Parse(dt.Rows[0]["tuoimin"].ToString());
            qdDTO.Songayduocmuon            = int.Parse(dt.Rows[0]["songayduocmuon"].ToString());
            qdDTO.Sosachduocmuon            = int.Parse(dt.Rows[0]["sosachduocmuon"].ToString());
            qdDTO.Kcnamxuatban              = int.Parse(dt.Rows[0]["kcnamxuatban"].ToString());
            qdDTO.Tienphattrasachtremoingay = int.Parse(dt.Rows[0]["tienphattrasachtremoingay"].ToString());



            return(true);
        }
 private void initFormPhieuMuon(docgiaDTO docgia)
 {
     txbTenBanDoc.Text   = docgia.HoTen;
     txbMaTheBanDoc.Text = docgia.MaThe.ToString();
 }
Beispiel #29
0
 private void initFormPhieuTra(docgiaDTO docgia)
 {
     txbTenBanDoc.Text    = docgia.HoTen;
     txbMaTheBanDoc.Text  = docgia.MaThe.ToString();
     txbTongTienPhat.Text = tongTienPhat.ToString();
 }
        private void cbNhapMaTheBanDoc_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                try
                {
                    if (cbNhapMaTheBanDoc.Text != "" && new docgiaDAL().isDocGia(listDocGia[cbNhapMaTheBanDoc.SelectedIndex].MaThe))
                    {
                        QuanLiBanDocBUS quanLiBanDoc = new QuanLiBanDocBUS();
                        QuanLiSachBUS   quanLiSach   = new QuanLiSachBUS();
                        docgiaDTO       docgia       = listDocGia[cbNhapMaTheBanDoc.SelectedIndex];

                        int index = 0;
                        for (int i = 0; i < quanLiBanDoc.DanhSachDocGia().Count; i++)
                        {
                            if (docgia.MaThe == quanLiBanDoc.DanhSachDocGia()[i].MaThe)
                            {
                                index = i;
                            }
                        }

                        if (codeMuonTra == 0)
                        {
                            frmPhieuMuon f = new frmPhieuMuon(docgia);
                            f.ShowDialog();
                            (mainForm as frmManHinhChinh).ShowThongTinBanDoc(index);
                        }
                        else if (codeMuonTra == 1)
                        {
                            frmThongTinBanDoc f = new frmThongTinBanDoc(docgia, mainForm);
                            f.ShowDialog();
                        }
                        else if (codeMuonTra == 2)
                        {
                            frmPhieuThuTienPhat f = new frmPhieuThuTienPhat(docgia, mainForm);
                            f.ShowDialog();
                        }
                        this.Close();
                    }
                    else
                    {
                        if (cbNhapMaTheBanDoc.Text == "")
                        {
                            MessageBox.Show("Vui lòng nhập mã bạn đọc", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        }
                        else
                        {
                            MessageBox.Show("Bạn đọc không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Lỗi định dạng hoặc mã không tồn tại. Vui lòng thử lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            if (e.KeyCode == Keys.Escape)
            {
                this.Close();
            }
        }