コード例 #1
0
        private void cbbDanhMuc_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbbDanhMuc.SelectedValue.ToString() == "System.Data.DataRowView")
            {
            }
            else
            {
                var id = cbbDanhMuc.SelectedValue.ToString();
                idDanhmuc = Convert.ToInt32(id);
                FMain_Load(sender, e);
            }
            DAO_Main main = new DAO_Main();

            cbbSanPham.DataSource = main.ListSP_DanhMuc(idDanhmuc);
            if (main.ListSP_DanhMuc(idDanhmuc).Count() == 0)
            {
                cbbSanPham.Text = "";
                lbSoLuong.Text  = "0";
                lv.Items.Clear();
            }
            else
            {
                cbbSanPham.DisplayMember = "TenSanPham";
                cbbSanPham.ValueMember   = "ID";
                var id = cbbSanPham.SelectedValue.ToString();
                idSanPham = Convert.ToInt32(id);
                int soluong = main.SoLuong(idSanPham);
                lbSoLuong.Text = soluong.ToString();

                db = new QuanLyKhoHangDataContext();
                string href    = "H:\\project\\c#\\Wfrom\\QuanLyKhoHnag_ChuoiCuaHangTienIch\\QuanLyKhoHnag_ChuoiCuaHangTienIch\\Image\\";
                var    sanpham = db.SanPhams.SingleOrDefault(x => x.ID == idSanPham);
                pictureBox1.Image = Image.FromFile(href + sanpham.HinhAnh);
            }
        }
コード例 #2
0
        private void Init()
        {
            DAO_SanPham sp   = new DAO_SanPham();
            DAO_Main    main = new DAO_Main();

            lv.FullRowSelect = true;
            lv.View          = View.Details;
            lv.GridLines     = true;
            lv.Columns.Add("ID");
            lv.Columns.Add("Tên Sản Phẩm", 120);
            lv.Columns.Add("Số Lượng", 100);
            lv.Columns.Add("Đơn Vị", 90);
            lv.Columns.Add("Ngày Thêm", 120);
            lv.Columns.Add("NSX", 120);
            lv.Columns.Add("HSD", 120);
            lv.Columns.Add("Danh Mục", 125);
            cbbDanhMuc.Text = "";
            cbbSanPham.Text = "";
        }
コード例 #3
0
        private void cbbSanPham_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbbSanPham.SelectedValue.ToString() == "System.Data.DataRowView")
            {
            }
            else if (cbbSanPham.SelectedValue.ToString() == "QuanLyKhoHnag_ChuoiCuaHangTienIch.DTO.DTO_SanPham")
            {
            }
            else
            {
                var id = cbbSanPham.SelectedValue.ToString();
                idSanPham = Convert.ToInt32(id);
                DAO_Main main    = new DAO_Main();
                int      soluong = main.SoLuong(idSanPham);
                lbSoLuong.Text = soluong.ToString();
                FMain_Load(sender, e);

                db = new QuanLyKhoHangDataContext();
                string href    = "H:\\project\\c#\\Wfrom\\QuanLyKhoHnag_ChuoiCuaHangTienIch\\QuanLyKhoHnag_ChuoiCuaHangTienIch\\Image\\";
                var    sanpham = db.SanPhams.SingleOrDefault(x => x.ID == idSanPham);
                pictureBox1.Image = Image.FromFile(href + sanpham.HinhAnh);
            }
        }
コード例 #4
0
        private void FMain_Load(object sender, EventArgs e)
        {
            DAO_SanPham        sp   = new DAO_SanPham();
            DAO_Main           main = new DAO_Main();
            List <DTO_SanPham> list = new List <DTO_SanPham>();

            if (cbbDanhMuc.Text == "" && cbbSanPham.Text == "")
            {
                lv.Items.Clear();
                list = main.ListSP();
                foreach (var item in list)
                {
                    ListViewItem it = new ListViewItem(item.ID.ToString());
                    it.SubItems.Add(item.Tensanpham);
                    it.SubItems.Add(item.Soluong.ToString());
                    it.SubItems.Add(item.Donvi.ToString());
                    it.SubItems.Add(item.Ngaythem.ToString());
                    it.SubItems.Add(item.Ngaysanxuat.ToString());
                    it.SubItems.Add(item.Hansudung.ToString());
                    object table   = Data.Instance.ExecuteScalar("select TenDanhMuc from DanhMucSanPham where ID = @id ", new object[] { item.DanhmucID });
                    string danhmuc = table.ToString();
                    it.SubItems.Add(danhmuc);
                    lv.Items.Add(it);
                }
            }
            else if (cbbDanhMuc.Text != "" && cbbSanPham.Text == "")
            {
                lv.Items.Clear();
                list = main.ListSP_DanhMuc(idDanhmuc);
                foreach (var item in list)
                {
                    ListViewItem it = new ListViewItem(item.ID.ToString());
                    it.SubItems.Add(item.Tensanpham);
                    it.SubItems.Add(item.Soluong.ToString());
                    it.SubItems.Add(item.Donvi.ToString());
                    it.SubItems.Add(item.Ngaythem.ToString());
                    it.SubItems.Add(item.Ngaysanxuat.ToString());
                    it.SubItems.Add(item.Hansudung.ToString());
                    object table   = Data.Instance.ExecuteScalar("select TenDanhMuc from DanhMucSanPham where ID = @id ", new object[] { item.DanhmucID });
                    string danhmuc = table.ToString();
                    it.SubItems.Add(danhmuc);
                    lv.Items.Add(it);
                }
            }
            else if (cbbDanhMuc.Text != "" && cbbSanPham.Text != "")
            {
                lv.Items.Clear();
                list = main.ListSP_DanhMuc_SanPham(idSanPham);
                foreach (var item in list)
                {
                    ListViewItem it = new ListViewItem(item.ID.ToString());
                    it.SubItems.Add(item.Tensanpham);
                    it.SubItems.Add(item.Soluong.ToString());
                    it.SubItems.Add(item.Donvi.ToString());
                    it.SubItems.Add(item.Ngaythem.ToString());
                    it.SubItems.Add(item.Ngaysanxuat.ToString());
                    it.SubItems.Add(item.Hansudung.ToString());
                    object table   = Data.Instance.ExecuteScalar("select TenDanhMuc from DanhMucSanPham where ID = @id ", new object[] { item.DanhmucID });
                    string danhmuc = table.ToString();
                    it.SubItems.Add(danhmuc);
                    lv.Items.Add(it);
                }
            }
        }