Beispiel #1
0
        public void SaveOrEdit()
        {
            try
            {
                if (txtLedgerName.Text == string.Empty)
                {
                    MessageBox.Show("Enter a ledger name");
                }

                else if (cmbGroup.SelectedIndex == -1)
                {
                    MessageBox.Show("Select an accountGroup");
                }

                else
                {
                    AccountLedgerInfo accountLedgerInfo = new AccountLedgerInfo();
                    AccountLedgerSP   spAccountLedger   = new AccountLedgerSP();
                    accountLedgerInfo.LedgerName     = txtLedgerName.Text.Trim();
                    accountLedgerInfo.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString());
                    accountLedgerInfo.CrOrDr         = cmbOpeningBalanceCrOrDr.Text;
                    accountLedgerInfo.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim());
                    if (chkactive.Checked)
                    {
                        accountLedgerInfo.Active = true;
                    }

                    else
                    {
                        accountLedgerInfo.Active = false;
                    }

                    if (btnSave.Text == "Save")
                    {
                        if (Messages.SaveConfirmation())
                        {
                            spAccountLedger.AccountLedgerAdd(accountLedgerInfo);
                            ClearFunction();
                            Messages.SavedMessage();
                        }
                    }

                    else
                    {
                        if (Messages.UpdateMessage())
                        {
                            accountLedgerInfo.LedgerId = ledgerId;
                            spAccountLedger.AccountLedgerUpdate(accountLedgerInfo);
                            ClearFunction();
                            Messages.UpdatedMessage();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }