public MaterialCategoryVm1(int parentID, string parentText) { var db = new SpecificationDbEntities(); //if this Parent exist var parent = db.MaterialCategory0.Find(parentID); var options = db.MaterialCategory1.Where(x => x.CategoryID == 0).ToList(); if (MyString.RemoveSpace(parent.CategoryName) == MyString.RemoveSpace(parentText)) { options = db.MaterialCategory1.Where(x => x.ParentID == parentID || x.CategoryID == 0) .OrderBy(x => x.CategoryName) .ToList(); } //Name="Choose"to "" var opt0 = options.Find(x => x.CategoryID == 0); opt0.CategoryName = ""; //Result Values = options.Select(x => new MyKeyValuePair { Value = x.CategoryName, Key = x.CategoryID, } ).ToList(); }
public CostDbItemSearchVm(string q, string typeText, int categoryID0, int categoryID1, int categoryID2, int estItemID) { var estCostTypeID = Convert.ToInt32(typeText); var db = new SpecificationDbEntities(); var estCostType = db.EST_Cost_Type.Find(estCostTypeID); var dbTypeID = estCostType.TemplateDbTypeID; IAutoCompleteReponses vm; //several estCostType may in one db Type, eg. all labour hours in LabourHourDB switch (dbTypeID) { case (int)NTemplateDbTypeID.Labour: vm = new CostDbItemSearchLabourHour(q, estCostTypeID); break; case (int)NTemplateDbTypeID.Material: vm = new CostDbItemSearchMaterial(q, categoryID0, categoryID1, categoryID2); break; default: if (estCostTypeID == (int)NEstCostType.ShopStandItem) { vm = new CostDbItemSearchStandardItem(q, estItemID); } else { vm = new CostDbItemSearchOthers(estCostTypeID); } break; } Values = vm.Values; }
public CostDbItemSearchMaterial(string q, int categoryID0, int categoryID1, int categoryID2) { Values = new List <MyKeyValuePair>(); if (categoryID0 == 0 && q.Length < 3) { return; } var db = new SpecificationDbEntities(); var qs = new QueryStringForMaterialSearch(q); List <Model.Material> materials; if (categoryID0 > 0) { materials = db.Materials.Where(x => x.CategoryID0 == categoryID0 && (categoryID1 == 0 | x.CategoryID1 == categoryID1) && (categoryID2 == 0 | x.CategoryID2 == categoryID2)) .ToList(); } else { materials = db.Materials.Where(x => x.MaterialCategory1.CategoryName.Contains(qs.Q0)).ToList(); } Values = GetMaterialsFilteredByQueryString(qs, materials); }
public void Create(EST_Drawing value) { var db = new SpecificationDbEntities(); db.EST_Drawing.Add(value); db.SaveChanges(); }
public void Delete(long drawingID) { var db = new SpecificationDbEntities(); var drw = db.EST_Drawing.Find(drawingID); db.Entry(drw).State = EntityState.Deleted; db.SaveChanges(); }
public CostDbItemSearchOthers(int estCostTypeID) { var db = new SpecificationDbEntities(); var options = db.EST_Cost_Db_Other.Where(x => x.EstCostTypeID == estCostTypeID).ToList().OrderBy(x => x.Name).ToList(); Values = options.Select(x => new MyKeyValuePair() { Value = x.Name + "--" + x.UnitPrice.ToString("C2") + "/" + x.Unit, Key = x.DbItemID, }).ToList(); }
public MaterialCategoryVm0() { var db = new SpecificationDbEntities(); var options = db.MaterialCategory0.Where(x => x.CategoryID >= 0).ToList().OrderBy(x => x.CategoryName).ToList(); Values = options.Select(x => new MyKeyValuePair { Value = x.CategoryName, Key = x.CategoryID, } ).ToList(); }
public void OnSalesDispatchingTaskDeleted(long salesDispatchingTaskID) { var db = new SpecificationDbEntities(); var reqTitle = db.Sales_Dispatching_DrawingRequisition_Estimation.FirstOrDefault(x => x.SubmitID == salesDispatchingTaskID); if (reqTitle == null) { return; } reqTitle.SubmitID = 0; var ver = reqTitle.Version; if (ver > 1) { ver = ver - 1; reqTitle.Version = ver; } else { reqTitle.Version = 0; } db.Entry(reqTitle).State = EntityState.Modified; db.SaveChanges(); if (reqTitle.Version > 0) { return; } //Reset Item Status to Original var items = db.EST_Item.Where(x => x.EstRevID == reqTitle.EstRevID).ToList(); foreach (var item in items) { if (item.Sales_Dispatching_DrawingRequisition_EstimationItem == null) { continue; } if (!item.Sales_Dispatching_DrawingRequisition_EstimationItem.Any( )) { continue; } foreach (var req in item.Sales_Dispatching_DrawingRequisition_EstimationItem) { req.Status = 0; db.Entry(req).State = EntityState.Modified; } } db.SaveChanges(); }
public CostParameterProject(int projectID) { var db = new SpecificationDbEntities(); var estRev = db.Sales_JobMasterList_EstRev.First(x => x.JobID == projectID); var estRevID = estRev.EstRevID; CostReportTypeID = (int)NCostReportTypeID.EstRevID; ProjectID = projectID; EstRevID = estRevID; EstItemID = 0; WorkorderID = 0; WorkorderItemID = 0; Configuration = db.EST_Cost_Configuration.First(x => x.EstRevID == estRevID); }
private int CreateNewEstimation(int projectID) { var dbSpec = new SpecificationDbEntities(); var est = new Sales_JobMasterList_EstRev() { JobID = projectID, erRev = 1, sa1ID = 0 }; dbSpec.Sales_JobMasterList_EstRev.Add(est); dbSpec.SaveChanges(); return(est.EstRevID); }
public CostDbItemSearchStandardItem(string q, int estItemID) { var db = new SpecificationDbEntities(); var quoteItem = db.EST_Item.Find(estItemID); var productID = quoteItem.ProductID; var options = db.EST_Cost_Template.Where(x => x.ProductID == productID).ToList(); if (MyConvert.IsNullString(q)) { Values = options.Select(x => new MyKeyValuePair() { Value = x.Name + "--" + 0.ToString("C2") + "/" + "EA", Key = x.TemplateID, }).ToList(); } else { var qs = new QueryStringForMaterialSearch(q); Values = GetStandardItemsFilteredByQueryString(qs, options); } }
public void Refresh() { var db = new SpecificationDbEntities(); Values = new List <MaterialBase>(); List <Model.Material> materials; switch (Value.TypeID) { case (int)NMaterialGenerateType.ByMaterialAdministrator: materials = db.Materials.Where(x => Value.CategoryID0 > 0 && Value.CategoryID0 == x.CategoryID0 && (Value.CategoryID1 == 0 || x.CategoryID1 == Value.CategoryID1) && (Value.CategoryID2 == 0 || x.CategoryID2 == Value.CategoryID2) && (Value.CategoryID3 == 0 || x.CategoryID3 == Value.CategoryID3) && x.TypeID == 0 ).ToList(); break; //case (int)NMaterialGenerateType.ByWorker: //case (int)NMaterialGenerateType.ByEstimator: default: materials = db.Materials.Where(x => x.TypeID == Value.TypeID).ToList(); break; } materials = materials.OrderBy(x => x.MaterialCategory1.CategoryName) .ThenBy(x => x.MaterialCategory2.CategoryName) .ThenBy(x => x.MaterialCategory3.CategoryName) .ThenBy(x => x.MaterialCategory4.CategoryName) .ToList(); foreach (var material in materials) { var mb = new MaterialBase(material); Values.Add(mb); } }
public CostDbItemSearchLabourHour(string q, int estCostTypeID) { var db = new SpecificationDbEntities(); var options = db.EST_Cost_Db_LabourHourProcedure.Where(x => x.EstCostTypeID == estCostTypeID).OrderBy(x => x.Name).ToList(); if (!MyCommon.MyConvert.IsNullString(q)) { q = q.ToUpper(); options = options.Where(x => x.Name.ToUpper().Contains(q)).ToList(); } Values = new List <MyKeyValuePair>(); foreach (var option in options) { var str = option.EST_Cost_Db_LabourHourPosition.RateB.ToString("C2") + "/" + "Hour"; var acr = new MyKeyValuePair { Value = option.Name + "--" + str, Key = option.DbItemID }; Values.Add(acr); } }
public void Refresh(SpecDomain.Model.Material material) { //Value Value = material; //Values var db = new SpecificationDbEntities(); Values = new List <MaterialBase>(); var materials = db.Materials.Where(x => Value.CategoryID0 > 0 && Value.CategoryID0 == x.CategoryID0 && (Value.CategoryID1 == 0 || x.CategoryID1 == Value.CategoryID1) && (Value.CategoryID2 == 0 || x.CategoryID2 == Value.CategoryID2) && (Value.CategoryID3 == 0 || x.CategoryID3 == Value.CategoryID3) ).OrderBy(x => x.MaterialCategory1.CategoryName) .ThenBy(x => x.MaterialCategory2.CategoryName) .ThenBy(x => x.MaterialCategory3.CategoryName) .ThenBy(x => x.MaterialCategory4.CategoryName) .ToList(); foreach (var m in materials) { var mb = new MaterialBase(m); Values.Add(mb); } //Dropdownlist var temp0 = db.MaterialCategory0.Where(x => x.CategoryID >= 0) .OrderBy(x => x.CategoryName) .ToList(); Categories0 = temp0.Select(x => new SelectListItem { Value = Convert.ToString(x.CategoryID), Text = x.CategoryName }); }
public MaterialCategoryVm3(int parentID, string parentText) { var db = new SpecificationDbEntities(); //if this Parent exist var parent = db.MaterialCategory2.Find(parentID); //Diff var options = db.MaterialCategory3.Where(x => x.CategoryID == 0).ToList(); //Diff if (MyString.RemoveSpace(parent.CategoryName) == MyString.RemoveSpace(parentText)) { options = db.MaterialCategory3.Where(x => x.ParentID == parentID || x.CategoryID == 0) //Diff .OrderBy(x => x.CategoryName) .ToList(); } var opt0 = options.Find(x => x.CategoryID == 0); opt0.CategoryName = ""; Values = options.Select(x => new MyKeyValuePair { Value = x.CategoryName, Key = x.CategoryID, } ).ToList(); }
public void RefreshNames() { //IDs Changed _db = new SpecificationDbEntities(); var cat0 = _db.MaterialCategory0.Find(CategoryID0); CategoryName0 = CategoryID0 == 0 ? "" : cat0.CategoryName; var cat1 = _db.MaterialCategory1.Find(CategoryID1); CategoryName1 = CategoryID1 == 0 ? "" : cat1.CategoryName; var cat2 = _db.MaterialCategory2.Find(CategoryID2); CategoryName2 = CategoryID2 == 0 ? "" : cat2.CategoryName; var cat3 = _db.MaterialCategory3.Find(CategoryID3); CategoryName4 = CategoryID3 == 0 ? "" : cat3.CategoryName; var cat4 = _db.MaterialCategory4.Find(CategoryID4); CategoryName4 = CategoryID4 == 0 ? "" : cat4.CategoryName; }