private void btnSave_Click(object sender, EventArgs e) { try { if (screen.Equals(1)) { if (dgvData.Rows.Count <= 0) { return; } if (!Convert.ToString(dgvData.CurrentRow.Cells["ShippingNo"].Value).Equals("")) { SHNo_tt.Text = Convert.ToString(dgvData.CurrentRow.Cells["ShippingNo"].Value); this.Close(); } else { SHNo_tt.Text = Convert.ToString(dgvData.CurrentRow.Cells["ShippingNo"].Value); CodeNo_tt.Text = Convert.ToString(dgvData.CurrentRow.Cells["CodeNo"].Value); this.Close(); } } else { if (dgvData.Rows.Count > 0) { Shipping a = new Shipping(Convert.ToString(dgvData.CurrentRow.Cells["ShippingNo"].Value), Convert.ToString(dgvData.CurrentRow.Cells["CodeNo"].Value)); a.ShowDialog(); } else { Shipping b = new Shipping(); b.ShowDialog(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }