83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
using MySql.Data.MySqlClient;
|
|
using NeshinaPolina07_11;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace dem
|
|
{
|
|
public partial class FORM2 : Form
|
|
{
|
|
|
|
public FORM2()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void label1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void FORM2_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var qwe = DB.GetInstance();
|
|
var con = qwe.GetConnection();
|
|
string qwerty = "select * from products";
|
|
using (MySqlCommand cmd = new MySqlCommand(qwerty, con))
|
|
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
|
|
{
|
|
DataTable dt = new DataTable();
|
|
adapter.Fill(dt);
|
|
dataGridView1.DataSource = dt;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
var qwe = DB.GetInstance();
|
|
var con = qwe.GetConnection();
|
|
string qwerty = "select * from orders";
|
|
using (MySqlCommand cmd = new MySqlCommand(qwerty, con))
|
|
using (MySqlDataAdapter adapter = new MySqlDataAdapter(cmd))
|
|
{
|
|
DataTable dt = new DataTable();
|
|
adapter.Fill(dt);
|
|
dataGridView1.DataSource = dt;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("Ошибка загрузки данных: " + ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|