// GET: DossierFclExports/Create public ActionResult Create() { ViewBag.numDoss = (DateTime.Now.Year + "E" + leDoss.numDossCompteur().ToString()); ViewBag.CLT_ID = new SelectList(db.Clients, "CLT_ID", "CLT_NOMRAIS"); return(View()); }
public ActionResult ResumeFcl(FormCollection fc) { try { var viewModel = new ResumeDossierFcl(); viewModel.Clients = rezCli; viewModel.DossierFclExports = rezDoss; viewModel.Bookings = rezBkg; viewModel.InstruTrans = rezInstru; viewModel.Transporteurs = rezTrans; viewModel.Mads = rezMad; viewModel.Devis = rezDevi; viewModel.CompagnieMaritimes = rezCompa; viewModel.Conteneurs = lstTC; viewModel.Marchandises = lsMarchandises; viewModel.LigneDeVentes = lstLV; //Instanciation de l'objet client rezCli.CLT_ID = leCliDuDoss.NewIdClient(); rezCli.CLT_REF = fc["Clients.CLT_REF"]; rezCli.CLT_NOMRAIS = fc["Clients.CLT_NOMRAIS"]; if (!String.IsNullOrEmpty(fc["Clients.CLT_SIRET"])) { rezCli.CLT_SIRET = Convert.ToInt32(fc["Clients.CLT_SIRET"]); } else { rezCli.CLT_SIRET = 0; } rezCli.CLT_ADRESSE = fc["Clients.CLT_ADRESSE"]; rezCli.CLT_CP = fc["Clients.CLT_CP"]; rezCli.CLT_VILLE = fc["Clients.CLT_VILLE"]; rezCli.CLT_PAYS = fc["Clients.CLT_PAYS"]; leCliDuDoss.AddClient(rezCli); //db.SaveChanges(); //Instanciation de l'objet dossier rezDoss.FCL_ID = (DateTime.Now.Year + "E" + leDoss.numDossCompteur().ToString()); rezDoss.CLT_ID = rezCli.CLT_ID; leDoss.AddDossier(rezDoss); //Instanciation de l'objet Transporteur rezTrans.TRS_REF = lesTransDuDoss.numTransCompteur().ToString(); rezTrans.TYTRANS_ID = Convert.ToInt32(fc["TYTRANS_ID"]); rezTrans.TRS_NOMRAIS = fc["Transporteurs.TRS_NOMRAIS"]; lesTransDuDoss.AddTrans(rezTrans); //Instanciation de l'objet MAD rezMad.MAD_ID = madDuDoss.NumMad(); rezMad.MAD_LIEU_ENLEV = fc["Mads.MAD_LIEU_ENLEV"]; rezMad.MAD_ADRES_ENLEV = fc["Mads.MAD_ADRES_ENLEV"]; if (!String.IsNullOrEmpty(fc["Mads.MAD_DATE"])) { rezMad.MAD_DATE = Convert.ToDateTime(fc["Mads.MAD_DATE"]); } else { rezMad.MAD_DATE = DateTime.Now; } madDuDoss.AddMad(rezMad); //Instanciation de l'objet Instruction Transporteur rezInstru.INSTR_NUMOFR = instruDoss.NumOffreAuto(); rezInstru.MAD_ID = rezMad.MAD_ID; rezInstru.FCL_ID = rezDoss.FCL_ID; rezInstru.TRS_REF = rezTrans.TRS_REF; instruDoss.AddInstruTrans(rezInstru); //Instanciation de l'objet CompagnieMaritime rezCompa.CM_REF = cmDuDoss.numCompMaritime().ToString(); rezCompa.CM_NOMRAIS = fc["CompagnieMaritimes.CM_NOMRAIS"]; rezCompa.CM_SIRET = 0; rezCompa.CM_ADRESSE = ""; rezCompa.CM_CP = ""; rezCompa.CM_VILLE = fc["CompagnieMaritimes.CM_VILLE"]; cmDuDoss.AddCM(rezCompa); //Instanciation de l'objet Booking rezBkg.BKG_ID = lesBkDuDoss.CompteurNumBkg(); rezBkg.BKG_NUM = fc["Bookings.BKG_NUM"]; rezBkg.FCL_ID = rezDoss.FCL_ID; rezBkg.CM_REF = rezCompa.CM_REF; rezBkg.BKG_NOMNAVIRE = fc["Bookings.BKG_NOMNAVIRE"]; rezBkg.BKG_DATE = DateTime.Now; if (!String.IsNullOrEmpty(fc["Bookings.BKG_ETA"])) { rezBkg.BKG_ETA = Convert.ToDateTime(fc["Bookings.BKG_ETA"]); } else { rezBkg.BKG_ETA = DateTime.Now; } if (!String.IsNullOrEmpty(fc["Bookings.BKG_ETD"])) { rezBkg.BKG_ETD = Convert.ToDateTime(fc["Bookings.BKG_ETD"]); } else { rezBkg.BKG_ETD = DateTime.Now; } rezBkg.BKG_FORWARDER = ""; rezBkg.BKG_LOADTERM = ""; rezBkg.BKG_NUMVYG = ""; rezBkg.BKG_PORTARRIVEE = fc["Bookings.BKG_PORTARRIVEE"]; rezBkg.BKG_PORTDEPART = fc["Bookings.BKG_PORTDEPART"]; rezBkg.BKG_PORTFORWARDER = ""; rezBkg.BKG_REFCOTATION = ""; rezBkg.BKG_OBS = ""; rezBkg.BKG_REFBL = fc["Bookings.BKG_REFBL"]; lesBkDuDoss.AddBooking(rezBkg); ViewBag.TYTRANS_ID = new SelectList(db.TypeTransporteurs, "TYTRANS_ID", "TYTRANS_LIBELLE"); return(RedirectToAction("Index", new { Controller = "DossierFclExports" })); } catch (RetryLimitExceededException /* dex */) { ModelState.AddModelError(" ", "Unable to save changes. Try again, and if the problem persists see your system administrator"); } return(RedirectToAction("Details", new { Controller = "DossierFclExports", id = rezDoss.FCL_ID })); }