private void usr_grd_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == usr_grd.Columns["editBtn"].Index && e.RowIndex >= 0) { //MessageBox.Show("Edit ID : "+usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString());LedgerId sup_id = Convert.ToInt32(usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString()); LedgerId = Convert.ToInt32(usr_grd.Rows[e.RowIndex].Cells["colLEDGERID"].Value.ToString()); Edit_supplier edt = new Edit_supplier(); edt.ShowDialog(); bind_data(); } if (e.ColumnIndex == usr_grd.Columns["btnDelete"].Index && e.RowIndex >= 0) { // MessageBox.Show("Deleted ID : "+usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString()); sup_id = Convert.ToInt32(usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString()); LedgerId = Convert.ToInt32(usr_grd.Rows[e.RowIndex].Cells["colLEDGERID"].Value.ToString()); DialogResult dialogResult = MessageBox.Show("Sure, You want to delete Customer", "Delete Customer", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { try { impfunc._Command = new SqlCommand(); impfunc._Command.Connection = impfunc.cnn; impfunc.cnn.Open(); impfunc._TR = impfunc.cnn.BeginTransaction(IsolationLevel.ReadCommitted); impfunc._Command.Transaction = impfunc._TR; impfunc.DELETE_RECORDS(impfunc.cnn, "SUPPLIER_MASTER", impfunc._TR, "ID", sup_id); impfunc.DELETE_RECORDS(impfunc.cnn, "LEDGER", impfunc._TR, "LedgerId", LedgerId); impfunc.DELETE_RECORDS(impfunc.cnn, "JOURNAL", impfunc._TR, "LedgerId", LedgerId); impfunc._TR.Commit(); impfunc.cnn.Close(); bind_data(); } catch (Exception ex) { impfunc._TR.Rollback(); impfunc.cnn.Close(); MessageBox.Show(("ERROR: " + (ex.Message + ("\r\n" + "PLEASE CONTACT Mr. Amit Tiwari")))); } finally { impfunc.cnn.Close(); } } else if (dialogResult == DialogResult.No) { return; } } if (e.ColumnIndex == usr_grd.Columns["btnAccount"].Index && e.RowIndex >= 0) { // MessageBox.Show("Deleted ID : "+usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString()); sup_id = Convert.ToInt32(usr_grd.Rows[e.RowIndex].Cells["ID"].Value.ToString()); view_supplier edt = new view_supplier(); edt.ShowDialog(); bind_data(); } }
private void srch_btn_Click(object sender, EventArgs e) { this.Close(); Edit_supplier edt = new Edit_supplier(); edt.ShowDialog(); }