|
@@ -0,0 +1,140 @@
|
|
|
+SqlConnection connection;
|
|
|
+SqlCommand command;
|
|
|
+SqlDataAdapter adapter;
|
|
|
+DataTable table;
|
|
|
+
|
|
|
+connection = SqlConnection("Server//....);
|
|
|
+connection = new SqlConnection;
|
|
|
+command = new SqlCommand();
|
|
|
+command.Connection = connection;
|
|
|
+command.Type = Command.Type.Text;
|
|
|
+adapter = new SqlAdapter(command);
|
|
|
+table = new DataTable();
|
|
|
+
|
|
|
+datagridview.Columns.Clear();
|
|
|
+datagridview.DataSource=null;
|
|
|
+command.CommandText=text;
|
|
|
+table.Clear();
|
|
|
+adapter.Fill(table);
|
|
|
+datagrid.DataSource=table;
|
|
|
+
|
|
|
+
|
|
|
+connection = new SqlConnection(::);
|
|
|
+command = new SqlCommand;
|
|
|
+command.Connection= connection;
|
|
|
+command.Type= Command.Tyype.Text;
|
|
|
+adapter = new SqlDataAdater(command);
|
|
|
+table= new DataTable();
|
|
|
+
|
|
|
+dgv.Columns.Clear();
|
|
|
+dgv.DataSource = null;
|
|
|
+command.CommandText=text;
|
|
|
+table.Clear();
|
|
|
+adapter.Fill(table);
|
|
|
+dgv.Datasource=table;
|
|
|
+
|
|
|
+connection = new SqlConnection("");
|
|
|
+commnd = new SqlCommand();
|
|
|
+coomand.Connection=connection;
|
|
|
+command.Type=Command.Type.Text;
|
|
|
+adapter= new SqlDataAdapter(command);
|
|
|
+table = new DataTable();
|
|
|
+
|
|
|
+dgv.Columns.Clear()l
|
|
|
+dgv.DataSource=null;
|
|
|
+command.CommandText=text;
|
|
|
+table.Clear();
|
|
|
+adapter.Fill(table);
|
|
|
+dgv.datasource=table;
|
|
|
+
|
|
|
+SqlConnection connection;
|
|
|
+SqlCommand command;
|
|
|
+SqlDataAdapter adapter;
|
|
|
+DataTable table;
|
|
|
+
|
|
|
+connection = new SqlConnection();
|
|
|
+connection = new SqlConnection;
|
|
|
+command = new command;
|
|
|
+command.Connection=connection;
|
|
|
+command.Type = Command.Type.Text;
|
|
|
+adapter = new SqlDataAdapter(coomand);
|
|
|
+table = new DataTable();
|
|
|
+
|
|
|
+dgv.COlumns.Clear();
|
|
|
+dgv.DataSource = null;
|
|
|
+command.CommandText=text;
|
|
|
+table.Clear();
|
|
|
+adapter.Fill(text);
|
|
|
+dgv.DataSource = table;
|
|
|
+
|
|
|
+
|
|
|
+SqlConnection connection;
|
|
|
+SqlCommand command;
|
|
|
+SqlDataAdapter adapter;
|
|
|
+DataTable table;
|
|
|
+
|
|
|
+connection = new SqlConnection();
|
|
|
+command = new SqlCommand();
|
|
|
+command.Connection = connection;
|
|
|
+command.Type = Command.Type.Text;
|
|
|
+adapter = new SqlDataAdapter(command);
|
|
|
+table = new DataTable();
|
|
|
+
|
|
|
+dgv.Columns.Clear();
|
|
|
+dgv.DataSource=null;
|
|
|
+command.CommandText=text;
|
|
|
+table.Clear();
|
|
|
+adapter.Fill(text);
|
|
|
+dgv.Datasource=table;
|
|
|
+
|
|
|
+
|
|
|
+if (MessageBox.Show("вы хотите удалить?", "Ошибка", MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
|
|
|
+ {
|
|
|
+ connection.Open();
|
|
|
+ command.CommandText = ("Delete From Users Where id=@id");
|
|
|
+ command.Parameters.AddWithValue("@id",dataGridView1.CurrentRow.Cells[0].Value);
|
|
|
+ command.ExecuteReader();
|
|
|
+ command.Parameters.Clear();
|
|
|
+ connection.Close();
|
|
|
+ MessageBox.Show("МНе похуй баля");
|
|
|
+ ShowTable("Select * From Users");
|
|
|
+ dataGridView1.Columns[0].Visible = false;
|
|
|
+
|
|
|
+
|
|
|
+ if(MessageBox.Show("Удалить пользователя?","Внимание",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
|
|
|
+ {
|
|
|
+ connection.Open();
|
|
|
+ command.CommandText=("Delete From Users Where id=@id");
|
|
|
+ command.Parameters.AddWithValue("@id", dataGridView1.CurrentRow.Cells[0].Value);
|
|
|
+ command.ExecuteReader();
|
|
|
+ command.Parameters.Clear();
|
|
|
+ connection.Close();
|
|
|
+ }
|
|
|
+
|
|
|
+ var db = new DataClasses1DataContext();
|
|
|
+ var data = new Users
|
|
|
+ {
|
|
|
+ Login = LogBox.Text,
|
|
|
+ Password = PassBox.Text
|
|
|
+ };
|
|
|
+ db.Users.InsertOnSubmit(data);
|
|
|
+ db.SubmitChanges();
|
|
|
+ MessageBox.Show("Пользователь успешно добавлен!");
|
|
|
+ Form1 p = new Form1();
|
|
|
+ p.Show();
|
|
|
+ this.Hide();
|
|
|
+
|
|
|
+ private void Войти_Click(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ var db = new BaseDataContext();
|
|
|
+ var data = db.Users.FirstOrDefault(u =>u.Login == LoginBox.Text&&u.Password == PassBox.Text);
|
|
|
+ if (data == null)
|
|
|
+ {
|
|
|
+ MessageBox.Show("ne");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Просмотр m = new Просмотр();
|
|
|
+ m.Show();
|
|
|
+ this.Hide();
|
|
|
+ }
|