/// <summary>
 /// Function to fill AccountLedger combobox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         DataTable dtbl = new DataTable();
         AccountLedgerSP spaccountledger = new AccountLedgerSP();
         dtbl = spaccountledger.AccountLedgerViewAll();
         DataRow dr = dtbl.NewRow();
         dr[0] = 0;
         dr[2] = "All";
         dtbl.Rows.InsertAt(dr, 0);
         cmbAccountLedger.DataSource = dtbl;
         cmbAccountLedger.ValueMember = "ledgerId";
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.SelectedIndex = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PPREP2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Cell begin edit event of grid, its for removing the item from the list once its added or Selected
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvPaymentVoucher_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     try
     {
         inUpdatingRowIndexForPartyRemove = -1;
         decUpdatingLedgerForPartyremove = 0;
         DataTable dtbl = new DataTable();
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         if (dgvPaymentVoucher.CurrentCell.ColumnIndex == dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index)
         {
             dtbl = spAccountLedger.AccountLedgerViewAll();
             if (dtbl.Rows.Count < 2)
             {
                 DataRow dr = dtbl.NewRow();
                 dr[0] = string.Empty;
                 dr[1] = string.Empty;
                 dtbl.Rows.InsertAt(dr, 0);
             }
             if (dgvPaymentVoucher.RowCount > 1)
             {
                 int inGridRowCount = dgvPaymentVoucher.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 (dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
                             {
                                 if (dtbl.Rows[inJ]["ledgerId"].ToString() == dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value.ToString())
                                 {
                                     dtbl.Rows.RemoveAt(inJ);
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, e.RowIndex];
             DataRow drow = dtbl.NewRow();
             drow["ledgerId"] = "0";
             drow["ledgerName"] = string.Empty;
             dtbl.Rows.InsertAt(drow, 0);
             dgvccCashOrBank.DataSource = dtbl;
             dgvccCashOrBank.ValueMember = "ledgerId";
             dgvccCashOrBank.DisplayMember = "ledgerName";
         }
         if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbAccountLedger")
         {
             if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
             {
                 if (spAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                 {
                     inUpdatingRowIndexForPartyRemove = e.RowIndex;
                     decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                 }
             }
         }
         if (dgvPaymentVoucher.Rows[e.RowIndex].Cells[e.ColumnIndex].OwningColumn.Name == "dgvcmbDrOrCr")
         {
             if (dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value != null && dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString() != string.Empty)
             {
                 if (spAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()))
                 {
                     inUpdatingRowIndexForPartyRemove = e.RowIndex;
                     decUpdatingLedgerForPartyremove = Convert.ToDecimal(dgvPaymentVoucher.Rows[e.RowIndex].Cells["dgvcmbAccountLedger"].Value.ToString());
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PV54:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill BankorCash combobox while return from Ledger creation when creating new ledger 
 /// </summary>
 /// <param name="decId"></param>
 /// <param name="str"></param>
 public void ReturnFromAccountLedgerForm(decimal decId, string str)
 {
     try
     {
         if (str == "CashOrBank")
         {
             if (decId != 0)
             {
                 TransactionsGeneralFill Obj = new TransactionsGeneralFill();
                 Obj.CashOrBankComboFill(cmbBankorCash, false);
                 cmbBankorCash.SelectedValue = decId.ToString();
             }
             cmbBankorCash.Focus();
         }
         else
         {
             if (decId != 0)
             {
                 int inCurrentRowIndex = dgvPaymentVoucher.CurrentRow.Index;
                 if (inCurrentRowIndex == dgvPaymentVoucher.Rows.Count - 1)
                 {
                     dgvPaymentVoucher.Rows.Add();
                 }
                 dgvPaymentVoucher.CurrentRow.HeaderCell.Value = "X";
                 dgvPaymentVoucher.CurrentRow.HeaderCell.Style.ForeColor = Color.Red;
                 DataTable dtbl = new DataTable();
                 AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                 dtbl = spAccountLedger.AccountLedgerViewAll();
                 DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvPaymentVoucher[dgvPaymentVoucher.Columns["dgvcmbAccountLedger"].Index, dgvPaymentVoucher.Rows[inCurrentRowIndex].Index];
                 DataRow dr = dtbl.NewRow();
                 dr["ledgerId"] = "0";
                 dr["ledgerName"] = string.Empty;
                 dtbl.Rows.InsertAt(dr, 0);
                 dgvccCashOrBank.DataSource = dtbl;
                 dgvccCashOrBank.ValueMember = "ledgerId";
                 dgvccCashOrBank.DisplayMember = "ledgerName";
                 dgvPaymentVoucher.Rows[inCurrentRowIndex].Cells["dgvcmbAccountLedger"].Value = decId;
                 dgvPaymentVoucher.Rows[inCurrentRowIndex].Cells["dgvcmbAccountLedger"].Selected = true;
           
                 
             }
         }
         
         this.Enabled = true;
         this.BringToFront();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PV29:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to add the new accountledger from accountLedger form
 /// </summary>
 /// <param name="decLedgerId"></param>
 public void CallFromAccountLedger(decimal decLedgerId)
 {
     try
     {
         if (decLedgerId != 0)
         {
             AccountLedgerSP spAccountLedger = new AccountLedgerSP();
             DataTable dtbl = new DataTable();
             dtbl = spAccountLedger.AccountLedgerViewAll();
             DataGridViewComboBoxCell dgvccAccountLedger = (DataGridViewComboBoxCell)dgvJournalVoucher[dgvJournalVoucher.Columns["dgvcmbAccountLedger"].Index, dgvJournalVoucher.CurrentRow.Index];
             dgvccAccountLedger.DataSource = dtbl;
             dgvccAccountLedger.ValueMember = "ledgerId";
             dgvccAccountLedger.DisplayMember = "ledgerName";
             dgvJournalVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value = decLedgerId;
         }
         dgvJournalVoucher.Focus();
         this.Enabled = true;
         this.BringToFront();
     }
     catch (Exception ex)
     {
         MessageBox.Show("JV30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill AccountLedgers for combobox
 /// </summary>
 /// <returns></returns>
 public DataTable AccountLedgerComboFill()
 {
     DataTable dtbl = new DataTable();
     try
     {
         AccountLedgerSP spaccountledger = new AccountLedgerSP();
         dtbl = spaccountledger.AccountLedgerViewAll();
     }
     catch (Exception ex)
     {
         MessageBox.Show("TGF:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return dtbl;
 }
 /// <summary>
 /// Account Ledger Combofill function
 /// </summary>
 public void cmbAccountNameFill()
 {
     try
     {
         isWorkLedgerIndexChange = false;
         AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
         cmbAccountLedger.DataSource = null;
         DataTable dtblParty = SpAccountLedger.AccountLedgerViewAll();
         cmbAccountLedger.DataSource = dtblParty;
         cmbAccountLedger.DisplayMember = "ledgerName";
         cmbAccountLedger.ValueMember = "ledgerId";
         isWorkLedgerIndexChange = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Beispiel #7
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);
     }
 }
        /// <summary>
        /// Function to fill Account ledger combobox while return from Account ledger creation when creating new ledger 
        /// </summary>
        /// <param name="decId"></param>
        /// <param name="str"></param>
        public void ReturnFromAccountLedgerForm(decimal decId, string str)//From AccountLedger form
        {
            try
            {
                if (str == "CashOrBank")
                {
                    if (decId != 0)
                    {
                        TransactionsGeneralFill Obj = new TransactionsGeneralFill();
                        Obj.CashOrBankComboFill(cmbCashOrBank, false);
                        cmbCashOrBank.SelectedValue = decId.ToString();
                    }
                    cmbCashOrBank.Focus();
                }
                else
                {
                    if (decId != 0)
                    {

                        DataTable dtbl = new DataTable();
                        AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                        dtbl = spAccountLedger.AccountLedgerViewAll();
                        DataGridViewComboBoxCell dgvccCashOrBank = (DataGridViewComboBoxCell)dgvReceiptVoucher[dgvReceiptVoucher.Columns["dgvcmbAccountLedger"].Index, dgvReceiptVoucher.CurrentRow.Index];
                        dgvccCashOrBank.DataSource = dtbl;
                        dgvccCashOrBank.ValueMember = "ledgerId";
                        dgvccCashOrBank.DisplayMember = "ledgerName";
                        dgvReceiptVoucher.CurrentRow.Cells["dgvcmbAccountLedger"].Value = decId;
                    }
                }
                this.Enabled = true;
                this.BringToFront();
            }
            catch (Exception ex)
            {
                MessageBox.Show("RV29:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }