using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace project
{
public partial class Form1 : Form
{
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter da;
public Form1()
{
InitializeComponent();
this.con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\data.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
this.cmd = new SqlCommand();
this.da = new SqlDataAdapter();
this.cmd.Connection = con;
this.da.SelectCommand = cmd;
}
private void button_New_Click(object sender, EventArgs e)
{
this.con.Open();
this.cmd.CommandText = "insert into table1 (name,family) values ('"+textBox_Name.Text+"','mohammad')";
this.cmd.ExecuteNonQuery();
this.con.Close();
}
private void button_Edit_Click(object sender, EventArgs e)
{
this.con.Open();
this.cmd.CommandText = "update person set pfname=N'" + textBox_Name.Text + "',plname=N'" + textBox_Tell.Text + "',ptell=''"+textBox_Tell.Text+",paddress=N'" + textBox_Address.Text + "' where pid=" + int.Parse(textBox_Id.Text);
this.cmd.ExecuteNonQuery();
this.con.Close();
}
private void button_Delete_Click(object sender, EventArgs e)
{
this.con.Open();
this.cmd.CommandText="Delete from table1 where id=" + int.Parse(textBox_Id.Text);
this.cmd.ExecuteNonQuery();
this.con.Close();
}
private void textBox_Id_TextChanged(object sender, EventArgs e)
{
}
private void button_Exit_Click(object sender, EventArgs e)
{
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}