Beispiel #1
0
        public static void SavePisteur(PisteurModel model)
        {
            string instanceName = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
            using (SqlConnection connPool = new SqlConnection(instanceName))
            {
                if (connPool.State == System.Data.ConnectionState.Closed)
                    connPool.Open();
                PISTEUR dataObj = new PISTEUR();

                dataObj.NOM = model.NOM;
                dataObj.PRENOM = model.PRENOM;
                dataObj.CONTACT = model.TEL;
                dataObj.ID_ZONE = model.ID_ZONE;
                dataObj.VILLAGE = model.VILLAGE;

                if (model.ID_AUTO != 0) dataObj.SetId(model.ID_AUTO);
                try
                {
                    dataObj.Save();
                }
                catch (SqlException ex)
                {
                    throw ex;
                }
                catch (Exception ex2)
                {
                    throw ex2;
                }
                finally
                {
                    try { connPool.Close(); }
                    catch (SqlException) { }
                    finally { connPool.Dispose(); }
                }
            }
        }
Beispiel #2
0
		public static List<PISTEUR> GetList()
		{
				List<PISTEUR> _list= new List<PISTEUR>();
				SqlDataReader dr = null;
				PISTEUR var = null;
				SqlParameter id_auto=new SqlParameter ("@ID_AUTO","0");
			try
			{
				 dr=SqlHelper.ExecuteReader(DbLink.Instance.Connection,
				"SPGETLIST_PISTEUR" ,id_auto);
				while (dr.Read())
				{
				var=new PISTEUR();
						var.SetId(dr.GetInt32(dr.GetOrdinal("ID_AUTO")));

						if(!(dr.IsDBNull(dr.GetOrdinal("NOM"))))
							{
								var.NOM = dr.GetString(dr.GetOrdinal("NOM"));
							}

						if(!(dr.IsDBNull(dr.GetOrdinal("PRENOM"))))
							{
								var.PRENOM = dr.GetString(dr.GetOrdinal("PRENOM"));
							}

						if(!(dr.IsDBNull(dr.GetOrdinal("CONTACT"))))
							{
								var.CONTACT = dr.GetString(dr.GetOrdinal("CONTACT"));
							}

						if(!(dr.IsDBNull(dr.GetOrdinal("VILLAGE"))))
							{
								var.VILLAGE = dr.GetString(dr.GetOrdinal("VILLAGE"));
							}

						if(!(dr.IsDBNull(dr.GetOrdinal("ID_ZONE"))))
							{
								var.ID_ZONE = dr.GetInt32(dr.GetOrdinal("ID_ZONE"));
							}
						var.SetZONE(dr.GetString(dr.GetOrdinal("ZONE")));
				_list.Add(var);
				}
			return _list;
			}
			catch (SqlException ex)
			{
				throw ex;
			}
			finally
			{
				dr.Close();
			}
		}