public void InitDisplay(int assemblyTypeId) { //clear to append new divMasterDataView.Controls.Clear(); using (AppDb ctx = new AppDb()) { IQueryable <AssemblySectionType> types = ctx.AssemblySectionTypes.Where(x => x.ShowInDashboard).OrderBy(x => x.DashboardOrderNo); IQueryable <ProductionLine> lines = ctx.ProductionLines.Where(l => l.AssemblyTypeId == assemblyTypeId && l.LineNumber < AppConfiguration.PRODUCTION_SUBASSY_LINENUMBER); for (int i = 0; i < types.Count(); i++) { AssemblySectionType sectionType = types.ElementAt(i); int count = ctx.vStations.Where(x => x.AssemblySectionTypeId == sectionType.Id).Count(); if (count == 0) { continue; } if (sectionType.IsSubAssy) { //subassy DrawSubAssyLine(ctx, sectionType); } else { //Main line foreach (ProductionLine line in lines) { DrawMainLine(ctx, line, sectionType, (i == 0)); if (!sectionType.IsMultiLine) { break; } } } } } //Get data from Repository var dashboard = ProductionRepository.GetProductionDashboard(assemblyTypeId); //Set UI from Repository lblOverall.Text = dashboard.Overall + " %"; lblDailyTarget.Text = dashboard.TargetAchieve + " / " + dashboard.TargetDPR; lblMonthlyTarget.Text = dashboard.MonthlyAchieve + " / " + dashboard.MonthlyDPR; btnOffline.Text = dashboard.OfflineCount.ToString(); btnRectification.Text = dashboard.RectiCount.ToString(); btnVoca.Text = dashboard.VocaCount.ToString(); btnPDI0.Text = dashboard.PDI0Count.ToString(); if (AppConfiguration.DEFAULT_ASSEMBLYTYPEID != assemblyTypeId) { lblVoca.Text = "Tear Down Audit"; btnPA.Visible = false; lblPa.Text = ""; lblPa.Visible = false; } else { lblVoca.Text = "VocA"; btnPA.Text = dashboard.PACount.ToString(); lblPa.Text = "PA"; } }
public void DrawMainLine(AppDb ctx, ProductionLine line, AssemblySectionType sectionType, bool showNewButton = false) { //Generate new div header in div master HtmlGenericControl divLineHeader = new HtmlGenericControl("div"); divLineHeader.Attributes.Add("class", "div-header"); //create button New for the Line if (showNewButton) { ASPxButton btnNew = new ASPxButton(); btnNew.ID = line.Id.ToString(); btnNew.Text = "New"; btnNew.AutoPostBack = false; btnNew.CssClass = "btn-new-line"; var command = "function (s, e) {window.location = '../Production/VINNumberChecker.aspx?LineId=" + line.Id + "'}"; btnNew.ClientSideEvents.Click = command; divLineHeader.Controls.Add(btnNew); } ASPxLabel lblMainLine = new ASPxLabel(); if (sectionType.IsMultiLine) { lblMainLine.Text = line.LineName + " " + sectionType.Name; } else { lblMainLine.Text = sectionType.Name; } lblMainLine.CssClass = "label-line"; divLineHeader.Controls.Add(lblMainLine); divMasterDataView.Controls.Add(divLineHeader); //Line content HtmlGenericControl divLineContent = new HtmlGenericControl("div"); divLineContent.Attributes.Add("class", "div-section"); divMasterDataView.Controls.Add(divLineContent); IQueryable <AssemblySection> mainsections = ctx.AssemblySections.Where(x => x.AssemblySectionTypeId == sectionType.Id).OrderBy(x => x.AreaNo); foreach (AssemblySection sect in mainsections) { IQueryable <Station> stations = ctx.Stations.Where(x => x.AssemblySectionId == sect.Id); if (stations.Count() == 0) { continue; } //Assembly section label ASPxLabel lblSection = new ASPxLabel(); lblSection.Text = sect.AssemblySectionName; lblSection.CssClass = "label-section"; divLineContent.Controls.Add(lblSection); //Generate new dataView in Dashboard ASPxDataView dvMaster = new ASPxDataView(); dvMaster.ID = "dv" + line.LineName + sect.AssemblySectionName; dvMaster.ItemTemplate = new StationDataViewTemplate(); dvMaster.CssClass = "dataview-master"; //dvMaster.ClientSideEvents.Init = "function(s, e) { setTimeout(function() { " + cbpDashboard.ClientInstanceName + ".PerformCallback('refresh; " + sect.Id + "'); }, " + AppConfiguration.ANDON_POLL_INTERVAL_MSEC + ") }; "; divLineContent.Controls.Add(dvMaster); //Station list foreach (Station sta in stations) { DataViewItem dvItem = new DataViewItem(); StationInfo info = new StationInfo(); info.StationId = sta.Id; info.StationName = sta.StationName; info.SectionId = sect.Id; info.LineId = line.Id; info.SectionTypeId = sectionType.Id; info.IsQGate = sta.IsQualityGate; info.Capacity = sta.Capacity; info.Items = ProductionRepository.GetProductionItems(info.LineId, info.StationId); dvItem.DataItem = info; dvMaster.Items.Add(dvItem); //add the collections of dataviewitems for easy updates dvStations.Add(dvItem); } dvMaster.SettingsTableLayout.ColumnCount = (stations.Count() <= 10 ? stations.Count() : 10); } }
public void DrawSubAssyLine(AppDb ctx, AssemblySectionType sectionType) { //Generate new div header in div master HtmlGenericControl divSubAssyHeader = new HtmlGenericControl("div"); divSubAssyHeader.Attributes.Add("class", "div-header"); ASPxLabel lblSubAssy = new ASPxLabel(); lblSubAssy.Text = "Sub Assembly"; lblSubAssy.CssClass = "label-line"; divSubAssyHeader.Controls.Add(lblSubAssy); divMasterDataView.Controls.Add(divSubAssyHeader); //SubAssy content HtmlGenericControl divSubAssyContent = new HtmlGenericControl("div"); divSubAssyContent.Attributes.Add("class", "div-section"); divMasterDataView.Controls.Add(divSubAssyContent); IQueryable <AssemblySection> subsections = ctx.AssemblySections.Where(x => x.AssemblySectionTypeId == sectionType.Id).OrderBy(x => x.AreaNo); foreach (AssemblySection sect in subsections) { IQueryable <Station> stations = ctx.Stations.Where(x => x.AssemblySectionId == sect.Id); if (stations.Count() == 0) { continue; } //Assembly section label ASPxLabel lblSection = new ASPxLabel(); lblSection.Text = sect.AssemblySectionName; lblSection.CssClass = "label-section"; divSubAssyContent.Controls.Add(lblSection); //Generate new dataView in Dashboard ASPxDataView dvMaster = new ASPxDataView(); dvMaster.ID = "dvSubAssy" + sect.AssemblySectionName; dvMaster.ItemTemplate = new StationDataViewTemplate(); dvMaster.CssClass = "dataview-master"; //dvMaster.ClientSideEvents.Init = "function(s, e) { setTimeout(function() { " + cbpDashboard.ClientInstanceName + ".PerformCallback('refresh; " + sect.Id + "'); }, " + AppConfiguration.ANDON_POLL_INTERVAL_MSEC + ") }; "; divSubAssyContent.Controls.Add(dvMaster); //Station list foreach (Station sta in stations) { DataViewItem dvItem = new DataViewItem(); StationInfo info = new StationInfo(); info.StationId = sta.Id; info.StationName = sta.StationName; info.SectionId = sect.Id; info.LineId = AppConfiguration.PRODUCTION_SUBASSY_LINENUMBER; info.SectionTypeId = sectionType.Id; info.IsQGate = sta.IsQualityGate; info.Capacity = sta.Capacity; info.Items = ProductionRepository.GetProductionItems(info.LineId, info.StationId); dvItem.DataItem = info; dvMaster.Items.Add(dvItem); //add the collections of dataviewitems for easy updates dvStations.Add(dvItem); } dvMaster.SettingsTableLayout.ColumnCount = (stations.Count() <= 10 ? stations.Count() : 10); } }