protected void grvIA_OnHtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e) { try { ASPxGridView grv = (sender as ASPxGridView); ASPxButton btnIAInfo = (ASPxButton)grv.FindRowCellTemplateControl(e.VisibleIndex, null, "btnIAInfo"); if (grv.GetRowValues(e.VisibleIndex, "Info") != null && grv.GetRowValues(e.VisibleIndex, "Info").ToString().Trim().Length > 0) { IA ia = IrregAltRepository.RetrieveIAHeadersById(Convert.ToInt32(btnIAInfo.CommandArgument)); btnIAInfo.Text = (grv.GetRowValues(e.VisibleIndex, "Info").ToString()) + System.Environment.NewLine + "(" + ia.InfoNumber + ")"; } ASPxLabel lblPart = (ASPxLabel)grv.FindRowCellTemplateControl(e.VisibleIndex, null, "lblPart"); if (lblPart != null) { int id = Convert.ToInt32(grv.GetRowValues(e.VisibleIndex, "Id")); lblPart.Text = IrregAltRepository.RetrieveIrregAlterationPartsById(id); } ASPxLabel lblModel = (ASPxLabel)grv.FindRowCellTemplateControl(e.VisibleIndex, null, "lblModelName"); if (lblModel != null) { string ModelName = ControlPlanRepository.RetrieveAssemblyModelNameById(Convert.ToInt32(hfDocControl["ModelId"])); lblModel.Text = ModelName; } } catch (Exception ex) { LoggerHelper.LogError(ex); } }
//int DataCount = 0; //List<Controlplan> DataStationDeviation = new List<Controlplan>(); protected override bool OnInit(object sender, EventArgs e) { //get TableMeta from Schema. Schema is loaded during login var schemaInfo = Application["SchemaInfo"] as SchemaInfo; tableMeta = schemaInfo.Tables.Where(s => s.Name.Equals(tableName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (tableMeta == null) { masterPage.MainContent.Controls.Add(new LiteralControl(string.Format("<h2>{0}</h2>", "Invalid Page"))); return(false); } //header info //int vpm = Request.QueryString["vpm"].ToInt32(0); //int modelId = Request.QueryString["model"].ToInt32(0); //int variantId = Request.QueryString["variant"].ToInt32(0); int cpId = Request.QueryString["CpId"].ToInt32(0); //int stationId = Request.QueryString["StationId"].ToInt32(0); //if (stationId == 0) // stationId = Request.QueryString["station"].ToInt32(0); using (AppDb ctx = new AppDb()) { if (cpId > 0) { cp = ctx.ControlPlans.Where(x => x.Id == cpId).FirstOrDefault(); } //else //{ // cp = ctx.ControlPlans.Where(x => x.ModelId == modelId && x.VariantId == variantId && x.PackingMonth == vpm.ToString()).FirstOrDefault(); //} } if (cp == null) { var panel1 = new System.Web.UI.WebControls.Panel(); panel1.CssClass = "mainContent"; panel1.Controls.Clear(); panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Model/Variant/PackingMonth for CP Station Detail</h2>"))); masterPage.MainContent.Controls.Clear(); masterPage.MainContent.Controls.Add(panel1); masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption)); return(false); } //else if (stationId == 0) //{ // var panel1 = new System.Web.UI.WebControls.Panel(); // panel1.CssClass = "mainContent"; // panel1.Controls.Clear(); // panel1.Controls.Add(new LiteralControl(string.Format("<h2 class='grid-header'>Invalid Station for CP Station Detail</h2>"))); // masterPage.MainContent.Controls.Clear(); // masterPage.MainContent.Controls.Add(panel1); // masterPage.PageTitle.Controls.Add(new LiteralControl(tableMeta.Caption)); // return false; //} //Set master key SetMasterKey("ControlPlanId", cp.Id); //Store the CP object so that it is accessible to other classes keyValues.Add("CP", cp); keyValues.Add("ControlPlanId", cp.Id); hfDocControl["PackingMonth"] = cp.PackingMonth; hfDocControl["ModelId"] = cp.AssemblyModelId; //create header string ModelName = ControlPlanRepository.RetrieveAssemblyModelNameById(cp.AssemblyModelId); //string StationName = ControlPlanRepository.RetrieveStationNameById(stationId); //lblStationName.Text = StationName; lblPackingMonth.Text = cp.PackingMonth; lblModel.Text = ModelName; //if (!IsPostBack && !IsCallback) //{ // if (Request.QueryString.Count > 0) // { // hfDocControl["ControlPlanId"] = cpId; // if (cp != null) // { // hfDocControl["PackingMonth"] = cp.PackingMonth; // hfDocControl["ModelId"] = cp.ModelId; // hfDocControl["VariantId"] = cp.VariantId; // lblPackingMonth.Text = cp.PackingMonth; // lblModel.Text = ModelRepository.RetrieveModelNameById(cp.ModelId) + " " + // ModelRepository.RetrieveVariantNameByModelIdAndVariantId( // cp.ModelId, cp.VariantId); // } // } //} //else //{ // if (Session["StationId"] != null) // { // if (popupDocControl.HeaderText.ToString() == "Document Control - Working Instruction") // { // grvDocControlDetail.DataSourceID = null; // grvDocControlDetail.DataSource = ControlPlanRepository.RetrieveDocumentByDocTypeAndStationId("CPWI", // Convert.ToInt32(Session["StationId"].ToString()), cp.PackingMonth, Convert.ToInt32(cp.ModelId), Convert.ToInt32(cp.VariantId)); // grvDocControlDetail.DataBind(); // } // else // { // grvDocControlDetail.DataSourceID = null; // grvDocControlDetail.DataSource = ControlPlanRepository.RetrieveDocumentByDocTypeAndStationIdII("CPII", // Convert.ToInt32(Session["StationId"].ToString()), cp.PackingMonth, Convert.ToInt32(cp.ModelId), Convert.ToInt32(cp.VariantId)); // grvDocControlDetail.DataBind(); // } // } //} return(true); }