Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
 public static XtraReport GetXtraReport(Audit audit, string lang)
 {
     return(new PdfReport(audit.Id, lang));
 }
Beispiel #3
0
        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;
            }
        }