Пример #1
0
 public void Edit(IIncome income)
 {
     if (income.IncomeId <= 0)
     {
         throw new ArgumentException("Income id should be greater than zero");
     }
     _incomeMongoRepository.Update(income);
     _incomeRepository.Update(income);
 }
Пример #2
0
 public void AddIncomeSource(IIncome income)
 {
     //error checking
     if (_income.ContainsKey(income.Name))
     {
         throw new ArgumentException("That income source already exists!");
     }
     _income.Add(income.Name, income);
 }
Пример #3
0
 public mantainModel(IBuyRecords buyRecords, IOutcome outcome, ICash cash, IIncome income, ISellrecord sellrecord, IAfterBuyExpncess afterBuyExpncess, IAfterSellExpncess afterSellExpncess)
 {
     this.buyRecords        = buyRecords;
     this.sellrecord        = sellrecord;
     this.afterBuyExpncess  = afterBuyExpncess;
     this.afterSellExpncess = afterSellExpncess;
     this.income            = income;
     this.cash    = cash;
     this.outcome = outcome;
 }
Пример #4
0
 public IncomeDto(IIncome model) : base(model.Id)
 {
     Date            = model.Date.ToShortDateString();
     Name            = model.Name;
     Notes           = model.Notes;
     Amount          = model.Amount;
     Remaining       = model.Amount - model.Transactions.Select(t => t.Amount).Sum();
     ParentFrequency = model.Parent?.Recurrence;
     ParentId        = model.Parent?.Id;
 }
Пример #5
0
 public SaleModel(ICar car, IManufacture manufacture, Ifile file, ISale sale, ISellrecord sellrecord, IIncome income, ICash cash, ICheck check, ICustomer customer)
 {
     this.car         = car;
     this.manufacture = manufacture;
     _file            = file;
     _sale            = sale;
     this.sellrecord  = sellrecord;
     this.income      = income;
     this.cash        = cash;
     this.check       = check;
     this.customer    = customer;
 }
Пример #6
0
        public int Add(IIncome income)
        {
            int incomeId = 0;

            //for (int i = 0; i < 2000; i++)
            //{
            //    incomeId = _incomeRepository.AddIncome(income);
            //}

            incomeId = _incomeRepository.AddIncome(income);
            if (incomeId >= 1)
            {
                _incomeMongoRepository.Add(income);
                //this.RefreshMongoDB(income.UserId);
            }
            return(incomeId);
        }
 private IncomeJSON Map_IncomeDTO_To_JSON(IIncome i)
 {
     return(new IncomeJSON()
     {
         RowNumber = i.RowNumber,
         IncomeId = i.IncomeId,
         IncomeType = Map_IncomeTypeDTO_To_JSON(i.IncomeType),
         UserId = i.UserId,
         Amount = i.Amount,
         Description = i.Description,
         IncomeDate = i.IncomeDate,
         CreatedBy = i.CreatedBy,
         ModifiedBy = i.ModifiedBy,
         Comments = i.Comments,
         ModifiedDate = i.ModifiedDate
     });
 }
Пример #8
0
        public int AddIncome(IIncome income)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Incomes.INCOME_ADD);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.USERId, income.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMETYPEID, income.IncomeType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.AMOUNT, income.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEDATE, income.IncomeDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.DESCRIPTION, income.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.COMMENTS, income.Comments);
            int incomeTypeId = int.Parse(cmd.ExecuteScalar().ToString());

            conn.Close();
            return(incomeTypeId);
        }
Пример #9
0
        public void Update(IIncome incomeDomain)
        {
            SqlConnection conn = SQLDbConnection.GetNewSqlConnectionObject();

            conn.Open();
            SqlCommand cmd = SQLDbConnection.GetNewSqlCommandObject(conn, Constants.StoredProcedures.Incomes.Income_Update);

            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEID, incomeDomain.IncomeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.USERId, incomeDomain.UserId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMETYPEID, incomeDomain.IncomeType.TypeId);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.INCOMEDATE, incomeDomain.IncomeDate);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.DESCRIPTION, incomeDomain.Description);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.COMMENTS, incomeDomain.Comments);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.AMOUNT, incomeDomain.Amount);
            cmd.Parameters.AddWithValue(Constants.StoredProcedures.Incomes.Parameters.MODIFIEDBY, incomeDomain.UserId);
            cmd.ExecuteNonQuery();
            cmd.Dispose(); //ToDo ==> If this is success ,implement this in all methods...
            conn.Close();
        }
Пример #10
0
        public EditIncomeForm(IIncome income, YearTop year)
        {
            InitializeComponent();

            if (year == null)
            {
                throw new ArgumentException("Year has not been initialized yet.");
            }
            else
            {
                _year = year;
            }

            frequencyCb.Items.AddRange(Enum.GetNames(typeof(IncomeFrequencyEnum)));

            var accountList = _year.GetAccountsNames();

            foreach (var account in accountList)
            {
                accountCb.Items.Add(account);
            }

            if (income != null)
            {
                _income         = income;
                nameTb.Text     = _income.Name;
                nameTb.ReadOnly = true;

                firstDepositDtp.Value   = _income.FirstDeposit;
                firstDepositDtp.Enabled = false;

                //editable fields
                amountTb.Text            = _income.PaydayAmount.ToString();
                frequencyCb.SelectedItem = _income.PaydayFrequency.ToString();
                accountCb.SelectedItem   = _income.DepositAccount.Name;
            }
            else
            {
                _income = null;
                firstDepositDtp.Value = DateTime.Today;
            }
        }
Пример #11
0
        private void saveBtn_Click_1(object sender, EventArgs e)
        {
            NewIncomeAddedEventArgs args = new NewIncomeAddedEventArgs();

            decimal amount;

            if (!decimal.TryParse(amountTb.Text, out amount))
            {
                amountTb.Text = 0.ToString();
                MessageBox.Show("Invalid amount!");
                return;
            }

            string   name         = nameTb.Text;
            DateTime firstDeposit = firstDepositDtp.Value.Date;

            IncomeFrequencyEnum frequency;

            Enum.TryParse(frequencyCb.SelectedItem.ToString(), out frequency);

            string accountName = accountCb.Text;

            if (_income == null)
            {
                _income        = new Income(name, amount, frequency, _year.GetAccount(accountName), firstDeposit);
                args.NewIncome = _income;
            }
            else
            {
                _income.DepositAccount  = _year.GetAccount(accountName);
                _income.PaydayAmount    = amount;
                _income.PaydayFrequency = frequency;

                args.NewIncome = null;
            }

            OnNewIncomeAdded(args);

            this.Close();
        }
Пример #12
0
 public static void RemoveIncome(IIncome income)
 {
     Budget.incomes.Remove(income);
 }
Пример #13
0
 public static void AddIncome(IIncome income)
 {
     Budget.incomes.Add(income);
 }