예제 #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ControlAccount controlAccount = (ControlAccount)tvControlAccount.SelectedNode.Tag;

            AccountService.DeleteControlAccount(controlAccount.ControlAccountRefId);
            RemoveNodeFromUI(tvControlAccount.SelectedNode);
        }
예제 #2
0
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            List <ControlAccount> _listControlAccount = new List <ControlAccount>();

            foreach (var _item in dgControlAccount.Items)
            {
                ControlAccount item = _item as ControlAccount;
                if (item != null && item.IsSelected == true)
                {
                    if (!IsValidControlAccount(item))
                    {
                        return;
                    }

                    item.CompanyId   = SharedState.CompanyId;
                    item.EntryBy     = SharedState.UserId;
                    item.DateOfEntry = DateTime.Now.Date;

                    _listControlAccount.Add(item);
                }
            }

            if (_listControlAccount.Count > 0)
            {
                ONSResult _ONSResult = _Setup_Save_BLL.SaveControlAccounts(_listControlAccount);
                MessageBox.Show(_ONSResult.Message, "Save", MessageBoxButton.OK, MessageBoxImage.Warning);
                LoadControlAccount();
            }
        }
예제 #3
0
 private void tvControlAccount_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (e.Node != null)
     {
         ControlAccount controlAccount = (ControlAccount)tvControlAccount.SelectedNode.Tag;
         LoadAccounts(controlAccount.ControlAccountRefId);
     }
 }
예제 #4
0
        public ONSResult UpdateControlAccount(ControlAccount parameter)
        {
            ONSResult _ONSResultInsert = new ONSResult();

            try
            {
                List <ControlAccount> list = new List <ControlAccount>();
                var query = from a in _dataContext.ControlAccounts
                            where a.ControlId == parameter.ControlId
                            select a;
                list = query.ToList <ControlAccount>();

                if (list.Count == 1)
                {
                    ControlAccount obj = list[0];
                    if (!String.IsNullOrEmpty(parameter.ControlId))
                    {
                        obj.ControlId = parameter.ControlId;
                    }
                    if (!String.IsNullOrEmpty(parameter.GroupId))
                    {
                        obj.GroupId = parameter.GroupId;
                    }
                    if (!String.IsNullOrEmpty(parameter.Name))
                    {
                        obj.Name = parameter.Name;
                    }
                    if (!String.IsNullOrEmpty(parameter.CompanyId))
                    {
                        obj.CompanyId = parameter.CompanyId;
                    }
                    if (parameter.DateOfEntry.HasValue)
                    {
                        obj.DateOfEntry = parameter.DateOfEntry.Value;
                    }
                    if (!String.IsNullOrEmpty(parameter.EntryBy))
                    {
                        obj.EntryBy = parameter.EntryBy;
                    }
                    if (!String.IsNullOrEmpty(parameter.Remarks))
                    {
                        obj.Remarks = parameter.Remarks;
                    }
                    _dataContext.SubmitChanges();
                }
                _ONSResultInsert.IsSuccess = true;
                _ONSResultInsert.Message   = "Control Account updated successfully.";
            }
            catch (Exception ex)
            {
                _ONSResultInsert.IsSuccess = false;
                _ONSResultInsert.Message   = ex.Message;
                _ErrorHandler.ONSERRORProcessing(ex);
            }

            return(_ONSResultInsert);
        }
예제 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            ControlAccount controlAccount = (ControlAccount)tvControlAccount.SelectedNode.Tag;
            frmAddAccount  frmAddAccount  = new frmAddAccount(controlAccount.ControlAccountRefId);

            if (frmAddAccount.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                AccountService.CreateAccount(frmAddAccount.Account);
            }
        }
예제 #6
0
        private void newChildAccountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ControlAccount       controlAccount       = (ControlAccount)tvControlAccount.SelectedNode.Tag;
            frmAddControlAccount frmAddControlAccount = new frmAddControlAccount(controlAccount.ControlAccountRefId);

            if (frmAddControlAccount.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                AccountService.InsertControlAccount(frmAddControlAccount.ControlAccount);
                this.AddNodeToUI(tvControlAccount.SelectedNode, frmAddControlAccount.ControlAccount);
            }
        }
예제 #7
0
 public Boolean InsertControlAccount(ControlAccount controlAccount)
 {
     try
     {
         ControlAccountRepository.Add(controlAccount);
         return(ControlAccountRepository.Save());
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #8
0
 public Boolean DeleteControlAccount(Guid controlAccountRefId)
 {
     try
     {
         ControlAccount controlaccount = this.ControlAccountRepository.FindBy(ca => ca.ControlAccountRefId.Equals(controlAccountRefId)).FirstOrDefault();
         this.ControlAccountRepository.Delete(controlaccount);
         return(this.AccountRepository.Save());
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
예제 #9
0
        private void ClearAll_Click(object sender, RoutedEventArgs e)
        {
            List <ControlAccount> _listControlAccount = new List <ControlAccount>();

            foreach (var item in dgControlAccount.Items)
            {
                ControlAccount _ControlAccount = item as ControlAccount;
                _ControlAccount.IsSelected = false;
                _listControlAccount.Add(_ControlAccount);
            }
            dgControlAccount.ItemsSource = null;
            dgControlAccount.ItemsSource = _listControlAccount;
        }
예제 #10
0
        private void FillSubControlAccounts(TreeNode parentNode)
        {
            ControlAccount        controlAccount = (ControlAccount)parentNode.Tag;
            List <ControlAccount> toplevelCA     = ControlsAccounts.Where(ca => ca.ParentControlAccountRefId.Equals(controlAccount.ControlAccountRefId)).ToList();

            foreach (ControlAccount ca in toplevelCA)
            {
                TreeNode tnode = new TreeNode(ca.ControlAccountNumber + "- " + ca.ControlAccountName);
                tnode.Tag = ca;
                parentNode.Nodes.Add(tnode);
                FillSubControlAccounts(tnode);
            }
        }
예제 #11
0
        private void AddNodeToUI(TreeNode node, ControlAccount controlAccount)
        {
            TreeNode treeNode = new TreeNode(controlAccount.ControlAccountName);

            treeNode.Tag = controlAccount;
            if (node == null)
            {
                tvControlAccount.Nodes.Add(treeNode);
            }
            else
            {
                node.Nodes.Add(treeNode);
            }
        }
예제 #12
0
        /// <summary>
        /// Selects the control accounts.
        /// </summary>
        /// <param name="_ControlAccount">The _ control account.</param>
        /// <returns></returns>
        public List <ControlAccount> SelectControlAccounts(ControlAccount _ControlAccount)
        {
            List <ControlAccount> listControlAccountSelect = new List <ControlAccount>();

            try
            {
                listControlAccountSelect = ApplicationState.DAClient.SelectControlAccount(_ControlAccount);
            }
            catch (Exception ex)
            {
                ErrorHandler _ErrorHandler = new ErrorHandler();
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(listControlAccountSelect);
        }
예제 #13
0
        private void InsertControlAccounts()
        {
            List <TempControlAccount> toplevelCA = this.tempcas.Where(ca => ca.ControlAccountParentRefId.Equals(null)).ToList();

            foreach (TempControlAccount ca in toplevelCA)
            {
                ControlAccount controlAccount = new ControlAccount();
                controlAccount.ControlAccountRefId       = Guid.NewGuid();
                controlAccount.ControlAccountName        = ca.ControlAccountName;
                controlAccount.ControlAccountNumber      = ca.ControlAccountNbr;
                controlAccount.ParentControlAccountRefId = null;
                AccountService.InsertControlAccount(controlAccount);
                InsertSubControlAccounts(ca, controlAccount);
            }
        }
예제 #14
0
        private bool IsValidControlAccount(ControlAccount item)
        {
            bool IsValid = true;

            if (String.IsNullOrEmpty(item.Name))
            {
                MessageBox.Show("Invalid control account selected.", "Checking", MessageBoxButton.OK, MessageBoxImage.Warning);
                IsValid = false;
            }

            if (String.IsNullOrEmpty(item.GroupId))
            {
                MessageBox.Show("Invalid group account selected.", "Checking", MessageBoxButton.OK, MessageBoxImage.Warning);
                IsValid = false;
            }

            return(IsValid);
        }
예제 #15
0
        /// <summary>
        /// Updates the control accounts.
        /// </summary>
        /// <param name="_ControlAccount">The _ control account.</param>
        /// <returns></returns>
        public ONSResult UpdateControlAccounts(ControlAccount _ControlAccount)
        {
            ONSResult _ONSResultSave = new ONSResult();

            try
            {
                using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, DBHelper.TransactionOptions))
                {
                    _ONSResultSave = ApplicationState.DAClient.UpdateControlAccount(_ControlAccount);
                    transaction.Complete();
                }
            }
            catch (Exception ex)
            {
                ErrorHandler _ErrorHandler = new ErrorHandler();
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(_ONSResultSave);
        }
예제 #16
0
        public ONSResult InsertControlAccount(ControlAccount parameter)
        {
            ONSResult _ONSResultInsert = new ONSResult();

            try
            {
                _dataContext.ControlAccounts.InsertOnSubmit(parameter);
                _dataContext.SubmitChanges();

                _ONSResultInsert.ID        = parameter.ControlId;
                _ONSResultInsert.IsSuccess = true;
                _ONSResultInsert.Message   = "Control Account inserted successfully.";
            }
            catch (Exception ex)
            {
                _ONSResultInsert.IsSuccess = false;
                _ONSResultInsert.Message   = ex.Message;
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(_ONSResultInsert);
        }
예제 #17
0
        public Guid?CreateAccount(String AccountName, Guid ControlAccountRefId)
        {
            try
            {
                ControlAccount controlAccount = this.GetControlAccount(ControlAccountRefId);

                Account account = new Account();
                account.AccountRefId        = Guid.NewGuid();
                account.AccountName         = AccountName;
                account.ControlAccountRefId = ControlAccountRefId;

                string maxAccountNumber = GetMaxAccountNumber(ControlAccountRefId);

                if (maxAccountNumber == null)
                {
                    account.AccountNumber = controlAccount.ControlAccountNumber + "0001";
                }
                else
                {
                    account.AccountNumber = (int.Parse(GetMaxAccountNumber(ControlAccountRefId)) + 1).ToString();
                }


                AccountRepository.Add(account);
                if (AccountRepository.Save())
                {
                    return(account.AccountRefId);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
예제 #18
0
        public List <ControlAccount> SelectControlAccount(ControlAccount parameter)
        {
            List <ControlAccount> list = new List <ControlAccount>();

            try
            {
                var query = from a in _dataContext.ControlAccounts
                            .WhereIf(!String.IsNullOrEmpty(parameter.ControlId), q => q.ControlId == parameter.ControlId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.GroupId), q => q.GroupId == parameter.GroupId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.Name), q => q.Name == parameter.Name)
                            .WhereIf(parameter.DateOfEntry.HasValue, q => q.DateOfEntry.Value.Date == parameter.DateOfEntry.Value.Date)
                            .WhereIf(!String.IsNullOrEmpty(parameter.EntryBy), q => q.EntryBy == parameter.EntryBy)
                            .WhereIf(!String.IsNullOrEmpty(parameter.CompanyId), q => q.CompanyId == parameter.CompanyId)
                            .WhereIf(!String.IsNullOrEmpty(parameter.Remarks), q => q.CompanyId == parameter.Remarks)
                            orderby a.Name ascending
                            select a;
                list = query.ToList <ControlAccount>();
            }
            catch (SqlException ex)
            {
                _ErrorHandler.ONSERRORProcessing(ex);
            }
            return(list);
        }
예제 #19
0
 public UserControlAccount()
 {
     InitializeComponent();
     control = new ControlAccount();
 }