Exemplo n.º 1
0
        private bool ValidateEntry()
        {
            try
            { DateTime dtDate = Convert.ToDateTime(txtDate.Text); }
            catch
            {
                MessageBox.Show("Invalid Date", "Entry");
                return(false);
            }

            if (this._IsAdd)
            {
                Layer.LedgerBL BL = new Layer.LedgerBL();
                BL.Exist(LocalAccess.l_CompanyCode, txtDocu.Text.Trim());
            }

            double nDebit  = 0;
            double nCredit = 0;

            foreach (DataGridViewRow dr in grdDetail.Rows)
            {
                if (dr.IsNewRow)
                {
                    continue;
                }
                string          sAccount = "" + dr.Cells["cAccount"].Value;
                Layer.AccountBL BL       = new Layer.AccountBL();
                if (!BL.Exist(sAccount))
                {
                    MessageBox.Show("Account Code does not exist.", "Entry");
                    return(false);
                }

                try { nDebit += Convert.ToDouble(dr.Cells["cDebit"].Value); }
                catch { }
                try { nCredit += Convert.ToDouble(dr.Cells["cCredit"].Value); }
                catch { }

                //nBalance = Math.Round(nBalance + nDebit - nCredit);
            }
            if (Math.Round(nDebit, 2) != Math.Round(nCredit, 2))
            {
                MessageBox.Show("Ledger Not Balance" + Environment.NewLine + "Debit: " + nDebit.ToString("#,##0.00") + Environment.NewLine + "Credit: " + nCredit.ToString("#,##0.00"), "Entry");
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public frmAccount(Item item)
        {
            InitializeComponent();
            lblTitle.Text   = "Edit Account";
            txtCode.Enabled = false;

            Layer.AccountBL BL = new Layer.AccountBL();
            BL.LoadByPK(item.Value);

            txtCode.Text = BL.AccountCode;
            txtType.Text = BL.AccountType;
            txtName.Text = BL.AccountName;

            this._IsAdd = false;
            btnAdd.Text = "Save";
        }
Exemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (lstAccount.SelectedIndex == -1)
            {
                return;
            }

            Item item = (Item)lstAccount.SelectedItem;

            DialogResult result = MessageBox.Show("Are you sure you want to delete this account :" + Environment.NewLine + item.Text, "Delete Account", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                Layer.AccountBL BL = new Layer.AccountBL();
                BL.AccountCode = item.Value;
                BL.DeleteByPK();
                LoadAccount();
            }
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Layer.AccountBL BL = new Layer.AccountBL();
            BL.AccountCode = txtCode.Text.Trim();
            BL.AccountType = txtType.Text.Trim();
            BL.AccountName = txtName.Text.Trim();

            if (BL.AccountCode == "" || BL.AccountType == "" || BL.AccountName == "")
            {
                MessageBox.Show("Account Code/Type/Name cannot be blank", "Add Account");
                return;
            }
            //if (BL.AccountType == "BS" || BL.AccountType == "PL" || BL.AccountType == "TD" || BL.AccountType == "TC")
            //{}
            //else
            //{
            //    MessageBox.Show("Invalid Account Type", "Add Account");
            //    return;
            //}

            if (this._IsAdd)
            {
                if (BL.Exist())
                {
                    MessageBox.Show("Account Code already exist.", "Add Account");
                    return;
                }
                BL.Insert();
            }
            else
            {
                BL.UpdateByPK();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }