public ActionResult Create([Bind(Include = "IdEgzemplarz,IdKsiazka")] Egzemplarz egzemplarz)
        {
            if (ModelState.IsValid)
            {
                db.Egzemplarzs.Add(egzemplarz);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane egzemplarza!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    ViewBag.IdKsiazka = new SelectList(db.Ksiazkas, "IdKsiazka", "Tytul", egzemplarz.IdKsiazka);
                    return(View(egzemplarz));
                }
                return(RedirectToAction("Index"));
            }
            ViewBag.IdKsiazka = new SelectList(db.Ksiazkas, "IdKsiazka", "Tytul", egzemplarz.IdKsiazka);
            return(View(egzemplarz));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "IdKsiazka,IdWydawnictwo,IdGatunek,Tytul,RokWydania")] Ksiazka ksiazka)
        {
            if (ModelState.IsValid)
            {
                db.Ksiazkas.Add(ksiazka);

                try {
                    db.SaveChanges();
                }
                catch (Exception e) {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane książki!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }

                    ViewBag.Exception     = message;
                    ViewBag.IdGatunek     = new SelectList(db.Gatuneks, "IdGatunek", "Nazwa", ksiazka.IdGatunek);
                    ViewBag.IdWydawnictwo = new SelectList(db.Wydawnictwoes, "IdWydawnictwo", "Nazwa", ksiazka.IdWydawnictwo);
                    return(View(ksiazka));
                }
                return(RedirectToAction("Index"));
            }

            ViewBag.IdGatunek     = new SelectList(db.Gatuneks, "IdGatunek", "Nazwa", ksiazka.IdGatunek);
            ViewBag.IdWydawnictwo = new SelectList(db.Wydawnictwoes, "IdWydawnictwo", "Nazwa", ksiazka.IdWydawnictwo);
            return(View(ksiazka));
        }
예제 #3
0
        public ActionResult CreateUsingProcedure([Bind(Include = "IdAutor, Imie, Nazwisko")] Autor autor)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    db.DodajAutora(autor.IdAutor, autor.Imie, autor.Nazwisko);
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane autora!";
                    }
                    else
                    {
                        message = e.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    return(View(autor));
                }
                return(RedirectToAction("Index"));
            }
            return(View(autor));
        }
예제 #4
0
        public ActionResult Create([Bind(Include = "IdWydawnictwo,Nazwa")] Wydawnictwo wydawnictwo)
        {
            if (ModelState.IsValid)
            {
                db.Wydawnictwoes.Add(wydawnictwo);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane wydawnictwa!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    return(View(wydawnictwo));
                }
                return(RedirectToAction("Index"));
            }
            return(View(wydawnictwo));
        }
        public ActionResult Create([Bind(Include = "IdGatunek,Nazwa")] Gatunek gatunek)
        {
            if (ModelState.IsValid)
            {
                db.Gatuneks.Add(gatunek);
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane gatunku!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    return(View(gatunek));
                }
                return(RedirectToAction("Index"));
            }
            return(View(gatunek));
        }
        public ActionResult Create([Bind(Include = "IdEgzemplarz,IdCzytelnik,Imie,Nazwisko,Tytul,IloscDni,WartoscKary")] PrzetrzymaneKsiazki przetrzymaneKsiazki)
        {
            if (ModelState.IsValid)
            {
                db.PrzetrzymaneKsiazkis.Add(przetrzymaneKsiazki);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(przetrzymaneKsiazki));
        }
        public ActionResult Create([Bind(Include = "ImieAutora,NazwiskoAutora,Tytul,RokWydania,NazwaWydawnictwa,LiczbaEgzemplarzy")] Ksiegozbior ksiegozbior)
        {
            if (ModelState.IsValid)
            {
                db.Ksiegozbiors.Add(ksiegozbior);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ksiegozbior));
        }
예제 #8
0
        public ActionResult Zwroc(Ksiazka k)
        {
            k.ID_Wypozyczajacego = null;
            k.ID_StanuKsiazki    = 1;

            dbObj.Entry(k).State = System.Data.Entity.EntityState.Modified;

            dbObj.SaveChanges();

            ViewBag.Returned = true;

            return(View("ZbiorKsiazek", dbObj.Ksiazkas.ToList()));
        }
예제 #9
0
        public ActionResult CreateAuthor(AddAuthor addAuthor)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (db)
                    {
                        var row = new Autorzy
                        {
                            imie          = addAuthor.imie,
                            nazwisko      = addAuthor.nazwisko,
                            dataUrodzenia = addAuthor.dataUrodzenia,
                        };

                        db.Autorzy.Add(row);
                        db.SaveChanges();
                        ViewBag.Message = "Autor dodany";
                    }
                }
                catch (Exception)
                { }
            }
            return(View(addAuthor));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "IdKsiazka,IdAutor")] Autorstwo autorstwo)
        {
            ViewBag.IdKsiazka = autorstwo.IdKsiazka;

            if (ModelState.IsValid)
            {
                db.DodajAutorstwo(autorstwo.IdKsiazka, autorstwo.IdAutor);
                try {
                    db.SaveChanges();
                }
                catch (Exception e) {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane autorstwa!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }
                    ViewBag.Exception = message;
                    return(View(autorstwo));
                }
                return(RedirectToAction("Index", new { id = autorstwo.IdKsiazka }));
            }

            return(View(autorstwo));
        }
        public ActionResult Create([Bind(Include = "IdWypozyczenie,IdEgzemplarz,IdCzytelnik,CzyOddane,TerminWypozyczenia,TerminOddania,Wersja")] Wypozyczenie wypozyczenie, int id)
        {
            wypozyczenie.IdCzytelnik = id;
            IEnumerable <int> ids = from w in db.Wypozyczenies
                                    select w.IdWypozyczenie;

            ViewBag.IdWypozyczenie      = (ids.Count() == 0) ? 1 : ids.Last() + 1;
            wypozyczenie.IdWypozyczenie = (ids.Count() == 0) ? 1 : ids.Last() + 1;
            ViewBag.Dzisiaj             = DateTime.Now.ToString("yyyy-MM-dd");
            ViewBag.Termin = DateTime.Now.AddDays(30).ToString("yyyy-MM-dd");

            if (ModelState.IsValid)
            {
                db.Wypozyczenies.Add(wypozyczenie);

                try {
                    db.SaveChanges();
                } catch (Exception e) {
                    string message = "";

                    if (e.InnerException == null)
                    {
                        message = "Podano nieprawidłowe dane wypozyczenia!";
                    }
                    else
                    {
                        message = e.InnerException.InnerException.Message;
                    }

                    ViewBag.IdCzytelnikaDlaWypozyczenia = id;
                    ViewBag.Exception    = message;
                    ViewBag.IdCzytelnik  = new SelectList(db.Czytelniks, "IdCzytelnik", "Imie", wypozyczenie.IdCzytelnik);
                    ViewBag.IdEgzemplarz = new SelectList(db.Egzemplarzs, "IdEgzemplarz", "IdEgzemplarz", wypozyczenie.IdEgzemplarz);
                    return(View(wypozyczenie));
                }
                return(RedirectToAction("../Czytelniks/Wypozyczenies/" + id));
            }

            ViewBag.IdCzytelnikaDlaWypozyczenia = id;
            ViewBag.IdCzytelnik  = new SelectList(db.Czytelniks, "IdCzytelnik", "Imie", wypozyczenie.IdCzytelnik);
            ViewBag.IdEgzemplarz = new SelectList(db.Egzemplarzs, "IdEgzemplarz", "IdEgzemplarz", wypozyczenie.IdEgzemplarz);
            return(View(wypozyczenie));
        }
        public ActionResult Usun(Wypozyczajacy w)
        {
            dbObj.Database.ExecuteSqlCommand("DELETE FROM Wypozyczajacy WHERE ID_Wypozyczajacego=" + w.ID_Wypozyczajacego.ToString());

            dbObj.SaveChanges();

            ViewBag.Deleted = true;

            return(View("ZbiorWypozyczajacych", dbObj.Wypozyczajacies.ToList()));
        }
예제 #13
0
        ////Edytowanie klienta
        private void Btn_edytuj_klienta_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                client1.Firstname = txt_name.Text;
                client1.Surename  = txt_surename.Text;
                client1.NrPhone   = txt_nrPhone.Text;
                client1.Info      = txt_info.Text;

                db.Entry(client1).State = EntityState.Modified;
                db.SaveChanges();

                MessageBox.Show("edytowano");
                frame1.Content = new ClientPage(frame1, db);
            } catch (SqlException f)
            {
                MessageBox.Show(f.Message);
            }catch (Exception f)
            {
                MessageBox.Show(f.Message);
            }
        }
예제 #14
0
        public ActionResult Zwroc(Ksiazka k)
        {
            Wypozyczajacy w = dbObj.Wypozyczajacies.Find(k.ID_Wypozyczajacego);

            k.ID_Wypozyczajacego = null;
            k.ID_StanuKsiazki    = 1;

            dbObj.Entry(k).State = System.Data.Entity.EntityState.Modified;

            dbObj.SaveChanges();

            ViewBag.Returned = true;

            var ksiazki = dbObj.Ksiazkas.ToList();

            if (ksiazki != null)
            {
                ViewBag.Ksiazki = ksiazki;
            }

            return(View("Wypozyczajacy", w));
        }
예제 #15
0
        public ActionResult BookDetails(int id, Wypozyczenia wypozyczenia)
        {
            var      model = Services.BookMethods.GetBook(id);
            DateTime today = DateTime.Now.Date;

            try
            {
                using (db)
                {
                    if (model.ilosc >= 1)
                    {
                        model.ilosc = model.ilosc - 1;
                        int userId = Services.UserMethods.GetUserID(System.Web.HttpContext.Current.User.Identity.Name);
                        var row    = db.Ksiazki.FirstOrDefault(k => k.idKsiazki == id);

                        wypozyczenia.terminWypozyczenia = today;
                        wypozyczenia.terminZwrotu       = today.AddDays(30);
                        wypozyczenia.idUzytkownika      = userId;
                        wypozyczenia.idStatusu          = 1;
                        wypozyczenia.idKsiazki          = id;
                        row.ilosc = model.ilosc;
                        db.Wypozyczenia.Add(wypozyczenia);
                        db.Ksiazki.AddOrUpdate(row);
                        db.SaveChanges();
                        ViewBag.Message = "Wypożyczono";
                    }
                    else
                    {
                        ViewBag.Message = "Brak książek na stanie";
                    }
                }
            }
            catch (Exception ex)
            { }
            return(View(model));
        }
        // POST: Czytelniks/Oddaj/5
        public ActionResult Oddaj(int id)
        {
            var wypozyczenie = (from wypozyczenia in db.Wypozyczenies
                                where wypozyczenia.IdWypozyczenie == id
                                select wypozyczenia).ToArray().FirstOrDefault();

            wypozyczenie.CzyOddane = true;

            db.SaveChanges();

            return(RedirectToAction("Wypozyczenies/" + wypozyczenie.IdCzytelnik));
        }
예제 #17
0
        public ActionResult AddKsiazka(Ksiazka model)
        {
            Ksiazka obj = new Ksiazka();

            obj.ID_Ksiazki         = model.ID_Ksiazki;
            obj.Nazwa_Ksiazki      = model.Nazwa_Ksiazki;
            obj.Autor_Ksiazki      = model.Autor_Ksiazki;
            obj.ID_Wypozyczajacego = model.ID_Wypozyczajacego;

            if (obj.ID_Wypozyczajacego != null)
            {
                obj.ID_StanuKsiazki = 2;
            }
            else
            {
                obj.ID_StanuKsiazki = 1;
            }

            if (obj.ID_Ksiazki == 0)
            {
                dbObj.Ksiazkas.Add(obj);
                ViewBag.Added = true;
            }
            else
            {
                dbObj.Entry(obj).State = System.Data.Entity.EntityState.Modified;
                ViewBag.Modified       = true;
            }


            dbObj.SaveChanges();

            var wypozyczajacy = dbObj.Wypozyczajacies.ToList();

            if (wypozyczajacy != null)
            {
                ViewBag.data = wypozyczajacy;
            }

            return(RedirectToAction("ZbiorKsiazek", "ZbiorKsiazek", dbObj.Ksiazkas.ToList()));
        }
        //Przycisk dodawanie klienta
        private void Btn_dodaj_kli_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txt_name.Text != "" && txt_surename.Text != "" && txt_nrPhone.Text != "")
                {
                    string name     = txt_name.Text;
                    string suremane = txt_surename.Text;
                    string nrphone  = txt_nrPhone.Text;
                    string info     = txt_info.Text;
                    string uwaga    = "Czy chcesz dodać uzytkownika " + name + " " + suremane + " ?";


                    if (MessageBox.Show(uwaga, "Uwaga", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        Clients klienci1 = new Clients();

                        klienci1.Firstname = name;
                        klienci1.Surename  = suremane;
                        klienci1.NrPhone   = nrphone;
                        klienci1.Info      = info;

                        db.Clients.Add(klienci1);
                        db.SaveChanges();


                        MessageBox.Show("Dodano klienta");
                        frame1.Content = new ClientPage(frame1, db);
                    }
                }
                else
                {
                    MessageBox.Show("Nie wszystkie pola są wypełnione ");
                }
            }
            catch (Exception f)
            {
                MessageBox.Show(f.Message);
            }
        }