Esempio n. 1
0
        public ActionResult ChoiceForecastResult()
        {
            ViewBag.EGHLayout = "CEQ";
            ActionResult rc = View("Index");

            try
            {
                CEQContext     db      = new CEQContext(this);
                CEQViewContext context = CEQViewContext.HandlerChoiceForecast(db, this.HttpContext.Request.Params);
                if (context != null && context.RegimChoice == CEQViewContext.REGIM_CHOICE.CHOICE)
                {
                    EGH01DB.RGEContext.Report rgereport = new RGEContext.Report();
                    if (EGH01DB.RGEContext.Report.GetById(db, (int)context.idforecat, out rgereport))
                    {
                        context.report = new EGH01DB.CEQContext.Report(db, rgereport);
                        rc             = View("CEQReport", context.report);
                    }
                }
                else if (context != null && context.RegimChoice == CEQViewContext.REGIM_CHOICE.SAVE)
                {
                    rc = View("Index");
                    XmlNode xn = context.report.toXmlNode();
                    EGH01DB.Primitives.Report report = new EGH01DB.Primitives.Report(1000, "Р", DateTime.Now, xn);
                    EGH01DB.Primitives.Report.Create(db, report);
                    int k = 1;

                    //XmlNode xn = fvc.ecoforecastx.CreateReport().toXmlNode();
                    //EGH01DB.Primitives.Report report = new EGH01DB.Primitives.Report(1000, "П", DateTime.Now, xn);
                    //EGH01DB.Primitives.Report.Create(db, report);
                }
                else if (context != null && context.RegimChoice == CEQViewContext.REGIM_CHOICE.CANCEL)
                {
                    rc = View("Index");
                }
                else
                {
                    rc = View(db);
                }
            }
            catch (EGHDBException e)
            {
                rc = View("Index");
            }
            catch (Exception e)
            {
                rc = View("Index");
            }
            return(rc);
        }
Esempio n. 2
0
        // GET: EGHCEQController_Report
        public ActionResult Report()
        {
            CEQContext db = null;

            ViewBag.EGHLayout = "CEQ.Report";
            ActionResult view = View("Index");

            ViewBag.stage = "Р";

            string menuitem = this.HttpContext.Request.Params["menuitem"] ?? "Empty";

            try
            {
                db          = new CEQContext();
                ViewBag.msg = "Соединение с базой данных установлено";
                view        = View("Report", db);


                if (menuitem.Equals("Report.Watch"))
                {
                    string id      = this.HttpContext.Request.Params["id"];
                    string comment = this.HttpContext.Request.Params["comment"];
                    if (id != null)
                    {
                        int c = 0;
                        if (int.TryParse(id, out c))
                        {
                            EGH01DB.Primitives.Report report = new EGH01DB.Primitives.Report();
                            if (EGH01DB.Primitives.Report.GetById(db, c, out report, out comment))
                            {
                                EGH01.Models.EGHRGE.ReportView rv = new Models.EGHRGE.ReportView();
                                rv.rep      = report.ToHTML();
                                ViewBag.msg = rv.rep;
                                view        = View("ReportWatch", report);
                            }
                        }
                    }
                }

                else if (menuitem.Equals("Report.Delete"))
                {
                    string id      = this.HttpContext.Request.Params["id"];
                    string comment = this.HttpContext.Request.Params["comment"];
                    if (id != null)
                    {
                        int c = 0;
                        if (int.TryParse(id, out c))
                        {
                            EGH01DB.Primitives.Report report = new EGH01DB.Primitives.Report();
                            if (EGH01DB.Primitives.Report.GetById(db, c, out report, out comment))
                            {
                                view = View("ReportDelete", report);
                            }
                        }
                    }
                }


                else if (menuitem.Equals("Report.SaveComment"))
                {
                    string id = this.HttpContext.Request.Params["id"];
                    string comment;

                    if (id != null)
                    {
                        int c = 0;
                        if (int.TryParse(id, out c))
                        {
                            Report report = new Report();
                            if (EGH01DB.Primitives.Report.GetById(db, c, out report, out comment))
                            {
                                comment = this.HttpContext.Request.Params["comment"];
                                EGH01DB.Primitives.Report.UpdateCommentById(db, c, comment);
                                view = View("Report", db);
                            }
                        }
                    }
                }
            }

            catch (RGEContext.Exception e)
            {
                ViewBag.msg = e.message;
            }
            catch (Exception e)
            {
                ViewBag.msg = e.Message;
            }

            return(view);
        }
Esempio n. 3
0
        public static bool Create(IDBContext dbcontext, Report report)
        {
            bool rc = false;

            using (SqlCommand cmd = new SqlCommand("EGH.CreateReport", dbcontext.connection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                {
                    SqlParameter parm          = new SqlParameter("@IdОтчета", SqlDbType.Int);
                    int          new_report_id = 0;
                    if (GetNextId(dbcontext, out new_report_id))
                    {
                        report.id = new_report_id;
                    }
                    parm.Value = report.id;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ДатаОтчета", SqlDbType.DateTime);
                    parm.Value = report.date;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@Стадия", SqlDbType.NChar);
                    parm.Value = report.stage;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@Родитель", SqlDbType.Int);
                    parm.IsNullable = true;
                    parm.Value      = (report.parent == null?0: report.parent.id);
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@ТекстОтчета", SqlDbType.Xml);
                    parm.IsNullable = true;
                    parm.Value      = report.xmlcontetnt.OuterXml;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@Комментарий", SqlDbType.NVarChar);
                    parm.IsNullable = true;
                    parm.Value      = report.comment;
                    cmd.Parameters.Add(parm);
                }
                {
                    SqlParameter parm = new SqlParameter("@exitrc", SqlDbType.Int);
                    parm.Direction = ParameterDirection.ReturnValue;
                    cmd.Parameters.Add(parm);
                }

                try
                {
                    cmd.ExecuteNonQuery();
                    rc = ((int)cmd.Parameters["@exitrc"].Value > 0);
                }
                catch (Exception e)
                {
                    rc = false;
                };
                return(rc);
            }
        }