//protected void lnkAddTask_Click(Object sender, EventArgs e) //{ // //if (OnExceptionListItemClick != null) // //{ // //LinkButton lnk = (LinkButton)sender; // //string[] cmd = lnk.CommandArgument.Split(','); // string[] cmd = lnkAddTask.CommandArgument.Split(','); // AddTask(Convert.ToDecimal(cmd[0].ToString()), Convert.ToDecimal(cmd[1].ToString())); // // call sending AuditID, QuestionID // // OnExceptionListItemClick(Convert.ToDecimal(cmd[0].ToString()), Convert.ToDecimal(cmd[1].ToString())); // //} //} private void AddTask(decimal auditID, decimal questionID) { int recordType = (int)TaskRecordType.Audit; AUDIT audit = EHSAuditMgr.SelectAuditById(new PSsqmEntities(), auditID); EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(auditID, questionID); uclTaskList.TaskWindow(50, auditQuestion.AuditId, auditQuestion.QuestionId, "350", auditQuestion.QuestionText, (decimal)audit.DETECT_PLANT_ID); //uclTask.BindTaskAdd(recordType, auditQuestion.AuditId, auditQuestion.QuestionId, "350", "T", auditQuestion.QuestionText, (decimal)audit.DETECT_PLANT_ID, ""); //string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);"; //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true); }
private void UpdateTaskList(string cmd, decimal recordID, decimal recordSubID) { // update the status when a task is added if (cmd == "added") { EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(recordID, recordSubID); if (auditQuestion != null) { auditQuestion.Status = "02"; EHSAuditMgr.UpdateAnswer(auditQuestion); } //SearchAudits(); } }
protected void ddlChartTypeChange(object sender, EventArgs e) { divChart.ViewStateMode = System.Web.UI.ViewStateMode.Disabled; //if (ddlChartType.SelectedValue == "" || HSCalcs().ehsCtl.IncidentHst == null || HSCalcs().ehsCtl.IncidentHst.Count == 0) if (ddlChartType.SelectedValue == "") { pnlChartSection.Style.Add("display", "none"); lnkChartClose.Visible = lnkPrint.Visible = false; } else { //PERSPECTIVE_VIEW view = null; //divSummaryCharts.Controls.Clear(); //view = ViewModel.LookupView(entities, "HSIR", "HSIR", 0); //if (view != null) //{ // PERSPECTIVE_VIEW_ITEM vi = view.PERSPECTIVE_VIEW_ITEM.Where(i => i.ITEM_SEQ.ToString() == ddlChartType.SelectedValue).FirstOrDefault(); // if (vi != null) // { // GaugeDefinition ggCfg = new GaugeDefinition().Initialize().ConfigureControl(vi, null, "", false, !string.IsNullOrEmpty(hfwidth.Value) ? Convert.ToInt32(hfwidth.Value) - 62 : 0, 0); // ggCfg.Position = null; // HSCalcs().ehsCtl.SetCalcParams(vi.CALCS_METHOD, vi.CALCS_SCOPE, vi.CALCS_STAT, (int)vi.SERIES_ORDER).IncidentSeries((EHSCalcsCtl.SeriesOrder)vi.SERIES_ORDER, SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToArray(), new DateTime(1900, 1, 1), SessionManager.UserContext.LocalTime.AddYears(100), HSCalcs().ehsCtl.GetIncidentTopics()); // uclChart.CreateControl((SQMChartType)vi.CONTROL_TYPE, ggCfg, HSCalcs().ehsCtl.Results, divSummaryCharts); // pnlChartSection.Style.Add("display", "inline"); // lnkChartClose.Visible = lnkPrint.Visible = true; // // return; // } //} divChart.Controls.Clear(); switch (ddlChartType.SelectedValue) { case "charts": decimal protection = 0; decimal protectionTotal = 0; decimal surveillance = 0; decimal surveillanceTotal = 0; decimal manualresponse = 0; decimal manualresponseTotal = 0; decimal humanelement = 0; decimal humanelementTotal = 0; decimal hazards = 0; decimal hazardsTotal = 0; decimal maintenence = 0; decimal maintenenceTotal = 0; int iTopic = 0; decimal answerValue; // get the current year results foreach (EHSAuditData audit in HSCalcs().ehsCtl.AuditHst) { foreach (AUDIT_ANSWER answer in audit.Audit.AUDIT_ANSWER) { try { answerValue = Convert.ToInt16(answer.ANSWER_VALUE); } catch { answerValue = 0; } EHSAuditQuestion question = EHSAuditMgr.SelectAuditQuestion(audit.Audit.AUDIT_ID, answer.AUDIT_QUESTION_ID); iTopic = Convert.ToInt16(question.TopicId); switch (iTopic) { case 3: protection += answerValue; protectionTotal += 3; break; case 4: surveillance += answerValue; surveillanceTotal += 3; break; case 5: manualresponse += answerValue; manualresponseTotal += 3; break; case 6: humanelement += answerValue; humanelementTotal += 3; break; case 7: hazards += answerValue; hazardsTotal += 3; break; case 8: maintenence += answerValue; maintenenceTotal += 3; break; } } } List <GaugeSeries> gaugeSeries = new List <GaugeSeries>(); GaugeSeries g = new GaugeSeries(); g.Name = "Percentage"; if (protectionTotal > 0) { answerValue = Math.Round((protection / protectionTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Protection")); if (surveillanceTotal > 0) { answerValue = Math.Round((surveillance / surveillanceTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Surveillance")); if (manualresponseTotal > 0) { answerValue = Math.Round((manualresponse / manualresponseTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Manual Response")); if (humanelementTotal > 0) { answerValue = Math.Round((humanelement / humanelementTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Human Element")); if (hazardsTotal > 0) { answerValue = Math.Round((hazards / hazardsTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Hazards")); if (maintenenceTotal > 0) { answerValue = Math.Round((maintenence / maintenenceTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Maintenence")); gaugeSeries.Add(g); GaugeDefinition gauge = new GaugeDefinition(); gauge.ColorPallete = "chartSeriesColor"; //gauge.ContainerHeight = 550; //gauge.ContainerWidth = 550; gauge.ControlType = 70; gauge.DisplayLabel = true; gauge.DisplayLegend = true; gauge.DisplayTitle = true; gauge.DisplayTooltip = true; gauge.Grouping = 0; gauge.Height = 550; gauge.Width = 650; gauge.ItemVisual = "CENTER"; gauge.MinorTics = false; gauge.Multiplier = 0; gauge.ScaleMax = 100; gauge.ScaleMin = 0; gauge.Title = "Audit Summary"; gauge.DisplayTitle = false; CalcsResult rslt = new CalcsResult(); rslt.metricSeries = gaugeSeries; rslt.Status = 0; rslt.ValidResult = true; uclChart.CreateControl(SQMChartType.SpiderChart, gauge, rslt, divChart); pnlChartSection.Style.Add("display", "inline"); lnkChartClose.Visible = lnkPrint.Visible = true; divChart.Visible = true; divDataResults.Visible = false; break; case "report": lnkChartClose.Visible = lnkPrint.Visible = true; divChart.Visible = false; divDataResults.Visible = true; break; } } }
PdfPTable QuestionSection(EHSAuditQuestion question, List <TASK_STATUS> tasks) { PdfPTable tableQuestion = new PdfPTable(new float[] { 202f, 203f, 135f }); tableQuestion.TotalWidth = 540f; tableQuestion.LockedWidth = true; //tableQuestion.SpacingBefore = 5f; PdfPCell cell; Paragraph p = new Paragraph(); cell = new PdfPCell() { Padding = 1f, PaddingBottom = 2f, BorderWidthBottom = 1 }; p.Add(new Phrase(FormatText(question.QuestionText), detailTxtFont)); try { if (!question.HelpText.Equals(null) || question.HelpText.Trim().Length > 0) { //String encodedString = HttpUtility.HtmlEncode(question.HelpText); string encodedString = FormatText(question.HelpText); p.Add(new Phrase("\n" + encodedString, detailTxtFont)); } } catch { // for some reason, the error trapping isn't catching the nulls } cell.AddElement(p); tableQuestion.AddCell(cell); cell = new PdfPCell() { Padding = 1f, BorderWidthBottom = 1 }; p = new Paragraph(); p.Add(new Phrase(FormatText(question.AnswerComment), detailTxtFont)); try { if (!question.ResolutionComment.Equals(null) || question.ResolutionComment.Trim().Length > 0) { string encodedString = FormatText(question.ResolutionComment); p.Add(new Phrase("\n \nResolution: " + encodedString, detailTxtFont)); } } catch { // for some reason, the error trapping isn't catching the nulls } cell.AddElement(p); tableQuestion.AddCell(cell); cell = new PdfPCell() { Padding = 1f, BorderWidthBottom = 1 }; if (question.QuestionType == EHSAuditQuestionType.RadioPercentage || question.QuestionType == EHSAuditQuestionType.RadioPercentageCommentLeft || question.QuestionType == EHSAuditQuestionType.Radio || question.QuestionType == EHSAuditQuestionType.RadioCommentLeft) { int i = 0; PdfPTable answerTable = new PdfPTable(new float[] { 20f, 114f }); answerTable.TotalWidth = 134f; answerTable.LockedWidth = true; PdfPCell answerCell = new PdfPCell(); foreach (var choice in question.AnswerChoices) { string imageURL = Server.MapPath("~"); if (choice.Value == question.AnswerValue) { imageURL += "\\images\\RadioOn.jpg"; } else { imageURL += "\\images\\RadioOff.jpg"; } iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(imageURL); image.ScaleToFit(15f, 15f); answerCell = new PdfPCell() { Padding = 1f, BorderWidth = 0 }; answerCell.AddElement(new Chunk(image, 0, 0)); answerTable.AddCell(answerCell); answerCell = new PdfPCell() { Padding = 1f, BorderWidth = 0 }; answerCell.AddElement(new Phrase(" " + choice.Text, detailTxtFont)); answerTable.AddCell(answerCell); //p = new Paragraph(); //p.Add(new Chunk(image, 0, 0)); //p.Add(new Phrase(" " + choice.Text, detailTxtFont)); //cell.AddElement(p); //try //{ // iTextSharp.text.Image jpg = iTextSharp.text.Image.GetInstance(imageURL); // jpg.ScaleToFit(20f, 20f); // cell.AddElement(jpg); //} //catch (Exception ex) //{ // // what it the error? //} //cell.AddElement(new Chunk(choice.Text, detailTxtFont)); if (question.QuestionType == EHSAuditQuestionType.RadioPercentage || question.QuestionType == EHSAuditQuestionType.RadioPercentageCommentLeft) { if (choice.ChoiceWeight > possibleScore) { possibleScore = choice.ChoiceWeight; } if (choice.Value == question.AnswerValue) { if (choice.ChoicePositive) { answerIsPositive = true; } totalWeightScore += choice.ChoiceWeight; totalTopicWeightScore += choice.ChoiceWeight; } } } cell.AddElement(answerTable); } else { cell.AddElement(new Paragraph(question.AnswerValue)); } tableQuestion.AddCell(cell); if (question.TasksAssigned > 0) { cell = new PdfPCell() { Padding = 1f, BorderWidthBottom = 1 }; cell.Colspan = 3; // get the tasks // add the new table to the main question table cell.AddElement(ActionSection(question.QuestionId, tasks)); tableQuestion.AddCell(cell); } return(tableQuestion); }