Exemplo n.º 1
0
        public IActionResult updateblog(int id)
        {
            //////////////////////////////////////////////////////////////////////////////////list
            var qlist  = db.tbl_category.Where(a => a.FatherIdCat == -2 || a.FatherIdCat == -3).ToList();
            var listtb = new List <Tb_Category> ();

            if (qlist != null)
            {
                foreach (var item in qlist)
                {
                    var qselect = db.tbl_category.Where(a => a.FatherIdCat == item.Id).ToList();
                    if (qselect.Count() != 0)
                    {
                        foreach (var item1 in qselect)
                        {
                            var b = new Tb_Category()
                            {
                                Id          = item1.Id,
                                NameCat     = item1.NameCat + "  " + "-->" + "  " + item.NameCat,
                                FatherIdCat = item1.FatherIdCat
                            };
                            listtb.Add(b);
                        }
                    }
                    else
                    {
                        listtb.Add(item);
                    }
                }
                ViewBag.list = new SelectList(listtb, "Id", "NameCat");
            }
            else
            {
                ViewBag.list = null;
            }

            //////////////////////////////////////////////////////////////////////////////////list
            if (err != null)
            {
                ViewBag.er = err;
                err        = null;
            }

            if (id != null)
            {
                Vm_Blog qblog = new Vm_Blog();
                var     list  = db.Tbl_Blog.Where(a => a.Id == id).SingleOrDefault();
                qblog.Id           = list.Id;
                qblog.TitleBLo     = list.TitleBLo;
                qblog.Language     = list.Language;
                qblog.IdCtegoryBlo = list.IdCtegoryBlo;
                qblog.SummaryBlo   = list.SummaryBlo;
                qblog.ImageMainBlo = list.ImageMainBlo;
                qblog.FullTextBlo  = list.FullTextBlo;
                qblog.KeywordsBlo  = list.KeywordsBlo;

                return(View(qblog));
            }
            return(View());
        }
Exemplo n.º 2
0
 private void fill(int id)
 {
     category        = db.Tb_Category.Where(z => z.Id == id).FirstOrDefault();
     txtcatname.Text = category.Cat_name;
     //  drpunit.SelectedValue = category.Unit;
     //chkstatus.Checked = category.Status;
     btnsubmit.Text  = "Update";
     ViewState["id"] = category.Id;
 }
Exemplo n.º 3
0
 protected void btnconfirm_Click(object sender, EventArgs e)
 {
     try
     {
         int id = Convert.ToInt32(hdndel.Value);
         category = db.Tb_Category.Where(z => z.Id == id).FirstOrDefault();
         db.Tb_Category.Remove(category);
         db.SaveChanges();
         Response.Redirect("~/Admin/ShowCategory.aspx?msg=" + "Dlt");
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 4
0
        public IActionResult Index()
        {
            //////////////////////////////////////////////////////////////////////////////////list
            var qlist  = db.tbl_category.Where(a => a.FatherIdCat == -2 || a.FatherIdCat == -3).ToList();
            var listtb = new List <Tb_Category> ();

            if (qlist != null)
            {
                foreach (var item in qlist)
                {
                    var qselect = db.tbl_category.Where(a => a.FatherIdCat == item.Id).ToList();
                    if (qselect.Count() != 0)
                    {
                        foreach (var item1 in qselect)
                        {
                            var b = new Tb_Category()
                            {
                                Id          = item1.Id,
                                NameCat     = item1.NameCat + "  " + "-->" + "  " + item.NameCat,
                                FatherIdCat = item1.FatherIdCat
                            };
                            listtb.Add(b);
                        }
                    }
                    else
                    {
                        listtb.Add(item);
                    }
                }
                ViewBag.list = new SelectList(listtb, "Id", "NameCat");
            }
            else
            {
                ViewBag.list = null;
            }

            //////////////////////////////////////////////////////////////////////////////////list
            if (err != null)
            {
                ViewBag.er = err;
                err        = null;
            }

            return(View());
        }
Exemplo n.º 5
0
        public IActionResult add(Vm_Category cat)
        {
            var qcat = db.tbl_category.Where(a => a.NameCat == cat.NameCat && a.FatherIdCat == cat.FatherIdCat).SingleOrDefault();

            if (qcat != null)
            {
                err = "این نام قبلا ثبت شده است";
            }
            else
            {
                var tbcat = new Tb_Category()
                {
                    Language    = cat.Language,
                    NameCat     = cat.NameCat,
                    FatherIdCat = cat.FatherIdCat
                };
                db.tbl_category.Add(tbcat);
                db.SaveChanges();
                suc = "اطلاعات با موفقیت ثبت شد";
            }
            return(RedirectToAction("index"));
        }
Exemplo n.º 6
0
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (btnsubmit.Text == "Submit")
        {
            category.Cat_name = txtcatname.Text;
            //category.Unit = drpunit.SelectedValue;
            //category.Status = chkstatus.Checked;
            db.Tb_Category.Add(category);
            db.SaveChanges();
            clear();
            Response.Redirect("~/Admin/ShowCategory.aspx?msg=" + "Svd");
        }
        else
        {
            category          = db.Tb_Category.Find(Convert.ToInt32(ViewState["id"]));
            category.Cat_name = txtcatname.Text;
            //  category.Unit = drpunit.SelectedValue;
            //category.Status = chkstatus.Checked;

            db.SaveChanges();
            clear();
            Response.Redirect("~/Admin/ShowCategory.aspx?msg=" + "upd");
        }
    }
Exemplo n.º 7
0
        public IActionResult update(int id)
        {
            //////////////////////////////////////////////////////////////////////////////////list
            var qlist  = db.tbl_category.Where(a => a.FatherIdCat == -1).ToList();
            var listtb = new List <Tb_Category> ();

            if (qlist != null)
            {
                foreach (var item in qlist)
                {
                    var qselect = db.tbl_category.Where(a => a.FatherIdCat == item.Id).ToList();
                    if (qselect.Count() != 0)
                    {
                        foreach (var item1 in qselect)
                        {
                            var b = new Tb_Category()
                            {
                                Id          = item1.Id,
                                NameCat     = item1.NameCat + "  " + "-->" + "  " + item.NameCat,
                                FatherIdCat = item1.FatherIdCat
                            };
                            listtb.Add(b);
                        }
                    }
                    else
                    {
                        listtb.Add(item);
                    }
                }
                ViewBag.list = new SelectList(listtb, "Id", "NameCat");
            }
            else
            {
                ViewBag.list = null;
            }

            //////////////////////////////////////////////////////////////////////////////////list
            var           qproduct = db.Tbl_Product.Where(a => a.Id == id).SingleOrDefault();
            var           qgallery = db.tb_GalleryProducts.Where(a => a.IdProduct == id).ToList();
            List <string> h        = new List <string>();

            foreach (var item in qgallery)
            {
                h.Add(item.ImagePath);
            }
            Vm_Product qp = new Vm_Product()
            {
                Id = qproduct.Id,
                TitleProductPro = qproduct.TitleProductPro,
                ImageMainPro    = qproduct.ImageMainPro,
                CategoryIdPro   = qproduct.CategoryIdPro,
                PricePro        = qproduct.PricePro,
                OfferPro        = qproduct.OfferPro,
                SizePro         = qproduct.SizePro,
                ColorPro        = qproduct.ColorPro,
                BrandPro        = qproduct.BrandPro,
                MaterialPro     = qproduct.MaterialPro,
                TotalPro        = qproduct.TotalPro,
                DescreptionPro  = qproduct.DescreptionPro,
                Language        = qproduct.Language,
            };

            ViewBag.img = h;
            return(View(qp));
        }