Beispiel #1
0
        private void SuaPhieuMuon_GUI()
        {
            PhieuMuonDTO phieuMuonDTO = new PhieuMuonDTO();
            SachDTO      sachDTO      = new SachDTO();
            TheDocGiaDTO theDG        = new TheDocGiaDTO();

            GetPhieuMuon_Data_From_GUI(phieuMuonDTO);
            theDG.Madg = phieuMuonDTO.Madg;

            int flag = 0;

            foreach (string ma in ListMaSach)
            {
                sachDTO.Masach = ma;
                bool updateSach = sachBus.UpdateData(sachDTO);
                if (updateSach)
                {
                    flag = 1;
                }
            }

            bool result   = phieuMuonBus.SuaPhieuMuon(phieuMuonDTO);
            bool resultDG = theDGBus.UpdateSoSachMuon(theDG, intTongSoSachDangChon);

            if (result && resultDG && flag == 1)
            {
                //SACH SOLUONG VA LUOT MUON
                MessageBox.Show("ĐÃ CẬP NHẬT PHIẾU MƯỢN THÀNH CÔNG!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("ĐÃ CÓ LỖI XẢY RA, VUI LÒNG KIỂM TRA LẠI", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        public static List <TTPhieuMuonDTO> SelecLendNote(PhieuMuonDTO phieuMuon)
        {
            string sqlstr = $"EXEC dbo.SelecLendNote '{phieuMuon.Ngaymuon}'";
            List <TTPhieuMuonDTO> chiTiet = new List <TTPhieuMuonDTO>();

            MySQL.Open();
            using (SqlDataReader dataReader = MySQL.ExecuteSQL(sqlstr))
            {
                while (dataReader.Read())
                {
                    chiTiet.Add(
                        new TTPhieuMuonDTO(
                            phieuMuon,
                            new SachDTO(
                                new DauSachDTO(
                                    dataReader["dausach"].ToString(),
                                    Int32.Parse(dataReader["songaytoida"].ToString())
                                    ),
                                Int32.Parse(dataReader["stt"].ToString())
                                ),
                            Int32.Parse(dataReader["phat"].ToString()),
                            DateTime.TryParse(dataReader["mapt"].ToString(), out DateTime mapt) ? mapt : new DateTime()
                            )
                        );
                }
            }
            MySQL.Close();
            return(chiTiet);
        }
Beispiel #3
0
        public List <PhieuMuonDTO> ConvertToList(DataTable temp)
        {
            List <PhieuMuonDTO> ans = new List <PhieuMuonDTO>();

            if (temp == null)
            {
                return(ans);
            }

            for (int i = 0; i < temp.Rows.Count; ++i)
            {
                PhieuMuonDTO receipt = new PhieuMuonDTO(temp.Rows[i]);

                if (ans.Count == 0)
                {
                    ans.Add(receipt);
                }
                else if (receipt.Mapm != ans[ans.Count - 1].Mapm)
                {
                    ans.Add(receipt);
                }
            }

            return(ans);
        }
Beispiel #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DataGridViewRow dgvRow = dtgrvSachTV.CurrentRow;
            int             MaSach = (int)dgvRow.Cells[0].Value;
            SachBUS         sb     = new SachBUS();

            sb.UpdateRecord(MaSach, true);

            ChiTietMuonDTO ctmuon = new ChiTietMuonDTO();

            ctmuon.MaSach  = MaSach;
            ctmuon.NgayTra = dtNgTra.Value;

            ChiTietMuonBUS ctmBus = new ChiTietMuonBUS();

            ctmBus.Insert(ctmuon);

            PhieuMuonDTO phieuMuon = new PhieuMuonDTO();

            phieuMuon.MaDocGia = int.Parse(txtMaDG.Text);
            phieuMuon.NgayMuon = DateTime.Now;

            PhieuMuonBUS pmBus = new PhieuMuonBUS();

            pmBus.Insert(phieuMuon);

            btnChon_Click(sender, e);
        }
Beispiel #5
0
 public bool them(PhieuMuonDTO item)
 {
     try
     {
         con.Open();
         string     sql = "INSERT INTO PhieuMuon VALUES(@maphieu, @madg, @ngaymuon, @manv)";
         SqlCommand cmd = new SqlCommand(sql, con);
         cmd.Parameters.AddWithValue("maphieu", item.MaPhieuMuon);
         cmd.Parameters.AddWithValue("madg", item.MaDocGia);
         cmd.Parameters.AddWithValue("ngaymuon", item.NgayMuon);
         cmd.Parameters.AddWithValue("manv", item.MaNhanVien);
         if (cmd.ExecuteNonQuery() > 0)
         {
             return(true);
         }
     }
     catch (Exception ex)
     {
     }
     finally
     {
         con.Close();
     }
     return(false);
 }
        public void UpdatePhieuMuon(PhieuMuonDTO phieumuonDTO)
        {
            var phieumuon = phieumuonRepository.GetBy(phieumuonDTO.MaPM);

            phieumuon.TrangThai = 0;
            phieumuonRepository.Update(phieumuon);
        }
        public void CreatePhieuMuon(PhieuMuonDTO phieumuonDTO)
        {
            var phieumuon = phieumuonDTO.MappingPhieuMuon();

            phieumuon.TrangThai = 1;
            phieumuonRepository.Add(phieumuon);
        }
Beispiel #8
0
 public static PhieuMuon MappingPhieuMuon(this PhieuMuonDTO pmDTO)
 {
     if (!(pmDTO.ChiTietPhieuMuons == null))
     {
         return(new PhieuMuon
         {
             MaPM = pmDTO.MaPM,
             MaDG = pmDTO.MaDG,
             NgayMuon = pmDTO.NgayMuon,
             TongPhiMuon = pmDTO.TongPhiMuon,
             UserId = pmDTO.UserId,
             //ChiTietPhieuMuons = pmDTO.ChiTietPhieuMuons
             ChiTietPhieuMuons = pmDTO.ChiTietPhieuMuons.MappingCTPMs().ToList()
         });
     }
     else
     {
         return(new PhieuMuon
         {
             MaPM = pmDTO.MaPM,
             MaDG = pmDTO.MaDG,
             NgayMuon = pmDTO.NgayMuon,
             TongPhiMuon = pmDTO.TongPhiMuon,
             UserId = pmDTO.UserId,
         });
     }
 }
        public int ThemPhieuMuon(PhieuMuonDTO PM)
        {
            int nRow = 0;

            try
            {
                string strSQL = "INSERT INTO PhieuMuonSach VALUES(@MaPM,@NgayMuon,@MaDG,@NgayHetHan)";
                provider.Connect();
                nRow = provider.ExecuteNonQuery(CommandType.Text, strSQL,
                                                new SqlParameter {
                    ParameterName = "@MaPM", Value = PM.MaPM
                },
                                                new SqlParameter {
                    ParameterName = "@NgayMuon", Value = PM.NgayMuon
                },
                                                new SqlParameter {
                    ParameterName = "@MaDG", Value = PM.MaDG
                },
                                                new SqlParameter {
                    ParameterName = "@NgayHetHan", Value = PM.NgayHetHan
                }
                                                );
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Beispiel #10
0
        public bool them(PhieuMuonDTO temp, bool MuonSach)
        {
            Console.WriteLine("Them the doc gia.");
            string query = string.Empty;

            if (MuonSach)
            {
                query += "INSERT INTO[dbo].[tblPhieuMuon]([maPhieu],[maSach],[maDocGia],[ngayMuon],[thoiHang])";
                query += " VALUES(@maPhieu,@maSach,@maDocGiam,@ngayMuon,@thoiHang)";
            }
            else
            {
                query += "INSERT INTO[dbo].[tblPhieuTra]([maPhieu],[maSach],[maDocGia],[ngayTra])";
                query += " VALUES(@maPhieu,@maSach,@maDocGiam,@ngayTra)";
            }
            Console.WriteLine("Query: " + query);
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    Console.WriteLine("Bat đầu ex query");
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    if (MuonSach)
                    {
                        cmd.Parameters.AddWithValue("@maPhieu", temp.MaPhieuMuon);
                        cmd.Parameters.AddWithValue("@maSach", temp.MaSach);
                        cmd.Parameters.AddWithValue("@maDocGiam", temp.MaDocGia);
                        cmd.Parameters.AddWithValue("@ngayMuon", temp.NgayMuon.Year + "-" + temp.NgayMuon.Month + "-" + temp.NgayMuon.Day);
                        cmd.Parameters.AddWithValue("@thoiHang", temp.ThoiHan);
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@maPhieu", temp.MaPhieuTra);
                        cmd.Parameters.AddWithValue("@maSach", temp.MaSach);
                        cmd.Parameters.AddWithValue("@maDocGiam", temp.MaDocGia);
                        cmd.Parameters.AddWithValue("@ngayTra", temp.NgayTra.Year + "-" + temp.NgayTra.Month + "-" + temp.NgayTra.Day);
                    }
                    Console.WriteLine("Ma Ta:" + temp.MaPhieuTra + "ma sach" + temp.MaSach + " Ma doc gia " + temp.MaDocGia);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();

                        con.Close();
                        con.Dispose();
                        Console.WriteLine("ex query thanh cong");
                    }
                    catch (Exception ex)
                    {
                        con.Close();
                        Console.WriteLine("ex query that bai");
                        return(false);
                    }
                }
            }
            return(true);
        }
Beispiel #11
0
        public void GetInfo_From(PhieuMuonDTO phieuMuon)
        {
            strMaDG     = phieuMuon.Madg;
            strNgayMuon = phieuMuon.Ngaymuon.ToShortDateString();

            //Tách từng mã sách ra thành 1 list mã sách
            ListMaSach = InputChecking.Instance.SeparateWords(phieuMuon.Masach.ToString());
        }
        private void btnLapPhieu_Click(object sender, EventArgs e)
        {
            if (STTSach > 1 && txtMaDG.Text != "" && dtgrvPM[1, 0].Value.ToString() != "")
            {
                if (TinhTrangDG.CompareTo("TTDG01") == 0)
                {
                    DateTime     ngayMuon  = new DateTime(dtNgayMuon.Value.Year, dtNgayMuon.Value.Month, dtNgayMuon.Value.Day);
                    DateTime     newTime   = ngayMuon.AddDays(MaxNgayMuon);
                    PhieuMuonDTO PhieuMuon = new PhieuMuonDTO();
                    PhieuMuon.MaPM       = txtMaPhieuMuon.Text;
                    PhieuMuon.NgayMuon   = dtNgayMuon.Value;
                    PhieuMuon.MaDG       = txtMaDG.Text;
                    PhieuMuon.NgayHetHan = newTime;
                    QuanLyPhieuMuonBUS BUS = new QuanLyPhieuMuonBUS();
                    int nRow = BUS.ThemPhieuMuon(PhieuMuon);


                    CT_PhieuMuonDTO CTPM;
                    for (int i = 0; i < dtgrvPM.RowCount; i++)
                    {
                        if (Convert.ToString(dtgrvPM.Rows[i].Cells[1].Value) != "")
                        {
                            CTPM        = new CT_PhieuMuonDTO();
                            CTPM.MaPM   = txtMaPhieuMuon.Text;
                            CTPM.MaSach = Convert.ToString(dtgrvPM.Rows[i].Cells[1].Value);
                            BUS.ThemChiTietPhieuMuon(CTPM);
                            BUS.CapNhatTinhTrangSach(CTPM.MaSach);
                        }
                    }

                    if (nRow > 0)
                    {
                        MessageBox.Show("Lập phiếu mượn thành công", "THÔNG BÁO");
                        LoadThemThanhCong();
                    }
                    else
                    {
                        MessageBox.Show("Lập phiếu mượn thất bại", "THÔNG BÁO");
                    }
                }
                else
                {
                    MessageBox.Show("Không thể mượn sách vì thẻ độc giả đã hết hạn", "THÔNG BÁO");
                    return;
                }
            }
            else if (txtMaDG.Text == "")
            {
                MessageBox.Show("Xin vui lòng nhập mã độc giả", "THÔNG BÁO");
                txtMaDG.Focus();
                return;
            }
            else if (STTSach == 1 || dtgrvPM[1, 0].Value.ToString() == "")
            {
                MessageBox.Show("Vui lòng thêm sách vào phiếu mượn", "THÔNG BÁO");
            }
        }
Beispiel #13
0
        public bool XoaPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            string query = string.Empty;

            object[] para = { phieuMuon.Mapm };

            query += "DELETE FROM  PHIEUMUON WHERE MAPM = @MAPM";

            return(dataprovider.excuteNonQuery(query, para));
        }
Beispiel #14
0
        public static int InserLendNote(PhieuMuonDTO phieuMuon)
        {
            string sqlstr = $"EXEC dbo.InserLendNote '{phieuMuon.Ngaymuon}', '{phieuMuon.Madg.Madg}'";

            MySQL.Open();
            int numrow = MySQL.ExecuteNonSQL(sqlstr);

            MySQL.Close();
            return(numrow);
        }
Beispiel #15
0
        /* Phương thức thêm phiếu mượn rồi trả về số dòng thực hiện được
         * thêm phiếu mượn trước rồi thêm chi tiết phiếu mượn sau */
        public static int AddLendNote(List <TTPhieuMuonDTO> phieuMuons)
        {
            PhieuMuonDTO phieuMuon = phieuMuons[0].Mapm;
            int          check     = TTPhieuMuonDAO.InserLendNote(phieuMuon);

            if (check > 0)
            {
                return(check + TTPhieuMuonDAO.InserDetailLendNote(phieuMuons));
            }
            return(0);
        }
Beispiel #16
0
        public bool ThemPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            string query = string.Empty;

            object[] listpara = { phieuMuon.Masach, phieuMuon.Madg, phieuMuon.Ngaymuon, phieuMuon.Hantra, phieuMuon.Soluong, phieuMuon.Mucphat };

            query += "INSERT INTO PHIEUMUON(MASACH, MADG, NGAYMUON, HANTRA, SOLUONG, MUCPHAT) ";
            query += "VALUES ( @MASACH , @MADG , @NGAYMUON , @HANTRA , @SOLUONG , @MUCPHAT  )";

            return(dataprovider.excuteNonQuery(query, listpara));
        }
Beispiel #17
0
        public frmTraSach(PhieuMuonDTO selectedreceipt)
        {
            InitializeComponent();

            sachBUS         = new SachBUS();
            theDGBus        = new TheDocGiaBUS();
            phieumuonBUS    = new PhieuMuonBUS();
            phieutraBUS     = new PhieuTraBUS();
            SelectedReceipt = selectedreceipt;
            SelectedBookIDs = new List <string>();
        }
 public int ThemPhieuMuon(PhieuMuonDTO PM)
 {
     try
     {
         QuanLyPhieuMuonDAO DAO = new QuanLyPhieuMuonDAO();
         return(DAO.ThemPhieuMuon(PM));
     }
     catch (SqlException ex)
     {
         throw ex;
     }
 }
Beispiel #19
0
 public static void MappingPhieuMuon(this PhieuMuonDTO pmDTO, PhieuMuon pm)
 {
     pm.MaPM        = pmDTO.MaPM;
     pm.MaDG        = pmDTO.MaDG;
     pm.NgayMuon    = pmDTO.NgayMuon;
     pm.TongPhiMuon = pmDTO.TongPhiMuon;
     pm.UserId      = pmDTO.UserId;
     //pm.ChiTietPhieuMuons = pmDTO.ChiTietPhieuMuons;
     if (pmDTO.ChiTietPhieuMuons != null)
     {
         pm.ChiTietPhieuMuons = pmDTO.ChiTietPhieuMuons.MappingCTPMs().ToList();
     }
 }
Beispiel #20
0
        public List <PhieuMuonDTO> GetMaSach()
        {
            List <PhieuMuonDTO> list = new List <PhieuMuonDTO>();
            string    query          = "SELECT DISTINCT MaSach FROM dbo.PHIEUMUON ";
            DataTable data           = DataProvider.Instance.ExecuteQuery(query);

            foreach (DataRow item in data.Rows)
            {
                PhieuMuonDTO phieuMuon = new PhieuMuonDTO(item);
                list.Add(phieuMuon);
            }
            return(list);
        } //Lấy danh sách mã sách
Beispiel #21
0
        public frmChiTietPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            InitializeComponent();
            sachBus  = new SachBUS();
            theDGBus = new TheDocGiaBUS();

            GetInfo_From(phieuMuon);
            GetTenDG_From_MaDG();
            AddSach_Into_ListSach();
            SetTenDG_NgayMuon();

            LoadDataGirdView_ChiTietPM();
        }
Beispiel #22
0
        public bool SuaPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            string query = string.Empty;

            object[] listpara = { phieuMuon.Masach, phieuMuon.Madg, phieuMuon.Soluong, phieuMuon.Mapm };

            query += "UPDATE PHIEUMUON ";
            query += "SET MASACH = @MASACH , MADG = @MADG , SOLUONG = @SOLUONG ";
            query += " WHERE MAPM = @MAPM";


            return(dataprovider.excuteNonQuery(query, listpara));
        }
Beispiel #23
0
        private void cbMaSach_SelectedIndexChanged(object sender, EventArgs e)
        {
            string   id;
            ComboBox cb = sender as ComboBox;

            if (cb.SelectedItem is null)
            {
                return;
            }

            PhieuMuonDTO selected = cb.SelectedItem as PhieuMuonDTO;

            id = selected.MaSach;
            loadPMTheoMaSach(id);
        }
Beispiel #24
0
        /**
         * @param phieuMuon
         */
        public void SuaPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            querry = "update PhieuMuon set MaDocGia=@MaDocGia,NgayMuon=@NgayMuon,MaNhanVien=@MaNhanVien where MaPhieuMuon=@MaPhieuMuon";
            connection.Open();
            command = new SqlCommand(querry, connection.sqlConnection);
            command.Parameters.AddWithValue("MaPhieuMuon", phieuMuon.MaPhieuMuon);
            command.Parameters.AddWithValue("MaDocGia", phieuMuon.MaPhieuMuon);
            command.Parameters.AddWithValue("NgayMuon", phieuMuon.NgayMuon);
            command.Parameters.AddWithValue("MaNhanVien", phieuMuon.MaNhanVien);
            command.ExecuteNonQuery();
            // TODO implement here

            connection.Close();
            // TODO implement here
        }
Beispiel #25
0
        /**
         * @param phieuMuon
         */
        public void ThemPhieuMuon(PhieuMuonDTO phieuMuon)
        {
            querry = "insert PhieuMuon values(@MaPhieuMuon,@MaDocGia,@NgayMuon,@MaNhanVien)";
            connection.Open();
            command = new SqlCommand(querry, connection.sqlConnection);
            command.Parameters.AddWithValue("MaPhieuMuon", phieuMuon.MaPhieuMuon);
            command.Parameters.AddWithValue("MaDocGia", phieuMuon.MaDocGia);
            command.Parameters.AddWithValue("NgayMuon", phieuMuon.NgayMuon);
            command.Parameters.AddWithValue("MaNhanVien", phieuMuon.MaNhanVien);
            command.ExecuteNonQuery();
            // TODO implement here

            connection.Close();
            // TODO implement here
        }
Beispiel #26
0
        private void GetPhieuMuon_Data_From_GUI(PhieuMuonDTO phieuMuonDTO)
        {
            phieuMuonDTO.Madg     = cmbxMaDG_frmMuon.Text.ToString();
            phieuMuonDTO.Soluong  = intTongSoSachDangChon;
            phieuMuonDTO.Ngaymuon = DateTime.Now;
            phieuMuonDTO.Hantra   = phieuMuonDTO.CalDueDate(Qd);
            phieuMuonDTO.Masach   = string.Empty;
            phieuMuonDTO.Mapm     = mapm;
            phieuMuonDTO.Mucphat  = MucPhat;

            foreach (string Ma in ListMaSach)
            {
                phieuMuonDTO.Masach += (Ma + " ");
            }
        }
Beispiel #27
0
        public static void Insert(PhieuMuonDTO PhieuMuon)
        {
            OleDbConnection connection = DataProvider.CreateConnection();
            string          cmdText    = "Insert into PHIEUMUON(NgayMuon, MaDG) values(?, ?)";
            OleDbCommand    command    = new OleDbCommand(cmdText, connection);

            command.Parameters.Add("@NgayMuon", OleDbType.Date);
            command.Parameters.Add("@MaDG", OleDbType.Integer);

            command.Parameters["@NgayMuon"].Value = PhieuMuon.NgayMuon;
            command.Parameters["@MaDG"].Value     = PhieuMuon.MaDocGia;

            command.ExecuteNonQuery();
            command.CommandText   = "select @@IDENTITY";
            PhieuMuon.MaPhieuMuon = (int)command.ExecuteScalar();
            connection.Close();
        }
Beispiel #28
0
        public IActionResult Index(string sortOrder, string searchString, int pageIndex = 1)
        {
            int pageSize = 8;
            int count;
            var dsphieumuon = phieuMuonService.GetPhieuMuons(sortOrder, searchString, pageIndex, pageSize, out count);
            var phieumuon   = new PhieuMuonDTO();
            var ctpm        = new ChiTietPhieuMuonDTO();
            var listSach    = sachService.GetSachs(sortOrder, searchString, pageIndex, pageSize, out count);
            var phieumuonVM = new PhieuMuonIndexVm()
            {
                PhieuMuons   = new PaginatedList <PhieuMuonDTO>(dsphieumuon, count, pageIndex, pageSize),
                SearchString = searchString,
                SortOrder    = sortOrder,
                phieumuon    = phieumuon,
                ctpm         = ctpm
            };

            return(View(phieumuonVM));
        }
Beispiel #29
0
        public List <PhieuMuonDTO> Select()
        {
            List <PhieuMuonDTO> ListPhieuMuon = new List <PhieuMuonDTO>();

            string query = "SELECT[MAPM],[MASACH],[MADG],[NGAYMUON],[HANTRA] ,[SOLUONG] FROM[PHIEUMUON]";


            DataTable DtPhieuMuon = DataProvider.Instance.Excutequery(query);

            foreach (DataRow row in DtPhieuMuon.Rows)
            {
                PhieuMuonDTO phieuMuon = new PhieuMuonDTO();

                phieuMuon.NewReceipt(row);
                ListPhieuMuon.Add(phieuMuon);
            }

            return(ListPhieuMuon);
        }
Beispiel #30
0
        public List <PhieuMuonDTO> Select_MaSach_By_MaPhieuMuon(string sKeyword)
        {
            List <PhieuMuonDTO> ListPhieuMuon = new List <PhieuMuonDTO>();

            string query = "SELECT[MAPM],[MASACH],[MADG],[NGAYMUON],[HANTRA] FROM[PHIEUMUON] ";

            query += "WHERE MAPM = @sKeyword ";

            DataTable DtPhieuMuon = dataprovider.Excutequery(query);

            foreach (DataRow row in DtPhieuMuon.Rows)
            {
                PhieuMuonDTO phieuMuon = new PhieuMuonDTO();

                phieuMuon.NewReceipt(row);
                ListPhieuMuon.Add(phieuMuon);
            }

            return(ListPhieuMuon);
        }