Esempio n. 1
0
 public void addCategory()
 {
     try
     {
         StockCategory Cmodel = new StockCategory();
         Cmodel.CatName  = txtCategory.Text;
         Cmodel.UserName = Session["username"].ToString();
         string ReturnMessage = Cdal.AddCategory(Cmodel);
         if (ReturnMessage.Contains("Successfully"))
         {
             lblSuccess.Visible = true;
             lblError.Visible   = false;
             lblError.Text      = "";
             lblSuccess.Text    = ReturnMessage;
             GetCategories();
         }
         else
         {
             lblSuccess.Visible = false;
             lblError.Visible   = true;
             lblError.Text      = ReturnMessage;
             lblSuccess.Text    = "";
         }
     }
     catch (Exception ex)
     {
         lblSuccess.Visible = false;
         lblError.Visible   = true;
         lblError.Text      = ex.ToString();
         lblSuccess.Text    = "";
     }
 }
Esempio n. 2
0
 public string AddCategory(StockCategory Category)
 {
     try
     {
         SqlParameter[] var =
         {
             new SqlParameter("@CatName",  Category.CatName),
             new SqlParameter("@UserName", Category.UserName),
         };
         int Count = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.Connect, CommandType.Text, "select count(CatId) from StockCategory where CatName=@CatName", var));
         if (Count == 0)
         {
             int returnValue = SqlHelper.ExecuteNonQuery(SqlHelper.Connect, CommandType.Text, "insert into StockCategory (CatName,UserName) values(@CatName,@UserName)", var);
             if (returnValue > 0)
             {
                 return("Successfully Added");
             }
             else
             {
                 return("Something went wrong. Please try again later!");
             }
         }
         else
         {
             return("Category Name already Exist");
         }
     }
     catch (Exception ex)
     {
         return(ex.ToString());
     }
 }
Esempio n. 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            StockCategory stockCategory = db.StockCategories.Find(id);

            db.StockCategories.Remove(stockCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        private List <StockCategory> GetSelectedItem()
        {
            List <StockCategory> items = new List <StockCategory>();
            StockCategory        itm   = new StockCategory();

            itm.lngslNo = Convert.ToInt64(DG.CurrentRow.Cells[0].Value.ToString());
            items.Add(itm);
            return(items);
        }
Esempio n. 5
0
 public ActionResult Edit([Bind(Include = "stockCatNo,category")] StockCategory stockCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(stockCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(stockCategory));
 }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "stockCatNo,category")] StockCategory stockCategory)
        {
            if (ModelState.IsValid)
            {
                db.StockCategories.Add(stockCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stockCategory));
        }
        public IActionResult Update(StockCategory stockCategory)
        {
            DynamicParameters dynamicParameters = new DynamicParameters();

            dynamicParameters.Add("@ID", stockCategory.ID);
            var data = _stockCategoryManager.Get("select * from StockCategories where ID = @ID", dynamicParameters);

            data.Icon     = stockCategory.Icon;
            data.Name     = stockCategory.Name;
            data.ParentID = stockCategory.ParentID;
            return(Ok(_stockCategoryManager.Update(data, "UPDATE [dbo].[StockCategories] SET [ParentID] = @ParentID,[Name] = @Name,[Icon] = @Icon WHERE ID = @ID")));
        }
Esempio n. 8
0
        // GET: StockCategories/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            StockCategory stockCategory = db.StockCategories.Find(id);

            if (stockCategory == null)
            {
                return(HttpNotFound());
            }
            return(View(stockCategory));
        }
Esempio n. 9
0
    public int CategoryExist(string CatName)
    {
        int count = 0;

        SqlParameter[] var =
        {
            new SqlParameter("@CatName", CatName)
        };
        count = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.Connect, CommandType.Text, "select count(CatName) from StockCategory where CatName=@CatName", var));
        return(count);

        StockCategory Category = new StockCategory();

        Category.CatName      = CatName;
        Category.CatNameExist = count;
        JavaScriptSerializer js = new JavaScriptSerializer();

        Context.Response.Write(js.Serialize(Category));
    }
Esempio n. 10
0
        public Task <List <StockCategory> > ListStockCtegory()
        {
            return(Task.Run(async() =>
            {
                string html = await RestApi.GetHtmlTaskAsync(StockCategoryUrl, Encoding.GetEncoding(950));
                html = html.Replace("\r\n", string.Empty);

                var categoryResults = HtmlHelper.DescendantsPath(html, "//table//tr",
                                                                 node =>
                {
                    string tableClassValue = node.ParentNode.Attributes["class"]?.Value;
                    string classValue = node.FirstChild.Attributes["class"]?.Value;

                    return classValue.StartsWith("t3t1") && !tableClassValue.StartsWith("t3t1");
                },
                                                                 node =>
                {
                    StockCategory mainCatgory = new StockCategory();
                    List <StockCategory> subCategories = HtmlHelper.Descendants(node.InnerHtml, "a", subNode =>
                    {
                        string name = subNode.InnerText.Trim();
                        string url = MoneyDjUrl + subNode.Attributes["href"].Value;
                        // 大項分類
                        if (subNode.ParentNode.Attributes["width"] == null)
                        {
                            mainCatgory.Name = name;
                            mainCatgory.Url = url;
                        }
                        StockCategory child = new StockCategory {
                            Name = name, Url = url
                        };
                        return child;
                    });

                    mainCatgory.AddDetailRange(subCategories);
                    return mainCatgory;
                });
                return categoryResults;
            }));
        }
 public IActionResult Create(StockCategory stockCategory)
 {
     return(Ok(_stockCategoryManager.Add(stockCategory, "INSERT INTO [dbo].[StockCategories]([ParentID],[Name],[Icon],[CompanyID])OUTPUT inserted.* VALUES (@ParentID,@Name,@Icon,@CompanyID)")));
 }
Esempio n. 12
0
 public IEnumerable <StockItem> ListAllFromCategory(StockCategory category)
 {
     //get all stock from specific category
     throw new NotImplementedException();
 }
Esempio n. 13
0
 public StockCategory Delete(StockCategory stockCategory, string sql)
 {
     return(_stockCategoryDal.Delete(stockCategory, sql));
 }
Esempio n. 14
0
 public StockCategory Update(StockCategory stockCategory, string sql)
 {
     return(_stockCategoryDal.Update(stockCategory, sql));
 }
Esempio n. 15
0
 public StockCategory Add(StockCategory stockCategory, string sql)
 {
     return(_stockCategoryDal.Add(stockCategory, sql));
 }