public void AddBom(bool checkLastRow) { var currentRowIndex = (SelectedMainRow.BomList.IndexOf(SelectedBomRow)); if (checkLastRow) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedBomRow, new ValidationContext(SelectedBomRow, null, null), valiationCollection, true); if (!isvalid) { return; } } var newrow = new BomViewModel { TblStandardBomHeader = SelectedMainRow.Iserial, IsAcc = false }; SelectedMainRow.BomList.Insert(currentRowIndex + 1, newrow); SelectedBomRow = newrow; }
public BomFabricBom(BomViewModel fabricViewModel) { InitializeComponent(); ViewModel = new BomFabricBomViewModel(fabricViewModel); DataContext = ViewModel; ViewModel.GetMaindata(); }
public BomFabricBomViewModel(BomViewModel viewModel) { if (!DesignerProperties.IsInDesignTool) { _fabricViewModel = viewModel; MainRowList = new SortableCollectionView <TblBomFabricBomViewModelViewModel>(); SelectedMainRow = new TblBomFabricBomViewModelViewModel(); Client.GetTblRouteGroupAsync(0, int.MaxValue, "it.Iserial", null, null); Client.GetTblRouteGroupCompleted += (s, sv) => { RouteGroupList = sv.Result; }; Client.GetBomFabricBomCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblBomFabricBomViewModelViewModel { ItemPerRow = new ItemsDto() }; var ItemRow = sv.FabricServiceList.FirstOrDefault( x => x.Iserial == row.Item && x.ItemGroup == row.ItemType); newrow.ItemPerRow.Code = ItemRow.Code; newrow.ItemPerRow.Name = ItemRow.Name; newrow.ItemPerRow.Unit = ItemRow.Unit; newrow.ItemPerRow.ItemGroup = ItemRow.ItemGroup; newrow.InjectFrom(row); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; Client.UpdateOrInsertBomFabricBomCompleted += (s, x) => { var savedRow = (TblBomFabricBomViewModelViewModel)MainRowList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.DeleteBomFabricBomCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; } }
public virtual void BuildSelectLists(BomViewModel bomViewModel) { }
public ActionResult BuildAbility(string search) { //LocationViewModel1 mymodel = new LocationsViewModel1(); var startDate = DateTime.Parse("12/16/2020"); var query = from a in db.BomLevel1s join tx in db.TxQohs on a.DetailPn equals tx.Pn join r in db.PoPlans.Where(a => a.ReceiptDateTime >= startDate).Where(y => y.PoOrderStatusId == 5) on tx.Pn equals r.CustomerPn into g join s in db.ShipPlans.Where(u => u.ShipDateTime >= startDate).Where(z => z.ShipPlanStatusId == 5) on tx.Pn equals s.CustomerPn into gr join j in db.WoBuilds.Where(u => u.WoEnterDateTime >= startDate) on tx.Pn equals j.CustomerPn into sr join c in db.CycleCounts.Where(u => u.CycleCountDateTime >= startDate) on tx.Pn equals c.CustomerPn into cr join n in db.NCRs.Where(u => u.StatusId != 2) on tx.Pn equals n.PartNumber into nr orderby tx.Pn orderby a.BomNo ascending select new { a.BomNo, a.UnitNo, a.DetailPn, a.Description, Qoh = tx.Qoh + (int?)g.Select(x => x.ReceivedQty).DefaultIfEmpty(0).Sum() - (int?)gr.Select(x => x.ShipQty).DefaultIfEmpty(0).Sum() + (int?)sr.Select(x => x.Qty).DefaultIfEmpty(0).Sum() + (int?)cr.Select(x => x.PortalAdjQty).DefaultIfEmpty(0).Sum(), a.QtyPer, NcrQty = (int?)nr.Select(x => x.Quantity).DefaultIfEmpty(0).Sum(), }; /*var query = from a in db.BomLevel1s * join tx in db.TxQohs on a.DetailPn equals tx.Pn * orderby a.BomNo ascending * select new * { * a.BomNo, * a.UnitNo, * a.DetailPn, * a.Description, * tx.Qoh, * a.QtyPer, * tx.NcrQty * };*/ //new LocationViewModel1 //{ // a.CustomerPn, a.PartDescription, a.Location, tx.Qoh // } List <BomViewModel> boms = new List <BomViewModel>(); foreach (var bom in query.ToList()) { BomViewModel mymodel = new BomViewModel() { BomNo = bom.BomNo, UnitNo = bom.UnitNo, DetailPn = bom.DetailPn, Description = bom.Description, Qoh = bom.Qoh, QtyPer = bom.QtyPer, NcrQty = bom.NcrQty, BuildAbility = (bom.Qoh / bom.QtyPer) }; boms.Add(mymodel); } return(View("~/Views/BomLevel1/BuildAbility.cshtml", boms.Where(x => x.UnitNo.Contains(search) || search == null).ToList())); }
public StandardBomViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.StandardBomForm.ToString()); GetSeason(); var calculationClient = new CRUD_ManagerServiceClient(); calculationClient.GetGenericCompleted += (s, sv) => { BomCalcMethodList = sv.Result; }; calculationClient.GetGenericAsync("BOM_CalcMethod", "%%", "%%", "%%", "Iserial", "ASC"); //Client.GetTblPaymentScheduleCompleted += (s, sv) => //{ // PaymentScheduleList = sv.Result; //}; //Client.GetTblPaymentScheduleAsync(0, int.MaxValue, "it.Iserial", null, null); var uomClient = new CRUD_ManagerServiceClient(); uomClient.GetGenericCompleted += (s, sv) => { UomList = sv.Result; }; uomClient.GetGenericAsync("tbl_lkp_UoM", "%%", "%%", "%%", "Iserial", "ASC"); MainRowList = new SortableCollectionView <TblStandardBomHeaderViewModel>(); SelectedMainRow = new TblStandardBomHeaderViewModel(); // MainRowList.CollectionChanged += MainRowList_CollectionChanged; var factorGroupClient = new CRUD_ManagerServiceClient(); factorGroupClient.GetGenericCompleted += (s, sv) => { FactoryGroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); var complixtyGroupClient = new CRUD_ManagerServiceClient(); complixtyGroupClient.GetGenericCompleted += (s, sv) => { //complix GroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetAllBrandsCompleted += (s, sv) => { BrandList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetTblStandardBOMHeaderCompleted += (s, sv) => { Loading = false; if (sv.Result != null) { foreach (var row in sv.Result) { var newrow = new TblStandardBomHeaderViewModel(); newrow.InjectFrom(row); if (!MainRowList.Contains(newrow)) { newrow.SeasonPerRow = new TblLkpSeason(); newrow.FactoryGroupPerRow = new GenericTable(); newrow.ComplexityGroupPerRow = new GenericTable(); if (BrandSectionList.All(x => x.Iserial != row.TblLkpBrandSection1.Iserial)) { BrandSectionList.Add(new LkpData.TblLkpBrandSection().InjectFrom(row.TblLkpBrandSection1) as LkpData.TblLkpBrandSection); } if (SeasonList.All(x => x.Iserial != row.TblLkpSeason)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row.TblLkpSeason1) as TblLkpSeason); } newrow.FactoryGroupPerRow = new GenericTable().InjectFrom(row.TblFactoryGroup1) as GenericTable; if (row.TblComplexityGroup1 != null) { newrow.ComplexityGroupPerRow = new GenericTable().InjectFrom(row.TblComplexityGroup1) as GenericTable; } newrow.SectionPerRow = row.TblLkpBrandSection1; newrow.SeasonPerRow = SeasonList.FirstOrDefault(x => x.Iserial == newrow.TblLkpSeason); MainRowList.Add(newrow); } } } Loading = false; FullCount = sv.fullCount; if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0)) { SelectedMainRow = MainRowList.FirstOrDefault(); } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } if (Export) { Export = false; var handler = ExportCompleted; if (handler != null) { handler(this, EventArgs.Empty); } //ExportGrid.ExportExcel("Style"); } }; GetMaindata(); Client.UpdateOrInsertTblStandardBOMHeaderCompleted += (s, sv) => { var savedRow = MainRowList.ElementAt(sv.outindex); if (savedRow != null) { savedRow.InjectFrom(sv.Result); } Loading = false; }; Client.DeleteTblStandardBOMHeaderCompleted += (s, ev) => { var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial); if (oldrow != null) { MainRowList.Remove(oldrow); } Loading = false; if (!MainRowList.Any()) { AddNewMainRow(false); } }; Client.DeleteTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { throw sv.Error; } var oldrow = SelectedMainRow.BomList.FirstOrDefault(x => x.Iserial == sv.Result); if (oldrow != null) { SelectedMainRow.BomList.Remove(oldrow); } }; Client.GetTblStandardBOMCompleted += (s, sv) => { SelectedMainRow.BomList.Clear(); foreach (var row in sv.Result) { var newrow = new BomViewModel { BOM_CalcMethodPerRow = new GenericTable().InjectFrom(row.BOM_CalcMethod) as GenericTable, BOM_FabricTypePerRow = new GenericTable().InjectFrom(row.BOM_FabricType) as GenericTable }; newrow.ColorPerRow = new TblColor(); newrow.ColorPerRow = row.TblColor1; newrow.InjectFrom(row); newrow.ItemPerRow = sv.itemsList.SingleOrDefault(x => x.Iserial == row.BOM_Fabric); SelectedMainRow.BomList.Add(newrow); } if (SelectedMainRow.BomList.Count == 0) { AddBom(false); } }; Client.UpdateOrInsertTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { MessageBox.Show(sv.Error.Message); return; } GetSalesOrderBom(); }; } }