protected void gvAudit_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e) { ASPxGridView gridview = sender as ASPxGridView; string activeLang = (Session["lang"] == null) ? Languages.Default : Utils.ConvertToTrimmedString(Session["lang"]); var auditId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "audit_id")); var auditDetailsId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "id")); var audit = new Audit((int)auditId); bool refresh = false; if (!audit.AuditExist() || audit.EndDate != null) { throw new Exception("Audit does not exist / has already been completed!"); } switch (e.Parameters) { case ToolbarButtons.NextPage: ChangePage(ToolbarButtons.NextPage); refresh = true; break; } if (refresh) { gridview.JSProperties["cp_refresh"] = true; } }
protected void Page_Load(object sender, EventArgs e) { int?auditId = Utils.ConvertToNullableInt(Session["audit_id"]); int?auditDetailId = Utils.ConvertToNullableInt(Session["audit_detail_id"]); if (auditId != null && auditDetailId != null && Audit.AuditExist((int)auditId) == true && Audit.AuditClosed((int)auditId) == false) { SetupFileManager((int)auditId, (int)auditDetailId); PhotoFiles.SavePhoto((int)auditId, (int)auditDetailId); } else { Response.Redirect(Pages.PerformAudit); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Session["gvAuditsExpandedRowId"] = -1; var id = Utils.ConvertToNullableInt(Request.QueryString["id"]); if (id != null) { if (Audit.AuditExist((int)id)) { gvAudits.DataColumns["id"].Settings.AutoFilterCondition = AutoFilterCondition.Equals; gvAudits.AutoFilterByColumn(gvAudits.Columns["id"], id.ToString()); gvAudits.DetailRows.ExpandRow(0); Session["gvAuditsExpandedRowId"] = 0; } } } }
protected void Page_Load(object sender, EventArgs e) { var id = Utils.ConvertToNullableInt(Request.QueryString["id"]); lblInfo.Text = string.Empty; if (id != null) { if (Audit.AuditExist((int)id)) { var report = AuditTypes.GetXtraReport(new Audit((int)id), Languages.Polish); var reportFileName = $"Audit_{id}"; Utils.PrintPDF(report, reportFileName); } else { lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Audit does not exist!"; } } else { lblInfo.Text = $"Printing of the document failed!{Environment.NewLine}Wrong parameter!"; } }
protected void gvAudits_ToolbarItemClick(object source, DevExpress.Web.Data.ASPxGridViewToolbarItemClickEventArgs e) { ASPxGridView gridview = source as ASPxGridView; var auditId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "id")); var audit = new Audit((int)auditId); if (!audit.AuditExist()) { throw new Exception("Audit does not exist!!"); } bool refresh = false; switch (e.Item.Name) { case ToolbarButtons.DeleteAudit: audit.Delete(); refresh = true; break; } if (refresh) { gridview.JSProperties["cp_refresh"] = true; } }
protected void gvAudit_ToolbarItemClick(object source, DevExpress.Web.Data.ASPxGridViewToolbarItemClickEventArgs e) { ASPxGridView gridview = source as ASPxGridView; string activeLang = (Session["lang"] == null) ? Languages.Default : Utils.ConvertToTrimmedString(Session["lang"]); var auditId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "audit_id")); var auditDetailsId = Utils.ConvertToNullableInt(gridview.GetRowValues(gridview.FocusedRowIndex, "id")); var allowedOK = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_OK")); var allowedNOK = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NOK")); var allowedNC = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NC")); var allowedNA = Utils.ConvertToNullableBool(gridview.GetRowValues(gridview.FocusedRowIndex, "answer_NA")); if (allowedNA == null || allowedNC == null || allowedNOK == null || allowedOK == null || auditId == null || auditDetailsId == null) { throw new Exception("System error!"); } var audit = new Audit((int)auditId); if (!audit.AuditExist() || audit.EndDate != null) { throw new Exception("Audit does not exist / has already been completed!"); } bool refresh = false; bool move = false; switch (e.Item.Name) { case ToolbarButtons.NextPage: ChangePage(ToolbarButtons.NextPage); gridview.FocusedRowIndex = 0; refresh = true; break; case ToolbarButtons.PrevPage: ChangePage(ToolbarButtons.PrevPage); gridview.FocusedRowIndex = 0; refresh = true; break; case ToolbarButtons.LangPol: Session["lang"] = Languages.Polish; refresh = true; break; case ToolbarButtons.LangEng: Session["lang"] = Languages.English; refresh = true; break; case ToolbarButtons.AnswerOK: ProcessAnswer(auditDetailsId, Answers.OK, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; move = true; break; case ToolbarButtons.AnswerNOK: ProcessAnswer(auditDetailsId, Answers.NOK, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; break; case ToolbarButtons.AnswerNC: ProcessAnswer(auditDetailsId, Answers.NC, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; break; case ToolbarButtons.AnswerNA: ProcessAnswer(auditDetailsId, Answers.NA, allowedOK, allowedNOK, allowedNC, allowedNA); refresh = true; move = true; break; case ToolbarButtons.Camera: Session["audit_id"] = auditId; Session["audit_detail_id"] = auditDetailsId; gridview.JSProperties["cp_launch_camera"] = true; break; case ToolbarButtons.DeleteAudit: audit.Delete(); gridview.JSProperties["cp_escape_page"] = true; Session["lang"] = null; Session["page"] = null; Session["audit_id"] = null; Session["audit_detail_id"] = null; Session["message"] = "Audit removed!"; break; case ToolbarButtons.PrintAudit: audit.SendEmailWithPdf(activeLang); break; case ToolbarButtons.EndAudit: if (audit.AuditQuestionAnsweredCount != audit.AuditQuestionCount) { throw new Exception("Answer all questions!"); } audit.End(); Session["lang"] = null; Session["page"] = null; Session["audit_id"] = null; Session["audit_detail_id"] = null; Session["message"] = $"Audit completed with score {audit.AuditScoreCalculated.ToString("#.##")}%!"; gridview.JSProperties["cp_escape_page"] = true; break; } if (refresh) { gridview.JSProperties["cp_refresh"] = true; } if (move) { gridview.JSProperties["cp_move"] = true; } }