コード例 #1
0
 protected void ProductDept_SelectedIndexChanged(object sender, EventArgs e)
 {
     #region Populating Category Dropdown
     try
     {
         connection.Open();
         SqlCommand     command = new SqlCommand("Select * From tblCategory Where DepartmentID = '" + ProductDept.SelectedValue.ToString() + "'", connection);
         DataSet        ds      = new DataSet();
         SqlDataAdapter sA      = new SqlDataAdapter(command);
         sA.Fill(ds);
         ProductCat.DataSource     = ds.Tables[0];
         ProductCat.DataTextField  = "Name";
         ProductCat.DataValueField = "CategoryID";
         ProductCat.DataBind();
         if (ProductCat != null)
         {
             ProductCat.Items.Insert(0, "Select Category");
             ProductCat.SelectedIndex = 0;
         }
     }
     catch (Exception ex)
     {
     }
     finally
     {
         connection.Close();
     }
     #endregion
 }
コード例 #2
0
        public IActionResult Browse(int typeId, string typeName)
        {
            ViewBag.catalogName = typeName;

            List <ProductCat>  productCats = new List <ProductCat>();
            List <ProductList> hotProducts = new List <ProductList>();

            foreach (var pt in db.Producttype.Where <Producttype>(m => m.ObjId > 0).GroupBy <Producttype, string>(m => m.Type))
            {
                ProductCat pc = new ProductCat();
                pc.typeName = pt.Key;
                pc.types    = new List <Producttype>();
                foreach (var p in pt)
                {
                    pc.types.Add(new Producttype {
                        ObjId = p.ObjId, Type = p.Type, ClassType = p.ClassType
                    });
                }
                productCats.Add(pc);
            }
            var products = from p in db.Product where p.ProductState == 1 && (from t in db.Productclass where t.TheProductType == typeId select t.TheProduct).Contains(p.ObjId) select p;

            foreach (var p in products)
            {
                ProductList p1 = new ProductList();
                p1.p = new Product {
                    ObjId = p.ObjId, Productname = p.Productname, Product_Img = p.Product_Img, Price = p.Price
                };
                hotProducts.Add(p1);
            }
            ViewBag.productCats = productCats;
            ViewBag.catProducts = hotProducts;
            ViewBag.contBuy     = Request.Path + Request.QueryString;
            return(View());
        }
 private void BindExcise_Prod_PostingGroupCode(string Excise_PostingGroupCode, DropDownList dd_Excise_PostingGrpCode)
 {
     try
     {
         List <ProductCat> list = ProductCat.ListExcisePostingGroupCode();
         if (list != null && list.Count > 0)
         {
             dd_Excise_PostingGrpCode.DataSource     = list;
             dd_Excise_PostingGrpCode.DataTextField  = "Code";
             dd_Excise_PostingGrpCode.DataValueField = "Code";
             dd_Excise_PostingGrpCode.DataBind();
             dd_Excise_PostingGrpCode.Items.Insert(0, new ListItem("-Select-", "0"));
         }
         else
         {
             dd_Excise_PostingGrpCode.DataSource = null;
             dd_Excise_PostingGrpCode.DataBind();
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
コード例 #4
0
        public ActionResult ProductCreate(FormCollection collection)
        {
            try
            {
                int x = Convert.ToInt32(collection["Hoeveelheid"]);
                if (x == 0)
                {
                    ViewBag.Error = "Voer een getal in";
                    return(View());
                }

                ProductCat categorie = new ProductCat(collection["Categorie"]);
                productcatrepo.Insert(categorie);
                categorie = productcatrepo.getlastcategorie();
                Product product = new Product(categorie, collection["Merk"], collection["Serie"],
                                              Convert.ToInt32(collection["Typenummer"]), Convert.ToDecimal(collection["Prijs"]));
                productrepo.Insert(product);

                for (int i = 0; i < x; i++)
                {
                    Product          product2         = productrepo.getlatestproduct();
                    ProductExemplaar productexemplaar = new ProductExemplaar(product2.Id, i,
                                                                             Convert.ToString(i) + Convert.ToString(product2.Typenummer));
                    productexemplaarrepo.insert(productexemplaar);
                }

                return(RedirectToAction("ProductIndex"));
            }
            catch (Exception e)
            {
                ViewBag.Fout = e.ToString();
                return(View("Error"));
            }
        }
コード例 #5
0
        public object Update([FromBody] ProductCat obj)
        {
            var msg = new JMessage();

            try
            {
                //var data = _context.EDMSCustomer.Where(x => x.CusCode == obj.CusCode).FirstOrDefault();
                obj.UpdatedTime = DateTime.Now.Date;
                obj.UpdatedBy   = ESEIM.AppContext.UserName;
                obj.PathImg     = obj.PathImg;

                _context.ProductCats.Update(obj);
                _context.SaveChanges();

                msg.Error = false;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_SUCCESS"), CommonUtil.ResourceValue("CATEGORY_MSG_PRODUCT"));

                return(msg);
            }
            catch
            {
                msg.Error = true;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_UPDATE_FAILED"), CommonUtil.ResourceValue("CATEGORY_MSG_PRODUCT"));
                return(msg);
            }
        }
コード例 #6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ProductCategory model = new ProductCategory();
            ProductCat      pt    = CreateProductCat();

            lblResult.Text = model.InsertProductCategory(pt);
        }
 private void BindStructureCode()
 {
     try
     {
         List <ProductCat> list = ProductCat.ListStructureCode();
         if (list != null && list.Count > 0)
         {
             drpStructure.DataSource     = list;
             drpStructure.DataTextField  = "Code";
             drpStructure.DataValueField = "Code";
             drpStructure.DataBind();
             drpStructure.Items.Insert(0, new ListItem("-Select-", "0"));
             //drpStructure.SelectedIndex = Convert.ToInt32(ConfigurationManager.AppSettings["DefaultStructur"]);
         }
         else
         {
             drpStructure.DataSource = null;
             drpStructure.DataBind();
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
コード例 #8
0
        public ProductCat getlatestcategorie()
        {
            ProductCat productcat = null;

            try
            {
                using (SqlConnection connection = Connection.SQLconnection)
                {
                    string query = "SELECT * FROM PRODUCTCAT WHERE ID IN (SELECT MAX(ID) FROM PRODUCTCAT)";

                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                productcat = ProductCatFromReader(reader);
                            }
                        }
                    }
                }
                return(productcat);
            }
            catch
            {
                return(null);
            }
        }
コード例 #9
0
 private void BindProductCategory()
 {
     try
     {
         List <ProductCat> list = ProductCat.List(SessionManager.GetAgentCode(HttpContext.Current));
         if (list != null && list.Count > 0)
         {
             rpt_ProductCat.DataSource = list;
             rpt_ProductCat.DataBind();
         }
         else
         {
             rpt_ProductCat.DataSource = null;
             rpt_ProductCat.DataBind();
             //l_Error.Text = "Product Category not found.";
             l_Error.Visible = true;
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
コード例 #10
0
        public object GetItemDetail(int id)
        {
            var listCommon = _context.CommonSettings.Select(x => new { x.CodeSet, x.ValueSet });
            //ProductCat query=new ProductCat();
            var query = from ad in _context.ProductCats

                        join b in listCommon on ad.Unit equals b.CodeSet into b1
                        from b in b1.DefaultIfEmpty()
                        join c in listCommon on ad.ProductGroup equals c.CodeSet into c1
                        from c in c1.DefaultIfEmpty()
                        where ad.ProductID == id
                        select new
            {
                ProductCode  = ad.ProductCode,
                ProductName  = ad.ProductName,
                PathImg      = ad.PathImg,
                Note         = ad.Note,
                Unit         = b != null ? b.ValueSet : "Không xác định",
                ProductGroup = c != null ? c.ValueSet : "Không xác định",
            };
            ProductCat query1 = new ProductCat();

            //var a = _context.ProductCats.AsNoTracking().Single(m => m.ProductID == id);
            return(Json(query));
        }
コード例 #11
0
        public ProductCat[] GetProductsByCategory()
        {
            using (AdomdConnection conn = new AdomdConnection("DataSource = localhost; Initial Catalog = FClubCube"))
            {
                conn.Open();
                AdomdCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"SELECT
                                    [Measures].[Fact Sale Count] ON COLUMNS,
                                        {[Dim Product].[Product Id].[Product Id]*[Dim Product].[Name].[Name]*[Dim Product].[Category].[Category]*[Dim Product].[Sub Category].[Sub Category]*[Dim Product].[Sub Sub Category].[Sub Sub Category]} ON ROWS
                                    From [F Club DW]";
                AdomdDataReader   dr          = cmd.ExecuteReader();
                List <ProductCat> productCats = new List <ProductCat>();
                while (dr.Read())
                {
                    ProductCat productCat = new ProductCat
                    {
                        productID = int.Parse(dr[0].ToString()),
                        name      = dr[1].ToString(),
                        cat       = dr[2].ToString(),
                        subCat    = dr[3].ToString(),
                        subSubCat = dr[4].ToString(),
                    };

                    productCats.Add(productCat);
                }
                dr.Close();

                ProductCat[] productSubCats = productCats.ToArray();

                conn.Close();

                return(productSubCats);
            }
        }
 private void BindNoSeriesCodeLocationWise(string Code)
 {
     try
     {
         List <ProductCat> list = ProductCat.ListNoseriesCodeLocationWiseData(Code);
         if (list != null && list.Count > 0)
         {
             drpNoseries.SelectedValue = list[0].NoSeries;
             //drpNoseries.DataSource = list;
             //drpNoseries.DataTextField = "Name";
             //drpNoseries.DataValueField = "Name";
             //drpNoseries.DataBind();
             //drpNoseries.Items.Insert(0, new ListItem("-Select-", "0"));
         }
         else
         {
             drpNoseries.DataSource = null;
             drpNoseries.DataBind();
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
コード例 #13
0
        public JsonResult CreateProccess(ProductCatCRUD model)
        {
            rs r;

            try
            {
                var entity = new ProductCat();
                entity.Name = model.Name;

                //entity.ParentId = (model.ParentId == -1) ? null : model.ParentId;
                entity.Description = model.Description;

                entity.QuanId = model.QuanId;
                if (string.IsNullOrWhiteSpace(model.ImageThumbnail))
                {
                    entity.ImageThumbnail = "/Content/images/sample/menu1.png";
                }
                else
                {
                    entity.ImageThumbnail = model.ImageThumbnail;
                }
                __db.ProductCat.Add(entity);
                __db.SaveChanges();
                r = rs.T("Ok");
            }
            catch (Exception ex)
            {
                r = rs.F(ex.Message);
            }
            return(Json(r, JsonRequestBehavior.DenyGet));
        }
    private void BindLocationCode()
    {
        try
        {
            List <ProductCat> list = ProductCat.ListLocationCode(hf_ShiptoCode.Value, Convert.ToString(Session["userName"]), hf_SelltoCustomerNo.Value);
            if (list != null && list.Count > 0)
            {
                drplocationcode.DataSource     = list;
                drplocationcode.DataTextField  = "Name";
                drplocationcode.DataValueField = "Code";
                drplocationcode.DataBind();
                drplocationcode.Items.Insert(0, new ListItem("-Select-", "0"));

                List <ProductCat> list1 = ProductCat.DefaultLocationCode(Convert.ToString(Request["OrderNo"].ToString()));

                if (list1.Count > 0)
                {
                    drplocationcode.SelectedValue = (list1[0].Code);
                    BindNoSeriesCodeLocationWise(Convert.ToString(list1[0].Code));
                    SelectDefaultStructure(drplocationcode.SelectedValue);
                }
            }
            else
            {
                drplocationcode.DataSource = null;
                drplocationcode.DataBind();
            }
        }
        catch (Exception ex)
        {
            var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
            var script  = string.Format("alert({0});", message);
            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
        }
    }
コード例 #15
0
        public List <ProductCat> GetByProductCat(ProductCat productCat)
        {
            List <ProductCat> productCats = new List <ProductCat>();

            try
            {
                using (SqlConnection connection = Connection.SQLconnection)
                {
                    string query = "SELECT * FROM productcat WHERE productcat_id = @id";

                    using (SqlCommand command = new SqlCommand(query, connection))
                    {
                        command.Parameters.AddWithValue("id", productCat.Id);
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                productCats.Add(ProductCatFromReader(reader));
                            }
                        }
                    }
                }
                return(productCats);
            }
            catch
            {
                return(null);
            }
        }
 private void BindStructureCode()
 {
     try
     {
         List <ProductCat> list = ProductCat.ListStructureCode();
         if (list != null && list.Count > 0)
         {
             drpStructure.DataSource     = list;
             drpStructure.DataTextField  = "Code";
             drpStructure.DataValueField = "Code";
             drpStructure.DataBind();
             drpStructure.Items.Insert(0, new ListItem("-Select-", "0"));
             // drpStructure.SelectedIndex = Convert.ToInt32(ConfigurationManager.AppSettings["DefaultStructur"]);
         }
         else
         {
             drpStructure.DataSource = null;
             drpStructure.DataBind();
         }
     }
     catch (Exception ex)
     {
         l_Error.Text    = ex.Message;
         l_Error.Visible = true;
     }
 }
コード例 #17
0
        private ProductCat CreateProductCat()
        {
            ProductCat p = new ProductCat();

            p.ProductCatName = txtCat.Text;

            return(p);
        }
コード例 #18
0
        public ActionResult Kids()
        {
            var model = new ProductCat();

            model.Products = ProductServices.Instance.GetKids();

            return(View(model));
        }
コード例 #19
0
 public static ProductCatViewModel ConvertProductCatToViewModel(ProductCat cat, IEnumerable <Product> products)
 {
     return(new ProductCatViewModel()
     {
         Id = cat.Id,
         Naam = cat.Naam,
         Products = ConvertProductToViewModelList(products)
     });
 }
コード例 #20
0
 public static DanhMucSanPham map(ProductCat item)
 {
     return(new DanhMucSanPham()
     {
         HinhAnh = Utils.site + item.ImageThumbnail,
         TenDanhMuc = item.Name,
         ID = item.Id,
     });
 }
コード例 #21
0
ファイル: ProductCategory.cs プロジェクト: JiaMazlee/CO5027
        public string InsertProductCategory(ProductCat ProductCat)
        {
            try
            {
                db_1722759_co5027_asgEntities db = new db_1722759_co5027_asgEntities();
                db.ProductCats.Add(ProductCat);
                db.SaveChanges();

                return(ProductCat.ProductCatName + " was succesfully inserted. Please Proceed to Product Page or Insert Another Product Category ");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
 private void SelectDefaultStructure(string LocationCode)
 {
     try
     {
         List <ProductCat> list = ProductCat.SelectDefaultStructure(LocationCode);
         if (list != null && list.Count > 0)
         {
             drpStructure.SelectedValue = list[0].Structure;
         }
     }
     catch (Exception ex)
     {
         var message = new JavaScriptSerializer().Serialize(ex.Message.ToString());
         var script  = string.Format("alert({0});", message);
         ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "", script, true);
     }
 }
コード例 #23
0
        public object Insert([FromBody] ProductCat obj)
        {
            var msg = new JMessage();

            try
            {
                if (_context.ProductCats.FirstOrDefault(x => x.ProductCode == obj.ProductCode) == null)
                {
                    ProductCat obj1 = new ProductCat();
                    obj1.ProductCode  = obj.ProductCode;
                    obj1.ProductName  = obj.ProductName;
                    obj1.ProductGroup = obj.ProductGroup;
                    obj1.Unit         = obj.Unit;
                    obj1.Note         = obj.Note;
                    obj1.PathImg      = obj.PathImg;
                    //obj1.ProductGroup = null;s
                    obj1.CreatedBy   = ESEIM.AppContext.UserName;
                    obj1.UpdatedBy   = null;
                    obj1.CreatedTime = DateTime.Now.Date;
                    obj1.UpdatedTime = null;
                    obj1.DeletedBy   = null;
                    obj1.DeletedTime = null;
                    obj1.IsDeleted   = true;


                    _context.ProductCats.Add(obj1);
                    _context.SaveChanges();
                    msg.Error = false;
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("CATEGORY_MSG_PRODUCT"));
                    //return msg;
                }
                else
                {
                    msg.Error = true;
                    msg.Title = String.Format(CommonUtil.ResourceValue("COM_MSG_ADD_SUCCESS"), CommonUtil.ResourceValue("CATEGORY_MSG_PRODUCT"));
                    //return msg;
                }
            }
            catch
            {
                msg.Error = true;
                //msg.Object = ex;
                msg.Title = String.Format(CommonUtil.ResourceValue("COM_ERR_ADD"));
            }
            return(msg);
        }
コード例 #24
0
        public IActionResult Catalog(int typeId, string typeName)
        {
            ViewBag.catalogName = typeName;
            //FlowerDbContext db = new FlowerDbContext();
            List <ProductCat>  productCats = new List <ProductCat>();
            List <ProductList> hotProducts = new List <ProductList>();

            foreach (var pt in db.ProductType.Where <ProductType>(m => m.ObjId > 0).GroupBy <ProductType, string>(m => m.ClassifyType))
            {
                ProductCat pc = new ProductCat();
                pc.typeName = pt.Key;
                pc.types    = new List <ProductType>();
                foreach (var p in pt)
                {
                    pc.types.Add(new ProductType {
                        ObjId = p.ObjId, ClassifyType = p.ClassifyType, TypeName = p.TypeName
                    });
                }
                productCats.Add(pc);
            }
            var products = from p in db.Product where p.ProductState == 1 && (from t in db.ProductClass where t.TheProductType == typeId select t.TheProduct).Contains(p.ObjId) select p;

            foreach (var p in products)
            {
                ProductList pl = new ProductList();
                pl.p = new Product {
                    ObjId = p.ObjId, ProductName = p.ProductName, BigImg = p.BigImg, Price = p.Price
                };
                pl.pList = new List <Prices>();
                var priceList = db.PriceList.Where <PriceList>(m => m.TheProduct == p.ObjId);
                foreach (var pclst in priceList)
                {
                    pl.pList.Add(new Prices
                    {
                        memberName = db.CustomerType.Where <CustomerType>(m => m.ObjId == pclst.TheCustomerType).First <CustomerType>().TypeName,
                        realPrice  = (double)pclst.RealPrice
                    });
                }
                hotProducts.Add(pl);
            }
            ViewBag.productCats = productCats;
            ViewBag.catProducts = hotProducts;
            ViewBag.contBuy     = Request.Path + Request.QueryString;
            return(View());
        }
コード例 #25
0
 public void Delete(ProductCat productCat)
 {
     try
     {
         using (SqlConnection connection = Connection.SQLconnection)
         {
             string query = "DELETE FROM productcat WHERE ID = @id";
             using (SqlCommand command = new SqlCommand(query, connection))
             {
                 command.Parameters.AddWithValue("@id", productCat.Id);
                 command.ExecuteNonQuery();
             }
         }
     }
     catch
     {
     }
 }
コード例 #26
0
ファイル: ProductCategory.cs プロジェクト: JiaMazlee/CO5027
        public string DeleteProductCat(int ProductCatID)
        {
            try
            {
                db_1722759_co5027_asgEntities db = new db_1722759_co5027_asgEntities();
                ProductCat ProductCat            = db.ProductCats.Find(ProductCatID);

                db.ProductCats.Attach(ProductCat);
                db.ProductCats.Remove(ProductCat);
                db.SaveChanges();

                return(ProductCat.ProductCatName + " was succesfully deleted");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #27
0
ファイル: ProductCategory.cs プロジェクト: JiaMazlee/CO5027
        public string UpdateProductCat(int ProductCatID, ProductCat ProductCat)
        {
            try
            {
                db_1722759_co5027_asgEntities db = new db_1722759_co5027_asgEntities();

                //Fetch object from db
                ProductCat p = db.ProductCats.Find(ProductCatID);

                p.ProductCatName = ProductCat.ProductCatName;

                db.SaveChanges();
                return(ProductCat.ProductCatName + " was succesfully updated");
            }
            catch (Exception e)
            {
                return("Error:" + e);
            }
        }
コード例 #28
0
 public void Insert(ProductCat productCat, ProductCat parentCat)
 {
     try
     {
         using (SqlConnection connection = Connection.SQLconnection)
         {
             string query = "INSERT INTO PRODUCTCAT VALUES (@pid ,@naam)";
             using (SqlCommand command = new SqlCommand(query, connection))
             {
                 command.Parameters.AddWithValue("@pid", parentCat.Id);
                 command.Parameters.AddWithValue("@naam", productCat.Naam);
                 command.ExecuteNonQuery();
             }
         }
     }
     catch (Exception)
     {
     }
 }
コード例 #29
0
        public JsonResult CreateProccess(ProductCatCRUD model)
        {
            rs r;

            try
            {
                var entity = new ProductCat();
                entity.Name          = model.Name;
                entity.ShowInProduct = model.ShowInProduct;
                entity.ParentId      = (model.ParentId == -1) ? null : model.ParentId;
                entity.Description   = model.Description;
                __db.ProductCat.Add(entity);
                __db.SaveChanges();
                r = rs.T("Ok");
            }
            catch (Exception ex)
            {
                r = rs.F(ex.Message);
            }
            return(Json(r, JsonRequestBehavior.DenyGet));
        }
コード例 #30
0
        public bool UpdateProductCat(ProductCat update)
        {
            try
            {
                var productCats = _db.ProductCats.Find(update.ID);
                productCats.Name            = update.Name;
                productCats.ModifiedDate    = DateTime.Now;
                productCats.Status          = update.Status;
                productCats.DisplayOrder    = update.DisplayOrder;
                productCats.MetaKeywords    = update.MetaKeywords;
                productCats.MetaDescription = update.MetaDescription;
                productCats.ParrentID       = update.ParrentID;

                _db.SaveChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }