Esempio n. 1
0
 /// <summary>
 /// Получить форму из базы
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public T GetForm <T>(string name)
 {
     try
     {
         EFReportForms rep_forms = new EFReportForms();
         ReportForms   forms     = rep_forms.GetReportForms(name);
         if (forms == null)
         {
             return(default(T));
         }
         return(XMLStringToClass <T>(forms.xml_form));
     }
     catch (Exception e)
     {
         e.WriteErrorMethod(String.Format("GetForm<{0}>(name={1})", typeof(T).ToString(), name), eventID);
         return(default(T));
     }
 }
Esempio n. 2
0
        public ReportForms DeleteReportForms(int id)
        {
            ReportForms dbEntry = context.ReportForms.Find(id);

            if (dbEntry != null)
            {
                try
                {
                    context.ReportForms.Remove(dbEntry);
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    e.WriteErrorMethod(String.Format("DeleteReportForms(id={0})", id), eventID);
                    return(null);
                }
            }
            return(dbEntry);
        }
Esempio n. 3
0
        public int SaveReportForms(ReportForms ReportForms)
        {
            ReportForms dbEntry;

            try
            {
                if (ReportForms.id == 0)
                {
                    dbEntry = new ReportForms()
                    {
                        id          = 0,
                        report      = ReportForms.report,
                        description = ReportForms.description,
                        xml_form    = ReportForms.xml_form
                    };
                    context.ReportForms.Add(dbEntry);
                }
                else
                {
                    dbEntry = context.ReportForms.Find(ReportForms.id);
                    if (dbEntry != null)
                    {
                        dbEntry.report      = ReportForms.report;
                        dbEntry.description = ReportForms.description;
                        dbEntry.xml_form    = ReportForms.xml_form;
                    }
                }

                context.SaveChanges();
            }
            catch (Exception e)
            {
                e.WriteErrorMethod(String.Format("SaveReportForms(ReportForms={0})", ReportForms.GetFieldsAndValue()), eventID);
                return(-1);
            }
            return(dbEntry.id);
        }