コード例 #1
0
 private void ValidateExpenditure(Expenditure model)
 {
     if (model.SốTiền <= 0)
     {
         ModelState.AddModelError("Sốtiền", "Số tiền quá ít!");
     }
 }
コード例 #2
0
        public async Task <ExpenditureResponseModel> UpdateExpenditure(ExpenditureUpdateRequestModel expenditureUpdateRequestModel)
        {
            var updateExpenditure = new Expenditure
            {
                Id          = expenditureUpdateRequestModel.Id,
                UserId      = expenditureUpdateRequestModel.UserId,
                Amount      = expenditureUpdateRequestModel.Amount,
                Description = expenditureUpdateRequestModel.Description,
                ExpDate     = expenditureUpdateRequestModel.ExpDate,
                Remarks     = expenditureUpdateRequestModel.Remarks
            };

            var updatedExpenditure = await _expenditureRepository.UpdateAsync(updateExpenditure);

            var updatedExpenditureResponseModel = new ExpenditureResponseModel
            {
                Id          = updatedExpenditure.Id,
                UserId      = updatedExpenditure.UserId,
                Amount      = updatedExpenditure.Amount,
                Description = updatedExpenditure.Description,
                ExpDate     = updatedExpenditure.ExpDate,
                Remarks     = updatedExpenditure.Remarks
            };

            return(updatedExpenditureResponseModel);
        }
コード例 #3
0
        public async Task <ExpenditureResponseModel> CreateExpenditure(ExpenditureRequestModel expenditureRequestModel)
        {
            var expenditure = new Expenditure
            {
                UserId      = expenditureRequestModel.UserId,
                Amount      = expenditureRequestModel.Amount,
                Description = expenditureRequestModel.Description,
                ExpDate     = expenditureRequestModel.ExpDate,
                Remarks     = expenditureRequestModel.Remarks
            };

            var createdExpenditure = await _expenditureRepository.AddAsync(expenditure);

            var createdExpenditureResponseModel = new ExpenditureResponseModel
            {
                Id          = createdExpenditure.Id,
                UserId      = createdExpenditure.UserId,
                Amount      = createdExpenditure.Amount,
                Description = createdExpenditure.Description,
                ExpDate     = createdExpenditure.ExpDate,
                Remarks     = createdExpenditure.Remarks
            };

            return(createdExpenditureResponseModel);
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("id,material_count_price,carriage_count_price")] Expenditure expenditure)
        {
            if (id != expenditure.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    expenditure.create_time = DateTime.Now.ToString("yyyy.MM.dd HH:mm:ss");
                    _context.Update(expenditure);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpenditureExists(expenditure.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(expenditure));
        }
コード例 #5
0
ファイル: ExpenditureService.cs プロジェクト: ken3d06/PFM
 private void SaveExpenditure(Expenditure expenditure)
 {
     ValidationContract.Required <ArgumentNullException>(expenditure != null, "Expenditure can never be null");
     ValidationContract.Required <ArgumentException>(expenditure != null && expenditure.CategoryId > 0, "At least one Category must be selected");
     ValidationContract.Required <ArgumentException>(expenditure != null && expenditure.PayMethodId > 0, "At least one payment method must be selected");
     _expenditureRepository.SaveExpenditure(expenditure);
 }
コード例 #6
0
        private void ExpenditureChartRefreshButton_Click(object sender, EventArgs e)
        {
            expendData.Clear(); // clears the dictionary

            foreach (var series in ExpenditureChart.Series)
            {
                series.Points.Clear(); // removes each point in series
            }

            DBC.getConnVar("NEAdb.db");
            using (SQLiteConnection con = new SQLiteConnection(DBC.connectionString))
            {
                con.Open(); // open database
                // select values from Date and Amount Spent columns in Expenditure table
                SQLiteCommand    cmdE     = new SQLiteCommand(@"SELECT Date, AmountSpentin£ FROM Expenditure", con);
                SQLiteDataReader SQLreadE = cmdE.ExecuteReader();
                Expenditure      Edata    = new Expenditure(); // new object using Expenditure class

                while (SQLreadE.Read())
                {
                    Edata.Date        = Convert.ToString(SQLreadE["Date"]);          // store Date values in variable
                    Edata.AmountSpent = Convert.ToInt32(SQLreadE["AmountSpentin£"]); // store Amount Spent values in variable
                    expendData.Add(Edata.Date, Edata.AmountSpent);                   // adds values to dictionary
                }
                ;

                foreach (KeyValuePair <string, float> ED in expendData)
                {   // ...add them as point in the chart
                    ExpenditureChart.Series["AmountSpent"].Points.AddXY(ED.Key, ED.Value);
                }

                con.Close(); // close database
            }
        }
コード例 #7
0
        public ViewResult EditExpenditure(int expenditureId)
        {
            Expenditure expenditure = repositoryExpenditure.Expenditures.FirstOrDefault
                                          (p => p.ExpenditureId == expenditureId);

            return(View(expenditure));
        }
コード例 #8
0
 private void ValidateExpenditure(Expenditure model)
 {
     if (model.Amount <= 0)
     {
         ModelState.AddModelError("Amount", "Số tiền quá ít!");
     }
 }
コード例 #9
0
        public void Calculator_Balance_Returns_Proper_Value()
        {
            #region setup
            Expenditure expenditure1 = new Expenditure();
            expenditure1.AmountMain      = 50;
            expenditure1.AmountSecondary = 0;

            Income income1 = new Income();
            income1.AmountMain      = 44;
            income1.AmountSecondary = 50;

            List <Expenditure> expenditures = new List <Expenditure>();
            expenditures.Add(expenditure1);

            List <Income> incomes = new List <Income>();
            incomes.Add(income1);

            FamilyMember familyMember = new FamilyMember();
            familyMember.Expenditures = expenditures;
            familyMember.Incomes      = incomes;
            Calculator calculator = new Calculator(familyMember);
            #endregion

            double expected = -5.50;
            double actual   = calculator.Balance();

            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool isNew = false;
                if (!IsValid())
                {
                    return;
                }
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    if (_Expenditure.ExpenditureID <= 0)
                    {
                        RefreshObject();
                        _Expenditure.ExpenditureID = db.Expenditures.Count() > 0? db.Expenditures.Max(obj => obj.ExpenditureID) + 1:1;
                        db.Expenditures.Add(_Expenditure);
                        isNew = true;
                    }
                    else
                    {
                        _Expenditure = db.Expenditures.FirstOrDefault(obj => obj.ExpenditureID == _Expenditure.ExpenditureID);
                        RefreshObject();
                    }

                    db.SaveChanges();

                    MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (!isNew)
                    {
                        if (ItemChanged != null)
                        {
                            ItemChanged();
                        }
                        this.Close();
                    }
                    else
                    {
                        if (ItemChanged != null)
                        {
                            ItemChanged();
                        }
                        _Expenditure = new Expenditure();
                        RefreshValue();
                        txtVoucherNo.Text = GenerateVoucher();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #11
0
        public Expenditure SearchPr(int id)
        {
            //query for select command
            Expenditure   ex  = new Expenditure();
            SqlConnection con = new SqlConnection(connection);

            con.Open();
            string        selectQuery = "Select * from tbl_Expenditure where exp_id = '" + id + "'";
            SqlCommand    command     = new SqlCommand(selectQuery, con);
            SqlDataReader reader      = command.ExecuteReader();

            while (reader.Read())
            {
                ex.exp_id          = Convert.ToInt32(reader["Exp_ID"].ToString());
                ex.emp_id          = Convert.ToInt32(reader["Emp_id"].ToString());
                ex.exp_purpose     = reader["Purpose"].ToString();
                ex.exp_for         = reader["Exp_for"].ToString();
                ex.exp_description = reader["Exp_Description"].ToString();
                ex.exp_amount      = Convert.ToDecimal(reader["Exp_amount"].ToString());
                ex.created_date    = Convert.ToDateTime(reader["created_date"].ToString());
                ex.created_by      = reader["created_by"].ToString();
            }
            con.Close();
            return(ex);
        }
コード例 #12
0
        // POST: api/ExpenditureProducts
        public int Post(Expenditure expenditure)

        {
            Expenditure e = new Expenditure();

            return(e.insert(expenditure));
        }
コード例 #13
0
ファイル: Loader.cs プロジェクト: rutkowskii/learn-xamarin
        private IEnumerable <Expenditure> ParseFile(string path)
        {
            DateTime?lastDate = null;

            foreach (var line in System.IO.File.ReadAllLines(path))
            {
                var splitProds = line.Split(',');

                var dt = splitProds[0] != string.Empty
                    ? DateTime.ParseExact(splitProds[0], "dd.MM.yyyy", CultureInfo.InvariantCulture)
                    : lastDate.Value;

                lastDate = dt;

                var sum      = decimal.Parse(splitProds[1]);
                var category = splitProds[2];

                AddCategoryIfNeeded(category);

                var exp = new Expenditure
                {
                    CategoryId = _categoriesByName[category].Id,
                    Id         = Guid.NewGuid(),
                    Sum        = sum,
                    Timestamp  = dt
                };
                yield return(exp);
            }
        }
コード例 #14
0
 public PieChartViewModel()
 {
     this.Expenditure = new List <CompanyExpense>();
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Seeds", Amount = 20d, Amount1 = 40d, Amount2 = 60d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Fertilizers ", Amount = 23d, Amount1 = 46d, Amount2 = 69d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Insurance", Amount = 12d, Amount1 = 24d, Amount2 = 36d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Labor", Amount = 25d, Amount1 = 50d, Amount2 = 75d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Warehousing", Amount = 10d, Amount1 = 20d, Amount2 = 30d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Taxes", Amount = 10d, Amount1 = 20d, Amount2 = 30d
     });
     Expenditure.Add(new CompanyExpense()
     {
         Expense = "Truck", Amount = 10d, Amount1 = 20d, Amount2 = 30d
     });
 }
コード例 #15
0
        public ViewModel()
        {
            this.Expenditure = new List <Model>();

            Expenditure.Add(new Model()
            {
                Expense = "Email", Amount = 20d
            });
            Expenditure.Add(new Model()
            {
                Expense = "Skype", Amount = 23d
            });
            Expenditure.Add(new Model()
            {
                Expense = "Phone", Amount = 12d
            });
            Expenditure.Add(new Model()
            {
                Expense = "Sms", Amount = 19d
            });
            Expenditure.Add(new Model()
            {
                Expense = "Facebook", Amount = 10d
            });
            Expenditure.Add(new Model()
            {
                Expense = "Twitter", Amount = 10d
            });
            Expenditure.Add(new Model()
            {
                Expense = "LinkedIn", Amount = 9d
            });
        }
コード例 #16
0
 private void btnAddExpen_Click(object sender, EventArgs e)
 {
     Expenditure.AddExpenditure(new Expenditure()
     {
         Amount = Convert.ToInt32(txtExpenditure.Text), Reason = txtReason.Text
     });
 }
コード例 #17
0
 public void ValidateExpenditure(Expenditure model)
 {
     if (model.amount <= 0)
     {
         ModelState.AddModelError("amount", "Số tiền quá ít");
     }
 }
コード例 #18
0
        public List <Expenditure> selectPayReceive()
        {
            //query for select command
            List <Expenditure> PayReceiveList = new List <Expenditure>();
            SqlConnection      con            = new SqlConnection(connection);

            con.Open();
            string        selectQuery = "Select * from tbl_Expenditure";
            SqlCommand    command     = new SqlCommand(selectQuery, con);
            SqlDataReader reader      = command.ExecuteReader();

            while (reader.Read())
            {
                Expenditure ex = new Expenditure();
                ex.exp_id          = Convert.ToInt32(reader["Exp_ID"].ToString());
                ex.emp_id          = Convert.ToInt32(reader["Emp_id"].ToString());
                ex.exp_purpose     = reader["Purpose"].ToString();
                ex.exp_for         = reader["Exp_for"].ToString();
                ex.exp_description = reader["Exp_Description"].ToString();
                ex.exp_amount      = Convert.ToDecimal(reader["Exp_amount"].ToString());
                ex.created_date    = Convert.ToDateTime(reader["created_date"].ToString());
                ex.created_by      = reader["created_by"].ToString();
                PayReceiveList.Add(ex);
            }
            con.Close();
            return(PayReceiveList);
        }
コード例 #19
0
        protected void cadastro_Click(object sender, EventArgs e)
        {
            string check;

            if (txt_REPLAY.Checked == true)
            {
                check = "Sim";
            }
            else
            {
                check = "Não";
            }
            MExpenditure mExpenditure   = new MExpenditure();
            string       classification = selectclassification.Value.Replace('_', ' ');
            string       formPayment    = selectformPayment.Value.Replace('_', ' ');
            Expenditure  cd             = new Expenditure();

            cd.ClassificationExpenditure = classification;
            cd.Expenditure_Date          = DateTime.Parse(txt_EXPENDITURE_DATE.Text);
            cd.Unitaty_Value             = decimal.Parse(txt_UNITARY_VALUE.Text, CultureInfo.InvariantCulture);
            cd.Amount        = int.Parse(txt_AMOUNT.Text);
            cd.ValorTotal    = cd.ValueTotal(cd.Unitaty_Value, cd.Amount);
            cd.Form_Payment  = formPayment;
            cd.PersonName    = txt_PERSON_NAME.Text;
            cd.Comment       = TextBox1.Text;
            cd.Replay        = check;
            cd.statusAproval = StatusAproval.Aguardando_Aprovação;

            mExpenditure.InsertEXPENDITURE(cd);

            //mExpenditure.InsertEXPENDITURE(classification, DateTime.Parse(txt_EXPENDITURE_DATE.Text), double.Parse(txt_UNITARY_VALUE.Text, CultureInfo.InvariantCulture), int.Parse(txt_AMOUNT.Text), formPayment, txt_PERSON_NAME.Text, TextBox1.Text, txt_REPLAY.Checked, "Aguardando Aprovação");
        }
コード例 #20
0
        public void AddExpenditure()
        {
            //var expenditure = new ExpenditureModel()
            //{
            //    Name = "Shop Advance",
            //    Amount = 150000,
            //    BillDate = new DateTime(2020, 06, 01),
            //    Type = ExpenditureTypeEnum.Shop,
            //    Notes = "Advance amount gave to the shop owner"
            //};

            var items = new List <ExpenditureItemsModel>();

            items.Add(new ExpenditureItemsModel()
            {
                Name      = "Sun screen lotion",
                Quantity  = 5,
                UnitPrice = 10
            });

            var expenditure = new ExpenditureModel()
            {
                Name             = "Nykaa",
                BillDate         = DateTime.UtcNow,
                Type             = ExpenditureTypeEnum.Products,
                ExpenditureItems = items,
                Notes            = "Product bought to use for the customers",
                Amount           = items.Sum(i => i.TotalPrice)
            };

            Expenditure.AddExpenditure(expenditure);
        }
コード例 #21
0
 public void SaveExpenditure(Expenditure expenditure)
 {
     if (expenditure.ExpenditureId == 0)
     {
         context.Expenditures.Add(expenditure);
     }
     else
     {
         Expenditure dbEntry = context.Expenditures.Find(expenditure.ExpenditureId);
         if (dbEntry != null)
         {
             dbEntry.DescriptionExpenditure = expenditure.DescriptionExpenditure;
             dbEntry.Entertaiment           = expenditure.Entertaiment;
             dbEntry.Food = expenditure.Food;
             dbEntry.HouseholdExpenses = expenditure.HouseholdExpenses;
             dbEntry.Loan            = expenditure.Loan;
             dbEntry.OtherExpenses   = expenditure.OtherExpenses;
             dbEntry.Travel          = expenditure.Travel;
             dbEntry.Auto            = expenditure.Auto;
             dbEntry.ExpensesAddedOn = expenditure.ExpensesAddedOn;
             dbEntry.Clothing        = expenditure.Clothing;
         }
     }
     context.SaveChanges();
 }
コード例 #22
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         Expenditure oExpenditure = new Expenditure();
         if (lsvExpenditure.SelectedItems != null && lsvExpenditure.SelectedItems.Count > 0)
         {
             oExpenditure = (Expenditure)lsvExpenditure.SelectedItems[0].Tag;
             if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 using (DLMSEntities db = new DLMSEntities())
                 {
                     db.Expenditures.Attach(oExpenditure);
                     db.Expenditures.Remove(oExpenditure);
                     //Save to database
                     db.SaveChanges();
                 }
                 RefreshList();
             }
         }
     }
     catch (Exception Ex)
     {
         MessageBox.Show("Cannot delete item due to " + Ex.Message);
     }
 }
コード例 #23
0
        private void CommonInit()
        {
            localExpense = new Expenditure();
            DontRun      = false;
            // Now subscribe to messages from the Category popup window
            MessagingCenter.Subscribe <Category_popup, string>(this, "NewCategory", (s, a) =>
            {
                // In the future, add a feature to detect if the item which was typed in was an already existing category
                Category_picker.Items.Add(a.ToString());
                Category_picker.SelectedIndex = Category_picker.Items.Count - 1;
                categoryDatabase.SaveCategory(new ExpenseCategory(a.ToString(), userName));
            });
            MessagingCenter.Subscribe <Category_popup>(this, "clickedAway", (obj) =>
            {
                DontRun = true;
                Category_picker.SelectedItem = -1;
                DontRun = false;
            });

            // subscribe to the messages which will indicate if the back button has been pressed
            MessagingCenter.Subscribe <MoneyPage>(this, "backClicked", (obj) =>
            {
                PopupNavigation.Instance.PopAsync(true);
            });


            // Now make a connection to the category database
            categoryDatabase = new SpendingCategoryDBController(DependencyService.Get <ISQLHelper>().getLocalFilePath("ExpenseCategoryDB.db3"));    // always get instance of the database at the opening of the app

            // Now let the Money Page know that this form has been loaded
            MessagingCenter.Send(this, "FormOpen", true);
        }
コード例 #24
0
        public ActionResult CreateExpenditure(Expenditure expenditure)
        {
            var result = new ContentResult {
                Content = expenditure.Comment, ContentType = "application/text"
            };

            return(result);
        }
コード例 #25
0
 public void ValidateExpenditure(Expenditure expenditure)
 {
     Guard.ArgumentNotNull(expenditure, "expenditure");
     if (expenditure.Amount >= 0)
     {
         throw new ValidationException("Amount of Expenditure should be less than zero.", ValidationErrorCode.InvalidAmount);
     }
 }
コード例 #26
0
 public ExpenseForm(Expenditure expense)
 {
     InitializeComponent();
     userName = expense.User;
     CommonInit();
     localExpense = expense;
     newExpense   = false;
 }
コード例 #27
0
        public ActionResult DeleteConfirmed(int id)
        {
            Expenditure expenditure = db.Expenditures.Find(id);

            db.Expenditures.Remove(expenditure);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #28
0
 public void Insert(Expenditure expenditure)
 {
     using (var context = new TrianglesDataContext())
     {
         context.Expenditures.InsertOnSubmit(expenditure);
         context.SubmitChanges();
     }
 }
コード例 #29
0
 public ExpenditureEditViewModel(Expenditure expenditure, string title = "Editar")
 {
     Id          = expenditure.Id;
     Date        = expenditure.Date;
     Value       = expenditure.Value;
     Description = expenditure.Description;
     PageTitle   = title;
 }
コード例 #30
0
        public Calculator(decimal income, decimal expenditure)
        {
            Income      newIncome      = new Income();
            Expenditure newExpenditure = new Expenditure();

            newIncome.Amount      = income;
            newExpenditure.Amount = expenditure;
        }
コード例 #31
0
ファイル: Converter.cs プロジェクト: JackyFei/dev
        internal BusinessLogic.Record.Expenditure Convert(Expenditure expenditure)
        {
            Guard.ArgumentNotNull(expenditure, "expenditure");
            var modelExpenditure = new BusinessLogic.Record.Expenditure {
            };

            return(modelExpenditure);
        }
コード例 #32
0
ファイル: ExpenditureMapper.cs プロジェクト: G-Rad/Triangles
        public static Models.Expenditure Map(Expenditure source)
        {
            var dest = new Models.Expenditure
                            {
                                Who = source.Who,
                                Amount = source.Amount,
                                Description = source.Description,
                                Id = source.Id
                            };

            return dest;
        }
コード例 #33
0
        public void Update(Expenditure expenditure)
        {
            using (var context = new TrianglesDataContext())
            {
                var existedExpenditure = context.Expenditures.First(x => x.Id == expenditure.Id);

                existedExpenditure.Amount = expenditure.Amount;
                existedExpenditure.Description = expenditure.Description;
                existedExpenditure.Who = expenditure.Who;

                context.SubmitChanges();
            }
        }