/// <summary>
        /// Affichage de la page Détails de la livraison séléctionnée
        /// </summary>
        /// <param name="id">id de la livraison selectionnée</param>
        /// <returns>retourne les données correspondantes</returns>
        // GET: Deliveries/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_607_shipping_delivery tbl_607_shipping_delivery = db.tbl_607_shipping_delivery.Find(id);

            if (tbl_607_shipping_delivery == null)
            {
                return(HttpNotFound());
            }
            return(View(tbl_607_shipping_delivery));
        }
        /// <summary>
        /// affiche la page d'édition d'une livraison
        /// </summary>
        /// <param name="id">id de la livraison sélectionnée</param>
        /// <returns>vue d'édition</returns>
        // GET: Deliveries/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tbl_607_shipping_delivery tbl_607_shipping_delivery = db.tbl_607_shipping_delivery.Find(id);

            if (tbl_607_shipping_delivery == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FK_ID_shipping_request = new SelectList(db.tbl_607_shipping_request, "ID", "ID", tbl_607_shipping_delivery.FK_ID_shipping_request);
            return(View(tbl_607_shipping_delivery));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            tbl_607_shipping_delivery tbl_607_shipping_delivery = db.tbl_607_shipping_delivery.Find(id);

            db.tbl_607_shipping_delivery.Remove(tbl_607_shipping_delivery);
            try
            {
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException ex)
            {
                string s = ex.Message;
                return(RedirectToAction("../Ooops", new { message = s }));
            }
        }
 public ActionResult Edit([Bind(Include = "ID,BL_ref,reception_date,FK_ID_shipping_request")] tbl_607_shipping_delivery tbl_607_shipping_delivery)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tbl_607_shipping_delivery).State = EntityState.Modified;
         try
         {
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         catch (DbEntityValidationException ex)
         {
             string s = ex.Message;
             return(RedirectToAction("../Ooops", new { message = s }));
         }
     }
     ViewBag.FK_ID_shipping_request = new SelectList(db.tbl_607_shipping_request, "ID", "ID", tbl_607_shipping_delivery.FK_ID_shipping_request);
     return(View(tbl_607_shipping_delivery));
 }
Exemple #5
0
        public ActionResult SaveData()
        {
            try
            {
                // vérification de l'existance du BL
                // extraction des numeros de BL existants sur le contrat
                var BLBase = (db.tbl_607_shipping_delivery.Include(t => t.tbl_607_shipping_request).Include(s => s.tbl_607_shipping_request.tbl_607_order)
                              .Include(o => o.tbl_607_shipping_request.tbl_607_order.tbl_607_order_details))
                             .Where(o => o.tbl_607_shipping_request.tbl_607_order.ID == BottlereceptionWizardViewModelTemp.idcontract).Select(t => t.BL_ref).ToList();


                tbl_607_shipping_delivery tbl_607_Shipping_Delivery = new tbl_607_shipping_delivery();
                // comparaison avec le numero saisi par l'utilisateur
                var Control = BLBase.Contains(BottlereceptionWizardViewModelTemp.BL_ref);
                if (Control)
                {
                    //BL existant, nous allons donc uniquement proceder à un update
                }
                else
                {
                    //BL inexistant, creation
                    tbl_607_Shipping_Delivery.BL_ref                 = BottlereceptionWizardViewModelTemp.BL_ref;
                    tbl_607_Shipping_Delivery.reception_date         = BottlereceptionWizardViewModelTemp.reception_date;
                    tbl_607_Shipping_Delivery.FK_ID_shipping_request = BottlereceptionWizardViewModelTemp.FK_ID_shipping_request;
                    db.tbl_607_shipping_delivery.Add(tbl_607_Shipping_Delivery);
                    db.SaveChanges(); //sauvegarde
                }

                // le certificat de conformite est unique et est lie a une bouteille
                tbl_607_conformity_certificate tbl_607_Conformity_Certificate = new tbl_607_conformity_certificate();
                tbl_607_Conformity_Certificate.ID = BottlereceptionWizardViewModelTemp.conformity_certificate;
                tbl_607_Conformity_Certificate.fabrication_date = BottlereceptionWizardViewModelTemp.fabrication_date;
                tbl_607_Conformity_Certificate.expiration_date  = BottlereceptionWizardViewModelTemp.expiration_date;
                db.tbl_607_conformity_certificate.Add(tbl_607_Conformity_Certificate);
                db.SaveChanges(); //sauvegarde

                // recuperation des id des enregistrements crees
                var FK_ID_shipping_delivery = db.tbl_607_shipping_delivery.Select(t => t.ID).Max();

                // recuperation de l'id location pour stock
                var stock = db.tbl_607_location.Where(t => t.bottle_location == "STOCK").Select(t => t.ID).First();

                // enregistrement dans la table bouteille
                tbl_607_bottle tbl_607_Bottle = new tbl_607_bottle();
                tbl_607_Bottle.manufacturer_bottle_number   = BottlereceptionWizardViewModelTemp.manufacturer_bottle_number;
                tbl_607_Bottle.bottle_conti_number          = BottlereceptionWizardViewModelTemp.bottle_conti_number;
                tbl_607_Bottle.FK_ID_conformity_certificate = BottlereceptionWizardViewModelTemp.conformity_certificate;
                tbl_607_Bottle.FK_ID_shipping_delivery      = FK_ID_shipping_delivery;
                tbl_607_Bottle.FK_ID_order    = BottlereceptionWizardViewModelTemp.idcontract;
                tbl_607_Bottle.FK_ID_location = stock;
                db.tbl_607_bottle.Add(tbl_607_Bottle);
                db.SaveChanges(); //sauvegarde

                // mise à jour de la quantité recue sur le poste
                tbl_607_order_details tbl_607_Order_Detail = db.tbl_607_order_details.Where(t => t.poste_number == BottlereceptionWizardViewModelTemp.posteNumber && t.FK_ID_order == BottlereceptionWizardViewModelTemp.idcontract).First();
                tbl_607_Order_Detail.recieved_quantity = tbl_607_Order_Detail.recieved_quantity++;
                db.SaveChanges(); //sauvegarde

                // mise a jour de la quantité sur la demande de livraison
                tbl_607_shipping_request_details tbl_607_Shipping_Request_Details = db.tbl_607_shipping_request_details.Where(t => t.FK_shipping_request == BottlereceptionWizardViewModelTemp.FK_ID_shipping_request).FirstOrDefault();
                tbl_607_Shipping_Request_Details.reception_quantity = tbl_607_Shipping_Request_Details.reception_quantity++;
                db.SaveChanges(); //sauvegarde

                // Recuperation de l'ID Bottle. L'ID gaz est deja connu = key du dico
                var idBottle = db.tbl_607_bottle.Select(t => t.ID).Max();

                //Nouvelle relève: valeurs par défaut 999bars et acteur: admin
                tbl_607_gaz_reporting tbl_607_Gaz_Reporting = new tbl_607_gaz_reporting();
                tbl_607_Gaz_Reporting.pressure_value = 999;
                tbl_607_Gaz_Reporting.FK_ID_actors   = 29;
                tbl_607_Gaz_Reporting.FK_ID_bottle   = idBottle;
                tbl_607_Gaz_Reporting.reporting_date = DateTime.Now;
                db.tbl_607_gaz_reporting.Add(tbl_607_Gaz_Reporting);

                // Recuperation des reals gaz dans le dictionnaire
                foreach (KeyValuePair <int, float> value in Tbl_607_Real_Gaz_Content_temp)
                {
                    tbl_607_real_gaz_content tbl_607_Real_Gaz_Content = new tbl_607_real_gaz_content();
                    tbl_607_join_bottle_gaz  tbl_607_Join_Bottle_Gaz  = new tbl_607_join_bottle_gaz();
                    // Enregistrement des reals gaz
                    tbl_607_Real_Gaz_Content.real_content = value.Value; //force l'ecriture dans la base alors que nous sommes encore dans la boucle
                    db.tbl_607_real_gaz_content.Add(tbl_607_Real_Gaz_Content);
                    db.SaveChanges();                                    //sauvegarde

                    //// Recuperation de l'id real gaz
                    var fk_real = db.tbl_607_real_gaz_content.Select(t => t.ID).Max();

                    //Ecriture de la jointure
                    tbl_607_Join_Bottle_Gaz.FK_ID_gaz          = value.Key;
                    tbl_607_Join_Bottle_Gaz.FK_ID_bottle       = idBottle;
                    tbl_607_Join_Bottle_Gaz.FK_ID_real_content = fk_real;
                    db.tbl_607_join_bottle_gaz.Add(tbl_607_Join_Bottle_Gaz); //force l'ecriture dans la base alors que nous sommes encore dans la boucle
                    db.SaveChanges();                                        //sauvegarde
                }

                //generation de la vue
                return(View("Index"));
            }
            catch (Exception ex)
            {
                //generation de la vue affichage erreur
                return(RedirectToAction("Index", "Ooops", new { message = ex }));
            }
        }