KalkulatorISP-31rrrrr/source/repos/WindowsFormsApp19/Form2.cs
2025-11-11 14:18:33 +04:00

52 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace WindowsFormsApp19
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
{
if ((textBox1.Text == "") || (textBox2.Text == "") || (textBox3.Text == "") || (textBox4.Text == "") || (textBox5.Text == ""))
{
MessageBox.Show("Заполните ВСЕ поля");
}
else
{
DataTable data = DbConnection.select(@"INSERT INTO Products (`Name`, `Article`,`Type`, `Min_cost`,`Type_coefficient`) VALUES ('" + textBox1.Text + "', '" + textBox2.Text + "', '" + textBox3.Text + ",'" + textBox4.Text + "','" + textBox5.Text + "');");
data = DbConnection.select(@"SELECT * FROM Products");
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
dataGridView1.DataSource = data;
}
}
}
private void Form2_Load(object sender, EventArgs e)
{
DataTable data = DbConnection.select("SELECT * FROM `Products`");
dataGridView1.DataSource = data;
}
}
}