public void display() { SqlConnection con = Database_Connection.OpenCon(); string query = "select * from operator_info"; SqlCommand cmd = new SqlCommand(query, con); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dataGridView1.DataSource = dt; cmd.ExecuteNonQuery(); Database_Connection.CloseCon(); }
private void buttonsearch_Click(object sender, EventArgs e) { SqlConnection con = Database_Connection.OpenCon(); string query = "select * from operator_info where id='" + bunifuMaterialTextboxid.Text + "'"; SqlCommand cmd = new SqlCommand(query, con); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); dataGridView1.DataSource = dt; cmd.ExecuteNonQuery(); Database_Connection.CloseCon(); }
private void Buttondelete_Click(object sender, EventArgs e) { SqlConnection con = Database_Connection.OpenCon(); string query = "delete from operator_info where id='" + bunifuMaterialTextboxid.Text + "'"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.Add("@id", bunifuMaterialTextboxid.Text); cmd.Parameters.Add("@name", bunifuMaterialTextboxname.Text); cmd.Parameters.Add("@fare", bunifuMaterialTextboxfare.Text); cmd.ExecuteNonQuery(); MessageBox.Show("delete successfully"); display(); Database_Connection.CloseCon(); }
private void Buttoninsert_Click(object sender, EventArgs e) { SqlConnection con = Database_Connection.OpenCon(); string query = "insert into operator_info(id,name,fare) values (@id,@name,@fare)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.Add("@id", bunifuMaterialTextboxid.Text); cmd.Parameters.Add("@name", bunifuMaterialTextboxname.Text); cmd.Parameters.Add("@fare", bunifuMaterialTextboxfare.Text); cmd.ExecuteNonQuery(); MessageBox.Show("insert successfully"); display(); Database_Connection.CloseCon(); }