private void LoadData()
        {
            if (String.IsNullOrEmpty(this.productCode) == false)
            {
                btnLovProduct.Enabled  = false;
                txtProductName.Enabled = false;
                cboCustomer.Enabled    = false;
            }

            CustomerPrice customerPrice = CustomerPriceController.GetCustomerPrice(this.customerCode, this.productCode, this.startDate);

            if (customerPrice != null)
            {
                cboCustomer.SelectedValue = customerPrice.Customer.CustomerCode;

                this.productCode    = customerPrice.Product.ProductCode;
                txtProductName.Text = customerPrice.Product.ProductName;
                txtUnitPrice.Text   = customerPrice.UnitPrice.ToString();
                txtDay.Text         = customerPrice.Day.ToString();

                dtpStartDate.Value    = customerPrice.StartDate;
                dtpStartDate.Enabled  = false;
                BtnSaveAndNew.Visible = false;
            }
        }
Esempio n. 2
0
        public string Export()
        {
            var _strB = new StringBuilder();

            try {
                _strB.Append(cdrRow.Start.ToString(AppConstants.CdrDateFormat));
                _strB.Append(",");
                _strB.Append(cdrRow.Start.ToString(AppConstants.CdrTimeFormat));
                _strB.Append(",");
                _strB.Append(Duration.ToString());
                _strB.Append(",");
                _strB.Append(CountryCode.ToString());
                _strB.Append(",");
                _strB.Append(LocalNumber);
                _strB.Append(",");
                _strB.Append(CustomerRouteName);
                _strB.Append(",");
                _strB.Append(ANI);
                _strB.Append(",");
                _strB.Append(OrigEPId);
                _strB.Append(",");
                _strB.Append(CustomerPrice.ToString(AppConstants.CdrAmountFormat));
                _strB.Append(",");
                _strB.Append(TermEPId);
                _strB.Append(",");
                _strB.Append(CarrierCost.ToString(AppConstants.CdrAmountFormat));
                _strB.Append(",");
                _strB.Append(RetailPrice.ToString(AppConstants.CdrAmountFormat));
            }
            catch (Exception _ex) {
                TimokLogger.Instance.LogRbr(LogSeverity.Error, "Cdr.Export", string.Format("Exception:\r\n{0}", _ex));
            }
            return(_strB.ToString());
        }
        public async Task <IActionResult> Edit(int id, [Bind("CustomerPriceId,CustomerId,ProductId,Price")] CustomerPrice customerPrice)
        {
            if (id != customerPrice.CustomerPriceId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customerPrice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerPriceExists(customerPrice.CustomerPriceId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "CustomerId", "Name", customerPrice.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Set <Product>(), "ProductId", "Description", customerPrice.ProductId);
            return(View(customerPrice));
        }
        public async Task <IActionResult> Create([Bind("CustomerPriceId,CustomerId,ProductId,Price")] CustomerPrice customerPrice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customerPrice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CustomerId"] = new SelectList(_context.Set <Customer>(), "CustomerId", "Name", customerPrice.CustomerId);
            ViewData["ProductId"]  = new SelectList(_context.Set <Product>(), "ProductId", "Description", customerPrice.ProductId);
            return(View(customerPrice));
        }
        public bool UpdateCustomerPrice(CustomerPriceDto newCustomerPriceDetails)
        {
            var updatedCustomerPriceDetails = this.customerprice;

            updatedCustomerPriceDetails = new CustomerPrice
            {
                CustomerPriceID = newCustomerPriceDetails.CustomerPriceId,
                CustomerID      = newCustomerPriceDetails.CustomerId,
                Price           = newCustomerPriceDetails.Price,
                ProductID       = newCustomerPriceDetails.ProductId
            };

            return(true);
        }
Esempio n. 6
0
        public async Task <IList <CustomerPrice> > GetCustomersPrices()
        {
            var productPrices = await _productPriceService.GetProductBasePrices();

            var newCustomerPrices = new List <CustomerPrice>();

            foreach (var customerId in Customers.Ids)
            {
                foreach (var baseProductPrice in productPrices)
                {
                    var calculatedPrice = await CalculateCustomerPrice(customerId, baseProductPrice.Price);

                    var customerPrice = new CustomerPrice(customerId, baseProductPrice.ProductId, calculatedPrice, baseProductPrice.IsActive);
                    newCustomerPrices.Add(customerPrice);
                }
            }

            return(newCustomerPrices);
        }
        private void Save()
        {
            try
            {
                var customerPrice = new CustomerPrice
                {
                    Customer = new Customer
                    {
                        CustomerCode = cboCustomer.SelectedValue.ToString()
                    },
                    Product = new Product
                    {
                        ProductCode = this.productCode
                    },
                    StartDate = dtpStartDate.Value,
                    EndDate   = dtpStartDate.Value.AddDays(Convert.ToInt16(txtDay.Text) - 1),
                    Day       = Convert.ToInt16(txtDay.Text),

                    UnitPrice  = Convert.ToDecimal(txtUnitPrice.Text),
                    CreateBy   = "system",
                    ModifiedBy = "system"
                };

                if (btnLovProduct.Enabled == true && cboCustomer.Enabled == true)
                {
                    CustomerPriceController.Insert(customerPrice);
                }
                else
                {
                    CustomerPriceController.Update(customerPrice);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 8
0
 private static void DisplaySingleCustomerPrice(CustomerPrice customerPrice)
 {
     HappyConsole.WriteGreenLine($"{customerPrice.CustomerId,2} {customerPrice.ProductId,13} {customerPrice.Price.ToString("C2"),17} {(customerPrice.IsActive ? "A" : ""),3}");
 }