public static string SelectName_Company_City(int contactId) { Contact contact = SelectContact(contactId); Company company = Tab_Company.SelectCompany(contact.CompanyId); if (contactId == 0 || contact.CompanyId < 1) { return("-leer-"); } return($"{contact.Name}, {company.Name}, {System.Text.RegularExpressions.Regex.Replace(company.City, @"\d", "")}"); }
private static void CreateNewDataBase() { Console.WriteLine("Erstelle eine neue Datenbank."); try { //Erstelle Datenbank-Datei und öffne einmal zum Testen Directory.CreateDirectory(Path.GetDirectoryName(DbPath)); FileStream stream = File.Create(DbPath); stream.Close(); //Erzeuge Tabellen in neuer Datenbank-Datei //Zeiten in UTC im Format TEXT (Lesbarkeit Rohdaten) #region Log Tab_Log.CreateTable(); Log log = new Log(Tab_Log.Topic.Startup, 3, "Datenbank neu erstellt."); Tab_Log.Insert(log); #endregion #region Company Tab_Company.CreateTable(); Company company1 = new Company("Kreutzträger Kältetechnik GmbH & Co. KG", "Theodor-Barth-Str. 21", "28307 Bremen"); Tab_Company.Insert(company1); #endregion #region Contact Tab_Contact.CreateTable(); Contact contact = new Contact { Id = 1, Name = "SMSZentrale", Password = Tab_Contact.Encrypt("7307"), Accesslevel = 9000, CompanyId = 1, Email = "*****@*****.**", Phone = 4915142265412, Via = Tab_Contact.Communication.Email, MaxInactiveHours = 4 }; Tab_Contact.Insert(contact); contact = new Contact { Id = 2, Name = "Bereitschaftshandy", Password = Tab_Contact.Encrypt("7307"), Accesslevel = 2000, CompanyId = 1, Email = "*****@*****.**", Phone = 491728362586, Via = Tab_Contact.Communication.Sms }; Tab_Contact.Insert(contact); contact = new Contact { Id = 3, Name = "Kreutzträger Service", Password = Tab_Contact.Encrypt("7307"), Accesslevel = 9000, CompanyId = 1, Email = "*****@*****.**", Via = Tab_Contact.Communication.Email }; Tab_Contact.Insert(contact); contact = new Contact { Name = "Henry Kreutzträger", Password = Tab_Contact.Encrypt("7307"), Accesslevel = 9000, CompanyId = 1, Email = "*****@*****.**", Phone = 491727889419, Via = Tab_Contact.Communication.Sms }; Tab_Contact.Insert(contact); contact = new Contact { Name = "Bernd Kreutzträger", Password = Tab_Contact.Encrypt("7307"), Accesslevel = 9000, CompanyId = 1, Email = "*****@*****.**", Phone = 491727875067, Via = Tab_Contact.Communication.Sms }; Tab_Contact.Insert(contact); #endregion #region Message Tab_Message.CreateTable(); Message message1 = new Message { Content = "Datenbank neu erstellt.", BlockedDays = Tab_Message.BlockWeek(), StartBlockHour = 8, EndBlockHour = 8 }; Tab_Message.Insert(message1); #endregion #region Recieved Tab_Recieved.CreateTable(); Recieved recieved1 = new Recieved(1, 1) { RecTime = DateTime.UtcNow }; Tab_Recieved.Insert(recieved1); #endregion #region Sent Tab_Sent.CreateTable(); Sent sent1 = new Sent(1, 1, Tab_Contact.Communication.Unknown) { SentTime = DateTime.UtcNow }; Tab_Sent.Insert(sent1); #endregion #region Bereitschaft Tab_Shift.CreateTable(); Shift shift1 = new Shift(1, DateTime.Now); Tab_Shift.Insert(shift1); #endregion Views_Create(); #region Hilfstabelle Dictionary <string, string> columns = new Dictionary <string, string> { { "Id", "INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT" }, { "DischargeTime", "TEXT" }, { "InternalReference", "INTEGER" } }; Sql.CreateTable("Reports", columns); #endregion } catch (Exception ex) { throw new Exception("Sql-Fehler CreateNewDataBase()\r\n" + ex.Message + "\r\n" + ex.InnerException); } }