public List <SelectedCbxModel> GetPhieuXuat(bool isSearch)
        {
            db = new DBQLVT();
            List <SelectedCbxModel> result = new List <SelectedCbxModel>();

            result = db.PhieuXuats.Where(m => m.TrangThai == CommonConstant.STATUS_DADUYET).Select(m => new SelectedCbxModel()
            {
                DisPlayMember = m.MaPX, ValueMember = m.MaPX
            }).ToList();
            if (isSearch)
            {
                SelectedCbxModel sel = new SelectedCbxModel();
                sel.ValueMember   = "";
                sel.DisPlayMember = "---Chọn---";
                result.Insert(0, sel);
            }
            return(result);
        }
        public List <SelectedCbxModel> GetCbxKhoVT(bool isSearch)
        {
            db = new DBQLVT();
            List <SelectedCbxModel> result = new List <SelectedCbxModel>();

            result = db.KhoVatTus.Select(m => new SelectedCbxModel()
            {
                DisPlayMember = m.TenKhoVT, ValueMember = m.MaKhoVT
            }).ToList();
            if (isSearch)
            {
                SelectedCbxModel sel = new SelectedCbxModel();
                sel.ValueMember   = "";
                sel.DisPlayMember = "---Chọn---";
                result.Insert(0, sel);
            }
            return(result);
        }
        public List <SelectedCbxModel> CreateTreeDV(bool isAdd)
        {
            db         = new DBQLVT();
            mlstReturn = new List <SelectedCbxModel>();
            List <PXTD> model = (from m in db.PXTDs select m).ToList();
            //List<KhoVatTu> vlstTest = model.ToList() as List<KhoVatTu>;
            var root = model.GenerateTree(c => c.MaPXTD, c => c.ParentID);

            GetTreeList(root);
            if (isAdd)//Them moi
            {
                SelectedCbxModel sel = new SelectedCbxModel()
                {
                    DisPlayMember = "---Chọn---", ValueMember = ""
                };
                mlstReturn.Insert(0, sel);
            }
            return(mlstReturn);
        }
        public List <SelectedCbxModel> GetCbxVatTuInKho(bool isAdd, string maPX)
        {
            db = new DBQLVT();
            List <SelectedCbxModel> result = new List <SelectedCbxModel>();
            var s     = db.PhieuXuats.Find(maPX).MaKhoXuat;
            var model = db.ChiTietKhoVatTus.Where(m => m.MaKhoVT == s)
                        .GroupBy(a => a.MaVT).Select(p => new { MaVT = p.Key, SoLuongTK = p.Sum(q => q.SoLuong) });
            var mos     = model.ToList();
            var results = from m in db.VatTus
                          join n in mos on m.MaVT equals n.MaVT
                          select new SelectedCbxModel()
            {
                DisPlayMember = m.MaVT + " - " + m.TenVT, ValueMember = n.MaVT, SL = n.SoLuongTK
            };

            if (isAdd)
            {
                SelectedCbxModel sel = new SelectedCbxModel();
                sel.ValueMember   = "";
                sel.DisPlayMember = "---Chọn---";
                results.ToList().Insert(0, sel);
            }
            return(results.ToList());
        }