Ejemplo n.º 1
0
        private void btn_Product_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            //Invoices.ChooseProductForm form = new Invoices.ChooseProductForm();
            //if (form.ShowDialog(this) == DialogResult.OK)
            //{
            //    this.btn_Product.EditValue = form.SelectedItem as Model.Product;
            //}
            //form.Dispose();
            //GC.Collect();

            Settings.BasicData.Products.ChooseProductsForm f = new Book.UI.Settings.BasicData.Products.ChooseProductsForm(Products);
            if (f.ShowDialog(this) == DialogResult.OK)
            {
                this.Products = f.Products.Where(P => P.Checked == true).ToList();

                ProductNames = "";
                ProductIds   = "";
                foreach (var item in Products)
                {
                    ProductNames += item.ProductName + ",";
                    ProductIds   += "'" + item.ProductId + "',";
                }

                ProductNames = ProductNames.TrimEnd(',');
                ProductIds   = ProductIds.TrimEnd(',');

                this.btn_Product.Text = this.ProductNames;
            }
        }
Ejemplo n.º 2
0
        private bool IsInvalidValidChars()
        {
            char[] chars   = { ';', ',' };
            int    invalid = ProductNames.Where(x => x.Name.IndexOfAny(chars) != -1).Count();

            return(invalid > 0);
        }
Ejemplo n.º 3
0
        void LoadProduct()
        {
            string id = currentProduct.Id.ToString();

            localProduct  = ctx.ProductNames.FirstOrDefault(x => x.ProductId == id);
            localStatuses = ctx.ProductStatuses.FirstOrDefault(x => x.ProductId == id);
            if (localStatuses?.ForbiddenStatus == "Зеленый" || localStatuses == null)
            {
                forbiddenWordTextBox.Text     = "";
                forbiddenWordCheckBox.Checked = false;
            }
            else
            {
                forbiddenWordTextBox.Text     = localStatuses.ForbiddenStatus;
                forbiddenWordCheckBox.Checked = true;
            }
            nameSiteTextBox.Text       = localProduct?.ProductName;
            nameSiteEngTextBox.Text    = localProduct?.ProductEngName;
            nameFileTextBox.Text       = currentProduct.Title;
            modelTextBox.Text          = localProduct?.ProductModel;
            brandTextBox.Text          = localProduct?.ProductBrand;
            typeTextBox.Text           = localProduct?.ProductType;
            classificationTextBox.Text = localProduct?.ProductClassification;
            departmentNameTextBox.Text = localProduct?.ProductDepartmentName;
        }
Ejemplo n.º 4
0
        public void Purchase(User user, ProductNames productName, string payerId)
        {
            var userData = _repository.SingleAttached(u => u.Id == user.Id);
            var product  = _productService.GetProductByName(productName);

            var data = product.GetProductExecutionData();

            userData.MembershipType = data.Membership;
            userData.PaypalPayerId  = payerId;
            var date = (DateTime.Now > userData.Expires) ? DateTime.Now : userData.Expires;

            switch ((TimeFrameType)data.TimeFrame)
            {
            case TimeFrameType.Year:
                userData.Expires = date.AddYears(data.Value);
                break;

            case TimeFrameType.Month:
                userData.Expires = date.AddMonths(data.Value);
                break;

            case TimeFrameType.Day:
                userData.Expires = date.AddDays(data.Value);
                break;

            case TimeFrameType.Hour:
                userData.Expires = date.AddHours(data.Value);
                break;
            }
            _repository.FullUpdate(userData);
            _repository.Save();
            _notificationService.Purchase(user, product);
        }
Ejemplo n.º 5
0
        private void ExecuteDelete(object parameter)
        {
            IMessageBoxService msg        = new MessageBoxService();
            string             title      = "Deleting Product Name";
            string             confirmtxt = "Do you want to delete the selected item";

            if (ProductNames.Where(x => x.IsChecked).Count() > 1)
            {
                title      = title + "s";
                confirmtxt = confirmtxt + "s";
            }
            if (msg.ShowMessage(confirmtxt + "?", title, GenericMessageBoxButton.OKCancel, GenericMessageBoxIcon.Question).Equals(GenericMessageBoxResult.OK))
            {
                foreach (ModelBaseVM si in ProductNames)
                {
                    if (si.IsChecked)
                    {
                        if (si.ID > 0)
                        {
                            DeleteProductName(si.ID);
                        }
                        deleteditems.Add(si);
                    }
                }

                foreach (ModelBaseVM pm in deleteditems)
                {
                    ProductNames.Remove(pm);
                }
                deleteditems.Clear();
                CheckValidation();
            }
            msg = null;
        }
Ejemplo n.º 6
0
        public void Purchase(User user, ProductNames productName, string payerId)
        {
            var userData = _repository.SingleAttached(u => u.Id == user.Id);
            var product = _productService.GetProductByName(productName);

            var data = product.GetProductExecutionData();
            userData.MembershipType = data.Membership;
            userData.PaypalPayerId = payerId;
            var date = (DateTime.Now > userData.Expires) ? DateTime.Now : userData.Expires;
            switch((TimeFrameType)data.TimeFrame) {
                case TimeFrameType.Year:
                    userData.Expires = date.AddYears(data.Value);
                    break;
                case TimeFrameType.Month:
                    userData.Expires = date.AddMonths(data.Value);
                    break;
                case TimeFrameType.Day:
                    userData.Expires = date.AddDays(data.Value);
                    break;
                case TimeFrameType.Hour:
                    userData.Expires = date.AddHours(data.Value);
                    break;
            }
            _repository.FullUpdate(userData);
            _repository.Save();
            _notificationService.Purchase(user, product);
        }
        public void TestXmlToCursor()
        {
            var northwind = GetContext();
            var ids       = ProductNames.Take(30);
            var list      = northwind.Products.Where(o => ids.Contains(o.ProductName)).ToList();

            Assert.AreEqual(30, list.Count);
        }
Ejemplo n.º 8
0
 public Product GetProductByName(ProductNames productName)
 {
     if (!Products.ContainsKey(productName.ToString()))
     {
         throw new KatushaProductNameNotFoundException(productName.ToString());
     }
     return(Products[productName.ToString()]);
 }
Ejemplo n.º 9
0
        private bool IsDuplicateName()
        {
            var query = ProductNames.GroupBy(x => x.Name.Trim().ToUpper())
                        .Where(g => g.Count() > 1)
                        .Select(y => y.Key)
                        .ToList();

            return(query.Count > 0);
        }
Ejemplo n.º 10
0
 private void ProductNames_ItemPropertyChanged(object sender, ItemPropertyChangedEventArgs e)
 {
     if (e.PropertyName != "IsChecked")
     {
         CheckValidation();
         isdirty = true;
     }
     IsSelected = ProductNames.Where(x => x.IsChecked).Count() > 0;
 }
Ejemplo n.º 11
0
 private void ExecuteAddNew(object parameter)
 {
     ProductNames.Add(new ModelBaseVM()
     {
         Name = string.Empty, IsEnabled = true, IsChecked = false
     });
     ScrollToIndex = ProductNames.Count() - 1;
     CheckValidation();
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Get the ProductDetails
 /// </summary>
 private void GetProductDetails()
 {
     for (int i = 0; i < 40; i++)
     {
         ProductInfoModel p = new ProductInfoModel();
         p.ProductName = ProductNames[r.Next(ProductNames.Count() - 1)];
         p.Year2008    = r.Next(100, 300);
         p.Year2009    = r.Next(400, 600);
         this.productDetails.Add(p);
     }
 }
Ejemplo n.º 13
0
        public static Product CreateProduct(ProductNames ProductName, String name, int id, double price, String picture, String issue)
        {
            Product product = null;

            switch (ProductName)
            {
            case ProductNames.Magazine:
                product = new Magazine(name, id, price, picture, issue);
                break;

            case ProductNames.MusicCD:
                product = new MusicCD(name, id, price, picture, issue);
                break;

            case ProductNames.Book:
                product = new Book(name, id, price, picture, issue);
                break;

            default:
                break;
            }

            return(product);
        }
Ejemplo n.º 14
0
 public Product GetProductByName(ProductNames productName)
 {
     if (!Products.ContainsKey(productName.ToString()))
         throw new KatushaProductNameNotFoundException(productName.ToString());
     return Products[productName.ToString()];
 }
Ejemplo n.º 15
0
        private void LoadProduct(ProductNames ProductName, string category)
        {
            switch (ProductName)
            {
            case ProductNames.All:
                foreach (Product item in products)
                {
                    currentProducts.Add(item);
                    ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                    flPanel.Controls.Add(productPanel);
                }
                break;

            case ProductNames.Magazine:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is Magazine)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadMagazine(category);
                }
                break;

            case ProductNames.MusicCD:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is MusicCD)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadMusicCD(category);
                }
                break;

            case ProductNames.Book:
                if (category == "All")
                {
                    foreach (Product item in products)
                    {
                        if (item is Book)
                        {
                            currentProducts.Add(item);
                            ProductPanel productPanel = ProductPanelCreator.CreatePanel(item);
                            flPanel.Controls.Add(productPanel);
                        }
                    }
                }
                else
                {
                    LoadBooks(category);
                }
                break;

            default:
                break;
            }
        }
 public KatushaNeedsPaymentException(User user, ProductNames product)
     : base("NeedsPayment", "Katusha needs payment, sorry", null)
 {
     User = user;
     Product = product;
 }
Ejemplo n.º 17
0
        public static IHtmlString DisplayProductData <TModel>(this HtmlHelper <TModel> htmlHelper, ProductNames productName)
        {
            var product = ProductService.GetProductByName(productName);
            var result  = "<b>" + product.Name + "</b> for <b>$" + product.Amount + "</b>";

            return(htmlHelper.Raw(result));
        }
 public KatushaNeedsPaymentButUserEmptyException(ProductNames product)
     : base("NeedsPayment", "Katusha needs payment, sorry", null)
 {
     Product = product;
 }
 public KatushaNeedsPaymentException(User user, ProductNames product)
     : base("NeedsPayment", "Katusha needs payment, sorry", null)
 {
     User    = user;
     Product = product;
 }
Ejemplo n.º 20
0
        private bool IsNameMissing()
        {
            int nummissing = ProductNames.Where(x => string.IsNullOrEmpty(x.Name.Trim())).Count();

            return(nummissing > 0);
        }
 public KatushaNeedsPaymentButUserEmptyException(ProductNames product)
     : base("NeedsPayment", "Katusha needs payment, sorry", null)
 {
     Product = product;
 }
Ejemplo n.º 22
0
 public void AddName(int id, string name)
 {
     ProductNames.Add(id, name);
 }