Exemple #1
0
        void LoadThongTin()
        {
            ThongTinSach temp = SBLL.LayThongTinSach(MaSach);

            lbMaDauSach.Text  = temp.MaDauSach;
            MaDauSach         = temp.MaDauSach;
            lbTenDauSach.Text = temp.TenDauSach;
            lbTacGia.Text     = temp.TenTacGia;
            lbTheLoai.Text    = temp.TheLoai;
            lbNgonNgu.Text    = temp.NgonNgu;
            lbNhaXuatBan.Text = temp.NhaXuatBan;
            lbMaSach.Text     = temp.MaSach;
            lbMaDauSach.Text  = temp.MaDauSach;
            lbNgayThem.Text   = temp.NgayThem;
            nbTap.Value       = temp.Tap;
            nbLanTB.Value     = temp.LanTaiBan;
            nbTang.Value      = temp.Tang;
            nbNgan.Value      = temp.Ngan;
            txbSoTrang.Text   = temp.SoTrang.ToString();
            txbNamXB.Text     = temp.NamXuatBan.ToString("dd/MM/yyyy");
            txbTinhTrang.Text = temp.TinhTrang;
            cbGia.Text        = temp.MaGiaSach.ToString() + " - " + temp.TenGiaSach;



            // Gợi ý dữ liệu cho giá sách
            List <GiaSach> LGS = SBLL.LayGiaSach();

            foreach (GiaSach a in LGS)
            {
                cbGia.Items.Add(a.MaGiaSach.ToString() + " - " + a.TenGiaSach);
            }
            //
        }
Exemple #2
0
        void LoadThongTin()
        {
            ThongTinSach temp = SBLL.LayThongTinSach(MaSach);

            lbMaDauSach.Text  = temp.MaDauSach;
            MaDauSach         = temp.MaDauSach;
            lbTenDauSach.Text = temp.TenDauSach;
            lbTacGia.Text     = temp.TenTacGia;
            lbTheLoai.Text    = temp.TheLoai;
            lbNgonNgu.Text    = temp.NgonNgu;
            lbNhaXuatBan.Text = temp.NhaXuatBan;
            lbMaSach.Text     = temp.MaSach;
            lbMaDauSach.Text  = temp.MaDauSach;
            lbNgayThem.Text   = temp.NgayThem;
            nbTap.Value       = temp.Tap;
            nbLanTB.Value     = temp.LanTaiBan;
            nbTang.Value      = temp.Tang;
            nbNgan.Value      = temp.Ngan;
            txbSoTrang.Text   = temp.SoTrang.ToString();
            txbNamXB.Text     = temp.NamXuatBan.ToString("dd/MM/yyyy");
            txbTinhTrang.Text = temp.TinhTrang;
            cbGia.Text        = temp.MaGiaSach.ToString() + " - " + temp.TenGiaSach;
            if (temp.HinhAnh != "")
            {
                pictureBox1.Image = new Bitmap(Application.StartupPath + "\\HinhAnh\\" + temp.HinhAnh);
            }
            // Gợi ý dữ liệu cho giá sách
            List <GiaSach> LGS = SBLL.LayGiaSach();

            foreach (GiaSach a in LGS)
            {
                cbGia.Items.Add(a.MaGiaSach.ToString() + " - " + a.TenGiaSach);
            }
            //
        }
        public List <ThongTinSach> ThongKeCuonSach()
        {
            List <ThongTinSach> LS = new List <ThongTinSach>();

            OpenConnection();
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "select * from ThongKeCuonSach";
            command.Connection  = conn;
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                ThongTinSach temp = new ThongTinSach();
                temp.TenDauSach = reader.GetString(0);
                if (!reader.IsDBNull(1))
                {
                    temp.Tap = reader.GetInt32(1);
                }
                else
                {
                    temp.Tap = 0;
                }
                if (!reader.IsDBNull(2))
                {
                    temp.LanTaiBan = reader.GetInt32(2);
                }
                else
                {
                    temp.LanTaiBan = 0;
                }
                if (!reader.IsDBNull(3))
                {
                    temp.SoTrang = reader.GetInt32(3);
                }
                else
                {
                    temp.SoTrang = 0;
                }
                if (!reader.IsDBNull(4))
                {
                    temp.SoCuon = reader.GetInt32(4);
                }
                else
                {
                    temp.SoCuon = 0;
                }

                LS.Add(temp);
            }
            reader.Close();
            return(LS);
        }
Exemple #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            ThongTinSach temp = new ThongTinSach();

            temp.MaSach    = lbMaSach.Text;
            temp.Tap       = Int32.Parse(nbTap.Value.ToString());
            temp.LanTaiBan = Int32.Parse(nbLanTB.Value.ToString());
            int sotrang;

            if (Int32.TryParse(txbSoTrang.Text, out sotrang) && sotrang > 0)
            {
                temp.SoTrang = sotrang;
                DateTime nxb = new DateTime();
                if (DateTime.TryParse(ChuyenDoiNgayThang(txbNamXB.Text), out nxb))
                {
                    temp.NamXuatBan = nxb;
                    temp.TinhTrang  = txbTinhTrang.Text;
                    string[] giasach = cbGia.Text.Split('-');
                    temp.MaGiaSach = Int32.Parse(giasach[0]);
                    temp.Tang      = Int32.Parse(nbTang.Value.ToString());
                    temp.Ngan      = Int32.Parse(nbNgan.Value.ToString());

                    /*string tenanh = "";
                     * if(pictureBox1.Image != null)
                     * {
                     *  tenanh = temp.MaSach + tenduoianh;
                     *  File.Copy(txbLink.Text, Path.Combine(Application.StartupPath + "\\HinhAnh\\",tenanh),true);
                     * }
                     * temp.HinhAnh = tenanh;
                     */
                    if (SBLL.SuaThongTinSach(temp))
                    {
                        MessageBox.Show("Sửa thông tin thành công");
                        LoadThongTin();
                    }
                    else
                    {
                        MessageBox.Show("Sửa thông tin thất bại");
                    }
                }
                else
                {
                    MessageBox.Show("Kiểm tra lại năm xuất bản");
                }
            }
            else
            {
                MessageBox.Show("Số trang phải là số nguyên dương");
            }
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            List <Sach> _sach    = new List <Sach>();
            SachBUS     _busSach = new SachBUS();

            dataGrid.Items.Clear();

            _sach = _busSach.GetList();

            List <TacGia> _tacGia    = new List <TacGia>();
            TacGiaBUS     _busTacGia = new TacGiaBUS();

            _tacGia = _busTacGia.GetList();

            List <NhaXuatBan> _nhaXuatBan    = new List <NhaXuatBan>();
            NhaXuatBanBUS     _busNhaXuatBan = new NhaXuatBanBUS();

            _nhaXuatBan = _busNhaXuatBan.GetList();

            List <TheLoai> _theLoai    = new List <TheLoai>();
            TheLoaiBUS     _busTheLoai = new TheLoaiBUS();

            _theLoai = _busTheLoai.GetList();

            foreach (Sach i in _sach)
            {
                ThongTinSach _thongTinSach = new ThongTinSach();
                _thongTinSach.MaSach     = i.MaSach;
                _thongTinSach.TenSach    = i.TenSach;
                _thongTinSach.TheLoai    = LayTenTheLoai(_theLoai, i.TheLoai);
                _thongTinSach.TacGia     = LayTenTacGia(_tacGia, i.TacGia);
                _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                _thongTinSach.NamXuatBan = i.NamXuatBan;
                _thongTinSach.GiaBan     = i.GiaBan.ToString();
                _thongTinSach.SoLuong    = i.SoLuong;

                dataGrid.Items.Add(_thongTinSach);
            }
        }
Exemple #6
0
        public bool SuaThongTinSach(ThongTinSach x)
        {
            OpenConnection();
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "SuaThongTinSach";
            command.Connection  = conn;

            command.Parameters.Add("@masach", SqlDbType.NChar).Value        = x.MaSach;
            command.Parameters.Add("@tap", SqlDbType.Int).Value             = x.Tap;
            command.Parameters.Add("@lantaiban", SqlDbType.Int).Value       = x.LanTaiBan;
            command.Parameters.Add("@sotrang", SqlDbType.Int).Value         = x.SoTrang;
            command.Parameters.Add("@namxuatban", SqlDbType.DateTime).Value = x.NamXuatBan;
            command.Parameters.Add("@tinhtrang", SqlDbType.NVarChar).Value  = x.TinhTrang;
            command.Parameters.Add("@giasach", SqlDbType.Int).Value         = x.MaGiaSach;
            command.Parameters.Add("@tang", SqlDbType.Int).Value            = x.Tang;
            command.Parameters.Add("@ngan", SqlDbType.Int).Value            = x.Ngan;
            command.Parameters.Add("@hinhanh", SqlDbType.NVarChar).Value    = x.HinhAnh;
            int kq = command.ExecuteNonQuery();

            return(kq > 0);
        }
        private void btTim_Click(object sender, RoutedEventArgs e)
        {
            List<Sach> _sach = new List<Sach>();
            SachBUS _busSach = new SachBUS();

            dataGrid.Items.Clear();

            _sach = _busSach.GetList();

            string _maTheLoai = "";
            foreach(TheLoai i in _theLoai)
            {
                if (i.TenTheLoai == cbbTheLoai.Text)
                {
                    _maTheLoai = i.MaTheLoai;
                    break;
                }
            }

            List<TacGia> _tacGia = new List<TacGia>();
            TacGiaBUS _busTacGia = new TacGiaBUS();
            _tacGia = _busTacGia.GetList();

            List<NhaXuatBan> _nhaXuatBan = new List<NhaXuatBan>();
            NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS();
            _nhaXuatBan = _busNhaXuatBan.GetList();

            int stt = 1;

            if (tbTenSach.Text == "")
            {
                foreach (Sach i in _sach)
                {
                    if (i.TheLoai == _maTheLoai)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt = stt++;
                        _thongTinSach.TenSach = i.TenSach;
                        _thongTinSach.TheLoai = cbbTheLoai.Text;
                        _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan = i.GiaBan.ToString();
                        _thongTinSach.SoLuong = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
            else if (tbTenSach.Text != "" && cbbTheLoai.Text != "")
            {
                foreach (Sach i in _sach)
                {
                    if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0 && i.TheLoai==_maTheLoai)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt = stt++;
                        _thongTinSach.TenSach = i.TenSach;
                        _thongTinSach.TheLoai = cbbTheLoai.Text;
                        _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan = i.GiaBan.ToString();
                        _thongTinSach.SoLuong = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
            else if(tbTenSach.Text!="")
            {
                foreach (Sach i in _sach)
                {
                    if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt = stt++;
                        _thongTinSach.TenSach = i.TenSach;
                        _thongTinSach.TheLoai = LayTenTheLoai(_theLoai,i.TheLoai);
                        _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan = i.GiaBan.ToString();
                        _thongTinSach.SoLuong = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
        }
Exemple #8
0
        public ThongTinSach LayThongTinSach(string MaSach)
        {
            ThongTinSach kq = new ThongTinSach();

            OpenConnection();
            SqlCommand command = new SqlCommand();

            command.CommandType = CommandType.Text;
            command.CommandText = "select * from dbo.ThongTinChiTietCuonSach(@masach)";
            command.Connection  = conn;
            command.Parameters.Add("@masach", SqlDbType.NChar).Value = MaSach;
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                kq.MaDauSach = reader.GetString(0);
                if (!reader.IsDBNull(1))
                {
                    kq.TenDauSach = reader.GetString(1);
                }
                else
                {
                    kq.TenDauSach = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(2))
                {
                    kq.TenTacGia = reader.GetString(2);
                }
                else
                {
                    kq.TenTacGia = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(3))
                {
                    kq.TheLoai = reader.GetString(3);
                }
                else
                {
                    kq.TheLoai = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(4))
                {
                    kq.NgonNgu = reader.GetString(4);
                }
                else
                {
                    kq.NgonNgu = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(5))
                {
                    kq.NhaXuatBan = reader.GetString(5);
                }
                else
                {
                    kq.NhaXuatBan = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(6))
                {
                    kq.MaSach = reader.GetString(6);
                }
                if (!reader.IsDBNull(7))
                {
                    kq.Tap = reader.GetInt32(7);
                }
                else
                {
                    kq.Tap = 0;
                }
                if (!reader.IsDBNull(8))
                {
                    kq.LanTaiBan = reader.GetInt32(8);
                }
                else
                {
                    kq.LanTaiBan = 0;
                }
                if (!reader.IsDBNull(9))
                {
                    kq.SoTrang = reader.GetInt32(9);
                }
                else
                {
                    kq.SoTrang = 0;
                }
                if (!reader.IsDBNull(10))
                {
                    kq.NgayThem = reader.GetDateTime(10).ToString("dd/MM/yyyy");
                }
                else
                {
                    kq.NgayThem = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(11))
                {
                    kq.NamXuatBan = reader.GetDateTime(11);
                }
                else
                {
                    kq.NamXuatBan = new DateTime();
                }
                if (!reader.IsDBNull(12))
                {
                    kq.TinhTrang = reader.GetString(12);
                }
                else
                {
                    kq.TinhTrang = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(13))
                {
                    kq.MaGiaSach = reader.GetInt32(13);
                }
                else
                {
                    kq.MaGiaSach = 0;
                }
                if (!reader.IsDBNull(14))
                {
                    kq.TenGiaSach = reader.GetString(14);
                }
                else
                {
                    kq.TenGiaSach = "Chưa có thông tin";
                }
                if (!reader.IsDBNull(15))
                {
                    kq.Tang = reader.GetInt32(15);
                }
                else
                {
                    kq.Tang = 0;
                }
                if (!reader.IsDBNull(16))
                {
                    kq.Ngan = reader.GetInt32(16);
                }
                else
                {
                    kq.Ngan = 0;
                }
                if (!reader.IsDBNull(17))
                {
                    kq.HinhAnh = reader.GetString(17);
                }
                else
                {
                    kq.HinhAnh = "";
                }
            }
            reader.Close();
            return(kq);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            List<Sach> _sach = new List<Sach>();
            SachBUS _busSach = new SachBUS();

            dataGrid.Items.Clear();

            _sach = _busSach.GetList();

            List<TacGia> _tacGia = new List<TacGia>();
            TacGiaBUS _busTacGia = new TacGiaBUS();
            _tacGia = _busTacGia.GetList();

            List<NhaXuatBan> _nhaXuatBan = new List<NhaXuatBan>();
            NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS();
            _nhaXuatBan = _busNhaXuatBan.GetList();

            List<TheLoai> _theLoai = new List<TheLoai>();
            TheLoaiBUS _busTheLoai = new TheLoaiBUS();
            _theLoai = _busTheLoai.GetList();

            foreach (Sach i in _sach)
            {
                ThongTinSach _thongTinSach = new ThongTinSach();
                _thongTinSach.MaSach = i.MaSach;
                _thongTinSach.TenSach = i.TenSach;
                _thongTinSach.TheLoai = LayTenTheLoai(_theLoai, i.TheLoai);
                _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia);
                _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                _thongTinSach.NamXuatBan = i.NamXuatBan;
                _thongTinSach.GiaBan = i.GiaBan.ToString();
                _thongTinSach.SoLuong = i.SoLuong;

                dataGrid.Items.Add(_thongTinSach);
            }
        }
Exemple #10
0
 public bool SuaThongTinSach(ThongTinSach temp)
 {
     return(SAC.SuaThongTinSach(temp));
 }
        private void btTim_Click(object sender, RoutedEventArgs e)
        {
            List <Sach> _sach    = new List <Sach>();
            SachBUS     _busSach = new SachBUS();

            dataGrid.Items.Clear();

            _sach = _busSach.GetList();

            string _maTheLoai = "";

            foreach (TheLoai i in _theLoai)
            {
                if (i.TenTheLoai == cbbTheLoai.Text)
                {
                    _maTheLoai = i.MaTheLoai;
                    break;
                }
            }

            List <TacGia> _tacGia    = new List <TacGia>();
            TacGiaBUS     _busTacGia = new TacGiaBUS();

            _tacGia = _busTacGia.GetList();

            List <NhaXuatBan> _nhaXuatBan    = new List <NhaXuatBan>();
            NhaXuatBanBUS     _busNhaXuatBan = new NhaXuatBanBUS();

            _nhaXuatBan = _busNhaXuatBan.GetList();

            int stt = 1;

            if (tbTenSach.Text == "")
            {
                foreach (Sach i in _sach)
                {
                    if (i.TheLoai == _maTheLoai)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt        = stt++;
                        _thongTinSach.TenSach    = i.TenSach;
                        _thongTinSach.TheLoai    = cbbTheLoai.Text;
                        _thongTinSach.TacGia     = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan     = i.GiaBan.ToString();
                        _thongTinSach.SoLuong    = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
            else if (tbTenSach.Text != "" && cbbTheLoai.Text != "")
            {
                foreach (Sach i in _sach)
                {
                    if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0 && i.TheLoai == _maTheLoai)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt        = stt++;
                        _thongTinSach.TenSach    = i.TenSach;
                        _thongTinSach.TheLoai    = cbbTheLoai.Text;
                        _thongTinSach.TacGia     = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan     = i.GiaBan.ToString();
                        _thongTinSach.SoLuong    = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
            else if (tbTenSach.Text != "")
            {
                foreach (Sach i in _sach)
                {
                    if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0)
                    {
                        ThongTinSach _thongTinSach = new ThongTinSach();
                        _thongTinSach.Stt        = stt++;
                        _thongTinSach.TenSach    = i.TenSach;
                        _thongTinSach.TheLoai    = LayTenTheLoai(_theLoai, i.TheLoai);
                        _thongTinSach.TacGia     = LayTenTacGia(_tacGia, i.TacGia);
                        _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan);
                        _thongTinSach.NamXuatBan = i.NamXuatBan;
                        _thongTinSach.GiaBan     = i.GiaBan.ToString();
                        _thongTinSach.SoLuong    = i.SoLuong;

                        dataGrid.Items.Add(_thongTinSach);
                    }
                }
            }
        }