示例#1
0
 public Product CreateProduct(string name, int classId)
 {
     using (var cc = new CustomersContext())
     {
         Product product = cc.Products.FirstOrDefault(p => p.Name == name && p.ClassId == classId);
         if (product == null)
         {
             ProductClass productClass = cc.ProductClasses.FirstOrDefault(c => c.Id == classId);
             if (productClass != null)
             {
                 product = cc.Products.Add(new Product()
                 {
                     Name    = name,
                     ClassId = productClass.Id
                 });
             }
             else
             {
                 product = cc.Products.Add(new Product()
                 {
                     Name    = name,
                     ClassId = NonClassifiedProductsClassId
                 });
             }
             cc.SaveChanges();
         }
         return(product);
     }
 }
        private void ShowAllProducts()
        {
            List <ProductClass> productList = new List <ProductClass>();

            SqlConnection connection = new SqlConnection(connectionString);

            string query = "SELECT * FROM Product_tbl";

            SqlCommand command = new SqlCommand(query, connection);

            connection.Open();
            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                int    productId    = (int)reader["ProductId"];
                string productName  = reader["ProductName"].ToString();
                string productCode  = reader["ProductCode"].ToString();
                double productPrice = (double)reader["ProductPrice"];
                string mfgDate      = reader["ProductMfgDate"].ToString();
                string expDate      = reader["ProductExpDate"].ToString();

                ProductClass product = new ProductClass(productName, productCode, productPrice, mfgDate, expDate);
                product.ProductId = productId;
                productList.Add(product);
            }
            reader.Close();
            connection.Close();
            productListGridView.DataSource = productList;
            productListGridView.DataBind();
        }
示例#3
0
        /// <summary>
        /// 查看单个商品
        /// </summary>
        /// <param name="nID"></param>
        /// <returns></returns>
        public Product Get_SingProduct(int nID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ID", SqlDbType.Int, 4, nID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_SingProduct", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            Product product = new Product();

            while (rec.Read())
            {
                ProductClass    productClass    = new ProductClass();
                ProductClassSQL productClassSQL = new ProductClassSQL();
                productClass         = productClassSQL.Get_SingProductClass(Int32.Parse(rec["ClassID"].ToString()));
                product.productClass = productClass;
                product.ID           = Int32.Parse(rec["ID"].ToString());
                product.Pro_Name     = rec["Pro_Name"].ToString();
                product.Pic          = rec["Pic"].ToString();
                product.Content      = rec["Content"].ToString();
                product.Updatatime   = DateTime.Parse(rec["Updatatime"].ToString());
                product.Click        = Int32.Parse(rec["Click"].ToString());
            }
            return(product);
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            string productName  = inputProductName.Value;
            string productCode  = inputProductCode.Value;
            double productPrice = Convert.ToDouble(inputProductPrice.Value);
            string mfgDate      = inputProductMfgDate.Value;
            string expDate      = inputProductExpDate.Value;

            ProductClass product = new ProductClass(productName, productCode, productPrice, mfgDate, expDate);

            int rowEffect = InsertProductInfo(connectionString, product);

            if (rowEffect > 0)
            {
                msgLabel.Text      = String.Empty;
                msgLabel.Text      = "Data saved successfully";
                msgLabel.ForeColor = Color.Green;
                ClearAllFields();
            }
            else
            {
                msgLabel.Text      = String.Empty;
                msgLabel.Text      = "Failed to save";
                msgLabel.ForeColor = Color.Red;
                ClearAllFields();
            }
        }
示例#5
0
        public void Add(ProductClass cat)
        {
            var Cmd = _context.CreateCommand();

            cat.DateCreated = DateTime.UtcNow;
            cat.Slug        = "";

            Cmd.CommandText = "INSERT INTO [dbo].[ProductClass]([Id],[Name],[Description],[IsLocked],[Slug],[Colour],[Image],[DateCreated])"
                              + " VALUES(@Id,@Name,@Description,@IsLocked,@Slug,@Colour,@Image,@DateCreated)";

            Cmd.Parameters.Add("Id", SqlDbType.UniqueIdentifier).Value = cat.Id;
            Cmd.AddParameters("Name", cat.Name);
            Cmd.AddParameters("Description", cat.Description);
            Cmd.AddParameters("IsLocked", cat.IsLocked);
            Cmd.AddParameters("Slug", cat.Slug);
            Cmd.AddParameters("Colour", cat.Colour);
            Cmd.AddParameters("Image", cat.Image);
            Cmd.AddParameters("DateCreated", cat.DateCreated);

            bool rt = Cmd.command.ExecuteNonQuery() > 0;

            Cmd.cacheStartsWithToClear(CacheKeys.Product.ProductClass);
            Cmd.Close();

            if (!rt)
            {
                throw new Exception("Add ProductAttribute false");
            }
        }
示例#6
0
        public ClassCtrl(string _acc, string ClassID)
        {
            Account = _acc;
            string    str = "select * from ProductClass where ParentID=''";
            DataTable dt  = db.getTable(str, Account);

            ParentClassList = CommonTools.TableToList <ProductClass>(dt);
            string    strsql = "select * from ProductClass where SID='" + ClassID + "'";
            DataTable dt1    = db.getTable(strsql, Account);

            if (dt1 != null && dt1.Rows.Count > 0)
            {
                DataRow dr = dt1.Rows[0];
                ProductClass           = new ProductClass();
                ProductClass.SID       = dr["SID"].ToString();
                ProductClass.ClassName = dr["ClassName"].ToString();
                ProductClass.ParentID  = dr["ParentID"].ToString();
                ProductClass.ID        = int.Parse(dr["ID"].ToString());
                Code = "0000";
                Msg  = "成功";
            }
            else
            {
                ProductClass = new ProductClass();
                Code         = "0001";
                Msg          = "未查到该类别";
            }
        }
示例#7
0
        public void Update(ProductClass cat)
        {
            cat.Slug = "";

            var Cmd = _context.CreateCommand();

            //Cmd.CommandText = "IF NOT EXISTS (SELECT * FROM [Topic] WHERE [Id] = @Id)";
            Cmd.CommandText = "UPDATE [dbo].[ProductClass] SET [Name] = @Name,[Description] = @Description,[IsLocked] = @IsLocked,[Slug] = @Slug,[Colour] = @Colour,[Image] = @Image,[DateCreated] = @DateCreated WHERE [Id] = @Id";

            Cmd.Parameters.Add("Id", SqlDbType.UniqueIdentifier).Value = cat.Id;
            Cmd.AddParameters("Name", cat.Name);
            Cmd.AddParameters("Description", cat.Description);
            Cmd.AddParameters("IsLocked", cat.IsLocked);
            Cmd.AddParameters("Slug", cat.Slug);
            Cmd.AddParameters("Colour", cat.Colour);
            Cmd.AddParameters("Image", cat.Image);
            Cmd.AddParameters("DateCreated", cat.DateCreated);

            bool ret = Cmd.command.ExecuteNonQuery() > 0;

            Cmd.Close();

            if (!ret)
            {
                throw new Exception("Update ProductClass false");
            }
        }
示例#8
0
        private void ProductList_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (Control cntrl in panelProductTypeView.Controls)
            {
                panelProductTypeView.Controls.Remove(cntrl);
            }

            if (ProductList.SelectedRows.Count != 0)
            {
                DataGridViewRow dgv             = ProductList.SelectedRows[0];
                ProductClass    selectedProduct = DisplayProductTable.Where(f => f.ID == int.Parse(dgv.Cells["ID"].Value.ToString())).FirstOrDefault();

                switch (selectedProduct.Type)
                {
                case ProductType.Call:
                    ucCallDetails CallDetails = new ucCallDetails(selectedProduct);
                    panelProductTypeView.Controls.Add(CallDetails);
                    break;

                case ProductType.SMS:
                    ucSMSDetails SMSDetails = new ucSMSDetails(selectedProduct);
                    panelProductTypeView.Controls.Add(SMSDetails);
                    break;
                }
            }
        }
示例#9
0
        private Dictionary <ProductClass, SortedDictionary <DateTime, int> > calculateMonthsSummary(List <Order> orderList)
        {
            Dictionary <ProductClass, SortedDictionary <DateTime, int> > productsMonthsSummary = new Dictionary <ProductClass, SortedDictionary <DateTime, int> >();


            foreach (Order order in orderList)
            {
                DateTime monthNumber = getMonthNumber(order.OrderDeliveryDate);

                foreach (PriceTable priceTableRow in order.OrderProductsList)
                {
                    ProductClass product = priceTableRow.Product;
                    SortedDictionary <DateTime, int> monthsSummary;

                    bool productExist = productsMonthsSummary.TryGetValue(priceTableRow.Product, out monthsSummary);

                    if (!productExist)
                    {
                        productsMonthsSummary.Add(product, monthsSummary = new SortedDictionary <DateTime, int>());
                    }

                    monthsSummary = updateMonthsSummry(monthsSummary, monthNumber, priceTableRow.Amount);
                    productsMonthsSummary[product] = monthsSummary;
                }
            }
            return(productsMonthsSummary);
        }
        public IHttpActionResult GetAllProducts(string id)
        {
            ProductClass product = null;

            using (var ctx = new EasyBillingEntities())
            {
                product = ctx.Products.Where(x => x.Token_Number == id).Select(s => new ProductClass()
                {
                    Token_Number = s.Token_Number,
                    Product_Code = s.Product_Code,
                    Product_name = s.Product_name,
                    Description  = s.Description,
                    Tax_rate     = s.Tax_rate,
                    txgrp        = (from a in ctx.Tax_Groups
                                    where a.GL_CODE == s.GL_CODE
                                    select a.Tax_Name).Distinct().FirstOrDefault(),
                    HSN_SAC_Code = s.HSN_SAC_Code,
                    GL_CODE      = s.GL_CODE,
                    IsActive     = s.IsActive,
                }).FirstOrDefault();
            }


            if (product == null)
            {
                return(NotFound());
            }

            return(Ok(product));
        }
示例#11
0
        public async Task <bool> EditAsync(ProductClass model)
        {
            this._repository.Update(model);
            int result = await _unitOfWork.SaveChangesAsync();

            return(result > 0);
        }
示例#12
0
        public int SaveProduct([FromBody] ProductClass productForm)
        {
            int answer = 0;

            try
            {
                using (FacturacionContext db = new FacturacionContext())
                {
                    using (var transaccion = new TransactionScope())
                    {
                        Product productModel = new Product();
                        productModel.DateCreated = DateTime.Now;
                        productModel.Name        = productForm.name;
                        productModel.Price       = productForm.price;
                        productModel.Stock       = productForm.stock;
                        db.Add(productModel);
                        db.SaveChanges();
                        transaccion.Complete();
                        answer = 1;
                    }
                }
            }
            catch (Exception)
            {
                answer = 2;
            }
            return(answer);
        }
示例#13
0
        public ProductClass CreateProductClass(string name, string shortName = null, int?parentId = null)
        {
            if (name != null)
            {
                using (var cc = new CustomersContext())
                {
                    ProductClass productClass = new ProductClass()
                    {
                        Name      = name,
                        ShortName = shortName
                    };

                    if (parentId != null)
                    {
                        ProductClass parentClass = cc.ProductClasses.FirstOrDefault(c => c.Id == parentId);
                        if (parentClass != null)
                        {
                            productClass.ParentId = parentClass.Id;
                        }
                    }
                    productClass = cc.ProductClasses.Add(productClass);
                    cc.SaveChanges();
                    return(productClass);
                }
            }
            return(null);
        }
示例#14
0
        public async Task <int> EditOneAsync(ProductClass productClass)
        {
            _context.ProductClass.Update(productClass);
            int result = await _context.SaveChangesAsync();

            return(result);
        }
示例#15
0
        public async Task <int> DeleteOneAsync(ProductClass productClass)
        {
            _context.ProductClass.Remove(productClass);
            int result = await _context.SaveChangesAsync();

            return(result);
        }
示例#16
0
        public async Task <int> AddAsync(ProductClass productClass)
        {
            _context.ProductClass.Add(productClass);
            int result = await _context.SaveChangesAsync();

            return(result);
        }
示例#17
0
        public static void getProductClassesFromTemp()
        {
            List <string> pClasses = getProductClassesStrings();

            foreach (var item in pClasses)
            {
                // TODO не создавать одинаковые тэги
                //Console.WriteLine("Input: ");
                //string str = Console.ReadLine();
                //Console.WriteLine("ParentId: ");
                //int? parent = Convert.ToInt32(Console.ReadLine());
                string[]               parts = item.Split(':');
                string                 name  = parts[0].Split('"')[1];
                List <string>          tags  = parts[1].Split('"').Where((it, index) => index % 2 != 0).ToList();
                ProductClassRepository productClassRepository = new ProductClassRepository();
                ProductClass           productClass           = productClassRepository.CreateProductClass(name, null, null);
                TagRepository          tagRepository          = new TagRepository();
                ClassTagRepository     classTagRepository     = new ClassTagRepository();
                if (tags.Any())
                {
                    foreach (var tagName in tags)
                    {
                        Tag      tag      = tagRepository.CreateTag(tagName);
                        ClassTag classTag = classTagRepository.CreateClassTag(productClass.Id, tag.Id);
                    }
                }
            }
        }
示例#18
0
        private static ProductClassList GenerateProductTree(ProductClassList productClassList)
        {
            ProductClassList productList = new ProductClassList();

            foreach (ProductClass product in productClassList.ProductList)
            {
                Dictionary <string, int>       initProductTree = product.InitProductTree;
                Dictionary <ProductClass, int> productTree     = new Dictionary <ProductClass, int>();

                foreach (KeyValuePair <string, int> initTreeBranch in initProductTree)
                {
                    ProductClass productSon = productClassList.GetProduct(initTreeBranch.Key);
                    if (productSon == null)
                    {
                        MessageBox.Show("Error: Product tree Incorrect", "Error");
                        return(null);
                    }
                    else
                    {
                        productTree.Add(productSon, initTreeBranch.Value);
                    }
                }
                product.ProductTree = productTree;
                productList.AddProduct(product);
            }
            return(productList);
        }
        public List <ProductClass> GetProductClassList(int id)
        {
            List <ProductClass> productClassList = new List <ProductClass>();

            string[] tableNames = new string[1];
            Dictionary <string, object> cmdParams = new Dictionary <string, object>();

            cmdParams.Add("@ID", id);

            DataSet ds = dbRepo.ExecuteProcedure("GetProductClass", 0, tableNames, cmdParams);

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    ProductClass pc = new ProductClass()
                    {
                        ID          = Convert.ToInt32(ds.Tables[0].Rows[i]["ID"]),
                        ClassName   = Convert.ToString(ds.Tables[0].Rows[i]["ClassName"]),
                        Description = Convert.ToString(ds.Tables[0].Rows[i]["Description"])
                    };
                    productClassList.Add(pc);
                }
            }
            return(productClassList);
        }
示例#20
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 24, Configuration.FieldSeparator),
                       Id,
                       ImplicatedProduct?.ToDelimitedString(),
                       GenericProduct,
                       ProductClass?.ToDelimitedString(),
                       TotalDurationOfTherapy?.ToDelimitedString(),
                       ProductManufactureDate.HasValue ? ProductManufactureDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProductExpirationDate.HasValue ? ProductExpirationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProductImplantationDate.HasValue ? ProductImplantationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       ProductExplantationDate.HasValue ? ProductExplantationDate.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       SingleUseDevice,
                       IndicationForProductUse?.ToDelimitedString(),
                       ProductProblem,
                       ProductSerialLotNumber != null ? string.Join(Configuration.FieldRepeatSeparator, ProductSerialLotNumber) : null,
                       ProductAvailableForInspection,
                       ProductEvaluationPerformed?.ToDelimitedString(),
                       ProductEvaluationStatus?.ToDelimitedString(),
                       ProductEvaluationResults?.ToDelimitedString(),
                       EvaluatedProductSource,
                       DateProductReturnedToManufacturer.HasValue ? DateProductReturnedToManufacturer.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       DeviceOperatorQualifications,
                       RelatednessAssessment,
                       ActionTakenInResponseToTheEvent != null ? string.Join(Configuration.FieldRepeatSeparator, ActionTakenInResponseToTheEvent) : null,
                       EventCausalityObservations != null ? string.Join(Configuration.FieldRepeatSeparator, EventCausalityObservations) : null,
                       IndirectExposureMechanism != null ? string.Join(Configuration.FieldRepeatSeparator, IndirectExposureMechanism) : null
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
示例#21
0
        public async Task <ResponseModel> Add([FromBody] ProductClass productClass)
        {
            if (ModelState.IsValid)
            {
                var result = await _productClassService.AddAsync(productClass);

                if (result > 0)
                {
                    return new ResponseModel {
                               code = 200, result = "产品添加成功"
                    }
                }
                ;
                return(new ResponseModel {
                    code = 0, result = "产品添加失败"
                });
            }
            else
            {
                string errorMsg = "参数验证失败";
                if (ModelState.ErrorCount > 0)
                {
                    foreach (var key in ModelState.Keys)
                    {
                        errorMsg += ModelState.GetValidationState(key) + "|";
                    }
                    errorMsg.TrimEnd('|');
                }
                return(new ResponseModel
                {
                    code = 400,
                    result = errorMsg
                });
            }
        }
示例#22
0
        // GET: Shop
        public ActionResult Index()
        {
            var            product    = new ProductClass();
            List <Product> allCatalog = null;

            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                var data   = "=" + User.Identity.Name;
                var result = client.UploadString("https://localhost:44362/api/UserApi/GetUserRole", "POST", data);
                product.UserRole = result;
            }

            using (var client = new HttpClient())
            {
                var task = client.GetAsync("https://localhost:44362/api/ShopApi/GetProducts").ContinueWith(
                    taskwithresponse =>
                {
                    var response   = taskwithresponse.Result;
                    var jsonString = response.Content.ReadAsStringAsync();
                    jsonString.Wait();
                    allCatalog = JsonConvert.DeserializeObject <List <Product> >(jsonString.Result);
                }
                    );
                task.Wait();
                product.Products = allCatalog;
            }


            return(View(product));
        }
示例#23
0
        public void Remove(string obj)
        {
            for (int i = 0; i < count; ++i)
            {
                if (array[i] == obj)
                {
                    ProductClass[] temp = new ProductClass[count - 1];
                    for (int j = 0; j < count; ++j)
                    {
                        if (j < i)
                        {
                            temp[j] = array[j];
                        }
                        else
                        {
                            temp[j] = array[j + 1];
                        }
                    }
                    --count;

                    array = new ProductClass[count];
                    for (int j = 0; j < count; ++j)
                    {
                        array[j] = temp[j];
                    }
                }
            }
        }
示例#24
0
        /// <summary>
        /// 查看分类
        /// </summary>
        /// <param name="nParentID"></param>
        /// <returns></returns>
        public List <ProductClass> Get_ProductClass(int nParentID)
        {
            SQLHelper.SQLHelper sqlHelper = new SQLHelper.SQLHelper();
            SqlParameter[]      ParamList =
            {
                sqlHelper.CreateInParam("@ParentID", SqlDbType.Int, 4, nParentID)
            };
            SqlDataReader rec = null;

            try
            {
                sqlHelper.RunProc("Get_ProductClass", ParamList, out rec);
            }
            catch (Exception ex)
            {
                SystemError.CreateErrorLog(ex.Message);
                throw new Exception(ex.Message, ex);
            }
            List <ProductClass> List_ProductClass = new List <ProductClass>();

            while (rec.Read())
            {
                Model.ProductClass productClass = new ProductClass();
                productClass.ClassID     = Int32.Parse(rec["ClassID"].ToString());
                productClass.ClassName   = rec["ClassName"].ToString();
                productClass.ParentID    = Int32.Parse(rec["ParentID"].ToString());
                productClass.ParentOrder = Int32.Parse(rec["ParentOrder"].ToString());
                List_ProductClass.Add(productClass);
                productClass = null;
            }
            return(List_ProductClass);
        }
示例#25
0
        private DataTable generateDataTableForProduct(ProductClass product)
        {
            DataTable suppliersListForProduct = new DataTable();

            foreach (SuppliersListForProductTableColumnsNames columnName in Enum.GetValues(typeof(SuppliersListForProductTableColumnsNames)))
            {
                suppliersListForProduct.Columns.Add(columnName.ToString());
            }

            foreach (Supplier supplier in suppliersList.SupplierList)
            {
                foreach (PriceMatrixStruct ps in supplier.PriceMatrix)
                {
                    if (ps.product.Equals(product))
                    {
                        DataRow dRow = suppliersListForProduct.NewRow();
                        dRow[SuppliersListForProductTableColumnsNames.Supplier_Name.ToString()]        = supplier.Name;
                        dRow[SuppliersListForProductTableColumnsNames.Supplier_ID.ToString()]          = supplier.ID;
                        dRow[SuppliersListForProductTableColumnsNames.Supplier_Reliability.ToString()] = supplier.Reliability;
                        dRow[SuppliersListForProductTableColumnsNames.Price.ToString()]     = ps.UnitPrice;
                        dRow[SuppliersListForProductTableColumnsNames.Lead_Time.ToString()] = ps.LeadTime;
                        suppliersListForProduct.Rows.Add(dRow);
                    }
                }
            }
            return(suppliersListForProduct);
        }//end generateDataTableForProduct
示例#26
0
        public void ShouldGetAllDescendants()
        {
            string wine               = "Вино";
            string redWine            = "Красное вино";
            string whiteWine          = "Белое вино";
            string redDryWine         = "Красное сухое вино";
            string whiteDryWine       = "Белое сухое вино";
            string redSemisweetWine   = "Красное полусладкое вино";
            string whiteSemisweetWine = "Белое полусладкое вино";
            string redSweetWine       = "Красное сладкое вино";
            string whiteSweetWine     = "Белое сладкое вино";

            ProductClassRepository repo = new ProductClassRepository();
            //repo.CreateProductClass(wine, null, null);
            ProductClass parent = repo.GetProductClass(wine);

            //repo.CreateProductClass(redWine, null, parent.Id);
            //repo.CreateProductClass(whiteWine, null, parent.Id);
            //parent = repo.GetProductClass(redWine);
            //repo.CreateProductClass(redDryWine, null, parent.Id);
            //repo.CreateProductClass(redSemisweetWine, null, parent.Id);
            //repo.CreateProductClass(redSweetWine, null, parent.Id);
            //parent = repo.GetProductClass(whiteWine);
            //repo.CreateProductClass(whiteDryWine, null, parent.Id);
            //repo.CreateProductClass(whiteSemisweetWine, null, parent.Id);
            //repo.CreateProductClass(whiteSweetWine, null, parent.Id);
            parent = repo.GetProductClass(wine);

            repo.GetProductClassDescendants(parent.Id);
        }
示例#27
0
        public ActionResult <string> SetData(ProductClassModifyModel data)
        {
            var newData = new ProductClass()
            {
                ProductClassID   = data.ProductClassID,
                ProductTypeID    = data.ProductTypeID,
                ProductClassName = data.ProductClassName,
                OrderID          = data.OrderID
            };

            try
            {
                if (repository.SaveData(newData))
                {
                    return(ActionResult <string> .SetSuccess($"保存 {ItemName} 成功", "保存成功"));
                }
                else
                {
                    return(ActionResult <string> .SetError($"{ItemName} 已经被删除", "保存失败"));
                }
            }
            catch (Exception ex)
            {
                return(ActionResult <string> .SetError(ex.Message, "保存失败"));
            }
        }
示例#28
0
        static void Main(string[] args)
        {
            string name;
            double price;
            double discount;

            ProductClass[] product = new ProductClass[2];

            for (int i = 0; i < 2; i++)
            {
                Console.WriteLine("Введите наименование первого продукта: ");
                name = Console.ReadLine();

                Console.WriteLine("Введите цену продукта: ");
                price = Double.Parse(Console.ReadLine());

                Console.WriteLine("Введите скидку на товар (%): ");
                discount = Double.Parse(Console.ReadLine());

                product[i] = new ProductClass(name, price, discount);
            }

            Console.WriteLine("Стоимость первого товара с учетом скидки {0}", product[0].PriceDiscount());
            Console.WriteLine("Стоимость второго товара с учетом скидки {0}", product[1].PriceDiscount());
            Console.WriteLine("Общая стоимость двух товаров равна {0}", product[0] + product[1]);



            Console.ReadKey();
        }
示例#29
0
        public async Task Get()
        {
            SplitRuleItem srp = null;
            ProductClass  pc  = null;

            using (var unitOfWork = this._context.ResolveService <IUnitOfWorkManager>().Begin())
            {
                var tlc = await this._context.ResolveService <IRepository <TenantLogisticChannel, long> >().GetAll().IgnoreQueryFilters()
                          .Include(p => p.LogisticChannelBy).ThenInclude(p => p.SplitRules).ThenInclude(p => p.ProductClasses)
                          .Include(p => p.LogisticChannelBy).ThenInclude(p => p.LogisticBy).FirstAsync(o => o.TenantId == this._context.GetTenantId());

                srp = tlc.LogisticChannelBy.SplitRules.First().ProductClasses.First();
                pc  = await this._context.ResolveService <IRepository <ProductClass, long> >().GetAll()
                      .FirstAsync(o => o.PTId.Equals(srp.StintMark));
            }
            srp.ShouldNotBeNull();
            var result = await this._service.Get(new Abp.Application.Services.Dto.EntityDto <long>(srp.Id));

            result.RuleName.ShouldBe(srp.SplitRuleBy.RuleName);
            result.StintMark.ShouldBe(srp.StintMark);
            result.ProductClass.ShouldBe(string.Format("{0}({1})", pc.ClassName, pc.PTId));
            result.MaxNum.ShouldBe(srp.MaxNum);
            result.MinNum.ShouldBe(srp.MinNum);
            result.Type.ShouldBe(srp.Type);
            result.TenantId.ShouldBe(srp.TenantId);
        }
示例#30
0
        public ActionResult DeleteConfirmed(int id)
        {
            ProductClass productClass = db.ProductClasses.Find(id);

            db.ProductClasses.Remove(productClass);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#31
0
    static public FixedList<ProductGroup> GetProductGroups(ProductClass productTerm) {
      string sql = "SELECT * FROM PLMProductGroups INNER JOIN PLMProductGroupRules ";
      sql += "ON PLMProductGroups.ProductGroupId = PLMProductGroupRules.ProductGroupId ";
      sql += "WHERE PLMProductGroupRules.ProductTypeId = " + productTerm.Id.ToString() + " AND ";
      sql += "PLMProductGroupRules.ProductGroupRuleStatus <> 'X' AND PLMProductGroups.ProductGroupStatus <> 'X' ";
      sql += "ORDER BY PLMProductGroups.ProductGroupName";

      return DataReader.GetList<ProductGroup>(DataOperation.Parse(sql),
                                              (x) => BaseObject.ParseList<ProductGroup>(x)).ToFixedList();

    }
示例#32
0
        public static void GetProductAttributesFromRemoteAndSaveToLocal(DateTime? localUpdate, DateTime? remoteUpdate,LoadingPage loadingPage)
        {
            var productQuery = ParseObject.GetQuery (ParseConstants.PRODUCTS_CLASS_NAME).
                WhereGreaterThan(ParseConstants.UPDATEDATE_NAME,localUpdate).
                WhereLessThanOrEqualTo(ParseConstants.UPDATEDATE_NAME,remoteUpdate);

            var productCount = productQuery.CountAsync().Result;

            int queryLimit = 1000;
            int j = 0;
            //DateTime startG = DateTime.Now;
            List<ProductClass> tempList = new List<ProductClass> ();
            for (int i = 0; i < productCount; i += queryLimit) {
                //DateTime start = DateTime.Now;
                var productObjects = productQuery.Limit(queryLimit).Skip(i).FindAsync ().Result;
                //TimeSpan delta = start - DateTime.Now;
                //System.Diagnostics.Debug.WriteLine ("delta time:" + delta.TotalMilliseconds.ToString());

                foreach (var productObject in productObjects) {
                    ProductClass tempProduct = new ProductClass ();
                    tempProduct.objectId = productObject.ObjectId;
                    tempProduct.Name = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_NAME);
                    tempProduct.ImageName = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_IMAGENAME);
                    tempProduct.ImageID = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_IMAGEID);
                    tempProduct.CategoryId = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_CATEGORYID);
                    tempProduct.Price = new Decimal(productObject.Get<double> (ParseConstants.PRODUCT_ATTRIBUTE_PRICE));
                    tempProduct.Quantity = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_QUANTITY);
                    tempProduct.IsTopSelling = productObject.Get<bool> (ParseConstants.PRODUCT_ATTRIBUTE_ISTOPSELLING);
                    tempProduct.Priority = productObject.Get<int> (ParseConstants.PRODUCT_ATTRIBUTE_PRIORITY);
                    tempProduct.IsInStock = productObject.Get<bool> (ParseConstants.PRODUCT_ATTRIBUTE_ISINSTOCK);
                    /*if (tempList.Count > 152) {
                    }
                    if (productObject.Get<object> (ParseConstants.PRODUCT_ATTRIBUTE_PARENTCATEGORY) == null)
                        tempProd*uct.ParentCategory = "";
                    else*/
                        tempProduct.ParentCategory = productObject.Get<string> (ParseConstants.PRODUCT_ATTRIBUTE_PARENTCATEGORY);
                    var storeList = productObject.Get<IEnumerable<object>> (ParseConstants.PRODUCT_ATTRIBUTE_STORES).Cast<Int64>().ToList ();

                    foreach (Int64 store in storeList ) {
                        tempProduct.Stores += store.ToString ();

                        if (store != storeList.Last ())
                            tempProduct.Stores += ",";
                    }

                    tempList.Add (tempProduct);

                    double scrollPos = Decimal.ToDouble (Decimal.Add(Decimal.Multiply (Decimal.Multiply (Decimal.Divide ((Decimal.Divide (1, productCount)), 10), 1), j++),new decimal(0.9f)));
                    Device.BeginInvokeOnMainThread (() => loadingPage.ProgressBar1.Progress = scrollPos);
                    //await loadingPage.ProgressBar1.ProgressTo (scrollPos, 1, Easing.Linear);
                }

            }
            mProductClass.AddProduct (tempList);
            //TimeSpan deltaG = startG - DateTime.Now;
            //System.Diagnostics.Debug.WriteLine ("delta time in general:" + deltaG.TotalMilliseconds.ToString());
            //	loadingPage.mFirstTokenSource.Cancel ();
        }