Ejemplo n.º 1
0
        //
        // GET: /VenteDetails/

        public ActionResult Index()
        {
            VENTE_DETAILS _venteDetails = new VENTE_DETAILS();

            List<Vente_Details> _list = new List<Vente_Details>(); ;
            foreach (VENTE_DETAILS item in VENTE_DETAILS.GetList())
            {
                Vente_Details ventesDetails = new Vente_Details();
                
                ventesDetails.ID_AUTO = item.ID_AUTO;
                ventesDetails.ID_CHARGEMENT = item.ID_CHARGEMENT;
                ventesDetails.ID_VENTE = item.ID_VENTE;

                VENTE vente = new VENTE();
                vente.LoadId(item.ID_VENTE);

                ventesDetails.VENTE = vente.ToString();

                CHARGERMENT charge = new CHARGERMENT();
                charge.LoadId(item.ID_CHARGEMENT);

                ventesDetails.CHARGEMENT = charge.ToString();

                ventesDetails.PRIX_UNITAIRE= item.PRIX_UNITAIRE;
                ventesDetails.QTE = item.QTE;
                ventesDetails.TOTAL = item.TOTAL;
                _list.Add(ventesDetails);
            }

            return View(_list);
        }
Ejemplo n.º 2
0
 public static List<VENTE_DETAILS> GetListByVente(int idVente,int idChargement)
 {
     List<VENTE_DETAILS> _list = new List<VENTE_DETAILS>();
     SqlDataReader dr = null;
     VENTE_DETAILS var = null;
     SqlParameter id_vente = new SqlParameter("@ID_VENTE", idVente);
     SqlParameter id_chargement = new SqlParameter("@ID_CHARGEMENT", idChargement);
     try
     {
         dr = SqlHelper.ExecuteReader(Connexion.Cnx,
        "SPGETLIST_VENTE_DETAILSBY_VENTE", id_vente, id_chargement);
         while (dr.Read())
         {
             var = new VENTE_DETAILS();
             var.SetId(dr.GetInt32(dr.GetOrdinal("ID_AUTO")));
             var.ID_VENTE = dr.GetInt32(dr.GetOrdinal("ID_VENTE"));
             var.ID_CHARGEMENT = dr.GetInt32(dr.GetOrdinal("ID_CHARGEMENT"));
             var.PRIX_UNITAIRE = dr.GetInt32(dr.GetOrdinal("PRIX_UNITAIRE"));
             var.QTE = dr.GetInt32(dr.GetOrdinal("QTE"));
             var.TOTAL = dr.GetInt32(dr.GetOrdinal("TOTAL"));
             var.SetCHARGERMENT(dr.GetString(dr.GetOrdinal("CHARGERMENT")));
             _list.Add(var);
         }
         return _list;
     }
     catch (SqlException ex)
     {
         throw ex;
     }
     finally
     {
         dr.Close();
     }
 }
Ejemplo n.º 3
0
		public static List<VENTE_DETAILS> GetList()
		{
				List<VENTE_DETAILS> _list= new List<VENTE_DETAILS>();
				SqlDataReader dr = null;
				VENTE_DETAILS var = null;
				SqlParameter id_auto=new SqlParameter ("@ID_AUTO","0");
			try
			{
                dr = SqlHelper.ExecuteReader(Connexion.Cnx,
				"SPGETLIST_VENTE_DETAILS" ,id_auto);
				while (dr.Read())
				{
				var=new VENTE_DETAILS();
						var.SetId(dr.GetInt32(dr.GetOrdinal("ID_AUTO")));
						var.ID_VENTE = dr.GetInt32(dr.GetOrdinal("ID_VENTE"));
						var.ID_CHARGEMENT = dr.GetInt32(dr.GetOrdinal("ID_CHARGEMENT"));
						var.PRIX_UNITAIRE = dr.GetInt32(dr.GetOrdinal("PRIX_UNITAIRE"));
						var.QTE = dr.GetInt32(dr.GetOrdinal("QTE"));
						var.TOTAL = dr.GetInt32(dr.GetOrdinal("TOTAL"));
				_list.Add(var);
				}
			return _list;
			}
			catch (SqlException ex)
			{
				throw ex;
			}
			finally
			{
				dr.Close();
			}
		}
Ejemplo n.º 4
0
        public ActionResult Create(Vente_Details VenteDetailsToCreate)
        {
            if (!ModelState.IsValid)
                return View();

            try
            {
                VENTE_DETAILS _venteDetails = new VENTE_DETAILS();
                _venteDetails.ID_CHARGEMENT = VenteDetailsToCreate.ID_CHARGEMENT;
                _venteDetails.ID_VENTE = VenteDetailsToCreate.ID_VENTE;
                _venteDetails.PRIX_UNITAIRE = VenteDetailsToCreate.PRIX_UNITAIRE;
                _venteDetails.QTE = VenteDetailsToCreate.QTE;
                _venteDetails.TOTAL = VenteDetailsToCreate.TOTAL;
               
                _venteDetails.Save();
                return RedirectToAction("../VenteDetails/Index");
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 5
0
        public ActionResult Delete(Vente_Details VenteDetailsToDel)
        {
            int id = Int32.Parse(RouteData.Values["id"].ToString());

            if (!ModelState.IsValid)
                return View();

            try
            {
                VENTE_DETAILS _venteDetails = new VENTE_DETAILS();
                _venteDetails.SetId(id);
                _venteDetails.Delete();
                return RedirectToAction("../VenteDetails/Index");//reafficher l liste
            }
            catch
            {
                return View();
            }
        }
Ejemplo n.º 6
0
        //
        // GET: /VenteDetails/Delete/5
 
        public ActionResult Delete()
        {
            int id = Int32.Parse(RouteData.Values["id"].ToString());
          
            Vente_Details ventesDetails = new Vente_Details();
            VENTE_DETAILS _venteDetails = new VENTE_DETAILS();
            _venteDetails.LoadId(id);
            ventesDetails.TOTAL = _venteDetails.TOTAL;
            ventesDetails.QTE = _venteDetails.QTE;
            ventesDetails.PRIX_UNITAIRE = _venteDetails.PRIX_UNITAIRE;
            ventesDetails.ID_VENTE = _venteDetails.ID_VENTE;
            ventesDetails.ID_CHARGEMENT = _venteDetails.ID_CHARGEMENT;

            VENTE vente = new VENTE();
            vente.LoadId(_venteDetails.ID_VENTE);

            ventesDetails.VENTE = vente.ToString();

            CHARGERMENT charge = new CHARGERMENT();
            charge.LoadId(_venteDetails.ID_CHARGEMENT);

            ventesDetails.CHARGEMENT = charge.ToString();


            IEnumerable<SelectListItem> list = ToSelectListItems();
            list.ToList().Find(x => x.Text.Equals(ventesDetails.VENTE)).Selected = true;
            ViewData["ID_VENTE"] = list;

            IEnumerable<SelectListItem> list1 = ToSelectListItems1();
            list1.ToList().Find(x => x.Text.Equals(ventesDetails.CHARGEMENT)).Selected = true;
            ViewData["ID_CHARGEMENT"] = list1;

            return View(ventesDetails);
        }
Ejemplo n.º 7
0
        public ActionResult Edit(Vente_Details ventesDetails)
        {
            int id = Int32.Parse(RouteData.Values["id"].ToString());

            if (!ModelState.IsValid)
                return View();

            try
            {
                VENTE_DETAILS _venteDetails = new VENTE_DETAILS();
                _venteDetails.TOTAL = ventesDetails.TOTAL;
                _venteDetails.PRIX_UNITAIRE = ventesDetails.PRIX_UNITAIRE;
                _venteDetails.QTE = ventesDetails.QTE;
                _venteDetails.ID_VENTE = ventesDetails.ID_VENTE;
                _venteDetails.ID_CHARGEMENT = ventesDetails.ID_CHARGEMENT;
                _venteDetails.SetId(id);
                _venteDetails.Save();
                return RedirectToAction("../VenteDetails/Index");
            }
            catch
            {
                return View();
            }

        }