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 })); }
public void PrintDelivery(int Id) { ReportDocument Rel = new ReportDocument(); string path = $"C:\\Logs\\Crystal\\Delivery.rpt"; ServisniZasah sz = ServisniZasah.GetZasah(Id); //log.Error($"adresa {path}"); try { Rel.Load(path); Rel.SetParameterValue("DocKey@", sz.DodaciList); Rel.SetParameterValue("ObjectId@", "15"); Rel.SetDatabaseLogon("sa", "*2012Versino", "SQL", SAP_dtb, false); BinaryReader stream = new BinaryReader(Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)); Rel.Close(); Rel.Dispose(); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length))); Response.Flush(); Response.Close(); } catch (Exception ex) { log.Error($"Nena4tena adresa {path} " + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } }
public ActionResult GenerateDL(int Id) { string retval = SAPDIAPI.GenerateDL(Id); ServisniZasah.UpdateDelivery(retval, Id); return(RedirectToAction("Details", "ServisniZasah", new { Id })); }
public ActionResult Create([Bind(Include = "Id,ZakaznikID,ProvozId,UmisteniId,DatumVyzvy,DatumVznikuPoruchy,DatumZasahu,DatumOdstraneni,Odkud,Kam,Zpět,Km,VozidloId,CestaCelkem,PraceHod,PraceSazba,Pracelidi,PraceCelkem,Celkem,Reklamace,PoruseniZarucnichPodminek,Mena,Closed,Porjekt,Nabidka,Zakazka,DodaciList")] ServisniZasah servisniZasah, string action) { if (ModelState.IsValid && !String.IsNullOrWhiteSpace(action)) { switch (action) { case "Přepočti cestu": servisniZasah.Km = ServisniZasah.GetDistance(servisniZasah.Odkud, servisniZasah.Kam, servisniZasah.Zpět); ModelState.Clear(); break; case "Vytvoř servisní zásah": var km = CenaArtikluZakaznik.GetCena("SP02", servisniZasah.ZakaznikID); decimal kmcena; if (km.ZCCena != 0) { kmcena = km.ZCCena; } else { kmcena = km.CenikCena; } servisniZasah.CestaCelkem = servisniZasah.Km * kmcena; var prace = CenaArtikluZakaznik.GetCena("SP01", servisniZasah.ZakaznikID); decimal pracecena; if (prace.ZCCena != 0) { pracecena = prace.ZCCena; } else { pracecena = prace.CenikCena; } servisniZasah.PraceSazba = pracecena; servisniZasah.PraceCelkem = servisniZasah.Pracelidi * servisniZasah.PraceSazba * servisniZasah.PraceHod; db.ServisniZasah.Add(servisniZasah); try { db.SaveChanges(); } catch (Exception ex) { log.Error("Error number: " + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } return(RedirectToAction("Details", "ServisniZasah", new { servisniZasah.Id })); default: break; } } ViewBag.ProvozId = new SelectList(db.Provoz, "Id", "NazevProvozu", servisniZasah.ProvozId); ViewBag.UmisteniId = new SelectList(db.Umisteni, "Id", "NazevUmisteni", servisniZasah.UmisteniId); ViewBag.VozidloId = new SelectList(db.Vozidlo, "Id", "NazevVozidla", servisniZasah.VozidloId); ViewBag.ZakaznikID = new SelectList(db.Zakaznik, "Id", "NazevZakaznika", servisniZasah.ZakaznikID); //return RedirectToAction("Create", "ServisniZasah", new { Zakaznik = servisniZasah.ZakaznikID, Provoz = servisniZasah.ProvozId, Umisteni = servisniZasah.UmisteniId, Odkud = servisniZasah.Odkud, Kam = servisniZasah.Kam, Zpet = servisniZasah.Zpět }); return(View("Create", servisniZasah)); }
public ActionResult DeleteConfirmed(int id) { ServisniZasah servisniZasah = db.ServisniZasah.Find(id); db.ServisniZasah.Remove(servisniZasah); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Poruchy(int Id) { ServisniZasah item = new ServisniZasah(); item = db.ServisniZasah.Find(Id); item.Poruchy = ServisniZasah.Recalculcateporuchy(Id); return(View(item.Poruchy)); }
public ActionResult SelectProject(int Id) { ServisniZasah sz = new ServisniZasah(); sz = ServisniZasah.GetZasah(Id); List <Projekt> list = Projekt.ProjectList(sz.Zakaznik.KodSAP, Id); return(View(list)); }
public ActionResult Add2(int ServisniZasahId, bool SIL, int?SCProvozuID) { SCProvozu scprovozu = new SCProvozu(); try { scprovozu = SCProvozu.GetSCProvozuById(SCProvozuID.Value); } catch (Exception ex) { log.Debug("ServisniZasahPrvek/Create Error number: ProvozId" + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } ServisniZasahPrvek szp = new ServisniZasahPrvek { ServisniZasahId = ServisniZasahId, SCProvozuID = SCProvozuID, ServisniZasah = ServisniZasah.GetZasah(ServisniZasahId), }; int?skupina = 0; try { skupina = scprovozu.Artikl.SkupinaArtiklu; } catch (Exception ex) { log.Debug("ServisniZasahPrvek/Create Error number: ProvozId" + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } int?artikl = 0; try { artikl = scprovozu.Artikl.Id; } catch (Exception ex) { log.Debug("ServisniZasahPrvek/Create Error number: ProvozId" + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } if (artikl != 0) { ViewBag.ArtiklID = new SelectList(db.Artikl.Where(t => (t.ServisArtikl == artikl || t.ServisSkupina == skupina) && t.KodSAP != "SP02" && t.KodSAP != "SP01"), "Id", "Nazev"); } else { ViewBag.ArtiklID = new SelectList(db.Artikl.Where(t => t.SkupinaArtiklu == 129 && t.KodSAP != "SP02" && t.KodSAP != "SP01"), "Id", "Nazev"); } if (skupina != null && skupina != 0) { ViewBag.PoruchaID = new SelectList(Porucha.GetPoruchyProSkupinu(scprovozu.Artikl.SkupinaArtiklu.Value), "Id", "NazevPoruchy"); } else { ViewBag.PoruchaID = new SelectList(Porucha.GetPoruchyProSkupinu(0), "Id", "NazevPoruchy"); } szp.ServisniZasah.Poruchy.SeznamPoruch = Porucha.GetPoruchyProSkupinu(skupina.Value); szp.SIL = SIL; return(View("Create", szp)); }
public ActionResult SelectProject([Bind(Include = "Code,Name,ServisniZasahId,Status")] Projekt projekt) { if (ModelState.IsValid) { ServisniZasah sz = new ServisniZasah(); sz = ServisniZasah.GetZasah(projekt.ServisniZasahId); sz.Projekt = projekt.Code; sz.ProjektStatus = projekt.Status; db.Entry(sz).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Details", "ServisniZasah", new { Id = projekt.ServisniZasahId })); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServisniZasah servisniZasah = db.ServisniZasah.Find(id); if (servisniZasah == null) { return(HttpNotFound()); } return(View(servisniZasah)); }
public ActionResult Create(int Zakaznik, int Provoz, int Umisteni, string Odkud, string Kam, string Zpet) { ServisniZasah sz = new ServisniZasah { ZakaznikID = Zakaznik, ProvozId = Provoz, UmisteniId = Umisteni }; if (!String.IsNullOrWhiteSpace(Odkud)) { sz.Odkud = Odkud; } else { sz.Odkud = "Semtín 79, Pardubice, Česká Republika"; } if (!String.IsNullOrWhiteSpace(Kam)) { sz.Kam = Kam; } else { sz.Kam = db.Provoz.Where(t => t.Id == Provoz).Select(t => t.AdresaProvozu).FirstOrDefault(); } if (!String.IsNullOrWhiteSpace(Zpet)) { sz.Zpět = Zpet; } else { sz.Zpět = "Semtín 79, Pardubice, Česká Republika"; } sz.Km = ServisniZasah.GetDistance(sz.Odkud, sz.Kam, sz.Zpět); sz.DatumOdstraneni = DateTime.Now; sz.DatumVyzvy = DateTime.Now; sz.DatumVznikuPoruchy = DateTime.Now; sz.DatumZasahu = DateTime.Now; sz.Mena = ServisniZasah.GetCurrency(sz.ZakaznikID); ViewBag.Provoz = db.Provoz.Where(t => t.Id == Provoz).Select(t => t.NazevProvozu).FirstOrDefault(); ViewBag.Umisteni = db.Umisteni.Where(t => t.Id == Umisteni).Select(t => t.NazevUmisteni).FirstOrDefault(); ViewBag.VozidloId = new SelectList(db.Vozidlo, "Id", "NazevVozidla", 1); ViewBag.Zakaznik = db.Zakaznik.Where(t => t.Id == Zakaznik).Select(t => t.NazevZakaznika).FirstOrDefault(); return(View(sz)); }
public ActionResult Add(int Id, bool SIL) { ServisniZasahPrvek szp = new ServisniZasahPrvek { ServisniZasahId = Id }; ServisniZasah sz = new ServisniZasah(); sz = db.ServisniZasah.Where(t => t.Id == Id).FirstOrDefault(); ViewBag.SCProvozuID = new SelectList(db.SCProvozu.Where(t => t.ProvozId == sz.ProvozId && t.Umisteni == sz.UmisteniId), "Id", "Znaceni"); szp.SIL = SIL; ViewBag.SIL = SIL; return(View(szp)); }
public ActionResult Header(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 Edit([Bind(Include = "Id,ZakaznikID,ProvozId,UmisteniId,DatumVyzvy,DatumVznikuPoruchy,DatumZasahu,DatumOdstraneni,Odkud,Kam,Zpět,Km,VozidloId,CestaCelkem,PraceHod,PraceSazba,Pracelidi,PraceCelkem,Celkem,Reklamace,PoruseniZarucnichPodminek,Mena,Closed,Porjekt,Nabidka,Zakazka,DodaciList")] ServisniZasah servisniZasah, string action) { switch (action) { case "Přepočti cestu": servisniZasah.Km = ServisniZasah.GetDistance(servisniZasah.Odkud, servisniZasah.Kam, servisniZasah.Zpět); ModelState.Clear(); break; case "Ulož": var km = CenaArtikluZakaznik.GetCena("SP02", servisniZasah.ZakaznikID); decimal kmcena; if (km.ZCCena != 0) { kmcena = km.ZCCena; } else { kmcena = km.CenikCena; } servisniZasah.CestaCelkem = servisniZasah.Km * kmcena; var prace = CenaArtikluZakaznik.GetCena("SP01", servisniZasah.ZakaznikID); decimal pracecena; if (prace.ZCCena != 0) { pracecena = prace.ZCCena; } else { pracecena = prace.CenikCena; } servisniZasah.PraceSazba = pracecena; servisniZasah.PraceCelkem = servisniZasah.Pracelidi * servisniZasah.PraceSazba * servisniZasah.PraceHod; if (ModelState.IsValid) { db.Entry(servisniZasah).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", "ServisniZasah", new { servisniZasah.Id })); } break; } ViewBag.ProvozId = new SelectList(db.Provoz, "Id", "NazevProvozu", servisniZasah.ProvozId); ViewBag.UmisteniId = new SelectList(db.Umisteni, "Id", "NazevUmisteni", servisniZasah.UmisteniId); ViewBag.VozidloId = new SelectList(db.Vozidlo, "Id", "NazevVozidla", servisniZasah.VozidloId); ViewBag.ZakaznikID = new SelectList(db.Zakaznik, "Id", "NazevZakaznika", servisniZasah.ZakaznikID); return(View(servisniZasah)); }
public ActionResult PoruchyChange(int Id, int Porucha, int?SCProvozuID) { ServisniZasahPrvek item2 = new ServisniZasahPrvek(); item2.PoruchaID = Porucha; item2.ServisniZasahId = Id; item2.SCProvozuID = SCProvozuID; db.ServisniZasahPrvek.Add(item2); db.SaveChanges(); ServisniZasah sz = db.ServisniZasah.Find(Id); //sz.Poruchy = ServisniZasah.Recalculcateporuchy(Id); return(RedirectToAction("Details", "ServisniZasah", new { Id })); }
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 })); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ServisniZasah servisniZasah = db.ServisniZasah.Find(id); if (servisniZasah == null) { return(HttpNotFound()); } ViewBag.ProvozId = new SelectList(db.Provoz, "Id", "NazevProvozu", servisniZasah.ProvozId); ViewBag.UmisteniId = new SelectList(db.Umisteni, "Id", "NazevUmisteni", servisniZasah.UmisteniId); ViewBag.VozidloId = new SelectList(db.Vozidlo, "Id", "NazevVozidla", servisniZasah.VozidloId); ViewBag.ZakaznikID = new SelectList(db.Zakaznik, "Id", "NazevZakaznika", servisniZasah.ZakaznikID); return(View(servisniZasah)); }
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 GenerateQuotation(int Id) { string retval = ""; try { retval = SAPDIAPI.GenerateQuotation(Id); } catch (Exception ex) { log.Error("Error number: " + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } try { ServisniZasah.UpdateQuotation(retval, Id); } catch (Exception ex) { log.Error("Error number: " + ex.HResult + " - " + ex.Message + " - " + ex.Data + " - " + ex.InnerException); } 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)); }