Пример #1
0
 public async Task <ActionResult> HandleSubCat(SubCat sub)
 {
     try
     {
         List <SubCatModel> cats = new List <SubCatModel>();
         cats.Add(new SubCatModel()
         {
             CatId   = sub.SubId,
             CatName = sub.SubName
         });
         SubCatUpload subCat = new SubCatUpload()
         {
             FatherCat = sub.FatherName,
             Subs      = cats
         };
         if (await svc.PostSubCategory(subCat))
         {
             TempData["IsSuccess"] = true;
         }
         else
         {
             TempData["IsSuccess"] = false;
         }
     }
     catch
     {
         TempData["IsSuccess"] = false;
     }
     return(RedirectToAction("CreateSubCat"));
 }
Пример #2
0
        public void ShowCategory(int id, int rootID, int parentID)
        {
            if (ProductInfoCatalog != null)
            {
                Category_V02 category     = CatalogHelper.FindCategory(ProductInfoCatalog, id, parentID, rootID);
                Category_V02 rootCategory = CatalogHelper.FindCategory(ProductInfoCatalog, rootID);
                if (category != null &&
                    rootCategory != null &&
                    CatalogProvider.IsDisplayable(rootCategory, Thread.CurrentThread.CurrentCulture.Name))
                {
                    CategoryName.Text            = category.DisplayName;
                    Overview.Text                = category.Description;
                    DivImage.Style["background"] = "url(" + category.ImagePath +
                                                   ");background-repeat: no-repeat; background-position: center right";
                    SubCat.PopulateProducts(category, rootCategory);

                    if (HLConfigManager.Configurations.DOConfiguration.AddScriptsForRecommendations)
                    {
                        // Send data to Adobe Target and Salesforce, only for main categories
                        if (category.ID == rootCategory.ID)
                        {
                            AT_categoryName = string.Format("{0}_{1}", Locale, category.DisplayName);
                        }
                    }
                }
                else
                {
                    if (!(id == 0 && rootID == 0 && parentID == 0))
                    {
                        LoggerHelper.Warn(string.Format("No category found in ShowCategory for {0}-{2}-{3} {1}", id, this.Locale, rootID, parentID));
                    }
                }
            }
        }
        private void SubCatagoryButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SubCat temp = SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.SelectedCat.SelectedSubCat;

            if (temp != null)
            {
                //SimpleIoc.Default.GetInstance<ViewModel.MainViewModel>().Mw.SelectedCat.SelectedSubCat = temp;
                //RaisePropertyChanged("SelectedSubCat");
                //RaisePropertyChanged("SubDir");



                if (SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.SelectedCat.SelectedSubCat.SubDir != null)
                {
                    SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.Thumbs.Clear();
                    DirectoryInfo catFolder = new DirectoryInfo(SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.SelectedCat.SelectedSubCat.SubDir);
                    FileInfo[]    cats      = catFolder.GetFiles("*", SearchOption.AllDirectories);
                    foreach (FileInfo c in cats)
                    {
                        SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.Thumbs.Add(c.FullName);
                    }
                }
                else
                {
                    SimpleIoc.Default.GetInstance <ViewModel.MainViewModel>().Mw.Thumbs.Clear();
                }
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SubCat subCat = db.SubCat.Find(id);

            db.SubCat.Remove(subCat);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
 public int?Post([FromBody] SubCat value)
 {
     if (subCatRepo.Add(value))
     {
         return(value.ID);
     }
     return(null);
 }
Пример #6
0
        public async Task <IActionResult> SubCat(int id, int page = 1)
        {
            SubCat subcat = await subCatRepo.GetByID(id);

            ViewBag.Title    = $"Loại: {subcat?.Name}";
            ViewBag.SubCatID = id;
            ListPaging <Book> value = await bookRepo.tGetBySubCatPage(id, pageSize, page);

            return(View("List", value));
        }
 public ActionResult Edit([Bind(Include = "ID,Name,CatID")] SubCat subCat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subCat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CatID = new SelectList(db.Cat, "ID", "Name", subCat.CatID);
     return(View(subCat));
 }
        public ActionResult Create([Bind(Include = "ID,Name,CatID")] SubCat subCat)
        {
            if (ModelState.IsValid)
            {
                db.SubCat.Add(subCat);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CatID = new SelectList(db.Cat, "ID", "Name", subCat.CatID);
            return(View(subCat));
        }
        // GET: SubCats/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubCat subCat = db.SubCat.Find(id);

            if (subCat == null)
            {
                return(HttpNotFound());
            }
            return(View(subCat));
        }
        // GET: SubCats/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SubCat subCat = db.SubCat.Find(id);

            if (subCat == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CatID = new SelectList(db.Cat, "ID", "Name", subCat.CatID);
            return(View(subCat));
        }
        public SubCat CreateSubCat(SubCat subCatdto)
        {
            try
            {
                _context.Add(subCatdto);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(null);
            }
            catch (DbUpdateException)
            {
                return(null);
            }

            return(subCatdto);
        }
        public bool UpdateSubCat(SubCat subCat)
        {
            try
            {
                _context.Update(subCat);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
            catch (DbUpdateException)
            {
                return(false);
            }

            return(true);
        }
Пример #13
0
        public async void AddOrUpdate(int index, int?id, string name, int catId)
        {
            if (id != null) // Update
            {
                SubCat value  = new SubCat(id, name, catId);
                bool   result = await subCatRepo.Update((int)id, value);

                if (result)
                {
                    value.Cat      = cats.Where(o => o.ID == catId).FirstOrDefault();
                    subCats[index] = value;
                    message        = MessageHelper.Get("up");
                }
                else
                {
                    message = MessageHelper.Get("upErr");
                }
            }
            else // Add
            {
                SubCat value = new SubCat(null, name, catId);
                id = await subCatRepo.Add(value);

                if (id != 0)
                {
                    value.ID  = (int)id;
                    value.Cat = cats.Where(o => o.ID == catId).FirstOrDefault();
                    subCats.Add(value);
                    message = MessageHelper.Get("add");
                }
                else
                {
                    message = MessageHelper.Get("addErr");
                }
            }
        }
Пример #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection Connection = new SqlConnection(Con.ConnectionString());

            if (Cat.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select a Catagory and Enter Sub Catagory for that";
                Cat.Focus();
            }
            else if ((SubCat.Text.ToString().Trim(' ')).ToString() == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Sub Catagory Name";
                SubCat.Text = "";
                SubCat.Focus();
            }
            else if (unit.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select a Unit for the Sub Catagory";
                unit.Focus();
            }
            else if ((Sup1.Checked == false) && (Sup2.Checked == false) && (Sup3.Checked == false))
            {
                toolStripStatusLabel1.Text = "Please Select atleast one Supplier for this Sub Catagory";
                Sup1.Focus();
            }
            else
            {
                try
                {
                    if (button1.Text.ToString() == "Save")
                    {
                        SqlCommand INSERT = new SqlCommand("INSERT INTO SubCatagory(Catagory,SubCatagory,Descriptions,Supplier1,Supplier2,Supplier3,Units) VALUES(@Catagory,@SubCatagory,@Descriptions,@Supplier1,@Supplier2,@Supplier3,@Units)", Connection);
                        INSERT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        INSERT.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());
                        if (Sup1.Checked == true)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier1", Sup1.Text.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier1", " ");
                        }
                        if (Sup2.Checked == true)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier2", Sup2.Text.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier2", " ");
                        }
                        if (Sup3.Checked == true)
                        {
                            INSERT.Parameters.AddWithValue("@Supplier3", Sup3.Text.ToString());
                        }
                        else
                        {
                            INSERT.Parameters.AddWithValue("@Supplier3", " ");
                        }

                        INSERT.Parameters.AddWithValue("@Units", unit.SelectedItem.ToString());
                        Connection.Open();
                        int a = INSERT.ExecuteNonQuery();
                        Connection.Close();
                        if (a == 1)
                        {
                            toolStripStatusLabel1.Text = "Successfully Saved";
                            SubCat.Text        = "";
                            Des.Text           = "";
                            Sup1.Checked       = true;
                            Sup2.Checked       = true;
                            Sup3.Checked       = true;
                            unit.SelectedIndex = 0;
                            SubCat.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error SubCatagory Not Saved";
                        }
                    }
                    else
                    {
                        SqlCommand UPDES = new SqlCommand("UPDATE SubCatagory SET Descriptions=@Description WHERE Catagory=@Catagory AND SubCatagory=@SubCatagory ", Connection);
                        UPDES.Parameters.AddWithValue("@Description", Des.Text.ToString());
                        UPDES.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPDES.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());

                        SqlCommand UPSUP1 = new SqlCommand("UPDATE SubCatagory SET Supplier1=@Supplier1 WHERE Catagory=@Catagory AND SubCatagory=@SubCatagory ", Connection);
                        UPSUP1.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPSUP1.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());
                        if (Sup1.Checked == true)
                        {
                            UPSUP1.Parameters.AddWithValue("@Supplier1", Sup1.Text.ToString());
                        }
                        else
                        {
                            UPSUP1.Parameters.AddWithValue("@Supplier1", " ");
                        }

                        SqlCommand UPSUP2 = new SqlCommand("UPDATE SubCatagory SET Supplier2=@Supplier2 WHERE Catagory=@Catagory AND SubCatagory=@SubCatagory ", Connection);
                        UPSUP2.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPSUP2.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());
                        if (Sup2.Checked == true)
                        {
                            UPSUP2.Parameters.AddWithValue("@Supplier2", Sup2.Text.ToString());
                        }
                        else
                        {
                            UPSUP2.Parameters.AddWithValue("@Supplier2", " ");
                        }

                        SqlCommand UPSUP3 = new SqlCommand("UPDATE SubCatagory SET Supplier3=@Supplier3 WHERE Catagory=@Catagory AND SubCatagory=@SubCatagory ", Connection);
                        UPSUP3.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPSUP3.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());
                        if (Sup3.Checked == true)
                        {
                            UPSUP3.Parameters.AddWithValue("@Supplier3", Sup3.Text.ToString());
                        }
                        else
                        {
                            UPSUP3.Parameters.AddWithValue("@Supplier3", " ");
                        }

                        SqlCommand UPUNIT = new SqlCommand("UPDATE SubCatagory SET Units=@Units WHERE Catagory=@Catagory AND SubCatagory=@SubCatagory", Connection);
                        UPUNIT.Parameters.AddWithValue("@Units", unit.Text.ToString());
                        UPUNIT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPUNIT.Parameters.AddWithValue("@SubCatagory", SubCat.Text.ToString());

                        int a, b, c, d, ei;
                        Connection.Open();
                        a  = UPDES.ExecuteNonQuery();
                        b  = UPSUP1.ExecuteNonQuery();
                        c  = UPSUP2.ExecuteNonQuery();
                        d  = UPSUP3.ExecuteNonQuery();
                        ei = UPUNIT.ExecuteNonQuery();


                        if ((a == 1) && (b == 1) && (c == 1) && (d == 1) && (ei == 1))
                        {
                            toolStripStatusLabel1.Text = "Successfully Updated";
                            SubCat.Text        = "";
                            Des.Text           = "";
                            Sup1.Checked       = true;
                            Sup2.Checked       = true;
                            Sup3.Checked       = true;
                            unit.SelectedIndex = 0;
                            SubCat.Focus();
                        }
                    }
                }
                catch (SqlException s)
                {
                    MessageBox.Show(s.ToString());
                }
            }
        }
Пример #15
0
        public ActionResult ShowCourseDetails(int id)
        {
            SubCat crs = db.SubCat.FirstOrDefault(s => s.ID == id);

            return(PartialView("_PartialData", crs));
        }
Пример #16
0
 public bool Put(int id, [FromBody] SubCat value)
 {
     return(subCatRepo.Update(value));
 }
Пример #17
0
        private void button4_Click(object sender, EventArgs e)
        {
            SqlConnection Connection = new SqlConnection(Con.ConnectionString());

            if (Cat.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select a Catagory";
                Cat.Focus();
            }
            else if (SubCat.SelectedIndex == -1)
            {
                toolStripStatusLabel1.Text = "Please Select Sub Catagory ";
                SubCat.Focus();
            }
            else if (ItemNo.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Item No";
                ItemNo.Text = "";
                ItemNo.Focus();
            }
            else if (Units.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Units";
                Units.Text = "";
                Units.Focus();
            }
            else if (StockPrice.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Stock Price";
                StockPrice.Text            = "";
                StockPrice.Focus();
            }
            else if (SalesPrice.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter Sales Price";
                SalesPrice.Text            = "";
                SalesPrice.Focus();
            }
            else if (UnitsInStock.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter how many Units have in Stock";
                UnitsInStock.Text          = "";
                UnitsInStock.Focus();
            }
            else if (ROL.Text.ToString().Trim(' ') == "")
            {
                toolStripStatusLabel1.Text = "Please Enter ReOrder Level";
                ROL.Text = "";
                ROL.Focus();
            }
            else if (Convert.ToDecimal(Profit.Text) < 0)
            {
                MessageBox.Show("Your Stock price larger than Sales Price" + Environment.NewLine + "Enter Correct Value or Change the Discount Rate", "Data Entry Problem", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);;
                SalesPrice.Focus();
            }
            else
            {
                try
                {
                    Connection.Open();
                    if (button4.Text.ToString() == "Save")
                    {
                        SqlCommand INSERT = new SqlCommand("INSERT INTO ItemList(ItemNo,Descriptions,Units,Catagory,SubCatagory,StockPrice,SalesPrice,Discount,UnitsInStock,ROL) VALUES(@ItemNo,@Descriptions,@Units,@Catagory,@SubCatagory,@StockPrice,@SalesPrice,@Discount,@UnitsInStock,@ROL)", Connection);
                        INSERT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Units", Units.Text.ToString());
                        INSERT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        INSERT.Parameters.AddWithValue("@SubCatagory", SubCat.SelectedItem.ToString());
                        INSERT.Parameters.AddWithValue("@StockPrice", Convert.ToDecimal(StockPrice.Text));
                        INSERT.Parameters.AddWithValue("@SalesPrice", Convert.ToDecimal(SalesPrice.Text));
                        INSERT.Parameters.AddWithValue("@Discount", Convert.ToInt16(Discount.Text));
                        INSERT.Parameters.AddWithValue("@UnitsInStock", Convert.ToInt64(UnitsInStock.Text));
                        INSERT.Parameters.AddWithValue("@ROL", Convert.ToInt32(ROL.Text));


                        if (INSERT.ExecuteNonQuery() == 1)
                        {
                            toolStripStatusLabel1.Text = "Sucessfully Saved";
                            ItemNo2.Items.Add(ItemNo.Text.ToString());
                            ItemNo.Text = "";
                            Des.Text    = "";
                            Units.Text  = "";
                            StockPrice.Clear();
                            SalesPrice.Text   = "";
                            Discount.Text     = "";
                            UnitsInStock.Text = "";
                            ROL.Text          = "";
                            Profit.Text       = "0.0";
                            ItemNo.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error Item Not Saved";
                        }
                    }
                    else
                    {
                        SqlCommand UPDES = new SqlCommand("UPDATE ItemList SET Descriptions=@Descriptions WHERE ItemNo=@ItemNo", Connection);
                        UPDES.Parameters.AddWithValue("@Descriptions", Des.Text.ToString());
                        UPDES.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPUNIT = new SqlCommand("UPDATE ItemList SET Units=@Units WHERE ItemNo=@ItemNo", Connection);
                        UPUNIT.Parameters.AddWithValue("@Units", Units.Text.ToString());
                        UPUNIT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPCAT = new SqlCommand("UPDATE ItemList SET Catagory=@Catagory WHERE ItemNo=@ItemNo", Connection);
                        UPCAT.Parameters.AddWithValue("@Catagory", Cat.SelectedItem.ToString());
                        UPCAT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSUBCAT = new SqlCommand("UPDATE ItemList SET SubCatagory=@SubCatagory WHERE ItemNo=@ItemNo", Connection);
                        UPSUBCAT.Parameters.AddWithValue("@SubCatagory", SubCat.SelectedItem.ToString());
                        UPSUBCAT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSTOCKPRICE = new SqlCommand("UPDATE ItemList SET StockPrice=@StockPrice WHERE ItemNo=@ItemNo", Connection);
                        UPSTOCKPRICE.Parameters.AddWithValue("@StockPrice", Convert.ToDecimal(StockPrice.Text));
                        UPSTOCKPRICE.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPSALESPRICE = new SqlCommand("UPDATE ItemList SET SalesPrice=@SalesPrice WHERE ItemNo=@ItemNo", Connection);
                        UPSALESPRICE.Parameters.AddWithValue("@SalesPrice", Convert.ToDecimal(SalesPrice.Text));
                        UPSALESPRICE.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPDISCOUNT = new SqlCommand("UPDATE ItemList SET Discount=@Discount WHERE ItemNo=@ItemNo", Connection);
                        UPDISCOUNT.Parameters.AddWithValue("@Discount", Convert.ToInt16(Discount.Text));
                        UPDISCOUNT.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPUNITSINSTOCK = new SqlCommand("UPDATE ItemList SET UnitsInStock=@UnitsInStock WHERE ItemNo=@ItemNo", Connection);
                        UPUNITSINSTOCK.Parameters.AddWithValue("@UnitsInStock", Convert.ToInt64(UnitsInStock.Text));
                        UPUNITSINSTOCK.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        SqlCommand UPROL = new SqlCommand("UPDATE ItemList SET ROL=@ROL WHERE ItemNo=@ItemNo", Connection);
                        UPROL.Parameters.AddWithValue("@ROL", Convert.ToInt32(ROL.Text));
                        UPROL.Parameters.AddWithValue("@ItemNo", ItemNo.Text.ToString());

                        int a, b, c, d, ei, f, g, h, i;
                        a  = UPDES.ExecuteNonQuery();
                        b  = UPUNIT.ExecuteNonQuery();
                        c  = UPSTOCKPRICE.ExecuteNonQuery();
                        d  = UPSALESPRICE.ExecuteNonQuery();
                        ei = UPDISCOUNT.ExecuteNonQuery();
                        f  = UPUNITSINSTOCK.ExecuteNonQuery();
                        g  = UPROL.ExecuteNonQuery();
                        h  = UPCAT.ExecuteNonQuery();
                        i  = UPSUBCAT.ExecuteNonQuery();

                        if ((a == 1) && (b == 1) && (c == 1) && (d == 1) && (ei == 1) && (f == 1) && (g == 1) && (h == 1) && (i == 1))
                        {
                            toolStripStatusLabel1.Text = "Update Sucessfully";
                            ItemNo.Text            = "";
                            Des.Text               = "";
                            Units.Text             = "";
                            StockPrice.Text        = "";
                            SalesPrice.Text        = "";
                            Discount.SelectedIndex = 0;
                            UnitsInStock.Text      = "";
                            ROL.Text               = "";
                            Profit.Text            = "0.0";
                            Cat.Focus();
                        }
                        else
                        {
                            toolStripStatusLabel1.Text = "Error, Item Not Updated";
                        }
                    }
                    Connection.Close();
                }
                catch
                {
                }
            }
        }