public void InstantiateIn(Control container) { int assemblyTypeId = HttpContext.Current.Session["assemblyType"].ToInt32(0); var dvMasterContainer = container as DataViewItemTemplateContainer; StationInfo info = dvMasterContainer.DataItem as StationInfo; if (info == null) { return; } var firstStationId = ProductionRepository.GetFirstStation(assemblyTypeId); ////set parameter //int _historyId = GetData(dataItem, "HistoryId").ToInt32(0); //string _model = GetData(dataItem, "ModelName").ToString(string.Empty); //string _variant = GetData(dataItem, "VariantName").ToString(string.Empty); //string _finNo = GetData(dataItem, "FINNumber").ToString(string.Empty); //string _statusId = GetData(dataItem, "StatusId").ToString(string.Empty); //string _stationName = GetData(dataItem, "StationName").ToString(string.Empty); //bool _isQGate = GetData(dataItem, "IsQGate") == "True" ? true : false; //string _stationId = GetData(dataItem, "StationId").ToString(string.Empty); //bool _isSubAssy = GetData(dataItem, "IsSubAssy") == "True" ? true : false; //bool _IsEndOfLine = GetData(dataItem, "IsEndOfLine") == "True" ? true : false; //string _sectionId = GetData(dataItem, "SectionId").ToString(string.Empty); //string _numSubAssy = GetData(dataItem, "NumSubAssy").ToString(string.Empty); //bool _isfinishLine = GetData(dataItem, "IsFinishLine") == "True" ? true : false; //bool isMechLine = GetData(dataItem, "IsMechLine") == "True" ? true : false; //bool isList = GetData(dataItem, "IsList") == "True" ? true : false; //string UrlImageCar = ProductionHistoryHelper.GetImageCar(_historyId); ////MemoryStream ms = new MemoryStream(ImageCar); ////System.Drawing.Image img = System.Drawing.Image.FromStream(ms); ////paramter get problem //int LineId = GetData(dataItem, "LineId").ToInt32(0); //int stationId = GetData(dataItem, "StationId").ToInt32(0); //if (firstStationId == stationId) //{ // var countCarHOP = ProductionRepository.GetVehicleCountInStation(stationId, LineId); // _stationName = _stationName + '(' + countCarHOP + ')'; //} //Generate new divTemplateDataView in Template dataView HtmlGenericControl div = new HtmlGenericControl("div"); //Generate new divHeader in divTemplateDataView HtmlGenericControl divHeader = new HtmlGenericControl("div"); divHeader.Attributes.Add("class", "div-station-name"); ASPxLabel lblStationName = new ASPxLabel(); lblStationName.CssClass = "lblStationName_" + info.LineId + "_" + info.StationId; divHeader.Controls.Add(lblStationName); //Generate new divBody in divTemplateDataView HtmlGenericControl divBody = new HtmlGenericControl("div"); divBody.Attributes.Add("class", "div-body"); ASPxLabel lblModel = new ASPxLabel(); lblModel.ID = "lblModel_" + info.LineId + "_" + info.StationId; lblModel.Text = ""; divBody.Controls.Add(lblModel); //Generate imageCondition ImageButton imgCondition = new ImageButton(); imgCondition.ID = "imgCondition_" + info.LineId + "_" + info.StationId; imgCondition.Enabled = false; imgCondition.CssClass = "img-notification"; divBody.Controls.Add(imgCondition); //Generate new divImage in divTemplateDataView HtmlGenericControl divImage = new HtmlGenericControl("div"); ASPxButton btnDetail = new ASPxButton(); btnDetail.ID = "btnDetail_" + info.LineId + "_" + info.StationId;; btnDetail.AutoPostBack = false; btnDetail.CssClass = "btn-details"; divImage.Controls.Add(btnDetail); //Generate new divFooter in divTemplateDataView HtmlGenericControl divFooter = new HtmlGenericControl("div"); divFooter.Attributes.Add("class", "div-footer"); ASPxLabel lblFINNumber = new ASPxLabel(); lblFINNumber.ID = "lblFINNumber_" + info.LineId + "_" + info.StationId; lblFINNumber.Text = ""; divFooter.Controls.Add(lblFINNumber); div.Controls.Add(divHeader); div.Controls.Add(divBody); div.Controls.Add(divImage); div.Controls.Add(divFooter); container.Controls.Add(div); if (info.Capacity <= 1 || info.Items == null || info.Items.Count == 0) { lblStationName.Text = info.StationName; } else { lblStationName.Text = String.Format("{0} ({1})", lblStationName, info.Items.Count); } if (info.Capacity > 1) { btnDetail.Text = info.Items.Count.ToString(); lblModel.Visible = false; imgCondition.Visible = false; lblFINNumber.Visible = false; } else { if (info.Items.Count == 0) { lblModel.Text = ""; imgCondition.Visible = false; lblFINNumber.Text = ""; btnDetail.ClientEnabled = false; btnDetail.ImageUrl = urlImgDefaultEmpty; } else { lblModel.Text = info.Items[0].ModelName; imgCondition.ImageUrl = FaultRepository.hasFault(info.Items[0].Id) || (ProductionRepository.GetAndonProductionProblem(info.LineId, DateTime.Now, "", info.StationId).Count() > 0) ? urlImgNotifRed : urlImgNotifGreen; if (info.Items[0].SerialNumber.Length < 17)//Engine Data { // Permintaaan 8 Character lblFINNumber.Text = string.IsNullOrWhiteSpace(info.Items[0].SerialNumber) ? string.Empty : info.Items[0].SerialNumber.Length < 14 ? string.Empty : info.Items[0].SerialNumber.Substring(6, 8); } else { lblFINNumber.Text = string.IsNullOrWhiteSpace(info.Items[0].SerialNumber) ? string.Empty : info.Items[0].SerialNumber.Length < 17 ? string.Empty : info.Items[0].SerialNumber.Substring(11, 6); } string UrlImageCar = ProductionHistoryHelper.GetImageCar(info.Items[0].Id); if (UrlImageCar == "" || UrlImageCar == null) { btnDetail.ImageUrl = urlImgDefaultCar; } else { btnDetail.ImageUrl = UrlImageCar; } } } //if Subassy DataView if (info.Capacity > 1) { btnDetail.ClientSideEvents.Click = "function (s, e) {window.location = '../Production/ProductionStationList.aspx?Stat=" + info.StationId + "'}"; } else { btnDetail.ClientSideEvents.Click = "function (s, e) {window.location = '../Production/ProductionDashboardDetail.aspx?Type=" + (info.IsQGate ? "1" : "0") + "&Hist=" + 0 + "&Stat=" + info.StationId + "&Sect=0'}"; } }