Example #1
0
 public static int Insert(TerritorioInfo _TerritorioInfo)
 {
     //Execute the query and return the new Guid
     object retval = _AdoHelper.ExecuteScalar(ConnectionString, "TerritorioInsert",
         new SqlParameter("@Descripcion", _TerritorioInfo.Descripcion),
         new SqlParameter("@Responsable", _TerritorioInfo.Responsable),
         new SqlParameter("@Abrv", _TerritorioInfo.Abrv)
     );
     return Int32.Parse(retval.ToString());
 }
Example #2
0
        public static void Delete(TerritorioInfo _TerritorioInfo)
        {
            try
            {
                _AdoHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "TerritorioDelete",
                    new SqlParameter("@TerritorioId", _TerritorioInfo.TerritorioId)
                );

            }
            catch (SqlException ex)
            {
                //Este numero es cuando tiene refernecia a otras tablas
                if (ex.Number != 547)
                    throw;
            }
            catch (Exception)
            {

                throw;
            }
        }
Example #3
0
        /// <summary>
        /// Creates a new instance of the Territorio class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private static TerritorioInfo MakeTerritorio(SqlDataReader dataReader)
        {
            TerritorioInfo territorio = new TerritorioInfo();

            if (dataReader.IsDBNull(TerritorioId) == false)
                territorio.TerritorioId = dataReader.GetInt32(TerritorioId);
            if (dataReader.IsDBNull(Descripcion) == false)
                territorio.Descripcion = dataReader.GetString(Descripcion);
            if (dataReader.IsDBNull(Responsable) == false)
                territorio.Responsable = dataReader.GetInt32(Responsable);
            if (dataReader.IsDBNull(Abrv) == false)
                territorio.Abrv = dataReader.GetString(Abrv);

            return territorio;
        }
Example #4
0
 public static void Update(TerritorioInfo _TerritorioInfo)
 {
     _AdoHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure, "TerritorioUpdate",
         new SqlParameter("@TerritorioId", _TerritorioInfo.TerritorioId),
         new SqlParameter("@Descripcion", _TerritorioInfo.Descripcion),
         new SqlParameter("@Responsable", _TerritorioInfo.Responsable),
         new SqlParameter("@Abrv", _TerritorioInfo.Abrv)
     );
 }