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); } }
protected void btnII_OnClick(object sender, EventArgs e) { try { ASPxButton btn = (sender as ASPxButton); ControlPlan cp = ControlPlanRepository.RetrieveControlPlanById(Convert.ToInt32(Request.QueryString["CpId"])); hfDocCtrlDetail["docType"] = "CPII"; grvDocControlDetail.DataSource = null; grvDocControlDetail.DataSource = ControlPlanRepository.RetrieveDocumentByDocTypeAndStationIdII("CPII", Convert.ToInt32(btn.CommandArgument), cp.PackingMonth, Convert.ToInt32(cp.AssemblyModelId)); grvDocControlDetail.DataBind(); Session["StationId"] = Convert.ToInt32(btn.CommandArgument); popupDocControl.HeaderText = "Document Control - Inspection Instruction"; popupDocControl.ShowOnPageLoad = true; } 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); }
/// <summary> /// Custom Page_Init function for inherited class /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> protected override bool OnInit(object sender, EventArgs e) { string org = ControlPlanRepository.GetUserOrganizationQM(assemblyTypeId, user.Id).ToUpper(); if (org == "QM/VPC") { //engineering > edit mode tableName = "ProductionPDI0ListQM"; } else if (org == "QM/QEP") { //qm tableName = "ProductionPDI0ListQM"; } else if (org == "QM/QA") { //qm tableName = "ProductionPDI0List"; } else if (org == "PROD/APC") { //logistic tableName = "ProductionPDI0List"; } else { tableName = "ProductionPDI0List"; } //} //override if mode is specified if (Request.QueryString["mode"] != null) { int mode = Request.QueryString["mode"].ToInt32(0); if (mode == 1) { //qm tableName = "ProductionPDI0ListQM"; } else if (mode == 2) { //engineering > edit mode tableName = "ProductionPDI0ListQM"; } else if (mode == 3) { //engineering > edit mode tableName = "ProductionPDI0List"; } else if (mode == 4) { //logistic tableName = "ProductionPDI0List"; } else { tableName = "ProductionPDI0List"; } } //since we determine the table dynamically, check for permission explicitly permissions = PermissionHelper.GetTablePermissions(tableName, user.Id, assemblyTypeId); if (permissions.Count() == 0) { //set redirect = 1 to prevent AccessDenied.aspx to try to re-check the permission Session["redirect"] = 1; //redirect Response.Redirect(AppConfiguration.PAGE_ACCESSDENIED + "?path=" + HttpContext.Current.Request.RawUrl); } int stationId = Request.QueryString["Stat"].ToInt32(0); //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); } return(true); }