/// <summary> /// function to fill particulars combo /// </summary> public void GroupNameViewForComboFill() { try { List<DataTable> ListObj = new List<DataTable>(); AccountGroupBll bllAccountGroup = new AccountGroupBll(); ListObj = bllAccountGroup.GroupNameViewForComboFill(); dgvcmbParticular.DataSource = ListObj[0]; dgvcmbParticular.ValueMember = "accountGroupId"; dgvcmbParticular.DisplayMember = "accountGroupName"; } catch (Exception ex) { MessageBox.Show("BU3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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; List<DataTable> ListObj = new List<DataTable>(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); if (cmbType.SelectedIndex == 0) { if (dgvBudget.CurrentCell.ColumnIndex == dgvBudget.Columns["dgvcmbParticular"].Index) { ListObj = bllAccountLedger.AccountLedgerViewAll(); DataRow dr = ListObj[0].NewRow(); dr[0] = 0; dr[2] = string.Empty; ListObj[0].Rows.InsertAt(dr, 0); if (ListObj[0].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 = ListObj[0].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 (ListObj[0].Rows[inJ]["ledgerId"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString()) { ListObj[0].Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex]; dgvccVoucherType.DataSource = ListObj[0]; 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) { if (bllAccountLedger.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) { if (bllAccountLedger.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) { AccountGroupBll bllAccountGroup = new AccountGroupBll(); ListObj = bllAccountGroup.GroupNameViewForComboFill(); DataRow dr = ListObj[0].NewRow(); dr[0] = 0; ListObj[0].Rows.InsertAt(dr, 0); if (ListObj[0].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 = ListObj[0].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 (ListObj[0].Rows[inJ]["accountGroupName"].ToString() == dgvBudget.Rows[inI].Cells["dgvcmbParticular"].Value.ToString()) { ListObj[0].Rows.RemoveAt(inJ); break; } } } } } } DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvBudget[dgvBudget.Columns["dgvcmbParticular"].Index, e.RowIndex]; dgvccVoucherType.DataSource = ListObj[0]; 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) { if (bllAccountLedger.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) { if (bllAccountLedger.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); } }