//database private void SetB1_Click(object sender, RoutedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart) delegate() { BackUp.NewDbBackup(); MessageBox.Show("تم اخذ نسخه احتياطيه من القاعده القديمه"); DataHolder.CreateConnection(co.DbUserName, co.DbUserPassword, co.Hostname); CreateDB.Createdb(co.DbName, DbName.Text); co.Write(); MessageBox.Show("تم الحفظ سيتم غلق البرنامج الان"); Environment.Exit(0); }); }
private void Install_Click(object sender, EventArgs e) { try { IniFile file = new IniFile(Constants.SetupConfigPath); if (this.Text == "تنصيب البرنامج") { if (!File.Exists(Constants.SetupConfigPath)) { file.Write("MySql", "Host", DBHost.Text); file.Write("MySql", "Username", DBUser.Text); file.Write("MySql", "Password", DBPass.Text); file.Write("MySql", "Database", DBName.Text); file.Write("Upgrade", "Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace(".", "")); if (!Directory.Exists(Application.StartupPath + @"BackUp\")) { Directory.CreateDirectory(Application.StartupPath + @"\BackUp\"); } DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.Createdb(DBName.Text); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Database")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.CreateTables(); MessageBox.Show("تم تنصيب الاعدادات\nمن فضلك انشاء حساب جديد لتتمكن من الدخول"); Register reg = new Register(); reg.ShowDialog(); this.Close(); } } else if (this.Text == "اعدادات البرنامج") { if (File.Exists(Constants.SetupConfigPath)) { BackUp.NewDbBackup(); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); CreateDB.Createdb(file.ReadString("MySql", "Database"), DBName.Text); file.Write("MySql", "Host", DBHost.Text); file.Write("MySql", "Username", DBUser.Text); file.Write("MySql", "Password", DBPass.Text); file.Write("MySql", "Database", DBName.Text); DataHolder.CreateConnection(Program.INIDecrypt(file.ReadString("MySql", "Username")), Program.INIDecrypt(file.ReadString("MySql", "Password")), Program.INIDecrypt(file.ReadString("MySql", "Database")), Program.INIDecrypt(file.ReadString("MySql", "Host"))); BackUp.NewDbRestore(); BillsTable.LBN(); MessageBox.Show("تم تغيير الاعدادات"); } } } catch (Exception ee) { Program.SaveException(ee); } }