//Обновление строки
        private void UpdateRecord()
        {
            if (dgvAddPayment.CurrentRow == null)
            {
                return;
            }
            v_AddPayment addPaymentSet = dgvAddPayment.CurrentRow.DataBoundItem as v_AddPayment;

            if (addPaymentSet == null)
            {
                MessageBox.Show("Не знайдений рядок для оновлення", "Помилка");
                return;
            }
            fmAddPaymentEdit fmEdit = new fmAddPaymentEdit(EnumFormMode.Edit, "Зміна додаткової виплати");

            fmEdit.SetData(addPaymentSet);
            if (fmEdit.ShowDialog() == DialogResult.OK)
            {
                AddPayment addPaymentGet = fmEdit.GetData();
                string     error;
                if (!_repoAddPayment.ModifyAddPayment(addPaymentGet, out error))
                {
                    MessageBox.Show("Помилка оновлення рядка.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
                RefreshTableAddPayment(_typeId, _datBeg, _datEnd);
            }
        }
Example #2
0
        public AddPayment GetData()
        {
            AddPayment addPayment = new AddPayment();

            addPayment.AddPayment_Id          = _id;
            addPayment.AddPayment_PersCard_Id = _cmbCardParams.PersCard_Id;
            addPayment.AddPayment_Date        = SalaryHelper.GetDateByIndex(cmbCalendar.SelectedIndex, DateTime.Today.Year - SetupProgram.YearSalary, false);

            int     resInt = 0;
            decimal resDec = 0;

            ResField fldId = resFldTypeAddPayment.FirstOrDefault(rec => rec.Name == "RefTypeAddPayment_Id");

            if (fldId != null)
            {
                if (int.TryParse(fldId.Val, out resInt))
                {
                    addPayment.AddPayment_TypeAddPayment_Id = resInt;
                }
            }
            //Сумма
            if (decimal.TryParse(tbSm.Text, out resDec))
            {
                addPayment.AddPayment_Sm = resDec;
            }

            return(addPayment);
        }
Example #3
0
        private void FillDataRec(SqlDataReader reader, AddPayment addPayment)
        {
            int      resInt  = 0;
            DateTime resDate = DateTime.MinValue;
            decimal  resDec  = 0;

            if (int.TryParse(reader["AddPayment_Id"].ToString(), out resInt))
            {
                addPayment.AddPayment_Id = resInt;
            }

            if (int.TryParse(reader["AddPayment_PersCard_Id"].ToString(), out resInt))
            {
                addPayment.AddPayment_PersCard_Id = resInt;
            }
            if (DateTime.TryParse(reader["AddPayment_Date"].ToString(), out resDate))
            {
                addPayment.AddPayment_Date = resDate;
            }
            if (int.TryParse(reader["AddPayment_TypeAddPayment_Id"].ToString(), out resInt))
            {
                addPayment.AddPayment_TypeAddPayment_Id = resInt;
            }

            if (decimal.TryParse(reader["AddPayment_Sm"].ToString(), out resDec))
            {
                addPayment.AddPayment_Sm = resDec;
            }
        }
Example #4
0
        static void AddPayment(StoreManager neto)
        {
            AddPayment[] payment = new AddPayment[] {
                new AddPayment {
                    OrderID           = "DEMO15-9",
                    CardAuthorisation = "1234",
                    AmountPaid        = 0.1M
                }
            };

            var result = neto.Payment.AddPayment(payment);

            switch (result.Ack)
            {
            case Ack.Success:
                foreach (var i in result.Payment)
                {
                    Console.WriteLine($"Created ID:{i.PaymentID} PaymentMethodName: {i.PaymentMethodName} at {result.CurrentTime}");
                }
                break;

            case Ack.Warning:
                foreach (var warn in result.Messages.Warning)
                {
                    Console.WriteLine($"Warning: {warn.Message}");
                }
                break;
            }
        }
Example #5
0
        private void metroTile1_Click(object sender, EventArgs e)
        {
            this.Close();
            AddPayment obj = new AddPayment();

            obj.Show();
        }
Example #6
0
        /// <exception cref="NL_ExceptionInputDataInvalid">Condition. </exception>
        public void AddPayment(int customerID, NL_Payments payment, int userID)
        {
            var stra = new AddPayment(customerID, payment, userID);

            stra.Context.CustomerID = customerID;
            stra.Context.UserID     = userID;
            stra.Execute();
        }
Example #7
0
        //Получить список доп выплат по параметрам
        public List <AddPayment> GetAddPaymentsByParams(int addPayment_id, int typeAddPayment_id, DateTime addPayment_dateBeg, DateTime addPayment_dateEnd, out string error)
        {
            error = string.Empty;

            List <AddPayment> addPayments = new List <AddPayment>();

            if (conn == null)
            {
                error = "conn == null";
                return(addPayments);
            }
            if (addPayment_id == 0 && typeAddPayment_id == 0 && addPayment_dateBeg == DateTime.MinValue && addPayment_dateEnd == DateTime.MinValue)
            {
                error = "Не задані вхідні параметри";
                return(addPayments);
            }
            if (addPayment_dateBeg == DateTime.MinValue || addPayment_dateEnd == DateTime.MinValue)
            {
                error = "Не заданий період";
                return(addPayments);
            }

            SqlCommand command = new SqlCommand(spAddPaymentSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;

            command.Parameters.AddWithValue("@inAddPayment_Id", addPayment_id);
            command.Parameters.AddWithValue("@inAddPayment_TypeAddPayment_id", typeAddPayment_id);
            command.Parameters.AddWithValue("@inAddPayment_DateBeg", (addPayment_dateBeg == DateTime.MinValue) ? Convert.DBNull : addPayment_dateBeg);
            command.Parameters.AddWithValue("@inAddPayment_DateEnd", (addPayment_dateEnd == DateTime.MinValue) ? Convert.DBNull : addPayment_dateEnd);

            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    AddPayment addPayment = new AddPayment();
                    FillDataRec(reader, addPayment);
                    addPayments.Add(addPayment);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(addPayments);
        }
Example #8
0
        public void SetData(AddPayment addPayment)
        {
            _id = addPayment.AddPayment_Id;
            cmbCalendar.SelectedIndex = SalaryHelper.GetIndexByDate(
                DateTime.Today.Year - SetupProgram.YearSalary, addPayment.AddPayment_Date, false);

            cmbCard.ReadCombobox(addPayment.AddPayment_PersCard_Id);
            cmbTypeAddPayment.ReadCombobox("RefTypeAddPayment_Id", addPayment.AddPayment_TypeAddPayment_Id.ToString());
            tbSm.Text = addPayment.AddPayment_Sm.ToString("0.00");
        }
Example #9
0
 private void metroButton2_Click(object sender, EventArgs e)
 {
     if (userRolesObj.getCheckstate("AddEditPayment") == true)
     {
         AddPayment addPayObj = new AddPayment(this);
         addPayObj.Show();
     }
     else
     {
         MessageBox.Show("you don't have permission to enter here, Contact admin For further Details");
         return;
     }
 }
Example #10
0
        }         // AddLoan

        public NLLongActionResult AddPayment(int customerID, NL_Payments payment, int userID)
        {
            AddPayment s = new AddPayment(customerID, payment, userID);

            s.Context.UserID     = userID;
            s.Context.CustomerID = customerID;
            var amd = ExecuteSync(out s, customerID, userID, customerID, payment, userID);

            return(new NLLongActionResult {
                MetaData = amd,
                Value = s.PaymentID,
                Error = s.Error
            });
        }         // AddPayment
Example #11
0
        public async void AddPayment()
        {
            Value = true;
            var connection = await apiService.CheckConnection();

            if (!connection.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert(
                    Languages.Warning,
                    Languages.CheckConnection,
                    Languages.Ok);

                return;
            }
            if (string.IsNullOrEmpty(Description) || string.IsNullOrEmpty(Code))
            {
                Value = true;
                return;
            }
            var payment = new AddPayment
            {
                code        = Code,
                description = Description
            };
            var cookie = Settings.Cookie;  //.Split(11, 33)
            var res    = cookie.Substring(11, 32);

            var response = await apiService.Save <AddPayment>(
                "https://portalesp.smart-path.it",
                "/Portalesp",
                "/payment/save",
                res,
                payment);

            Debug.WriteLine("********responseIn ViewModel*************");
            Debug.WriteLine(response);
            if (!response.IsSuccess)
            {
                await Application.Current.MainPage.DisplayAlert("Error", response.Message, "ok");

                return;
            }
            Value = false;
            MessagingCenter.Send((App)Application.Current, "OnSaved");
            DependencyService.Get <INotification>().CreateNotification("PortalSP", "Payment Added");
            await App.Current.MainPage.Navigation.PopPopupAsync(true);
        }
Example #12
0
        //Добавить доп выплату
        public int AddAddPayment(AddPayment addPayment, out string error)
        {
            error = string.Empty;
            if (addPayment == null)
            {
                error = "addPayment == null";
                return(0);
            }
            if (conn == null)
            {
                error = "conn == null";
                return(0);
            }
            SqlCommand command = new SqlCommand(spAddPaymentInsert, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inAddPayment_PersCard_Id", addPayment.AddPayment_PersCard_Id == 0
                ? Convert.DBNull : addPayment.AddPayment_PersCard_Id);
            command.Parameters.AddWithValue("@inAddPayment_TypeAddPayment_Id", addPayment.AddPayment_TypeAddPayment_Id == 0
                ? Convert.DBNull : addPayment.AddPayment_TypeAddPayment_Id);
            command.Parameters.AddWithValue("@inAddPayment_Date", addPayment.AddPayment_Date == DateTime.MinValue
                ? Convert.DBNull : addPayment.AddPayment_Date);
            command.Parameters.AddWithValue("@inAddPayment_Sm", addPayment.AddPayment_Sm);
            // определяем выходной параметр
            SqlParameter outId = new SqlParameter
            {
                ParameterName = "outId",
                Direction     = ParameterDirection.Output,
                SqlDbType     = SqlDbType.Int
            };

            command.Parameters.Add(outId);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(0);
            }
            int id = 0;

            int.TryParse(command.Parameters["outId"].Value.ToString(), out id);
            return(id);
        }
Example #13
0
		public void AddPaymentTest() {
			const int customerid = 390;
			const long loanID = 15;
			/*NL_Payments nlpayment = new NL_Payments() {
				Amount = 100m,
				CreatedByUserID = 357,
				PaymentTime = new DateTime(2015, 10, 25),
				LoanID = loanID,
				Notes = "offset",
				PaymentStatusID = (int)NLPaymentStatuses.Active,
				PaymentMethodID = (int)NLLoanTransactionMethods.SetupFeeOffset
			};*/
			/*	DateTime prebatedate = DateTime.UtcNow; // new DateTime(2015, 12, 6);
				NL_Payments nlpayment = new NL_Payments() {
					Amount = 5m,
					CreatedByUserID = customerid,
					CreationTime = prebatedate,
					LoanID = loanID,
					PaymentTime = prebatedate,
					Notes = "rebate",
					PaymentStatusID = (int)NLPaymentStatuses.Active,
					PaymentMethodID = (int)NLLoanTransactionMethods.SystemRepay
				};*/
			DateTime pdate = DateTime.Now; // new DateTime(2016, 1, 7);
			NL_Payments nlpayment = new NL_Payments() {
				Amount = 50m,
				CreatedByUserID = 357,
				CreationTime = DateTime.UtcNow,
				LoanID = loanID,
				PaymentTime = pdate,
				Notes = "payment3",
				PaymentStatusID = (int)NLPaymentStatuses.Active,
				PaymentMethodID = (int)NLLoanTransactionMethods.Manual
			};
			try {
				AddPayment pstrategy = new AddPayment(customerid, nlpayment, 357);
				pstrategy.Execute();
				m_oLog.Debug(pstrategy.Error);
			} catch (Exception ex) {
				m_oLog.Debug(ex);
			}
		}
Example #14
0
        //Получить список доп выплат
        public List <AddPayment> GetAllAddPayments(out string error)
        {
            error = string.Empty;

            List <AddPayment> addPayments = new List <AddPayment>();

            if (conn == null)
            {
                error = "conn == null";
                return(addPayments);
            }

            SqlCommand command = new SqlCommand(spAddPaymentSelect, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            SqlDataReader reader = null;

            try
            {
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    AddPayment addPayment = new AddPayment();
                    FillDataRec(reader, addPayment);
                    addPayments.Add(addPayment);
                }
            }
            catch (Exception exc)
            {
                error = exc.Message;
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }
            return(addPayments);
        }
Example #15
0
        public async Task <IActionResult> AddOrReplacePaymentMethod([FromBody] AddPayment addPayment)
        {
            var accountId = User.ReadClaimAsGuidValue("urn:codefliptodo:accountid");
            var account   = await _accountRepository.FindAccountByIdAsync(accountId);

            var previousPaymentMethodId = account.PaymentMethodId;
            var gateway        = _braintreeConfiguration.GetGateway();
            var subscriptionId = Guid.NewGuid().ToString();

            addPayment.AccountId = accountId;

            var paymentMethodAdded = await _mediator.Send(addPayment);

            if (account.SubscriptionId != null)
            {
                var updateSubscription = new UpdateSubscriptionPaymentMethod
                {
                    AccountId = accountId
                };

                await _mediator.Send(updateSubscription);
            }

            if (previousPaymentMethodId != null)
            {
                var deletePayment = new DeletePaymentMethod
                {
                    PaymentMethodId = previousPaymentMethodId,
                    AccountId       = accountId
                };
                await _mediator.Send(deletePayment);
            }

            if (paymentMethodAdded)
            {
                return(Ok());
            }

            return(BadRequest());
        }
        //Вставка строки
        private void InsertRecord()
        {
            fmAddPaymentEdit fmEdit        = new fmAddPaymentEdit(EnumFormMode.Insert, "Створення додаткової виплати");
            AddPayment       addPaymentSet = new AddPayment();
            int month = SalaryHelper.GetMonthByIndex(cmbCalendar.SelectedIndex, true);

            if (month == 0)
            {
                addPaymentSet.AddPayment_Date = DateTime.MinValue.AddYears(DateTime.Today.Year - 1).AddMonths(DateTime.Today.Month - 1);
            }
            else
            {
                int year = SalaryHelper.GetYearByIndex(DateTime.Today.Year - SetupProgram.YearSalary, cmbCalendar.SelectedIndex, true);
                addPaymentSet.AddPayment_Date = DateTime.MinValue.AddYears(year - 1).AddMonths(month - 1);
            }

            if (MenuItemTypeAddPayment.CheckState == CheckState.Checked && dgvTypeAddPayment.CurrentRow != null)
            {
                v_TypeAddPayment type = dgvTypeAddPayment.CurrentRow.DataBoundItem as v_TypeAddPayment;
                if (type != null)
                {
                    addPaymentSet.AddPayment_TypeAddPayment_Id = type.Id;
                }
            }
            fmEdit.SetData(addPaymentSet);
            if (fmEdit.ShowDialog() == DialogResult.OK)
            {
                string     error;
                AddPayment addPaymentGet = fmEdit.GetData();
                int        id            = _repoAddPayment.AddAddPayment(addPaymentGet, out error);
                if (id == 0)
                {
                    MessageBox.Show("Помилка додавання рядка.\nТехнічна інформація: " + error, "Помилка");
                    return;
                }
                RefreshTableAddPayment(_typeId, _datBeg, _datEnd);
                dgvAddPayment.SetPositionRow <v_AddPayment>("AddPayment_Id", id.ToString());
            }
        }
Example #17
0
        //Изменить доп выплату
        public bool ModifyAddPayment(AddPayment addPayment, out string error)
        {
            error = string.Empty;
            if (conn == null)
            {
                error = "conn == null";
                return(false);
            }
            if (addPayment == null)
            {
                error = "addPayment == null";
                return(false);
            }
            SqlCommand command = new SqlCommand(spAddPaymentUpdate, conn);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Connection  = conn;
            command.Parameters.AddWithValue("@inAddPayment_Id", addPayment.AddPayment_Id);
            command.Parameters.AddWithValue("@inAddPayment_PersCard_Id", addPayment.AddPayment_PersCard_Id == 0
                ? Convert.DBNull : addPayment.AddPayment_PersCard_Id);
            command.Parameters.AddWithValue("@inAddPayment_TypeAddPayment_Id", addPayment.AddPayment_TypeAddPayment_Id == 0
                ? Convert.DBNull : addPayment.AddPayment_TypeAddPayment_Id);
            command.Parameters.AddWithValue("@inAddPayment_Date", addPayment.AddPayment_Date == DateTime.MinValue
                ? Convert.DBNull : addPayment.AddPayment_Date);
            command.Parameters.AddWithValue("@inAddPayment_Sm", addPayment.AddPayment_Sm);
            try
            {
                command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                error = ex.Message;
                return(false);
            }
            return(true);
        }
        static void Main(string[] args)
        {
            var customer = new CustomerList();
            var run      = true;

            while (run)



            {
                var userInput = MainMenu(customer.CustomerId);
                switch (int.Parse(userInput))
                {
                case 1:
                    Console.Clear();



                    Console.WriteLine("You've chosen to create a new customer account.");

                    Console.WriteLine("Enter your first name");
                    var firstName = Console.ReadLine();

                    Console.WriteLine("Enter your last name");
                    var lastName = Console.ReadLine();

                    Console.WriteLine("Enter your street address");
                    var address = Console.ReadLine();

                    Console.WriteLine("Enter your city");
                    var city = Console.ReadLine();

                    Console.WriteLine("Enter your state");
                    var state = Console.ReadLine();

                    Console.WriteLine("Enter your postal code");
                    var postalCode = Console.ReadLine();

                    Console.WriteLine("Finally, enter your phone number");
                    var phone = Console.ReadLine();


                    var newCustomerInfo = new CreateCustomerAccount();
                    var newCustomer     = newCustomerInfo.AddNewCustomerInfo(firstName, lastName, address, city, state, postalCode, phone);

                    if (newCustomer)
                    {
                        Console.WriteLine("You added a customer!");
                    }
                    System.Threading.Thread.Sleep(1000);
                    break;

                case 2:
                    Console.Clear();
                    var counter             = 0;
                    var customerList        = new SelectCustomer();
                    var listOfCustomerNames = customerList.GetCustomerName();
                    Console.WriteLine("Which customer will be active?");
                    foreach (var list in listOfCustomerNames)
                    {
                        counter++;
                        Console.WriteLine($"{counter} {list.FirstName} {list.LastName}");
                    }

                    var selectedCustomer      = Console.ReadLine();
                    var selectedCustomerIndex = int.Parse(selectedCustomer.ToString());
                    customer = listOfCustomerNames[selectedCustomerIndex - 1];
                    Console.WriteLine($"the selected customer is {customer.FirstName} {customer.LastName}");
                    System.Threading.Thread.Sleep(1000);
                    break;

                case 3:
                    Console.Clear();

                    Console.WriteLine("What kind of Credit Card are you adding?");
                    var pmtType = Console.ReadLine();

                    Console.WriteLine("What is the account number?");
                    var acctNumber    = Console.ReadLine();
                    var acctNumberInt = long.Parse(acctNumber.ToString());

                    var customerId = customer.CustomerId;

                    var payment = new AddPayment();

                    payment.AddPaymentType(pmtType, customerId, acctNumberInt);

                    Console.WriteLine($"You have added {pmtType} {acctNumber} to {customer.FirstName} {customer.LastName}");
                    System.Threading.Thread.Sleep(1000);

                    break;

                case 4:
                    Console.Clear();
                    //Add product to sell
                    var productAdder = new ProductAdder();
                    Console.WriteLine("Enter the Product Name: ");
                    var productName = Console.ReadLine();
                    Console.WriteLine("Enter the Product Description: ");
                    var productDescription = Console.ReadLine();
                    Console.WriteLine("Enter the Product Price: ");
                    var productPrice = Convert.ToDouble(Console.ReadLine());
                    Console.WriteLine("Enter the Product Quantity: ");
                    var quantity  = Convert.ToInt32(Console.ReadLine());
                    var customers = productAdder.GetAllCustomers();

                    var counter4 = 0;
                    Console.WriteLine("Please select the customer whose product you are adding:");
                    foreach (var person in customers)
                    {
                        counter4++;
                        Console.WriteLine($"{counter4}. {person.FirstName} {person.LastName}");
                    }

                    var customerToAddProduct = int.Parse(Console.ReadLine());

                    var customerIdToAdd = customers[customerToAddProduct - 1];
                    var newProduct      = productAdder.AddNewProduct(productName, productDescription, productPrice, quantity, customerIdToAdd.CustomerId);
                    if (newProduct)
                    {
                        Console.WriteLine($"You added {productName} to {customerIdToAdd.FirstName} {customerIdToAdd.LastName}!");
                    }
                    System.Threading.Thread.Sleep(1000);
                    break;

                case 5:
                    Console.Clear();
                    //Add product to shopping cart
                    var productQuery  = new ProductQuery();
                    var allProducts   = productQuery.GetAllProducts();
                    var addProduct    = new AddProduct();
                    var orderModifier = new OrderModifier();

                    var order          = 0;
                    var addingProducts = true;
                    while (addingProducts)
                    {
                        Console.WriteLine("All Products");
                        var counter2 = 0;
                        foreach (var product in allProducts)
                        {
                            counter2++;
                            Console.WriteLine($"{counter2}. {product.ProductName}: {product.ProductPrice}");
                        }
                        counter2++;
                        Console.WriteLine($"{counter2}. Done adding products.");

                        Console.WriteLine("What product would you like to add to the order?");
                        var productToAdd = Console.ReadLine();
                        Console.WriteLine("");
                        var selectedProductIndex = int.Parse(productToAdd.ToString());
                        if (selectedProductIndex == counter2)
                        {
                            addingProducts = false;
                            break;
                        }
                        Console.WriteLine("How many would you like to add?");
                        var numberToAdd = Console.ReadLine();
                        var addedNumber = int.Parse(numberToAdd.ToString());
                        Console.WriteLine("");

                        var selectedProduct = allProducts[selectedProductIndex - 1];
                        if (order == 0)
                        {
                            order = orderModifier.CreateOrder(customer.CustomerId);
                        }
                        var addNewProduct = addProduct.AddProductToOrder(selectedProduct.ProductId, addedNumber, order);
                        if (addNewProduct)
                        {
                            Console.WriteLine($"You added {selectedProduct.ProductName} to your order!");
                        }
                        System.Threading.Thread.Sleep(1000);
                        Console.Clear();
                    }
                    break;

                case 6:
                    Console.Clear();
                    //Complete an order
                    break;

                case 7:
                    Console.Clear();
                    //Remove customer product
                    Console.WriteLine("Please choose product to delete:");

                    var removeCustomerProduct = new RemoveProduct();
                    removeCustomerProduct.RemoveCustomerProduct(customer);

                    break;

                case 8:
                    Console.Clear();
                    //Update product information
                    var getAllProducts   = new ProductQuery();
                    var productsToUpdate = getAllProducts.GetCustomerProducts(customer.CustomerId);
                    Console.WriteLine("All Products");
                    var counter3 = 0;
                    foreach (var product in productsToUpdate)
                    {
                        counter3++;
                        Console.WriteLine($"{counter3}. {product.ProductName}: {product.ProductPrice}");
                    }

                    Console.WriteLine("What product would you like to update?");
                    var productToUpdate = Console.ReadLine();
                    Console.WriteLine("");
                    var updateProductIndex = int.Parse(productToUpdate.ToString());
                    var updateThisProduct  = productsToUpdate[updateProductIndex - 1];
                    Console.Clear();
                    var productModifier = new AddProduct();
                    var updateProduct   = productModifier.UpdateProduct(updateThisProduct);
                    if (updateProduct)
                    {
                        Console.WriteLine("Product updated!");
                    }


                    System.Threading.Thread.Sleep(1000);
                    break;

                case 9:
                    Console.Clear();
                    //Show stale products
                    break;

                case 10:
                    Console.Clear();
                    var revenueQuery   = new RevenueQuery();
                    var listOfRevenues = revenueQuery.GetCustomerRevenue(customer.FirstName, customer.LastName);

                    var personRevenue = from personOrder in listOfRevenues
                                        group personOrder by personOrder.OrderId into g
                                        orderby g.Key
                                        select g;

                    var revenueCounter = 0.00;

                    Console.WriteLine($"This is the revenue report for {customer.FirstName} {customer.LastName}");
                    foreach (var revenueResult in personRevenue)
                    {
                        Console.WriteLine($"\nOrder #{revenueResult.Key}\n--------------------------------------");


                        foreach (var item in revenueResult)
                        {
                            revenueCounter += item.indivItemTotal;
                            Console.WriteLine($"{item.ProductName}     {item.OrderItemQuantity}   ${item.indivItemTotal} ");
                        }
                        //Console.WriteLine()
                    }
                    Console.WriteLine($"\nTotal Revenue is ${revenueCounter}");
                    Console.ReadLine();

                    break;

                case 11:
                    Console.Clear();
                    //Show overall product popularity
                    var revenueReport = new RevenueReport();
                    revenueReport.GetTop3Revenue();
                    break;

                case 12:
                    //Leave Bangazon!
                    run = false;
                    break;
                }
            }

            string MainMenu(int customerid)
            {
                View mainMenu = new View()
                                .AddMenuOption("1. Create a customer account")
                                .AddMenuOption("2. Choose active customer")
                                .AddMenuOption("4. Add product to sell")
                                .AddMenuOption("9. Show stale products")
                                .AddMenuOption("10. Show customer revenue report")
                                .AddMenuOption("11. Show overall product popularity")
                                .AddMenuOption("12. Leave Bangazon!");

                Console.Write(mainMenu.GetFullMenu());

                if (customerid > 0)
                {
                    mainMenu = new View()
                               .AddMenuOption("1. Create a customer account")
                               .AddMenuOption("2. Choose active customer")
                               .AddMenuOption("3. Create a payment option")
                               .AddMenuOption("4. Add product to sell")
                               .AddMenuOption("5. Add product to shopping cart")
                               .AddMenuOption("6. Complete an order")
                               .AddMenuOption("7. Remove customer product")
                               .AddMenuOption("8. Update product information")
                               .AddMenuOption("9. Show stale products")
                               .AddMenuOption("10. Show customer revenue report")
                               .AddMenuOption("11. Show overall product popularity")
                               .AddMenuOption("12. Leave Bangazon!");
                    Console.Write(mainMenu.GetFullMenu());
                }

                var userOption = Console.ReadLine();

                return(userOption);
            }
        }
Example #19
0
		} //Execute


		public void CopyPaypointTransactions() {

			const string query = "select t.PostDate,t.Amount,t.[Description], t.IP, t.PaypointId, t.LoanTransactionMethodId, c.Id as CardID, nl.[LoanID], l.CustomerId " +
				"from NL_Loans nl join LoanTransaction t on t.LoanId=nl.OldLoanID " +
				"join Loan l on l.Id=t.LoanId " +
				"left join PayPointCard c on c.TransactionId = t.PaypointId " +
				"left join [dbo].[NL_Payments] p on p.LoanID=nl.LoanID " +
				"where t.[Status]='Done' and t.[Type]='PaypointTransaction' and p.PaymentID is null order by t.LoanId, t.PostDate";

			List<LoanTransactionModel> transactionsList = DB.Fill<LoanTransactionModel>(query, CommandSpecies.Text);

			foreach (LoanTransactionModel transaction in transactionsList) {

				bool savePayment = false;

				var args = new object[] {transaction, query};

				if (transaction == null || transaction.Amount == 0) {
					//Error = "transaction not found/or amount=0";
					//Log.Debug(Error);
					NL_AddLog(LogType.Info, "transaction not found or amount=0", args, null, null, null);
					continue;
				}
				
				//check the payment exists
				List<NL_Payments> nlPayments = DB.Fill<NL_Payments>("NL_PaymentsGet", CommandSpecies.StoredProcedure, new QueryParameter("LoanID", transaction.LoanID));

				NL_Payments payment = nlPayments.FirstOrDefault(p => p.Amount == transaction.Amount && transaction.PostDate.Date.Equals(p.PaymentTime.Date) && transaction.LoanTransactionMethodId==p.PaymentMethodID && p.CreationTime.Date.Equals(transaction.PostDate.Date));

				if (payment == null) {
					payment = new NL_Payments() {
						Amount = transaction.Amount,
						CreatedByUserID = 1,
						LoanID = transaction.LoanID,
						PaymentStatusID = (int)NLPaymentStatuses.Active,
						PaymentMethodID = transaction.LoanTransactionMethodId,
						CreationTime = transaction.PostDate,
						PaymentTime = transaction.PostDate,
						Notes = (transaction.Description.Equals("system-repay") && transaction.Amount == 5m) ? "rebate" : transaction.Description
					};
					savePayment = true;
				} else {
					NL_AddLog(LogType.Info, "Payment exists", args, payment, null, null);
				}

				if (!string.IsNullOrEmpty(transaction.CardID.ToString())) {

					var paypointTrans = payment.PaypointTransactions.FirstOrDefault(ppt => ppt.PaypointUniqueID == transaction.PaypointId && ppt.PaypointCardID == transaction.CardID && ppt.TransactionTime.Date.Equals(transaction.PostDate.Date));

					if (paypointTrans == null) {
						payment.PaypointTransactions.Add(new NL_PaypointTransactions() {
							Amount = transaction.Amount,
							IP = transaction.IP,
							Notes = transaction.Description,
							PaypointTransactionStatusID = (int)NLPaypointTransactionStatuses.Done,
							PaypointUniqueID = transaction.PaypointId,
							PaypointCardID = transaction.CardID,
							TransactionTime = transaction.PostDate
						});
						savePayment = true;
					} else {
						NL_AddLog(LogType.Info, "PPT exists", args, paypointTrans, null, null);
					}
				}

				if (savePayment) {

					NL_AddLog(LogType.Info, "Copying transaction", args, payment, null, null);

					try {
						AddPayment p = new AddPayment(transaction.CustomerId, payment, 1);
						p.Context.UserID = 1;
						p.Context.CustomerID = transaction.CustomerId;
						p.Execute();

						// ReSharper disable once CatchAllClause
					} catch (Exception ex) {
						Error = String.Format("failed to copy paypoint transaction {0}, err: {1}", transaction, ex.Message);
						Log.Debug(Error);
						NL_AddLog(LogType.Error, "Copying failed", new object[] {
							transaction, payment
						}, Error, ex.Message, ex.StackTrace);
					}
				}
			}
		}
        static void Main(string[] args)
        {
            // Create database tables if none exist
            DatabaseInterface dab = new DatabaseInterface("BANGAZONCLI_DB");

            dab.CheckCustomerTable();
            dab.CheckOrderTable();
            dab.CheckProductTable();
            dab.CheckProductOrderTable();
            dab.CheckPaymentTypeTable();
            DbInitializer.Initialize(dab);

            // Seed the database if none exists
            // var db = new DatabaseInitializer();
            // db.VerifyDataExists();

            // Present the main menu from MainMenu.cs file
            MainMenu           menu = new MainMenu();
            CustomerManager    cm   = new CustomerManager(dab);
            OrderManager       om   = new OrderManager(dab);
            PaymentTypeManager ptm  = new PaymentTypeManager(dab);
            ProductManager     pm   = new ProductManager(dab);

            // Read in the user's choice
            int choice;

            // If option 1 was chosen, create a new customer account
            do
            {
                // Show the main menu
                choice = menu.Show();

                switch (choice)
                {
                // Menu option 1: Adding Customer
                case 1:
                    CreateCustomer.DoAction(cm);
                    break;

                // Menu option 2: Choosing Active Customer
                case 2:
                    ChooseCustomer.DoAction(cm);
                    break;

                // Menu option 3: Create Payment Options
                case 3:

                    AddPayment.AddPay(ptm);
                    break;

                // Menu option 4: Add product to sell
                case 4:
                    CreateProduct.DoAction(pm);
                    break;

                // Menu option 5: Add product to shopping cart
                case 5:
                    AddProductCart.DoAction(om, pm, cm);
                    break;

                // Menu option 6: Complete an order
                case 6:

                    break;

                // Menu option 7: Remove customer product
                case 7:

                    break;

                // Menu option 8: Update product information
                case 8:

                    break;

                // Menu option 9: Show stale products
                case 9:

                    break;

                // Menu option 10: Show customer revenue report
                case 10:

                    break;

                // Menu option 11: Show overall product popularity
                case 11:

                    break;
                }
            } while (choice != 12);
        }