Ejemplo n.º 1
0
        // GET: Wyplatas/Details/5

        /*   public ActionResult Details(int? id)
         * {
         *     if (id == null)
         *     {
         *         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *     }
         *     Wyplata wyplata = db.Wyplata.Find(id);
         *     if (wyplata == null)
         *     {
         *         return HttpNotFound();
         *     }
         *     return View(wyplata);
         * }
         */
        // GET: Wyplatas/Create

        /*    public ActionResult Create()
         *  {
         *      ViewBag.IdPracownika = new SelectList(db.Table, "IdUzytkownika", "Imie");
         *      return View();
         *  } */

        // POST: Wyplatas/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.

        /*   [HttpPost]
         * [ValidateAntiForgeryToken]
         * public ActionResult Create([Bind(Include = "IdWyplata,Zus,Dochodowy,Data,PlacaNetto,IdPracownika,Emerytalna,rentowa,chorobowa")] Wyplata wyplata)
         * {
         *     if (ModelState.IsValid)
         *     {
         *         db.Wyplata.Add(wyplata);
         *         db.SaveChanges();
         *         return RedirectToAction("Index");
         *     }
         *
         *     ViewBag.IdPracownika = new SelectList(db.Table, "IdUzytkownika", "Imie", wyplata.IdPracownika);
         *     return View(wyplata);
         * } */

        // GET: Wyplatas/Edit/5

        /*   public ActionResult Edit(int? id)
         * {
         *     if (id == null)
         *     {
         *         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
         *     }
         *     Wyplata wyplata = db.Wyplata.Find(id);
         *     if (wyplata == null)
         *     {
         *         return HttpNotFound();
         *     }
         *     ViewBag.IdPracownika = new SelectList(db.Table, "IdUzytkownika", "Imie", wyplata.IdPracownika);
         *     return View(wyplata);
         * } */

        // POST: Wyplatas/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.

        /* [HttpPost]
         * [ValidateAntiForgeryToken]
         * public ActionResult Edit([Bind(Include = "IdWyplata,Zus,Dochodowy,Data,PlacaNetto,IdPracownika,Emerytalna,rentowa,chorobowa")] Wyplata wyplata)
         * {
         *   if (ModelState.IsValid)
         *   {
         *       db.Entry(wyplata).State = EntityState.Modified;
         *       db.SaveChanges();
         *       return RedirectToAction("Index");
         *   }
         *   ViewBag.IdPracownika = new SelectList(db.Table, "IdUzytkownika", "Imie", wyplata.IdPracownika);
         *   return View(wyplata);
         * } */

        // GET: Wyplatas/Delete/5
        public ActionResult Delete(int?id)
        {
            if (Session["Uprawnienia"] != null)
            {
                var list = Session["Uprawnienia"] as List <UzytkownikModels>;
                if (list.Select(p => p.uprawnienia).First() == 2)
                {
                    if (id == null)
                    {
                        return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                    }
                    Wyplata wyplata = db.Wyplata.Find(id);
                    if (wyplata == null)
                    {
                        return(HttpNotFound());
                    }
                    return(View(wyplata));
                }
                else
                {
                    return(View("../Home/Index"));
                }
            }
            else
            {
                return(View("../Home/Index"));
            }
        }
Ejemplo n.º 2
0
        // GET: DodajWyplate
        public ActionResult Index(int?id)
        {
            double wyplataBrutto;

            if (Session["Uprawnienia"] != null)
            {
                var list = Session["Uprawnienia"] as List <UzytkownikModels>;
                if (list.Select(p => p.uprawnienia).First() == 2)
                {
                    int     id2;
                    Wyplata wyplata    = new Wyplata();
                    Table   uzytkownik = new Table();
                    db4e37397b7458442a8c4ea6b801845440Entities1 db = new db4e37397b7458442a8c4ea6b801845440Entities1();
                    wyplataBrutto = db.Table.Where(p => p.IdUzytkownika == id).Select(p => p.WyplataBrutto).First().Value;
                    if (db.Wyplata.Any())
                    {
                        id2 = db.Wyplata.OrderByDescending(p => p.IdWyplata).Select(p => p.IdWyplata).First();

                        wyplata.IdWyplata    = id2 + 1;
                        wyplata.IdPracownika = id;
                        wyplata.Emerytalna   = wyplataBrutto * 0.0976;
                        wyplata.chorobowa    = wyplataBrutto * 0.0245;
                        wyplata.rentowa      = wyplataBrutto * 0.015;
                        wyplata.Zus          = wyplataBrutto * 0.09;
                        wyplata.Dochodowy    = (wyplataBrutto - ((wyplataBrutto * 0.09) + (wyplataBrutto * 0.0976) + (wyplataBrutto * 0.015) + (wyplataBrutto * 0.0245))) * 0.18;
                        wyplata.PlacaNetto   = wyplataBrutto - wyplata.rentowa - wyplata.chorobowa - wyplata.Emerytalna - wyplata.Dochodowy;
                        wyplata.Data         = DateTime.Now.Date;
                        db.Wyplata.Add(wyplata);
                        db.SaveChanges();
                    }
                    else
                    {
                        wyplata.IdWyplata    = 1;
                        wyplata.IdPracownika = id;
                        wyplata.Emerytalna   = wyplataBrutto * 0.0976;
                        wyplata.chorobowa    = wyplataBrutto * 0.0245;
                        wyplata.rentowa      = wyplataBrutto * 0.015;
                        wyplata.Zus          = wyplataBrutto * 0.09;
                        wyplata.Dochodowy    = (wyplataBrutto - ((wyplataBrutto * 0.09) + (wyplataBrutto * 0.0976) + (wyplataBrutto * 0.015) + (wyplataBrutto * 0.0245))) * 0.18;
                        wyplata.PlacaNetto   = wyplataBrutto - wyplata.rentowa - wyplata.chorobowa - wyplata.Emerytalna - wyplata.Dochodowy;
                        wyplata.Data         = DateTime.Now.Date;
                        db.Wyplata.Add(wyplata);
                        db.SaveChanges();
                    }
                    TempData["Wyplata"] = "Dodano wyplate";
                }
                else
                {
                    return(View("../Home/Index"));
                }
            }
            else
            {
                return(View("../Home/Index"));
            }
            return(RedirectToAction("Index", "EdycjaAdmin"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Kod wykonywany przy usuwaniu wypłaty
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtUsunWyplate_Click(object sender, RoutedEventArgs e)
        {
            Wyplata w1 = (Wyplata)wyplatasDataGrid.SelectedItem; //pobranie obiekty wypłaty z tabeli

            if (w1 != null)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Czy usunąć wypłatę dla pracownika " + w1.Pracownik.Imie + " " + w1.Pracownik.Nazwisko + "?", "Usuwanie wypłaty", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    Wyplata.UsunWyplate(w1, dbcontext);                                                                                       //usunięcie wypłaty
                    wyplatasDataGrid.ItemsSource = dbcontext.Wyplaty.Local.Where(w => w.Pracownik.Equals(CbPracownik.SelectedItem)).ToList(); //przeładowanie danych
                    wyplatasDataGrid.Items.Refresh();
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Kod wykonywany przy dodawaniu nowej wypłaty
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BtDodajWyplate_Click(object sender, RoutedEventArgs e)
 {
     if (CbPracownik.SelectedIndex < 0) //sprawdzenie czy wybrano pracownika z listy
     {
         MessageBox.Show("Wybierz pracownika!");
     }
     else
     {
         if (TbPrLbGodz.Text == "")
         {
             MessageBox.Show("Podaj liczbę godzin!");
         }
         else
         {
             if (CbMiesiac.SelectedIndex < 0)
             {
                 MessageBox.Show("Wybierz miesiąc!");
             }
             else
             {
                 if (CbRok.SelectedIndex < 0)
                 {
                     MessageBox.Show("Wybierz rok!");
                 }
                 else
                 {
                     try
                     {
                         Wyplata.DodajWyplate(CbMiesiac.Text + " " + CbRok.Text, decimal.Parse(TbPrLbGodz.Text), CbPracownik.SelectedItem as Pracownik, dbcontext); //dodanie wypłaty
                         wyplatasDataGrid.ItemsSource = dbcontext.Wyplaty.Local.Where(w => w.Pracownik.Equals(CbPracownik.SelectedItem));                           //przeładowanie danych
                         wyplatasDataGrid.Items.Refresh();
                         CbRok.SelectedItem = null; CbMiesiac.SelectedItem = null; TbPrLbGodz.Clear();                                                              //czyszczenie pól
                     }
                     catch (FormatException ex)
                     {
                         MessageBox.Show("Popraw format danych!");  //komunikat jeśli wprowadzono niepoprawny format danych
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 public ActionResult DeleteConfirmed(int id)
 {
     if (Session["Uprawnienia"] != null)
     {
         var list = Session["Uprawnienia"] as List <UzytkownikModels>;
         if (list.Select(p => p.uprawnienia).First() == 2)
         {
             Wyplata wyplata = db.Wyplata.Find(id);
             int?    id2     = wyplata.IdPracownika;
             db.Wyplata.Remove(wyplata);
             db.SaveChanges();
             return(RedirectToAction("Index", new { id = id2 }));
         }
         else
         {
             return(View("../Home/Index"));
         }
     }
     else
     {
         return(View("../Home/Index"));
     }
 }
Ejemplo n.º 6
0
        private void oblicz_Click(object sender, RoutedEventArgs e)
        {
            kwBrutto = Double.Parse(brutto.Text);
            if (CbUmowaoPrace.IsSelected)
            {
                if (ageCheckBox.IsChecked == true)
                {
                    var          wyplata      = new Wyplata();
                    UmowaBuilder umowaBuilder = new Umowa_o_Prace();
                    umowaBuilder.BuildUbEmerytalne();
                    umowaBuilder.BuildUbRentowe();
                    umowaBuilder.BuildUbChorobowe();
                    umowaBuilder.BuildUbZdrowotne();
                    umowaBuilder.Umowa.DisplayConfiguration();
                    var prac = new UEmerytalne(new URentowe(new UWypadkowe(new FP(new FGSP(new Pracodawca())))));
                    pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                    OplatyPracodawcy.Content = "Zawierają: \n" + prac.GetNazwa();
                }
                else
                {
                    var          wyplata      = new Wyplata();
                    UmowaBuilder umowaBuilder = new Umowa_o_Prace();
                    wyplata.ConstructUmowa(umowaBuilder);
                    umowaBuilder.Umowa.DisplayConfiguration();
                    var prac = new UEmerytalne(new URentowe(new UWypadkowe(new FP(new FGSP(new Pracodawca())))));
                    pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                    OplatyPracodawcy.Content = "Zawierają: \n" + prac.GetNazwa();
                }
            }
            else if (CbUmowaZlecenie.IsSelected)
            {
                if (ageCheckBox.IsChecked == true)
                {
                    var          wyplata      = new Wyplata();
                    UmowaBuilder umowaBuilder = new Umowa_Zlecenie();
                    umowaBuilder.Umowa.DisplayConfiguration();
                    var prac = new Pracodawca();
                    pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                    OplatyPracodawcy.Content = "Zawierają: \n" + prac.GetNazwa();
                }
                else
                {
                    if (jobCheckBox.IsChecked == true)
                    {
                        var          wyplata      = new Wyplata();
                        UmowaBuilder umowaBuilder = new Umowa_Zlecenie();
                        wyplata.ConstructUmowa(umowaBuilder);
                        umowaBuilder.Umowa.DisplayConfiguration();
                        var prac = new UEmerytalne(new URentowe(new UWypadkowe(new FP(new FGSP(new Pracodawca())))));
                        pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                        OplatyPracodawcy.Content = "Zawierają: \n" + prac.GetNazwa();
                    }
                    else
                    {
                        var          wyplata      = new Wyplata();
                        UmowaBuilder umowaBuilder = new Umowa_Zlecenie();
                        umowaBuilder.BuildUbZdrowotne();
                        umowaBuilder.BuildPoDochodowy();
                        umowaBuilder.Umowa.DisplayConfiguration();
                        var prac = new Pracodawca();
                        pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                        OplatyPracodawcy.Content = "Zawierają: \n" + prac.GetNazwa();
                    }
                }
            }
            else if (CbUmowaoDzielo.IsSelected)
            {
                var          wyplata      = new Wyplata();
                UmowaBuilder umowaBuilder = new Umowa_o_Dzielo();
                wyplata.ConstructUmowa(umowaBuilder);
                umowaBuilder.Umowa.DisplayConfiguration();
                var prac = new Pracodawca();
                pracodawca.Text          = Math.Round(prac.GetKoszty(), 2).ToString();
                OplatyPracodawcy.Content = prac.GetNazwa();
            }


            Visibily();
        }