Ejemplo n.º 1
0
        public void RefreshMaterialID()
        {
            MaterialID = 0;
            var material = _db.Materials.FirstOrDefault(x => CategoryID0 > 0 && x.CategoryID0 == CategoryID0 &&
                                                        (CategoryID1 == 0 || x.CategoryID1 == CategoryID1) &&
                                                        (CategoryID2 == 0 || x.CategoryID2 == CategoryID2) &&
                                                        (CategoryID3 == 0 || x.CategoryID3 == CategoryID3) &&
                                                        (CategoryID4 == 0 || x.CategoryID4 == CategoryID4));

            if (material != null)
            {
                MaterialID = material.MaterialID;

                var mp = _db.MaterialPrices.FirstOrDefault(x => x.MaterialID == MaterialID);
                if (mp == null)
                {
                    return;
                }

                UnitName     = mp.MaterialPriceUnit.UnitName;
                CurrentPrice = string.Format("{0:C2}", mp.Price);
                Price        = MyConvert.ConvertToDouble(mp.Price);
                MaterialName = MaterialCommon.GetMaterialName(material);
            }
        }
Ejemplo n.º 2
0
        public MaterialSearchJobCosting(int categoryID0, int categoryID1, int categoryID2)
        {
            var materials = _db.Materials.Where(x => categoryID0 > 0 &&
                                                categoryID0 == x.CategoryID0 &&
                                                (x.CategoryID1 == categoryID1 && categoryID1 > 0) &&
                                                (categoryID2 == 0 || x.CategoryID2 == categoryID2)
                                                ).OrderBy(x => x.MaterialCategory1.CategoryName)
                            .ThenBy(x => x.MaterialCategory2.CategoryName)
                            .ThenBy(x => x.MaterialCategory3.CategoryName)
                            .ThenBy(x => x.MaterialCategory4.CategoryName)
                            .ToList();

            Values = new List <SelectListItem>();
            foreach (var material in materials)
            {
                var mb = new SelectListItem();
                mb.Value = material.MaterialID.ToString("");
                mb.Text  = MaterialCommon.GetMaterialName(material);
                Values.Add(mb);
            }
        }