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 WindowsFormsApplication3 { using System.Data.SqlDb; public partial class Form1 : Form { bool newMode; DataSet ds = new DataSet(); string strSql; string strCon; SqlDataAdapter da; SqlConnection con; DataRow newRow; SqlCommandBuilder cb; public Form1() { InitializeComponent(); /* bool newMode; DataSet ds = new DataSet(); string strSql; string strCon; SqlDataAdapter da; SqlConnection con; DataRow newRow; SqlCommandBuilder cb;*/ } private void empty() { TextRecord.Text = ""; textBox1.Text = ""; textBox2.Text = ""; } private void button1_Click(object sender, EventArgs e) { newRow = ds.Tables["SlaghterHouse"].NewRow(); newMode = true; TextRecord.BackColor = Color.Red; TextRecord.Text = "New Record"; MessageBox.Show("Enter new record and Press Save "); } private void button2_Click(object sender, EventArgs e) { int Zarfiyat; int Shomare; SqlCommand cmdClasf; string strSql; this.BindingContext[ds, "SlaghterHouse"].AddNew(); Shomare = Convert.ToInt16(textBox1.Text, 10); Zarfiyat = Convert.ToInt16(textBox2.Text); strSql = "Insert Into SlaghterHouse(" + " ShomareKarton," + "ZarfiyatKarton" + ") VALUES (" + Shomare + "," + Zarfiyat + " )"; con.Open(); cmdClasf.ExecuteNonQuery(); con.Close(); MessageBox.Show("Insert Completed."); ds.Clear(); da.Fill(ds, "SlaghterHouse"); con.Close(); } /* private void textBox3_TextChanged(object sender, EventArgs e) { }*/ // } private void Form1_Load(object sender, EventArgs e) { newMode = false; strCon= "Data Source=%SQLEXPRESS;Initial Catalog=SlaghterHouseted ; Integrated Security:"; strSql = "Select * from SlaghterHouse"; con = new SqlConnection(strCon); con.Open(); da = new SqlDataAdapter(strSql,con); da.Fill(ds,"SlaghterHouse"); textBox2.DataBinding.Add(new Binding("text", ds, "SlaghterHouse.shomareKarton")); textBox3.DataBinding.Add(new Binding("text",ds,"SlaghterHouse.ZarfiyateKarton")); //System.ComponentModel.DesignerAttribute("System.Web.UI.Design.ReadWriteControlDesigner, System.Design") System.Web.UI.ToolboxDataAttribute("<{0}:BranchNotesTableControl runat=server>") con.Close(); } } }