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(); }
/// <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); } }
/// <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); } }
/// <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"); } }