Exemplo n.º 1
0
        /// <summary>
        /// checking checking existance entries for save or edit function
        /// </summary>
        public void SaveOrEditMessage()
        {
            try
            {
                //create ledger for the tax
                AccountLedgerSP spAccountLedger = new AccountLedgerSP();
                string strTaxNameForLedger = string.Empty;
                strTaxNameForLedger = txtTaxName.Text;

                
                    if (btnSave.Text == "Save")
                    {
                        if (!spAccountLedger.AccountLedgerCheckExistence(strTaxNameForLedger, 0))
                        {
                            if (PublicVariables.isMessageAdd)
                            {
                                if (Messages.SaveMessage())
                                {

                                    SaveFunction();
                                    TaxSelectionGridFill();
                                    TaxSearchGridFill();
                                }
                            }
                            else
                            {
                                SaveFunction();
                                TaxSelectionGridFill();
                                TaxSearchGridFill();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Cannot save. Ledger already exists");
                        }
                    }
                    else
                    {
                        if (!spAccountLedger.AccountLedgerCheckExistence(strTaxNameForLedger, decLedgerId))
                        {
                            if (PublicVariables.isMessageEdit)
                            {
                                if (Messages.UpdateMessage())
                                {
                                    EditFunction();
                                    TaxSelectionGridFill();
                                    TaxSearchGridFill();
                                }
                            }
                            else
                            {
                                EditFunction();
                                TaxSelectionGridFill();
                                TaxSearchGridFill();
                            }
                        }
                        else
                        {
                            Messages.InformationMessage("Cannot save. Ledger already exists");
                        }
                    }
                
            }
            catch (Exception ex)
            {
                MessageBox.Show("TC6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// check if data present in database
        /// </summary>
        /// <returns></returns>
        public bool CheckAlreadyExist()
        {
            bool isOk = true;
            try
            {
                AccountLedgerSP spAccountledger = new AccountLedgerSP();
                int inCompleteRow = 0;
                int inCurrentindex = 0;
                string strMessage = "Row";
                foreach (DataGridViewRow dgvRow in dgvMultipleAccountLedger.Rows)
                {
                    if (dgvRow.Cells["dgvtxtLedgerName"].Value != null)
                    {
                        string LedgerName = dgvRow.Cells["dgvtxtLedgerName"].Value.ToString();
                        if (spAccountledger.AccountLedgerCheckExistence(LedgerName, 0) == true)
                        {
                            isOk = false;
                            if (inCompleteRow == 0)
                            {
                                strMessage = strMessage + Convert.ToString(dgvRow.Index + 1);
                                inCurrentindex = dgvRow.Index;
                                inCompleteRow++;
                            }
                            else
                            {
                                strMessage = strMessage + ", " + Convert.ToString(dgvRow.Index + 1);
                            }
                        }
                    }
                }
                if (!isOk)
                {
                    strMessage = strMessage + " contains already exisitng ledgers. Do you want to continue?";
                    if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                    {
                        isOk = true;
                        for (int inK = 0; inK < dgvMultipleAccountLedger.Rows.Count; inK++)
                        {
                            if (dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value != null)
                            {
                                string strLedgerName = dgvMultipleAccountLedger.Rows[inK].Cells["dgvtxtLedgerName"].Value.ToString().Trim();
                                if (spAccountledger.AccountLedgerCheckExistence(strLedgerName, 0) == true)
                                {
                                    if (!dgvMultipleAccountLedger.Rows[inK].IsNewRow)
                                    {
                                        dgvMultipleAccountLedger.Rows.RemoveAt(inK);
                                        inK--;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"].Selected = true;
                        dgvMultipleAccountLedger.CurrentCell = dgvMultipleAccountLedger.Rows[inCurrentindex].Cells["dgvtxtLedgerName"];
                        dgvMultipleAccountLedger.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MAL5:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }

            return isOk;
        }