bvc.txt 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. SqlConnection connection;
  2. SqlCommand command;
  3. SqlDataAdapter adapter;
  4. DataTable table;
  5. connection = SqlConnection("Server//....);
  6. connection = new SqlConnection;
  7. command = new SqlCommand();
  8. command.Connection = connection;
  9. command.Type = Command.Type.Text;
  10. adapter = new SqlAdapter(command);
  11. table = new DataTable();
  12. datagridview.Columns.Clear();
  13. datagridview.DataSource=null;
  14. command.CommandText=text;
  15. table.Clear();
  16. adapter.Fill(table);
  17. datagrid.DataSource=table;
  18. connection = new SqlConnection(::);
  19. command = new SqlCommand;
  20. command.Connection= connection;
  21. command.Type= Command.Tyype.Text;
  22. adapter = new SqlDataAdater(command);
  23. table= new DataTable();
  24. dgv.Columns.Clear();
  25. dgv.DataSource = null;
  26. command.CommandText=text;
  27. table.Clear();
  28. adapter.Fill(table);
  29. dgv.Datasource=table;
  30. connection = new SqlConnection("");
  31. commnd = new SqlCommand();
  32. coomand.Connection=connection;
  33. command.Type=Command.Type.Text;
  34. adapter= new SqlDataAdapter(command);
  35. table = new DataTable();
  36. dgv.Columns.Clear()l
  37. dgv.DataSource=null;
  38. command.CommandText=text;
  39. table.Clear();
  40. adapter.Fill(table);
  41. dgv.datasource=table;
  42. SqlConnection connection;
  43. SqlCommand command;
  44. SqlDataAdapter adapter;
  45. DataTable table;
  46. connection = new SqlConnection();
  47. connection = new SqlConnection;
  48. command = new command;
  49. command.Connection=connection;
  50. command.Type = Command.Type.Text;
  51. adapter = new SqlDataAdapter(coomand);
  52. table = new DataTable();
  53. dgv.COlumns.Clear();
  54. dgv.DataSource = null;
  55. command.CommandText=text;
  56. table.Clear();
  57. adapter.Fill(text);
  58. dgv.DataSource = table;
  59. SqlConnection connection;
  60. SqlCommand command;
  61. SqlDataAdapter adapter;
  62. DataTable table;
  63. connection = new SqlConnection();
  64. command = new SqlCommand();
  65. command.Connection = connection;
  66. command.Type = Command.Type.Text;
  67. adapter = new SqlDataAdapter(command);
  68. table = new DataTable();
  69. dgv.Columns.Clear();
  70. dgv.DataSource=null;
  71. command.CommandText=text;
  72. table.Clear();
  73. adapter.Fill(text);
  74. dgv.Datasource=table;
  75. if (MessageBox.Show("вы хотите удалить?", "Ошибка", MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
  76. {
  77. connection.Open();
  78. command.CommandText = ("Delete From Users Where id=@id");
  79. command.Parameters.AddWithValue("@id",dataGridView1.CurrentRow.Cells[0].Value);
  80. command.ExecuteReader();
  81. command.Parameters.Clear();
  82. connection.Close();
  83. MessageBox.Show("МНе похуй баля");
  84. ShowTable("Select * From Users");
  85. dataGridView1.Columns[0].Visible = false;
  86. if(MessageBox.Show("Удалить пользователя?","Внимание",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
  87. {
  88. connection.Open();
  89. command.CommandText=("Delete From Users Where id=@id");
  90. command.Parameters.AddWithValue("@id", dataGridView1.CurrentRow.Cells[0].Value);
  91. command.ExecuteReader();
  92. command.Parameters.Clear();
  93. connection.Close();
  94. }
  95. var db = new DataClasses1DataContext();
  96. var data = new Users
  97. {
  98. Login = LogBox.Text,
  99. Password = PassBox.Text
  100. };
  101. db.Users.InsertOnSubmit(data);
  102. db.SubmitChanges();
  103. MessageBox.Show("Пользователь успешно добавлен!");
  104. Form1 p = new Form1();
  105. p.Show();
  106. this.Hide();
  107. private void Войти_Click(object sender, EventArgs e)
  108. {
  109. var db = new BaseDataContext();
  110. var data = db.Users.FirstOrDefault(u =>u.Login == LoginBox.Text&&u.Password == PassBox.Text);
  111. if (data == null)
  112. {
  113. MessageBox.Show("ne");
  114. }
  115. else
  116. {
  117. Просмотр m = new Просмотр();
  118. m.Show();
  119. this.Hide();
  120. }