Example #1
0
 private void LoadCommonSettings()
 {
     try
     {
         Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
         if (dc.ProgramSettings.Count() > 0)
         {
             _LoadedCommonSettings = dc.ProgramSettings.First();
         }
         else
         {
             _LoadedCommonSettings = GetDefualtCommonSettings();
         }
     }
     catch
     {
         _LoadedCommonSettings = GetDefualtCommonSettings();
     }
 }
Example #2
0
 public void SaveAndReloadCommonSettings(Model.Common.ProgramSetting instance)
 {
     try
     {
         Model.Common.ArchiveCommonDataClassesDataContext dc = new Model.Common.ArchiveCommonDataClassesDataContext(Setting.Sql.ThisProgram.DatabaseConnection.ConnectionString);
         var query = dc.ProgramSettings.Select(t => t);
         if (query.Count() > 0)
         {
             Model.Common.ProgramSetting original = query.First();
             Model.Common.ProgramSetting.Copy(original, instance);
         }
         else
         {
             Model.Common.ProgramSetting.Insert(dc, instance);
         }
         dc.SubmitChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("خطا در ذخیره تنظیمات" + "\r\n\r\n" + ex.Message);
     }
     LoadCommonSettings();
 }