Advertisement
Guest User

Untitled

a guest
Mar 27th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 25.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.IO;
  5. using System.Diagnostics;
  6. using System.Data.SqlClient;
  7. using MySql.Data.MySqlClient;
  8. using System.Windows.Forms;
  9.  
  10.  
  11. namespace БД_Мессенджера
  12. {
  13.    
  14.     public partial class admin_form : Form
  15.     {
  16.      static int table_counter;
  17.         public admin_form()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.        
  22.         private void admin_form_Load(object sender, EventArgs e)
  23.         {
  24.             ConnectionWork.AddConnectionString("Server = localhost; database = messenger; UID = admin; password = randomlycreatedpassword; Integrated Security = True");
  25.             ConnectionWork.AddConnectionString("Server = localhost; database = messenger; UID = manager; password = randomlygivenpasswordformanager; Integrated Security = True");
  26.             ConnectionWork.AddConnectionString("Server = localhost; database = messenger; UID = user; password = randomlygivenpasswordforuser; Integrated Security = True");
  27.                 ConnectionWork.SetConnection(2);
  28.  
  29.             SqlWorker _SqlWorker = new SqlWorker();
  30.             try
  31.             {
  32.                 _SqlWorker.Work("Connect", "Проверка работоспособности с MySQL сервером прошла успешно...");
  33.             }
  34.             catch
  35.             {
  36.                 Debug.LoadLogSrting("При проверке соединения к серверу возникли проблеммы!");
  37.             }
  38.  
  39.             //_SqlWorker.Work("Connect", "Идёт подключение к SQLServer. Пожалуйста подождите...");
  40.             _SqlWorker.Work("FillTable", "Идёт заполнение таблицы из базы данных praktika");
  41.         }
  42.  
  43.        
  44.        
  45.             static class Debug
  46.         {
  47.             private static string NameLog = "Нет никаких процессов...";
  48.             public static string Log(string s = "")
  49.             {
  50.                 s = NameLog;
  51.                 return s;
  52.             }
  53.             public static void LoadLogSrting(string s)
  54.             {
  55.                 NameLog = s;
  56.                 using (var writer = new StreamWriter("LogFile.txt", true))
  57.                 {
  58.                     writer.WriteLine(s + "   (" + DateTime.Now.ToString("День: dd MMMM yyyy |Час: HH:mm:ss") + ")");
  59.                 }
  60.             }
  61.             public static string Blocket(string s = "Эта функция на данный момент заблокирована!")
  62.             {
  63.                 return s;
  64.             }
  65.             public static void OpenLog()
  66.             {
  67.                 Process.Start("LogFile.txt");
  68.             }
  69.         }
  70.      
  71.         class SqlConnector: admin_form
  72.             {
  73.  
  74.             protected string connectionString = ConnectionWork.CurrentConnection;
  75.             DataSet ds = new DataSet();
  76.                 SqlDataAdapter adapter = new SqlDataAdapter();
  77.                 DataTable dataTable = new DataTable();
  78.                 MySqlConnection conn;
  79.                 MySqlCommand cmd;
  80.                 MySqlDataAdapter adptr;
  81.                 protected void Connection(string s)
  82.                 {
  83.                     try
  84.                     {
  85.                     if (admin == true)
  86.                     {
  87.                         manager = false;
  88.                         user = false;
  89.                         string connectionString = "Server=localhost; database=messenger; UID=admin; password=randomlycreatedpassword; Integrated Security=True";
  90.                     }
  91.                     if (manager == true)
  92.                     {
  93.                         admin = false;
  94.                         user = false;
  95.                         string connectionString = "Server=localhost; database=messenger; UID=manager; password=randomlygivenpasswordformanager; Integrated Security=True";
  96.                     }
  97.                     if (user == true)
  98.                     {
  99.                         manager = false;
  100.                         admin = false;
  101.                         string connectionString = "Server=localhost; database=messenger; UID=user; password=randomlygivenpasswordforuser; Integrated Security=True";
  102.  
  103.                     }
  104.                     conn = new MySqlConnection(connectionString);
  105.                         cmd = new MySqlCommand();
  106.                         cmd.Connection = conn;
  107.                         cmd.CommandText = s;
  108.  
  109.                         Debug.LoadLogSrting("Идёт заполнение Адаптера...");
  110.                         adptr = new MySqlDataAdapter(cmd);
  111.                         adptr.Fill(ds);
  112.  
  113.                         Debug.LoadLogSrting("Подключение к MySQL серверу прошло успешно...");
  114.                         adptr.Fill(dataTable);
  115.                     }
  116.                     catch (MySqlException ex)
  117.                     {
  118.                         Debug.LoadLogSrting("Подключение к MySQL серверу провалилось :(");
  119.                         MessageBox.Show(ex.Message);
  120.                     }
  121.                 }
  122.                 protected void delete()
  123.                 {
  124.                 string s;
  125.                 string connectionString = "Server=localhost; database=messenger; UID=admin; password=randomlycreatedpassword; Integrated Security=True";
  126.                 conn = new MySqlConnection(connectionString);
  127.                 s = (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentCell.Value.ToString();
  128.                 MySqlCommand cmd = new MySqlCommand();
  129.                 cmd.Connection = conn;
  130.                 conn.Open();
  131.                 cmd.CommandText = "delete from user_table where id= " + s;
  132.                 cmd.ExecuteNonQuery();
  133.                 conn.Close();
  134.             }
  135.                 protected void update()
  136.                 {
  137.  
  138.                 }
  139.  
  140.                 protected void create()
  141.             {
  142.                 try
  143.                 {if (admin)
  144.                     {
  145.                         manager = false;
  146.                         user = false;
  147.                         ConnectionWork.SetConnection(0);
  148.                     }
  149.                 if (manager == true)
  150.                     {
  151.                         admin = false;
  152.                         user = false;
  153.                         ConnectionWork.SetConnection(1);
  154.                     }
  155.                 if (user ==true)
  156.                     {
  157.                         manager = false;
  158.                         admin = false;
  159.                         ConnectionWork.SetConnection(2);
  160.                     }
  161.                     conn = new MySqlConnection(connectionString);
  162.                     MySqlCommand cmd = new MySqlCommand();
  163.                     cmd.Connection = conn;
  164.                     conn.Open();
  165.                     switch (table_counter)
  166.                     {
  167.                         case 1:
  168.                             cmd.CommandText = "insert into `messenger`.`user_table`(id,name,surname,age,about,position,password) values ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["name"].Value + "','" +(Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["surname"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["age"].Value +"','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["about"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["position"].Value + "','" +(Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["password"].Value + "');";
  169.                             cmd.ExecuteNonQuery();
  170.                             break;
  171.                         case 2:
  172.                             cmd.CommandText = "INSERT INTO `messenger`.`status` (`user_id`, `is_active`, `is_blocked`, `is_reported`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["user_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["is_active"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["is_blocked"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["is_reported"].Value + "'); ";
  173.                             cmd.ExecuteNonQuery();
  174.                             break;
  175.                         case 3:
  176.                             cmd.CommandText = "INSERT INTO `messenger`.`reports` (`id`, `user_id`, `report_type`, `report_text`, `created_at`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["user_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_text"].Value + "','" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "');";
  177.                             if ((Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value.ToString() != "Мошенничество" || (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value.ToString() != "Оскорбление" || (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value.ToString() != "Пропоганда наркотиков" || (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value.ToString() != "Рассылка спама" || (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["report_type"].Value.ToString() != "Мошенничество")
  178.  
  179.                                 MessageBox.Show("Список допустимых типов жалоб:"+ "\n"+ "Мошенничество" + "\n" + "Оскорбление" + "\n" + "Пропоганда наркотиков" + "\n" + "Рассылка спама" + "\n" + "Мошенничество");                                
  180.                            
  181.                               else  cmd.ExecuteNonQuery();
  182.                             break;
  183.                         case 4:
  184.                             cmd.CommandText = "INSERT INTO `messenger`.`participants` (`user_id`, `chat_id`, `participant_id`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["user_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["participant_id"].Value + "');";
  185.                             cmd.ExecuteNonQuery();
  186.                             break;
  187.                         case 5:
  188.                             cmd.CommandText= "INSERT INTO `messenger`.`messages` (`user_id`, `message_id`, `message`,`created_at`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["user_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["message_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["message"].Value + "','" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "');";
  189.                             cmd.ExecuteNonQuery();
  190.                             break;
  191.                         case 6:
  192.                             cmd.CommandText= "INSERT INTO `messenger`.`contact_inf` (`user_id`, `vk_link`, `facebook_link`, `twitter_link`, `email`, `phone`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["user_id"].Value + "','"+ (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["vk_link"].Value + "','" + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["facebook_link"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["twitter_link"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["email"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["phone"].Value + "');";
  193.                             cmd.ExecuteNonQuery();
  194.                             break;
  195.                         case 7:
  196.                             cmd.CommandText = "INSERT INTO `messenger`.`chats` (`chat_id`, `chat_type`, `created_at`, `user_id`) VALUES ('" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_id"].Value + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_type"].Value + "','" + DateTime.Now.ToString("yyyy/MM/dd HH:mm") + "','" + (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_type"].Value + "');";
  197.                             if ((Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_type"].Value.ToString() != "Private message" || (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentRow.Cells["chat_type"].Value.ToString() != "Public dialog")
  198.                                 MessageBox.Show("Список допустимых типов:" + "\n" + "Private message" + "\n" + "Public dialog");
  199.                               else  cmd.ExecuteNonQuery();
  200.                             break;
  201.                         case 8:
  202.                             break;
  203.                     }
  204.                 }
  205.                 catch (MySqlException ex) { MessageBox.Show(ex.ToString(),"Ошибка",MessageBoxButtons.OK, MessageBoxIcon.Error); }
  206.                
  207.                 conn.Close();
  208.  
  209.             }
  210.                 protected virtual void FillT()
  211.                 {
  212.                     int a = Application.OpenForms.Count - 1;
  213.  
  214.                     try
  215.                     {
  216.                         (Application.OpenForms[a] as admin_form).bunifuCustomDataGrid2.DataSource = ds.Tables[0];
  217.                         Debug.LoadLogSrting("Таблица была успешно заполнена.");
  218.                     }
  219.                     catch
  220.                     {
  221.                         Debug.LoadLogSrting("Заполнение таблицы провалилось...");
  222.                         MessageBox.Show("Ошибка, заполнение таблицы прерванно!");
  223.                     }
  224.                 }
  225.                 protected void Disconnect()
  226.                 {
  227.                     try
  228.                     {
  229.                         conn.Close();
  230.                         Debug.LoadLogSrting("Закрытие соединения с MySQL сервером прошло успешно...");
  231.                     }
  232.                     catch
  233.                     {
  234.                         Debug.LoadLogSrting("Закрытие соединения с MySQL провалилось...");
  235.                         MessageBox.Show("При закрытии соединения с сервером произошла ошибка, возможно какойто процесс остался не завершённым");
  236.                     }
  237.                 }
  238.  
  239.             }
  240.             class SqlWorker : SqlConnector
  241.             {
  242.  
  243.                 public void Work(string element, string log, string s = "SELECT * FROM messenger.user_info;")
  244.                 {
  245.                     switch (element)
  246.                     {
  247.                         case "Connect":
  248.                             Debug.LoadLogSrting(log);
  249.                             Connection(s);
  250.                             break;
  251.                         case "Disconnect":
  252.                             Debug.LoadLogSrting(log);
  253.                             Disconnect();
  254.                             break;
  255.                         case "delete":
  256.                             delete();
  257.                             break;
  258.                         case "FillTable":
  259.                             Debug.LoadLogSrting(log);
  260.                             FillT();
  261.                             break;
  262.                         case "update":
  263.                             update();
  264.                             break;
  265.                         case "create":
  266.                             create();
  267.                             break;
  268.                         default:
  269.                             Debug.LoadLogSrting("Ошибка, Класс SqlWorker не может работать с таким элементом :(");
  270.                             MessageBox.Show("Мастер подключения приостановлен \"" + element + "\" не является обрабатываемым элементом мастера!");
  271.                             break;
  272.  
  273.                     }
  274.                 }
  275.  
  276.                 private void button1_Click(object sender, EventArgs e)
  277.                 {
  278.                     string connectionString = "Server=localhost; database=messenger; UID=admin; password=randomlycreatedpassword; Integrated Security=True";
  279.                 SqlConnector sql1 = new SqlConnector();
  280.                     MySqlConnection connect = new MySqlConnection(connectionString);
  281.                     string s = "SELECT * FROM messenger.user_info;";
  282.                     MySqlCommand com = new MySqlCommand(s, connect);
  283.                     DataSet ds = new DataSet();
  284.                 }
  285.             }
  286.  
  287.         private void button2_Click(object sender, EventArgs e)
  288.         {
  289.             this.timer1.Start();
  290.             SqlWorker _SqlWorker1 = new SqlWorker();
  291.             _SqlWorker1.Work("Connect", "Идёт подключение к SQLServer. Пожалуйста подождите...", "SELECT * FROM messenger.user_message;");
  292.             _SqlWorker1.Work("FillTable", "Идёт заполнение таблицы из базы данных praktika");
  293.          
  294.         }
  295.  
  296.         private void timer1_Tick(object sender, EventArgs e)
  297.         {
  298.             if (bunifuProgressBar1.Value == 750)
  299.             {
  300.                 timer1.Stop();
  301.                 bunifuProgressBar1.Value = -250;
  302.             }
  303.             bunifuProgressBar1.Value += 250;
  304.            
  305.         }
  306.  
  307.         private void button3_Click(object sender, EventArgs e)
  308.         {
  309.             SqlWorker _SqlWorker1 = new SqlWorker();
  310.             _SqlWorker1.Work("create", "");
  311.         }
  312.  
  313.         private void button4_Click(object sender, EventArgs e)
  314.         {
  315.             SqlWorker _SqlWorker1 = new SqlWorker();
  316.             _SqlWorker1.Work("delete", "");
  317.  
  318.         }
  319.        public bool admin;
  320.        public bool manager;
  321.        public bool user=true;
  322.         private void авторизацияToolStripMenuItem_Click(object sender, EventArgs e)
  323.         {  
  324.             Authorization form = new Authorization();
  325.             form.ShowDialog();
  326.          
  327.         }
  328.  
  329.         private void выходToolStripMenuItem_Click(object sender, EventArgs e)
  330.         {
  331.             Application.Exit();
  332.         }
  333.  
  334.         private void button6_Click(object sender, EventArgs e)
  335.         {
  336.             table_counter = 1;
  337.             SqlWorker _sqlworker = new SqlWorker();
  338.             _sqlworker.Work("Connect", "Заполнение таблицой user_table", "select * from messenger.user_table");
  339.             _sqlworker.Work("FillTable", " ");
  340.         }
  341.  
  342.         private void button7_Click(object sender, EventArgs e)
  343.         {
  344.             table_counter = 2;
  345.                SqlWorker _sqlworker = new SqlWorker();
  346.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.status");
  347.             _sqlworker.Work("FillTable", " ");
  348.         }
  349.  
  350.         private void button10_Click(object sender, EventArgs e)
  351.         {
  352.           table_counter = 3;
  353.             SqlWorker _sqlworker = new SqlWorker();
  354.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.reports");
  355.             _sqlworker.Work("FillTable", " ");
  356.         }
  357.  
  358.         private void button9_Click(object sender, EventArgs e)
  359.         {
  360.           table_counter = 4;
  361.             SqlWorker _sqlworker = new SqlWorker();
  362.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.participants");
  363.             _sqlworker.Work("FillTable", " ");
  364.         }
  365.  
  366.         private void button8_Click(object sender, EventArgs e)
  367.         {
  368.             table_counter = 5;
  369.             SqlWorker _sqlworker = new SqlWorker();
  370.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.messages");
  371.             _sqlworker.Work("FillTable", " ");
  372.         }
  373.  
  374.         private void button13_Click(object sender, EventArgs e)
  375.         {
  376.             table_counter = 6;
  377.             SqlWorker _sqlworker = new SqlWorker();
  378.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.contact_inf");
  379.             _sqlworker.Work("FillTable", " ");
  380.         }
  381.  
  382.         private void button12_Click(object sender, EventArgs e)
  383.         {
  384.             table_counter = 7;
  385.             SqlWorker _sqlworker = new SqlWorker();
  386.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.chats");
  387.             _sqlworker.Work("FillTable", " ");
  388.         }
  389.  
  390.         private void button11_Click(object sender, EventArgs e)
  391.         {
  392.             table_counter = 8;
  393.             SqlWorker _sqlworker = new SqlWorker();
  394.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select * from messenger.black_list");
  395.             _sqlworker.Work("FillTable", " ");
  396.         }
  397.  
  398.         private void справкаToolStripMenuItem_Click(object sender, EventArgs e)
  399.         {
  400.             Help help_form = new Help();
  401.             help_form.Show();
  402.         }
  403.  
  404.         private void button29_Click(object sender, EventArgs e)
  405.         {
  406.             SqlWorker _sqlworker = new SqlWorker();
  407.             _sqlworker.Work("Connect", "Заполнение таблицой status", "SELECT * FROM messenger.chats_view;");
  408.             _sqlworker.Work("FillTable", " ");
  409.         }
  410.  
  411.         private void button30_Click(object sender, EventArgs e)
  412.         {
  413.             SqlWorker _sqlworker = new SqlWorker();
  414.             _sqlworker.Work("Connect", "Заполнение таблицой status", " SELECT* FROM messenger.status_view;");
  415.             _sqlworker.Work("FillTable", " ");
  416.         }
  417.  
  418.         private void button25_Click(object sender, EventArgs e)
  419.         {
  420.             SqlWorker _sqlworker = new SqlWorker();
  421.             _sqlworker.Work("Connect", "Заполнение таблицой status", "SELECT * FROM messenger.user_info;");
  422.             _sqlworker.Work("FillTable", " ");
  423.         }
  424.  
  425.         private void button26_Click(object sender, EventArgs e)
  426.         {
  427.             SqlWorker _sqlworker = new SqlWorker();
  428.             _sqlworker.Work("Connect", "Заполнение таблицой status", "SELECT * FROM messenger.user_message;");
  429.             _sqlworker.Work("FillTable", " ");
  430.         }
  431.  
  432.         private void button27_Click(object sender, EventArgs e)
  433.         {
  434.             SqlWorker _sqlworker = new SqlWorker();
  435.             _sqlworker.Work("Connect", "Заполнение таблицой status", "SELECT * FROM messenger.user_report;");
  436.             _sqlworker.Work("FillTable", " ");
  437.         }
  438.  
  439.         private void button2_Click_1(object sender, EventArgs e)
  440.         {
  441.             SqlWorker _sqlworker = new SqlWorker();
  442.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select messenger.avg_age();");
  443.             _sqlworker.Work("FillTable", " ");
  444.         }
  445.  
  446.         private void button14_Click(object sender, EventArgs e)
  447.         {
  448.             SqlWorker _sqlworker = new SqlWorker();
  449.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select messenger.blocked_count();");
  450.             _sqlworker.Work("FillTable", " ");
  451.        
  452.         }
  453.  
  454.         private void button15_Click(object sender, EventArgs e)
  455.         {
  456.             SqlWorker _sqlworker = new SqlWorker();
  457.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select messenger.count_user_message("+ (Application.OpenForms[0] as admin_form).bunifuCustomDataGrid2.CurrentCell.Value.ToString() + ");");
  458.             _sqlworker.Work("FillTable", " ");
  459.         }
  460.  
  461.         private void button16_Click(object sender, EventArgs e)
  462.         {
  463.             SqlWorker _sqlworker = new SqlWorker();
  464.             _sqlworker.Work("Connect", "Заполнение таблицой status", "select messenger.user_count();");
  465.             _sqlworker.Work("FillTable", " ");
  466.         }
  467.     }
  468.    
  469.     }
  470.     public static class ConnectionWork
  471.     {
  472.         static string _currentconnection;
  473.         private static List<string> Connection = new List<string>();
  474.  
  475.         public static void AddConnectionString(string _connection)
  476.         {
  477.             Connection.Add(_connection);
  478.         }
  479.  
  480.         public static void SetConnection(int index)
  481.         {
  482.             CurrentConnection = Connection[index];
  483.         }
  484.         public static string CurrentConnection
  485.         {
  486.             get
  487.             {
  488.                 return _currentconnection;
  489.             }
  490.             set
  491.             {
  492.                 _currentconnection = value;
  493.             }
  494.         }
  495.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement