private void OpenCustomerLedgerddUpdateForm(bool isEdit)
        {
            try
            {
                frmCustomerLedgerMasterAddUpdate form = new frmCustomerLedgerMasterAddUpdate(isEdit);
                form.IsInChildMode = true;
                ExtensionMethods.AddChildFormToPanel(this, form, ExtensionMethods.MainPanel);
                form.WindowState = FormWindowState.Maximized;

                if (isEdit && dgvCustomerLedger.SelectedRows[0] != null)
                {
                    CustomerLedgerMaster existingItem = (CustomerLedgerMaster)dgvCustomerLedger.SelectedRows[0].DataBoundItem;
                    form.frmCustomerLedgerMasterAddUpdate_Fill_UsingExistingItem(existingItem);
                    form.LoadCustomerCompanyDiscountGrid();
                }
                form.FormClosed += Form_FormClosed;
                form.Show();

                if (!isEdit)
                {
                    CustomerLedgerMaster nextCust = new CustomerLedgerMaster()
                    {
                        CustomerLedgerName = txtSearch.Text
                    };
                    form.ConfigureCustomerLedger(nextCust);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvCustomerLedger.SelectedRows.Count == 0)
                {
                    MessageBox.Show("Please select atleast one row to edit");
                }

                if (dgvCustomerLedger.SelectedRows[0] != null)
                {
                    frmCustomerLedgerMasterAddUpdate form = new frmCustomerLedgerMasterAddUpdate(true);
                    form.IsInChildMode = true;
                    ExtensionMethods.AddChildFormToPanel(this, form, ExtensionMethods.MainPanel);
                    form.WindowState = FormWindowState.Maximized;

                    CustomerLedgerMaster existingItem = (CustomerLedgerMaster)dgvCustomerLedger.SelectedRows[0].DataBoundItem;
                    form.frmCustomerLedgerMasterAddUpdate_Fill_UsingExistingItem(existingItem);
                    form.LoadCustomerCompanyDiscountGrid();

                    form.FormClosed += Form_FormClosed;
                    form.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void dgvCustomerLedger_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex != -1)
         {
             frmCustomerLedgerMasterAddUpdate form = new frmCustomerLedgerMasterAddUpdate(true);
             form.IsInChildMode = true;
             ExtensionMethods.AddChildFormToPanel(this, form, ExtensionMethods.MainPanel);
             CustomerLedgerMaster existingItem = (CustomerLedgerMaster)dgvCustomerLedger.CurrentRow.DataBoundItem;
             form.frmCustomerLedgerMasterAddUpdate_Fill_UsingExistingItem(existingItem);
             form.LoadCustomerCompanyDiscountGrid();
             form.FormClosed += Form_FormClosed;
             form.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }