public ActionResult EditGood(t_siz_goods good)
 {
     good.author = currentuser.login;
     good.date   = DateTime.Now;
     repository.AddGood(good);
     return(RedirectToAction("Print"));
 }
Exemple #2
0
 public void AddGood(t_siz_goods good)
 {
     if (good.id == 0)
         context.t_siz_goods.Add(good);
     else
     {
         t_siz_goods dbEbtry = context.t_siz_goods.Find(good.id);
         if (dbEbtry != null)
         {
             dbEbtry.deleted = 1;
             if (good.deleted != 1)
                 context.t_siz_goods.Add(good);
             context.SaveChanges();
             foreach (var dg in context.t_siz_depgood)
             {
                 if (dg.good == dbEbtry.id)
                 {
                     dg.deleted = 1;
                     context.t_siz_depgood.Add(new t_siz_depgood() { deleted = 0, good = good.id, department = dg.department });
                 }
             }
         }
     }
     context.SaveChanges();
 }
Exemple #3
0
 public ActionResult CreateGood(t_siz_goods good)
 {
     currentuser = GetUserAu();
     good.author = currentuser.login;
     good.date   = DateTime.Now;
     //УКАЗАТЬ ОТДЕЛ
     repository.AddGood(good);
     repository.InitSize(good);
     return(RedirectToAction("Print"));
 }
        public ActionResult AddSizeTable(long id)
        {
            var res  = repository.SIZSizeList;
            var res2 = repository.GoodSize.Where(t => t.good == id).Select(p => p.size).ToList();

            ViewBag.Res  = res;
            ViewBag.Res2 = res2;
            t_siz_goods res3 = repository.GetById(id, typeof(t_siz_goods).ToString()) as t_siz_goods;

            return(PartialView("AddSizeTable", res3));
        }
Exemple #5
0
        public ActionResult AddDeptTable(long id)
        {
            var res  = repository.SIZDepartmentList;
            var res2 = repository.DepGood.Where(t => t.good == id && t.deleted != 1).OrderBy(s => s.t_siz_department.name).Select(p => p.department).ToList();

            ViewBag.Res  = res;
            ViewBag.Res2 = res2;
            t_siz_goods res3 = repository.GetById(id, typeof(t_siz_goods).ToString()) as t_siz_goods;

            return(PartialView("AddDeptTable", res3));
        }
Exemple #6
0
        public ActionResult EditGood(t_siz_goods good)
        {
            currentuser = GetUserAu();
            good.author = currentuser.login;
            good.date   = DateTime.Now;
            long oldid = good.id;

            repository.AddGood(good);
            repository.InitSize(good, oldid);
            return(RedirectToAction("Print"));
        }
Exemple #7
0
 public void InitSize(t_siz_goods good, long oldid=0)
 {
     foreach (var s in context.t_siz_goodsize.Where(t => t.good == oldid))
         s.deleted = 1;
     List<long> sizes = new List<long>(context.t_siz_goods_size.Where(p => p.type == good.sizetype).Select(t => t.id));
     foreach (long t in sizes)
     {
         t_siz_goodsize gs = new t_siz_goodsize() { good = good.id, size = t, sign = 1, deleted = 0 };
         context.t_siz_goodsize.Add(gs);
     }
     context.SaveChanges();
 }
 public ActionResult AddSizeTable(t_siz_goods good, long[] selectedSizes)
 {
     if (selectedSizes != null)
     {
         List <t_siz_goodsize> sizes = new List <t_siz_goodsize>();
         foreach (var p in selectedSizes)
         {
             sizes.Add(new t_siz_goodsize()
             {
                 good = good.id, size = p, sign = 1
             });
         }
         repository.AddGoodSize(good.id, sizes);
     }
     return(RedirectToAction("Print"));
 }
Exemple #9
0
 public ActionResult AddDeptTable(t_siz_goods good, long[] selectedDept)
 {
     if (selectedDept != null)
     {
         List <t_siz_depgood> depts = new List <t_siz_depgood>();
         foreach (var p in selectedDept)
         {
             depts.Add(new t_siz_depgood()
             {
                 good = good.id, department = p
             });
         }
         repository.AddDepGood(good.id, depts);
     }
     return(RedirectToAction("Print"));
 }
        public ActionResult DeleteCurrentGood(long id)
        {
            t_siz_goods current = repository.GetById(id, typeof(t_siz_goods).ToString()) as t_siz_goods;

            if (current != null)
            {
                current.author  = currentuser.login;
                current.date    = DateTime.Now;
                current.deleted = 1;
                //УКАЗАТЬ ОТДЕЛ
                repository.AddGood(current);
                return(RedirectToAction("Print"));
            }
            else
            {
                return(PartialView("Error"));
            }
        }
        public ActionResult EditGood(long id)
        {
            t_siz_goods current = repository.GetById(id, typeof(t_siz_goods).ToString()) as t_siz_goods;

            if (current != null)
            {
                int        selectIndex = 1;
                SelectList Goods       = new SelectList(repository.SIZGoodsList, "id", "name", selectIndex);
                ViewBag.Goods = Goods;
                SelectList Mans = new SelectList(repository.SIZManList, "id", "name", selectIndex);
                ViewBag.Mans = Mans;
                return(PartialView("EditGood", current));
            }
            else
            {
                return(PartialView("Error"));
            }
        }