Пример #1
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     try
     {
         string    Notatka  = ListaNotatek.SelectedValue.ToString();
         XDocument Dokument = XDocument.Load("ZapisaneDane.xml");
         Dokument.Descendants().Elements("Tresc_notatki")
         .Where(UsuwanieNotatki => UsuwanieNotatki.Value == Notatka)
         .Where(UsuwanieNotatki => UsuwanieNotatki.Parent.Name == "Notatka")
         .Select(UsuwanieNotatki => UsuwanieNotatki.Parent)
         .Remove();
         Dokument.Save("ZapisaneDane.xml");
         ListaNotatek.Items.Clear();
         string Semestr   = WyborSemestrMojeNotatki.Text;
         string Przedmiot = WyborPrzedmiotMojeNotatki.Text;
         var    Filtr     = XElement.Load("ZapisaneDane.xml")
                            .Descendants("Notatka")
                            .Where(Nody => Nody.Element("Semestr").Value == Semestr && Nody.Element("Przedmiot").Value == Przedmiot)
                            .OrderBy(Zmienna => (Zmienna.Element("Tresc_notatki").Value))
                            .ToList <XElement>();
         foreach (var Tresc in Filtr)
         {
             string NowaTresc = Tresc.Element("Tresc_notatki").Value;
             ListaNotatek.Items.Add(NowaTresc);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("Brak wybranej notatki do usuniecia", "Wystąpił błąd");
     }
 }
Пример #2
0
 public ActionResult Create(Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             model.TypTresci = (TypTresci)session.Load("TypTresci", 1);
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(model);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         ViewBag.Message = e.Message + "##ZRODLO##" + e.Source + "##DALEJ##" + e.InnerException;
         return(View());
     }
 }
Пример #3
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         if (WyborSemestrMojeNotatki.SelectedValue == null)
         {
             MessageBox.Show("Nie wprowadzono semstru", "Brak filtru");
         }
         else if (WyborPrzedmiotMojeNotatki.SelectedValue == null)
         {
             MessageBox.Show("Nie wprowadzono przedmiotu", "Brak filtru");
         }
         else
         {
             ListaNotatek.Items.Clear();
         }
         string Semestr   = WyborSemestrMojeNotatki.Text;
         string Przedmiot = WyborPrzedmiotMojeNotatki.Text;
         var    Filtr     = XElement.Load("ZapisaneDane.xml")
                            .Descendants("Notatka")
                            .Where(Nody => Nody.Element("Semestr").Value == Semestr && Nody.Element("Przedmiot").Value == Przedmiot)
                            .OrderBy(Zmienna => (Zmienna.Element("Tresc_notatki").Value))
                            .ToList <XElement>();
         foreach (var Tresc in Filtr)
         {
             string NowaTresc = Tresc.Element("Tresc_notatki").Value;
             ListaNotatek.Items.Add(NowaTresc);
         }
     }
     catch (Exception Wyjątek)
     {
         MessageBox.Show(Wyjątek.ToString(), "Wystąpił błąd");
     }
 }
Пример #4
0
        public ActionResult Delete(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Tresc        tresc = new Tresc();
            List <Tresc> Lista = new List <Tresc>();

            using (ISession session = NhibernateSession.OpenSession())
            {
                /* tresc = session.Query<Tresc>().Where(b => b.id == id).FirstOrDefault();
                 * List<TypTresci> jakas = session.Query<TypTresci>().ToList();
                 * WirtualnyDziennik.Models.TypTresci.ListaDostepnych = new List<System.Web.Mvc.SelectListItem>();
                 * for (int i = 0; i < jakas.Count(); i++)
                 * {
                 *   SelectListItem Item = new SelectListItem();
                 *   Item.Text = jakas[i].nazwa;
                 *   WirtualnyDziennik.Models.TypTresci.ListaDostepnych.Add(Item);
                 * }*/
                tresc = session.Query <Tresc>().Where(b => b.id == id).FirstOrDefault();
                using (ITransaction trans = session.BeginTransaction())
                {
                    session.Delete(tresc);
                    trans.Commit();
                }
                Lista = session.Query <Tresc>().ToList();
            }
            // ViewBag.SubmitAction = "Confirm delete";
            return(RedirectToAction("Index", "Tresc"));
        }
Пример #5
0
 public ActionResult Edit(int id, Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             Tresc tresc = session.Get <Tresc>(id);
             tresc.tytul     = model.tytul;
             tresc.tresc     = model.tresc;
             tresc.TypTresci = model.TypTresci;
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.SaveOrUpdate(tresc);
                 transaction.Commit();
             }
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #6
0
        public ActionResult Edit(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Tresc tresc = new Tresc();

            using (ISession session = NhibernateSession.OpenSession())
            {
                List <TypTresci> jakas = session.Query <TypTresci>().ToList();
                WirtualnyDziennik.Models.TypTresci.ListaDostepnych = new List <System.Web.Mvc.SelectListItem>();
                for (int i = 0; i < jakas.Count(); i++)
                {
                    SelectListItem Item = new SelectListItem();
                    Item.Text  = jakas[i].nazwa;
                    Item.Value = jakas[i].id.ToString();
                    TypTresci.ListaDostepnych.Add(Item);
                }
                tresc = session.Query <Tresc>().Where(b => b.id == id).FirstOrDefault();
            }

            ViewBag.SubmitAction = "Save";
            return(View(tresc));
        }
Пример #7
0
 public ActionResult Message(Tresc model)
 {
     if (this.Session["UserProfile"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     try
     {
         using (ISession session = NhibernateSession.OpenSession())
         {
             UserProfileSessionData uspd = this.Session["UserProfile"] as UserProfileSessionData;
             model.OD        = uspd.Name;
             model.TypTresci = (TypTresci)session.Load("TypTresci", 2);
             using (ITransaction transaction = session.BeginTransaction())
             {
                 session.Save(model);
                 transaction.Commit();
             }
         }
         return(View());
     }
     catch (Exception e)
     {
         return(View());
     }
 }
Пример #8
0
        public ActionResult Details(int id)
        {
            if (this.Session["UserProfile"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            Tresc tresc = new Tresc();

            using (ISession session = NhibernateSession.OpenSession())
            {
                tresc = session.Query <Tresc>().Where(b => b.id == id).FirstOrDefault();
            }

            return(View(tresc));
        }
Пример #9
0
        } = DateTime.Now;                                       // tu uwaga bo to pobiera terazniejszy czas,
                                                                //czyli obiekt musi być utworzony dokładnie gdy wcisniemy przycisk!


        //konstruktor niepotrzebny
        //referencje na twórcę i inne potem
        //metody z klasy object, może sie przydadzą
        public override string ToString()
        {
            return($"Sprawa:\n ID {Id} \nNazwisko klienta {NazwiskoKlienta}\nTresc sprawy {Tresc.Substring(0, 50)}...\nDecyzja {Decyzja}\n");
            //co ty na to?
        }