Esempio n. 1
0
        public void AddAccount(string account, string name)
        {
            if (_code_account.ContainsKey(account))
            {
                _code_account[account].Name = name;
            }
            else
            {
                _code_account.Add(account, new Account()
                {
                    AccountType   = AccountTypes.Real,
                    Code          = account,
                    Name          = name,
                    CommPerc      = 0,
                    IsShortEnable = false
                });
            }

            var db_acc = _da.GetAccounts().FirstOrDefault(r => r.Code == account);

            if (db_acc == null)
            {
                _da.InsertAccount(_code_account[account]);
            }
            else if (db_acc.Name != name)
            {
                db_acc.Name = name;
                _da.UpdateAccount(db_acc);
            }
        }