Esempio n. 1
0
 /// <summary>
 /// datagridview cell beginend edit
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvBudget_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     try
     {
         inUpdatingRowIndexForPartyRemove = -1;
         decUpdatingLedgerForPartyremove = 0;
         DataTable dtbl = new DataTable();
         AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
         if (cmbType.SelectedIndex == 0)
         {
             if (dgvBudget.CurrentCell.ColumnIndex == dgvBudget.Columns["dgvcmbParticular"].Index)
             {
                 dtbl = SpAccountLedger.AccountLedgerViewAll();
                 DataRow dr = dtbl.NewRow();
                 dr[0] = 0;
                 dr[2] = string.Empty;
                 dtbl.Rows.InsertAt(dr, 0);
                 if (dtbl.Rows.Count > 0)
                 {
                     if (dgvBudget.RowCount > 1)
                     {
                         int inGridRowCount = dgvBudget.RowCount;
                         for (int inI = 0; inI < inGridRowCount - 1; inI++)
                         {
                             if (inI != e.RowIndex)
                             {
                                 int inTableRowcount = dtbl.Rows.Count;
                                 for (int inJ = 0; inJ < inTableRowcount; inJ++)
                                 {
                                     if (dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                                     {
                                         if (dtbl.Rows[inJ]["ledgerId"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString())
                                         {
                                             dtbl.Rows.RemoveAt(inJ);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex];
                     dgvccVoucherType.DataSource = dtbl;
                     dgvccVoucherType.ValueMember = "ledgerId";
                     dgvccVoucherType.DisplayMember = "ledgerName";
                 }
             }
             if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbParticular")
             {
                 if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                 {
                     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                     if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString()))
                     {
                         inUpdatingRowIndexForPartyRemove = e.RowIndex;
                         decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString());
                     }
                 }
             }
             if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
             {
                 if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                 {
                     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                     if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString()))
                     {
                         inUpdatingRowIndexForPartyRemove = e.RowIndex;
                         decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString());
                     }
                 }
             }
         }
         else
         {
             if (dgvBudget.CurrentCell.ColumnIndex == dgvBudget.Columns["dgvcmbParticular"].Index)
             {
                 AccountGroupSP spAccountGroup = new AccountGroupSP();
                 dtbl = spAccountGroup.GroupNameViewForComboFill();
                 DataRow dr = dtbl.NewRow();
                 dr[0] = 0;
                 dtbl.Rows.InsertAt(dr, 0);
                 if (dtbl.Rows.Count > 0)
                 {
                     if (dgvBudget.RowCount > 1)
                     {
                         int inGridRowCount = dgvBudget.RowCount;
                         for (int inI = 0; inI < inGridRowCount - 1; inI++)
                         {
                             if (inI != e.RowIndex)
                             {
                                 int inTableRowcount = dtbl.Rows.Count;
                                 for (int inJ = 0; inJ < inTableRowcount; inJ++)
                                 {
                                     if (dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                                     {
                                         if (dtbl.Rows[inJ]["accountGroupName"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString())
                                         {
                                             dtbl.Rows.RemoveAt(inJ);
                                             break;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                     DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex];
                     dgvccVoucherType.DataSource = dtbl;
                     dgvccVoucherType.ValueMember = "accountGroupId";
                     dgvccVoucherType.DisplayMember = "accountGroupName";
                 }
             }
             if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbParticular")
             {
                 if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                 {
                     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                     if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString()))
                     {
                         inUpdatingRowIndexForPartyRemove = e.RowIndex;
                         decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString());
                     }
                 }
             }
             if (dgvBudget.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
             {
                 if (dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value != null && dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString() != string.Empty)
                 {
                     AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                     if (spAccountLedger.AccountGroupIdCheck(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].FormattedValue.ToString()))
                     {
                         inUpdatingRowIndexForPartyRemove = e.RowIndex;
                         decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvBudget.Rows[e.RowIndex].Cells["dgvcmbParticular"].Value.ToString());
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("BU37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// function to fill particulars combo
 /// </summary>
 public void GroupNameViewForComboFill()
 {
     try
     {
         DataTable dtbl = new DataTable();
         AccountGroupSP spAccountGroup = new AccountGroupSP();
         dtbl = spAccountGroup.GroupNameViewForComboFill();
         dgvcmbParticular.DataSource = dtbl;
         dgvcmbParticular.ValueMember = "accountGroupId";
         dgvcmbParticular.DisplayMember = "accountGroupName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("BU3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }