using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp10
{
public partial class Form1 : Form
{
String path = @"Data Source = DESKTOP - 2PC2RB2\SQLEXPRESS; Initial Catalog = edu; Integrated Security = True";
SqlConnection con;
public Form1()
{
InitializeComponent();
con = new SqlConnection(path);
}
private void Form1_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'eduDataSet1.lesson' table. You can move, or remove it, as needed.
this.lessonTableAdapter.Fill(this.eduDataSet1.lesson);
this.reportViewer1.RefreshReport();
this.reportViewer1.RefreshReport();
UpdateData();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd = new SqlCommand("insert into lesson (LID, LName, LCredit, LRel) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3 + "','" + textBox4 + "')", con);
cmd.ExecuteReader();
con.Close();
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
UpdateData();
MessageBox.Show("????????? ?????????");
}
public void UpdateData()
{
}
private void label5_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
try
{
if (textBox5.Text != "")
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from lesson where LID = '" +
textBox5.Text + "'";
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("????????? ??????????.");
}
else
{
MessageBox.Show("?? ?????? ?????? ????? ??????? ??!!!");
}
}
catch (Exception ex)
{
MessageBox.Show("?? ????? ???? ???????? ?????!!!");
}
UpdateData();
}
}
}

Jignesh KumarRank #91 · 22.9K reputationPosted Apr 11, 2021, 12:10 AM EDT
Salman BegRank #284 · 8.8K reputationPosted Apr 11, 2021, 12:01 AM EDT
Madan ShekarRank #428 · 5.9K reputationPosted Aug 7, 2021, 4:38 AM EDT
Priyanka K SRank #1,385 · 1.2K reputationPosted Aug 7, 2021, 4:31 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Aug 7, 2021, 10:58 AM EDT
Ganesan CRank #369 · 6.8K reputationPosted Aug 7, 2021, 1:54 PM EDT