Exemple #1
0
        public ActionResult Poruseni(int Id)
        {
            var servisniZasah = db.ServisniZasah.Find(Id);

            if (servisniZasah.PoruseniZarucnichPodminek == true)
            {
                servisniZasah.PoruseniZarucnichPodminek = false;
                foreach (var item in servisniZasah.ServisniZasahPrvek)
                {
                    ServisniZasahPrvek szp = new ServisniZasahPrvek();
                    szp = db.ServisniZasahPrvek.Find(item.Id);
                    szp.PoruseniZarucnichPodminek = false;
                    db.Entry(szp).State           = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            else
            {
                servisniZasah.PoruseniZarucnichPodminek = true;
                foreach (var item in servisniZasah.ServisniZasahPrvek)
                {
                    ServisniZasahPrvek szp = new ServisniZasahPrvek();
                    szp = db.ServisniZasahPrvek.Find(item.Id);
                    szp.PoruseniZarucnichPodminek = true;
                    db.Entry(szp).State           = EntityState.Modified;
                    db.SaveChanges();
                }
            }
            db.Entry(servisniZasah).State = EntityState.Modified;
            db.SaveChanges();
            ServisniZasah.UpdateHeader(servisniZasah.Id);
            return(RedirectToAction("Details", "ServisniZasah", new { Id = servisniZasah.Id }));
        }
Exemple #2
0
        public ActionResult Predelivery(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServisniZasah.UpdateHeader(id.Value);
            ServisniZasah servisniZasah = db.ServisniZasah.Find(id);

            if (servisniZasah == null)
            {
                return(HttpNotFound());
            }
            return(View(servisniZasah));
        }
        public ActionResult Poruseni(int Id)
        {
            var servisniZasahPrvek = ServisniZasahPrvek.GetPrvekById(Id);

            if (servisniZasahPrvek.PoruseniZarucnichPodminek == true)
            {
                servisniZasahPrvek.PoruseniZarucnichPodminek = false;
            }
            else
            {
                servisniZasahPrvek.PoruseniZarucnichPodminek = true;
            }
            db.Entry(servisniZasahPrvek).State = EntityState.Modified;
            db.SaveChanges();
            ServisniZasah.UpdateHeader(servisniZasahPrvek.ServisniZasahId);
            return(RedirectToAction("Details", "ServisniZasah", new { Id = servisniZasahPrvek.ServisniZasahId }));
        }
Exemple #4
0
        public ActionResult Close(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ServisniZasah.UpdateHeader(Id.Value);
            ServisniZasah servisniZasah = db.ServisniZasah.Find(Id);

            servisniZasah.Closed          = true;
            db.Entry(servisniZasah).State = EntityState.Modified;
            db.SaveChanges();

            if (servisniZasah == null)
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Details", "ServisniZasah", new { Id }));
        }
        public ActionResult Edit([Bind(Include = "Id,ServisniZasahId,SCProvozuID,PoruchaID,ArtiklID,Pocet,CenaZaKus,CenaCelkem")] ServisniZasahPrvek servisniZasahPrvek)
        {
            if (ModelState.IsValid)
            {
                decimal cena;
                cena = ServisniZasah.GetCenaForprvek(servisniZasahPrvek);
                servisniZasahPrvek.CenaZaKus  = cena;
                servisniZasahPrvek.CenaCelkem = cena * servisniZasahPrvek.Pocet;

                ServisniZasah sz = new ServisniZasah();
                sz = ServisniZasah.GetZasah(servisniZasahPrvek.ServisniZasahId);

                //datum ukonceni platnosti zaruky umisteni
                var umisteni = Umisteni.GetDatumZaruky(sz.UmisteniId);
                //datum ukonceni platnosti zaruky SCProvozu
                DateTime?scprovozu = DateTime.MinValue;
                if (servisniZasahPrvek.SCProvozuID != null)
                {
                    scprovozu = SCProvozu.GetDatumZaruky(servisniZasahPrvek.SCProvozuID.Value);
                }
                DateTime?datum = DateTime.Now;
                //v zaruce?
                if (scprovozu != null)
                {
                    datum = scprovozu;
                }
                else
                {
                    if (umisteni != null)
                    {
                        if (scprovozu != null)
                        {
                            if (scprovozu >= umisteni)
                            {
                                datum = scprovozu;
                            }
                            if (scprovozu < umisteni)
                            {
                                datum = umisteni;
                            }
                        }
                        else
                        {
                            datum = umisteni;
                        }
                    }
                }
                if (datum >= sz.DatumVyzvy)
                {
                    var porucha = Porucha.ReklamaceById(servisniZasahPrvek.PoruchaID);
                    if (porucha == true)
                    {
                        servisniZasahPrvek.Reklamace = true;
                    }
                }
                db.Entry(servisniZasahPrvek).State = EntityState.Modified;
                db.SaveChanges();
                ServisniZasah.UpdateHeader(servisniZasahPrvek.ServisniZasahId);
                return(RedirectToAction("Details", "ServisniZasah", new { Id = servisniZasahPrvek.ServisniZasahId }));
            }
            ViewBag.ArtiklID        = new SelectList(db.Artikl, "Id", "Nazev", servisniZasahPrvek.ArtiklID);
            ViewBag.PoruchaID       = new SelectList(db.Porucha, "Id", "NazevPoruchy", servisniZasahPrvek.PoruchaID);
            ViewBag.SCProvozuID     = new SelectList(db.SCProvozu, "Id", "Lokace", servisniZasahPrvek.SCProvozuID);
            ViewBag.ServisniZasahId = new SelectList(db.ServisniZasah, "Id", "Odkud", servisniZasahPrvek.ServisniZasahId);
            return(View(servisniZasahPrvek));
        }
        public ActionResult Create([Bind(Include = "Id,ServisniZasahId,SCProvozuID,PoruchaID,ArtiklID,Pocet,CenaZaKus,CenaCelkem,SIL")] ServisniZasahPrvek servisniZasahPrvek)
        {
            if (ModelState.IsValid)
            {
                decimal cena;
                if (servisniZasahPrvek.ArtiklID != null)
                {
                    cena = ServisniZasah.GetCenaForprvek(servisniZasahPrvek);
                    servisniZasahPrvek.CenaZaKus  = cena;
                    servisniZasahPrvek.CenaCelkem = cena * servisniZasahPrvek.Pocet;
                }
                ServisniZasah sz = new ServisniZasah();
                sz = ServisniZasah.GetZasah(servisniZasahPrvek.ServisniZasahId);

                //datum ukonceni platnosti zaruky umisteni
                var umisteni = Umisteni.GetDatumZaruky(sz.UmisteniId);
                //datum ukonceni platnosti zaruky SCProvozu
                DateTime?scprovozu = null;
                try
                {
                    scprovozu = SCProvozu.GetDatumZaruky(servisniZasahPrvek.SCProvozuID.Value);
                }
                catch (Exception ex)
                {
                    scprovozu = null;
                    log.Debug("Error number:" + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException);
                }

                DateTime?datum = DateTime.Now;
                //v zaruce?
                if (scprovozu != null)
                {
                    datum = scprovozu;
                }
                else
                {
                    if (umisteni != null)
                    {
                        if (scprovozu != null)
                        {
                            if (scprovozu >= umisteni)
                            {
                                datum = scprovozu;
                            }
                            if (scprovozu < umisteni)
                            {
                                datum = umisteni;
                            }
                        }
                        else
                        {
                            datum = umisteni;
                        }
                    }
                }
                if (datum >= sz.DatumVyzvy)
                {
                    //var porucha = Porucha.ReklamaceById(servisniZasahPrvek.PoruchaID);
                    var porucha = false;
                    if (porucha == true)
                    {
                        servisniZasahPrvek.Reklamace = true;
                    }
                }

                db.ServisniZasahPrvek.Add(servisniZasahPrvek);



                db.SaveChanges();
                ServisniZasah.UpdateHeader(servisniZasahPrvek.ServisniZasahId);



                return(RedirectToAction("Details", "ServisniZasah", new { Id = servisniZasahPrvek.ServisniZasahId }));
            }

            ViewBag.ArtiklID        = new SelectList(db.Artikl, "Id", "Nazev", servisniZasahPrvek.ArtiklID);
            ViewBag.PoruchaID       = new SelectList(db.Porucha, "Id", "NazevPoruchy", servisniZasahPrvek.PoruchaID);
            ViewBag.SCProvozuID     = new SelectList(db.SCProvozu, "Id", "Lokace", servisniZasahPrvek.SCProvozuID);
            ViewBag.ServisniZasahId = new SelectList(db.ServisniZasah, "Id", "Odkud", servisniZasahPrvek.ServisniZasahId);
            return(View(servisniZasahPrvek));
        }