Beispiel #1
0
 public ReportTab(UC_NewLog userControl, ReportFormData RFD)
 {
     folderPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
     this.myUC  = userControl;
     rpData     = RFD;
     mrd        = new MyReportDefault();
 }
Beispiel #2
0
 /// <summary>
 /// Will save to a new Collection if colName don't exists, otherwise it will update the existing one.
 /// </summary>
 /// <param name="rData">Report data class</param>
 /// <param name="rColName">Report data collection name</param>
 public void SaveReportData(ReportFormData rData, string colName)
 {
     if (CheckIfCollectionExists(colName))
     {
         UpdateReportData(rData, colName);
     }
     else
     {
         InsertReportData(rData, colName);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Updates an existing documents entrys
        /// </summary>
        /// <param name="data"></param>
        private void UpdateReportData(ReportFormData data, string colName)
        {
            // Open database (or create if doesn't exist)
            using (var db = new LiteDatabase(dbPath))
            {
                // Get a collection (or create, if doesn't exist)
                var col = db.GetCollection <ReportFormData>(colName);

                col.Update(data);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Inserts new data in a collection. Generate a new collection if neccessary.
        /// </summary>
        /// <param name="data"></param>
        /// <param name="colName"></param>
        private void InsertReportData(ReportFormData data, string colName)
        {
            // Open database (or create if doesn't exist)
            using (var db = new LiteDatabase(dbPath))
            {
                // Get a collection (or create, if doesn't exist)
                var col = db.GetCollection <ReportFormData>(colName);

                col.Insert(data);

                //Create index
                col.EnsureIndex("Id");
            }
        }