Ejemplo n.º 1
0
        public BudgetTransaction(TransactionViewModels vm)
        {
            BudgetTransactionID = vm.BudgetTransactionID;
            BudgetID            = vm.BudgetID;
            PaymentID           = vm.PaymentID;
            Description         = vm.Description;
            Amount         = vm.Amount;
            PreviousAmount = vm.PreviousAmount;
            RemainAmount   = vm.RemainAmount;
            Status         = vm.Status;

            Budget = new Budget()
            {
                Year         = vm.Year,
                BudgetAmount = vm.BudgetAmount,
                CostCenterID = vm.CostCenterID,
                AccountID    = vm.AccountID
            };

            Budget.Account = new Account()
            {
                AccountID   = vm.AccountID,
                AccountName = vm.AccountName,
            };

            Budget.CostCenter = new CostCenter()
            {
                CostCenterID   = vm.CostCenterID,
                CostCenterName = vm.CostCenterName
            };
        }
Ejemplo n.º 2
0
        // GET: Transactions
        public ActionResult Index(int BankAccountId)
        {
            TransactionViewModels model = new TransactionViewModels();

            var transactions = db.Transactions
                               .Where(m => m.BankAccountId == BankAccountId)
                               .Include(t => t.BankAccount)
                               .Include(t => t.Category)
                               .Include(t => t.EnteredBy);

            model.TA = transactions.ToList();

            model.BankAccountId = BankAccountId;

            return(View(model));
            //return View(transactions.ToList());
        }
        private List <TransactionViewModels> TransactionRecordList(int RecordCount)
        {
            List <TransactionViewModels> tmpTransactionRecordList = new List <TransactionViewModels>();
            Random tmpRandom = new Random();

            for (int i = 1; i <= RecordCount; i++)
            {
                var tmpRecordData = new TransactionViewModels()
                {
                    Date     = DateTime.Now.AddDays(-tmpRandom.Next(0, 30)),
                    Amount   = (decimal)tmpRandom.Next(100, 9999),
                    Category = this.GetTransactionCategoryDesc(tmpRandom.Next(0, 100) % 2),
                };
                tmpTransactionRecordList.Add(tmpRecordData);
            }

            return(tmpTransactionRecordList);
        }
Ejemplo n.º 4
0
        private TransactionViewModels ConvertReaderToTransactionVM(SqlDataReader reader)
        {
            TransactionViewModels vm = new TransactionViewModels();

            return(vm);
        }
Ejemplo n.º 5
0
        public PaymentViewModel GetVMPaymentByID(string paymentid)
        {
            PaymentViewModel             payment      = null;
            List <TransactionViewModels> transactions = new List <TransactionViewModels>();

            using (SqlConnection conn = new SqlConnection(SqlManager.ConnectionString))
            {
                conn.Open();

                using (SqlCommand cmd = new SqlCommand(cmd_get_payment_by_id, conn))
                {
                    cmd.Parameters.AddWithValue("PaymentID", paymentid);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            payment = ConvertReaderToPaymentVM(reader);
                        }
                    }
                }

                using (SqlCommand cmd = new SqlCommand(cmd_get_payment_transaction, conn))
                {
                    cmd.Parameters.AddWithValue("PaymentID", paymentid);
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            TransactionViewModels vm = new TransactionViewModels();

                            vm.BudgetTransactionID = Guid.Parse(reader["BudgetTransactionID"].ToString());
                            vm.BudgetID            = Guid.Parse(reader["BudgetID"].ToString());
                            vm.Year           = reader["Year"].ToString();
                            vm.CostCenterID   = reader["CostCenterID"].ToString();
                            vm.CostCenterName = reader["CostCenterName"].ToString();
                            vm.AccountID      = reader["AccountID"].ToString();
                            vm.AccountName    = reader["AccountName"].ToString();

                            vm.PaymentID   = Guid.Parse(reader["PaymentID"].ToString());
                            vm.Description = reader["Description"].ToString();

                            decimal budgetamount, amount, previous, remain;
                            vm.BudgetAmount   = decimal.TryParse(reader["BudgetAmount"].ToString(), out budgetamount) ? budgetamount : 0;
                            vm.Amount         = decimal.TryParse(reader["Amount"].ToString(), out amount) ? amount : 0;
                            vm.PreviousAmount = decimal.TryParse(reader["PreviousAmount"].ToString(), out previous) ? previous : 0;
                            vm.RemainAmount   = decimal.TryParse(reader["RemainAmount"].ToString(), out remain) ? remain : 0;

                            RecordStatus status;
                            vm.Status = Enum.TryParse(reader["Status"].ToString(), out status) ? status : 0;

                            vm.RecordTimeStamp.CreatedAt  = reader.GetNullableDateTime("CreatedAt");
                            vm.RecordTimeStamp.CreatedBy  = reader["CreatedBy"].ToString();
                            vm.RecordTimeStamp.ModifiedAt = reader.GetNullableDateTime("ModifiedAt");
                            vm.RecordTimeStamp.ModifiedBy = reader["ModifiedBy"].ToString();
                            vm.RecordTimeStamp.DeletedAt  = reader.GetNullableDateTime("DeletedAt");
                            vm.RecordTimeStamp.DeletedBy  = reader["DeletedBy"].ToString();

                            transactions.Add(vm);
                        }
                    }
                }

                if (payment != null)
                {
                    payment.RecordTimeStamp.GetRecordsNameInfo();
                    payment.Transactions = transactions;
                }

                conn.Close();
            }

            return(payment);
        }