Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("TypeDepenseId,Nom")] TypeDepense typeDepense)
        {
            if (id != typeDepense.TypeDepenseId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    TempData["Confirmation"] = typeDepense.Nom + " a été modifié avec succès.";
                    _context.Update(typeDepense);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeDepenseExists(typeDepense.TypeDepenseId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeDepense));
        }
        public async Task <ActionResult <TypeDepense> > PostTypeDepense(TypeDepense typeDepense)
        {
            _context.typeDepenses.Add(typeDepense);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTypeDepense", new { id = typeDepense.Id }, typeDepense));
        }
Beispiel #3
0
        private void Enregistrer()
        {
            try
            {
                if (designTxt.Text == "")
                {
                    DynamicClasses.GetInstance().Alert("Champs vides détectés", DialogForms.FrmAlert.enmType.Error);
                }
                else
                {
                    TypeDepense typ = new TypeDepense();
                    typ.Id          = id;
                    typ.Designation = designTxt.Text;

                    typ.SaveDatas(typ);

                    DynamicClasses.GetInstance().Alert("Type save", DialogForms.FrmAlert.enmType.Success);

                    designTxt.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public async Task <IActionResult> PutTypeDepense(int id, TypeDepense typeDepense)
        {
            if (id != typeDepense.Id)
            {
                return(BadRequest());
            }

            _context.Entry(typeDepense).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeDepenseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Label")] TypeDepense typeDepense)
        {
            if (id != typeDepense.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeDepense);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeDepenseExists(typeDepense.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeDepense));
        }
        public async Task <IActionResult> Create([Bind("ID,Label")] TypeDepense typeDepense)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typeDepense);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeDepense));
        }
Beispiel #7
0
        public async Task <IActionResult> Create([Bind("TypeDepenseId,Nom")] TypeDepense typeDepense)
        {
            if (ModelState.IsValid)
            {
                TempData["Confirmation"] = typeDepense.Nom + " a été enregistré avec succès.";

                _context.Add(typeDepense);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeDepense));
        }
Beispiel #8
0
        public void ListCmbTypeDepense()
        {
            var l = TypeDepense.getAll();

            foreach (var item in l)
            {
                LoadCombo lCombo = new LoadCombo();
                lCombo.Id      = item.Id;
                lCombo.Libelle = item.Designation;
                ListTypeDepense.Add(lCombo);
            }
            cmbTypeDepense.ItemsSource = ListTypeDepense;
        }
Beispiel #9
0
 public JsonResult AjouterDepense(string txDepense)
 {
     if (!String.IsNullOrEmpty(txDepense))
     {
         if (!_context.TypeDepenses.Any(td => td.Nom.ToUpper().ToString().Equals(txDepense.ToUpper())))
         {
             var typeDepense = new TypeDepense();
             typeDepense.Nom = txDepense;
             _context.Add(typeDepense);
             _context.SaveChanges();
             return(Json(true));
         }
     }
     return(Json(false));
 }
Beispiel #10
0
        public void Insert()
        {
            var input  = string.Empty;
            var dialog = new InputDialog("Type de dépense", "Saisissez le type de dépense", input);

            if (dialog.ShowDialog() == true)
            {
                if (!string.IsNullOrEmpty(dialog.Input))
                {
                    var typ = new TypeDepense
                    {
                        Designation = dialog.Input
                    };

                    typ.Insert();

                    ListeTypeDepense.Add(typ);
                    TabTypeDepense.Items.Refresh();
                }
            }
        }
Beispiel #11
0
        private void BtnValider_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtMontant.Text) ||
                    //cmbHistoriquePanne.SelectedIndex == -1 ||
                    cmbTypeDepense.SelectedIndex == -1
                    //cmbVoyage.SelectedIndex == -1
                    )
                {
                    MessageBox.Show("Veuillez remplir tous les champs !", "mTransport", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    Depense T = new Depense();
                    T.Montant = Decimal.Parse(txtMontant.Text);

                    var td = cmbTypeDepense.SelectedItem as LoadCombo;
                    T.IdTypeDepense = td.Id;
                    var vg = cmbVoyage.SelectedItem as LoadCombo;
                    if (voyageId > 0)
                    {
                        T.IdVoyage = vg.Id;
                    }
                    if (Id > 0)
                    {
                        T.Id = Id;
                        var k = Voyage.getVoyage(vg.Id);
                        var m = TypeDepense.getTypeDepense(td.Id);
                        T.TypeDepense = m;
                        if (voyageId > 0)
                        {
                            T.Voyage = k;
                        }

                        T.Update();
                        MessageBox.Show("Modification effectuée !");
                        LoadTabDepense();
                        GriserChamps();
                        Id = 0;
                    }
                    else
                    {
                        T.Insert();
                        var m = TypeDepense.getTypeDepense(td.Id);
                        T.TypeDepense = m;
                        if (voyageId > 0)
                        {
                            var k = Voyage.getVoyage(vg.Id);
                            T.Voyage = k;
                        }
                        ListDepense.Add(T);
                        TabDepense.Items.Refresh();
                        MessageBox.Show("Enregistrement effectué !");
                        GriserChamps();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #12
0
 private void LoadTabTypeDepense()
 {
     ListeTypeDepense           = TypeDepense.getAll();
     TabTypeDepense.ItemsSource = ListeTypeDepense;
 }