private void Delete_button_Click(object sender, EventArgs e) { BranchID_Label.Show(); SqlConnection con = new SqlConnection(conStr); SqlCommand cmd = new SqlCommand("BranchMaster_Delete", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BrachID", BranchID_Label.Text); cmd.Parameters.AddWithValue("@branchname", Branchname_txtbox.Text); cmd.Parameters.AddWithValue("@location", Location_txtbox.Text); cmd.Parameters.AddWithValue("@kgstno", kgst_txtbox.Text); cmd.Parameters.AddWithValue("@phoneno", PhoneNo_txtbox.Text); con.Open(); int i = cmd.ExecuteNonQuery(); if (i != 0) { MessageBox.Show("Data Deleted"); DisplayData(); BranchID_Label.Hide(); ClearTextBoxes(); } }
private void Branchmaster_datagrid_CellClick(object sender, DataGridViewCellEventArgs e) { BranchID_Label.Show(); if (e.RowIndex >= 0) { DataGridViewRow row = this.Branchmaster_datagrid.Rows[e.RowIndex]; Branchname_txtbox.Text = row.Cells["BrannchName"].Value.ToString(); Location_txtbox.Text = row.Cells["Location"].Value.ToString(); kgst_txtbox.Text = row.Cells["Kgst.No"].Value.ToString(); PhoneNo_txtbox.Text = row.Cells["PhoneNo"].Value.ToString(); BranchID_Label.Text = row.Cells["BranchId"].Value.ToString(); } }