private void label4_Click(object sender, EventArgs e) { dataGridView1.Rows.Clear(); DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `Admin`=@ad ", db.GetConnection()); command.Parameters.Add("@ad", MySqlDbType.VarChar).Value = 2; adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count == 0) { MessageBox.Show("Никого нету"); return; } db.openConnection(); MySqlDataReader reader = command.ExecuteReader(); List <string[]> data = new List <string[]>(); while (reader.Read()) { data.Add(new string[6]); data[data.Count - 1][0] = reader[0].ToString(); data[data.Count - 1][1] = reader[1].ToString(); data[data.Count - 1][2] = reader[2].ToString(); data[data.Count - 1][3] = reader[3].ToString(); data[data.Count - 1][4] = reader[4].ToString(); data[data.Count - 1][5] = reader[5].ToString(); } reader.Close(); foreach (string[] s in data) { dataGridView1.Rows.Add(s); } if (table.Rows.Count > 0) { MessageBox.Show("Обновленно"); } else { MessageBox.Show("Заказов нету"); } db.closeConnection(); }
private void bRegister_Click(object sender, EventArgs e) { if (loginReg.Text == "Введите логин") { MessageBox.Show("Введите логин"); return; } if (checkuser()) { return; } DB db = new DB(); MySqlCommand command = new MySqlCommand("INSERT INTO `users` (`login`, `pass`, `Name`, `Famil`, `Otche`,`Admin`,`Valutka`) VALUES (@login, @pass, @name, @famil, @otche, @Admin,'0')", db.GetConnection()); command.Parameters.Add("@login", MySqlDbType.VarChar).Value = loginReg.Text; command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = passReg.Text; command.Parameters.Add("@Name", MySqlDbType.VarChar).Value = NameU.Text; command.Parameters.Add("@Famil", MySqlDbType.VarChar).Value = FamilU.Text; command.Parameters.Add("@Otche", MySqlDbType.VarChar).Value = OtcheU.Text; command.Parameters.Add("@Admin", MySqlDbType.VarChar).Value = Admin.Text; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Аккаунт был создан"); this.Hide(); Login debil = new Login(); debil.Show(); } else { MessageBox.Show("Аккаунт не был создан"); } db.closeConnection(); }
private void label5_Click(object sender, EventArgs e) { DataGridViewRow row = dataGridView1.CurrentRow; DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("UPDATE `zapic` set `idAv`=@namz, `nameAv`=@vidwork, `idAvu`=@adVu, `Status`=@stat WHERE `id`=@id", db.GetConnection()); command.Parameters.Add("@id", MySqlDbType.VarChar).Value = row.Cells[0].Value.ToString(); command.Parameters.Add("@namz", MySqlDbType.VarChar).Value = id; command.Parameters.Add("@vidwork", MySqlDbType.VarChar).Value = nameAv; command.Parameters.Add("@adVu", MySqlDbType.VarChar).Value = id; command.Parameters.Add("@stat", MySqlDbType.VarChar).Value = 2; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Заказ взят"); this.Hide(); AvtoMesh avto = new AvtoMesh(); avto.Show(); avto.id.Text = id; avto.nameAv = nameAv; avto.admin = ad; avto.Valutka.Text = valll; } else { MessageBox.Show("Ошибка"); } db.closeConnection(); }
private void button1_Click(object sender, EventArgs e) { DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("DELETE FROM `zapic` WHERE `uid`=@id", db.GetConnection()); command.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Удалено"); } else { MessageBox.Show("Ошибка"); } db.closeConnection(); }
private void button1_Click(object sender, EventArgs e) { if (Zakazi()) { return; } DB db = new DB(); MySqlCommand command = new MySqlCommand("INSERT INTO `zapic` (`nameZ`, `uid`, `vidwork`, `mark`, `date`, `idAv`, `nameAv`, `Payment`,`Status`,`idAvu`, `idMen`) VALUES (@naz, @id, @vid, @marka, @data,'0','0','0','0','0','0')", db.GetConnection()); command.Parameters.Add("@naz", MySqlDbType.VarChar).Value = nazv.Text; command.Parameters.Add("@id", MySqlDbType.VarChar).Value = label9.Text; command.Parameters.Add("@vid", MySqlDbType.VarChar).Value = vidrab.Text; command.Parameters.Add("@marka", MySqlDbType.VarChar).Value = marka.Text; command.Parameters.Add("@data", MySqlDbType.VarChar).Value = data.Text; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Запись на рассмотрение"); this.Hide(); Menu mainMenu = new Menu(); mainMenu.Show(); mainMenu.id.Text = id8; mainMenu.admin = admin; mainMenu.Valutka.Text = valll; } else { MessageBox.Show("Нет мест"); } db.closeConnection(); }
private void bLogin_Click(object sender, EventArgs e) { DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("UPDATE `users` set `Valutka`=`Valutka`+@namz WHERE `id`=@id", db.GetConnection()); command.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; command.Parameters.Add("@namz", MySqlDbType.VarChar).Value = balnc.Text; db.openConnection(); if (command.ExecuteNonQuery() == 1) { MessageBox.Show("Баланс успешно пополнен"); } else { MessageBox.Show("Ошибка"); } db.closeConnection(); DB dbb = new DB(); DataTable ttable = new DataTable(); MySqlDataAdapter aadapter = new MySqlDataAdapter(); MySqlCommand ccommand = new MySqlCommand("SELECT * FROM `users` WHERE `id`=@id", dbb.GetConnection()); ccommand.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; aadapter.SelectCommand = ccommand; aadapter.Fill(ttable); valll = ttable.Rows[0][7].ToString(); dbb.openConnection(); if (ad == "1") { this.Hide(); AdminPanel adminPanel = new AdminPanel(); adminPanel.Show(); adminPanel.id.Text = id; adminPanel.admin = ad; adminPanel.Valutka.Text = valll; } if (ad == "2") { this.Hide(); AvtoMesh avtoMesh = new AvtoMesh(); avtoMesh.id.Text = id; avtoMesh.admin = ad; avtoMesh.Valutka.Text = valll; } if (ad == "0") { this.Hide(); Menu mainMenu = new Menu(); mainMenu.Show(); mainMenu.id.Text = id; mainMenu.admin = ad; mainMenu.Valutka.Text = valll; } dbb.closeConnection(); }
private void label6_Click(object sender, EventArgs e) { DataGridViewRow row = dataGridView1.CurrentRow; DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("UPDATE `zapic` set `Status`=@val WHERE `id`=@id", db.GetConnection()); if (table.Rows.Count == 0) { MessageBox.Show("Выберите заказ"); return; } command.Parameters.Add("@id", MySqlDbType.VarChar).Value = row.Cells[0].Value.ToString(); command.Parameters.Add("@val", MySqlDbType.VarChar).Value = 0; status = row.Cells[6].Value.ToString(); if (status == "2") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } if (status == "1") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } if (status == "0") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } db.openConnection(); if (command.ExecuteNonQuery() == 1) { } else { MessageBox.Show("Ошибка"); } MySqlCommand ccommand = new MySqlCommand("UPDATE `users` set `Valutka`=`Valutka`+((@val*90)/100) WHERE `id`=@id", db.GetConnection()); ccommand.Parameters.Add("@id", MySqlDbType.VarChar).Value = row.Cells[7].Value.ToString(); ccommand.Parameters.Add("@val", MySqlDbType.VarChar).Value = row.Cells[3].Value.ToString(); if (status == "2") { return; } if (status == "1") { return; } if (status == "0") { return; } if (ccommand.ExecuteNonQuery() == 1) { } else { MessageBox.Show("Ошибка"); } MySqlCommand cccommand = new MySqlCommand("UPDATE `users` set `Valutka`=`Valutka`+((@val*10)/100) WHERE `id`=@id", db.GetConnection()); cccommand.Parameters.Add("@id", MySqlDbType.VarChar).Value = row.Cells[4].Value.ToString(); cccommand.Parameters.Add("@val", MySqlDbType.VarChar).Value = row.Cells[3].Value.ToString(); if (status == "2") { return; } if (status == "1") { return; } if (status == "0") { return; } if (cccommand.ExecuteNonQuery() == 1) { } else { MessageBox.Show("Ошибка"); } MySqlCommand scommand = new MySqlCommand("DELETE FROM `zapic` WHERE `id`=@id", db.GetConnection()); scommand.Parameters.Add("@id", MySqlDbType.VarChar).Value = row.Cells[0].Value.ToString(); status = row.Cells[6].Value.ToString(); if (status == "2") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } if (status == "1") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } if (status == "0") { MessageBox.Show("Этот заказ нельзя оплатить"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } return; } if (scommand.ExecuteNonQuery() == 1) { MessageBox.Show("Оплачено"); if (label5.Visible == false) { label5.Visible = true; } if (label2.Visible == false) { label2.Visible = true; } if (label6.Visible == true) { label6.Visible = false; } if (label8.Visible == true) { label8.Visible = false; } this.label4_Click(sender, e); } else { MessageBox.Show("Ошибка"); } db.closeConnection(); }
private void label4_Click(object sender, EventArgs e) { if (dataGridView2.Visible == true) { dataGridView2.Visible = false; } if (dataGridView1.Visible == false) { dataGridView1.Visible = true; } if (label2.Visible == true) { label2.Visible = false; } if (label5.Visible == false) { label5.Visible = true; } dataGridView1.Rows.Clear(); DB db = new DB(); DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(); MySqlCommand command = new MySqlCommand("SELECT * FROM `zapic` WHERE `idAV`='0' AND `nameAv` = '0' AND `Status` = '1'", db.GetConnection()); adapter.SelectCommand = command; adapter.Fill(table); if (table.Rows.Count == 0) { MessageBox.Show("Заказов нету"); return; } db.openConnection(); MySqlDataReader reader = command.ExecuteReader(); List <string[]> data = new List <string[]>(); while (reader.Read()) { data.Add(new string[9]); data[data.Count - 1][0] = reader[0].ToString(); data[data.Count - 1][1] = reader[1].ToString(); data[data.Count - 1][2] = reader[2].ToString(); data[data.Count - 1][3] = reader[3].ToString(); data[data.Count - 1][4] = reader[4].ToString(); data[data.Count - 1][5] = reader[5].ToString(); data[data.Count - 1][6] = reader[6].ToString(); data[data.Count - 1][7] = reader[7].ToString(); data[data.Count - 1][8] = reader[9].ToString(); } reader.Close(); foreach (string[] s in data) { dataGridView1.Rows.Add(s); } if (table.Rows.Count > 0) { MessageBox.Show("Обновленно"); } else { MessageBox.Show("Заказов нету"); } db.closeConnection(); }