public void CloneDQGroup(int?currentId, List <country> listLanguage)
        {
            var index     = 0;
            var proMaster = db.artgrps.FirstOrDefault(x => x.GROUPNO == currentId);

            if (proMaster != null)
            {
                foreach (var itemlang in listLanguage)
                {
                    if (proMaster.CodeLanguage != itemlang.language.ToLower())
                    {
                        var check = db.artgrps.FirstOrDefault(x => x.IdCurrentItem == currentId && x.CodeLanguage == itemlang.language.ToLower());
                        if (check == null)
                        {
                            var tblgroup = new artgrp
                            {
                                CREATED       = proMaster.CREATED,
                                LASTCHANGE    = proMaster.LASTCHANGE,
                                GROUPCODE     = proMaster.GROUPCODE,
                                GROUPNAME     = proMaster.GROUPNAME,
                                IsActive      = proMaster.IsActive,
                                EXPORTABLE    = proMaster.EXPORTABLE,
                                METAGROUPNO   = proMaster.METAGROUPNO,
                                CodeLanguage  = itemlang.language.ToLower(),
                                IdCurrentItem = proMaster.IdCurrentItem,
                            };
                            db.artgrps.Add(tblgroup);
                        }
                    }
                }
                db.SaveChanges();
            }
        }
Exemple #2
0
        public JsonResult UpdateStatusGroup(string status, string[] ids)
        {
            var  _ids    = ids.Select(t => int.Parse(t)).ToList();
            bool _status = false;
            var  msg     = "Update Success";

            try
            {
                var _items = db.artgrps.Where(x => _ids.Contains(x.GROUPNO));
                foreach (var item in _items)
                {
                    var list = db.artgrps.Where(x => x.IdCurrentItem == item.GROUPNO).ToList();
                    foreach (var item1 in list)
                    {
                        artgrp metagrup = db.artgrps.Find(item1.GROUPNO);
                        metagrup.IsActive        = false;
                        db.Entry(metagrup).State = EntityState.Modified;
                    }
                }
                db.SaveChanges();
                _status = true;
            }
            catch (Exception)
            {
                msg = "Update Failed";
            }
            return(Json(new { status = _status, mgs = msg }));
        }
        public ActionResult Index()
        {
            var artGrp = (from a in db.artikel
                          join g in db.artikelgruppen on a.gruppe equals g.artgr
                          select(new
            {
                id = a.artnr,
                artikelname = a.bezeichnung,
                artikelgruppe = g.grtext
            })).ToList();

            // neue leere Liste
            List <artgrp> list = new List <artgrp>();
            artgrp        tempObj;

            // eine Schleife, damit jeder Datensatz in eine neue Liste geschrieben wird
            foreach (var a in artGrp)
            {
                // neue Instanz
                tempObj = new artgrp();

                // Werte setzen
                tempObj.id            = a.id;
                tempObj.artikelname   = a.artikelname;
                tempObj.artikelgruppe = a.artikelgruppe;

                list.Add(tempObj);
            }

            // Liste zurückgeben
            return(View(list));
        }
Exemple #4
0
        public ActionResult CreateGroup(AllModel model, HttpPostedFileBase[] inputfile)
        {
            if (model.tblGroupArray != null)
            {
                var groupF = new artgrp();

                groupF.METAGROUPNO  = model.tblGroup.METAGROUPNO;
                groupF.IsActive     = model.tblGroup.IsActive;
                groupF.CREATED      = DateTime.Now;
                groupF.LASTCHANGE   = DateTime.Now;
                groupF.EXPORTABLE   = "T";
                groupF.CodeLanguage = model.tblGroupArray[0].CodeLanguage.ToLower();
                groupF.GROUPCODE    = model.tblGroupArray[0].GROUPCODE;
                groupF.GROUPNAME    = model.tblGroupArray[0].GROUPNAME;
                db.artgrps.Add(groupF);
                db.SaveChanges();
                var updategroupF = db.artgrps.Find(groupF.GROUPNO);
                updategroupF.IdCurrentItem   = groupF.GROUPNO;
                db.Entry(updategroupF).State = EntityState.Modified;
                db.SaveChanges();
                foreach (var item in model.tblGroupArray.Skip(1).ToList())
                {
                    item.METAGROUPNO   = model.tblGroup.METAGROUPNO;
                    item.IsActive      = model.tblGroup.IsActive;
                    item.CREATED       = DateTime.Now;
                    item.LASTCHANGE    = DateTime.Now;
                    item.EXPORTABLE    = "T";
                    item.IdCurrentItem = groupF.IdCurrentItem;
                    db.artgrps.Add(item);
                }
                db.SaveChanges();
                if (inputfile != null)
                {
                    for (int i = 0; i < inputfile.Length; i++)
                    {
                        if (inputfile[i] != null)
                        {
                            var fname = "" + "." +
                                        inputfile[i].FileName.Split('.').Last();
                            string path = Server.MapPath("~/Content/MetagroupImage");
                            if (!Directory.Exists(path))
                            {
                                Directory.CreateDirectory(path);
                            }
                            path = Path.Combine(path + "/", fname);
                            inputfile[i].SaveAs(path);
                        }
                    }
                }
            }



            return(RedirectToAction("IndexGroup"));
        }
Exemple #5
0
        public ActionResult DeleteGroup(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var list = db.artgrps.Where(x => x.IdCurrentItem == id).ToList();

            foreach (var item in list)
            {
                artgrp artgrp = db.artgrps.Find(item.GROUPNO);
                artgrp.IsActive        = false;
                db.Entry(artgrp).State = EntityState.Modified;
            }

            db.SaveChanges();

            return(RedirectToAction("IndexGroup"));
        }
Exemple #6
0
        public ActionResult EditGroup(int id)
        {
            var listMasterGroup = db.metagrups.Where(x => x.PARENTNO != 0).ToList();

            listMasterGroup.Insert(0, new metagrup {
                METAGROUPNO = 0, METAGROUPNAME = "Select Meta Group"
            });
            ViewBag.ListMasterGroup = listMasterGroup;
            var proMaster = db.artgrps.FirstOrDefault(x => x.GROUPNO == id);

            var list = db.countries.Where(x => x.status == 1 && x.islanguage == 1).ToList();

            ViewBag.ListCountry = list;
            foreach (var itemLang in list)
            {
                var pro = db.artgrps.FirstOrDefault(x => x.IdCurrentItem == id && x.CodeLanguage == itemLang.language.ToLower());
                if (pro == null)
                {
                    if (proMaster != null)
                    {
                        var tblItem = new artgrp();
                        tblItem.CREATED       = proMaster.CREATED;
                        tblItem.LASTCHANGE    = proMaster.LASTCHANGE;
                        tblItem.GROUPCODE     = proMaster.GROUPCODE;
                        tblItem.GROUPNAME     = proMaster.GROUPNAME;
                        tblItem.IsActive      = proMaster.IsActive;
                        tblItem.EXPORTABLE    = proMaster.EXPORTABLE;
                        tblItem.METAGROUPNO   = proMaster.METAGROUPNO;
                        tblItem.CodeLanguage  = itemLang.language.ToLower();
                        tblItem.IdCurrentItem = proMaster.IdCurrentItem;
                        db.artgrps.Add(tblItem);
                    }
                }
            }
            db.SaveChanges();
            var listCode = list.Select(y => y.language.ToLower()).ToList();
            var item     = db.artgrps.ToList().Where(x => x.IdCurrentItem == id && listCode.Contains(x.CodeLanguage)).ToList();

            return(View(new AllModel {
                listGroup = item, tblGroup = proMaster
            }));
        }