Esempio n. 1
0
        public Report_VM(ReportItem_M reportItemM, IFilterTable filter)
        {
            _reportItemM = reportItemM;
            _reports     = new ObservableCollection <TableModel_M>();

            _filter = filter;
        }
Esempio n. 2
0
        private void AddReport(object obj = null)
        {
            if (!CanAddReport(obj))
            {
                return;
            }
            MessStatus.ClearStatus();
            CurrentReport = null;

            //todo: нужно сделать выбор добавления отчета
            enTypeReport typeReport = (enTypeReport)Enum.Parse(typeof(enTypeReport), (string)obj);

            ReportItem_M report = _model.NewReport(typeReport, _filter.IdTable);

            MessStatus.ClearStatus();
            switch (report.Type)
            {
            case enTypeReport.All:
                _model.OpenDesignAll(report, _filter);
                break;

            case enTypeReport.Table:
                _model.OpenDesignTable(report, _filter);
                break;

            case enTypeReport.Object:
                _model.OpenDesignObject(report, _filter);
                break;

            default:
                break;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Переименовать отчет
        /// </summary>
        /// <param name="obj">Отчет</param>
        public void Rename(object obj = null)
        {
            ReportItem_M item = (ReportItem_M)obj;

            var frm = new SaveReportFrm();

            frm.DataContext = item.Clone();
            var result = frm.ShowDialog();

            if (result == true)
            {
                Program.ReportModel.Apply((ReportItem_M)frm.DataContext);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Добавить или изменить рабочий набор
        /// </summary>
        /// <param name="workSet">рабочий набор</param>
        public ReportItem_M Apply(ReportItem_M report)
        {
            int idReport;

            using (var sqlCmd = new SqlWork())
            {
                if (report.IsNew)
                {
                    sqlCmd.sql = @"
                            INSERT INTO 
                                sys_scheme.report_templates 
                            (
                                type_report, body, caption, id_table
                            ) VALUES (
                                :type_report, :body, :caption, :id_table
                            ) RETURNING 
                                id;";
                }
                else
                {
                    sqlCmd.sql = @"
                            UPDATE 
                                sys_scheme.report_templates 
                            SET
                                type_report = :type_report,
                                caption = :caption,
                                body = :body
                            WHERE 
                                id = :id
                            RETURNING 
                                id;";
                }
                var id = (report.IdTable == -1)
                        ? (int?)null
                        : report.IdTable;
                sqlCmd.AddParam(":id", report.IdReport, DbType.Int32);
                sqlCmd.AddParam(":type_report", (int)report.Type, DbType.Int32);
                sqlCmd.AddParam(":caption", report.Caption, DbType.String);
                sqlCmd.AddParam(":body", report.Body, DbType.String);
                sqlCmd.AddParam(":id_table", id, DbType.Int32);

                idReport = sqlCmd.ExecuteScalar <int>();
                if (report.IsNew)
                {
                    ReportItem_M.SetReportId(report, idReport);
                }
            }
            Reload();
            return(report);
        }
Esempio n. 5
0
        public void Reload()
        {
            var listRepots = new List <IReportItem_M>();

            using (var sqlCmd = new SqlWork())
            {
                sqlCmd.sql = @"
                                    SELECT 
                                        id, 
                                        type_report, 
                                        body, 
                                        id_table, 
                                        caption 
                                    FROM 
                                        sys_scheme.report_templates
                                    ORDER BY id";

                if (!sqlCmd.ExecuteReader())
                {
                    return;
                }
                while (sqlCmd.CanRead())
                {
                    var id = sqlCmd.GetInt32("id");

                    ReportItem_M rep = FindReportById(id) as ReportItem_M;
                    if (rep == null)
                    {
                        var type    = sqlCmd.GetValue <enTypeReport>("type_report");
                        var idTable = sqlCmd.GetValue <int?>("id_table");

                        rep         = new ReportItem_M(id, type, idTable);
                        rep.Caption = sqlCmd.GetString("caption");
                    }
                    else
                    {
                        string caption = sqlCmd.GetString("caption");
                        if (caption != rep.Caption)
                        {
                            rep         = new ReportItem_M(rep);
                            rep.Caption = caption;
                        }
                    }
                    rep.Body = sqlCmd.GetString("body");

                    listRepots.Add(rep);
                }
                ExtraFunctions.Sorts.SortList(_reports, listRepots);
            }
        }
Esempio n. 6
0
        internal void OpenDesignAll(ReportItem_M report, IFilterTable filter)
        {
            if (report.Type != enTypeReport.All)
            {
                throw new Exception(Resources.Report_M_ErrorDesign);
            }

            var reportVM = new Report_VM((ReportItem_M)report.Clone(), filter);

            foreach (var item in Program.app.tables_info)
            {
                var tm = new TableModel_M(item, enTypeReport.All);
                reportVM.Reports.Add(tm);
            }
            reportVM.OpenDesign();
        }
Esempio n. 7
0
 public static void SetReportId(ReportItem_M item, int id)
 {
     item._idReport = id;
     item._isNew    = false;
 }
Esempio n. 8
0
 public bool AccessChecked(ReportItem_M CurrentReport)
 {
     return(Program.user_info.admin);
 }