Пример #1
0
        public void update(mercados mer)
        {
            string cnx = db.Database.Connection.ConnectionString;

            con = new SqlConnection(cnx);
            try
            {
                comando = new SqlCommand("usp_MercadoUpdate", con);
                comando.Parameters.AddWithValue("@IdMercado", mer.IdMercado);
                comando.Parameters.AddWithValue("@IdZona", mer.IdZona);
                comando.Parameters.AddWithValue("@NombreCorto", mer.NombreCorto);
                comando.Parameters.AddWithValue("@NombreLargo", mer.NombreLargo);
                comando.Parameters.AddWithValue("@Direccion", mer.Direccion);
                comando.Parameters.AddWithValue("@Observ", mer.Observ);
                comando.Parameters.AddWithValue("@ubigeo", mer.ubigeo);
                comando.CommandType = System.Data.CommandType.StoredProcedure;
                con.Open();
                comando.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
        }
Пример #2
0
        public mercados BuscarMercado(int id)
        {
            mercados mrca = new mercados();
            string   cnx  = db.Database.Connection.ConnectionString;

            con = new SqlConnection(cnx);
            bool   hayRegistros;
            string find = "select*from mercados where IdMercado='" + id + "'";

            try
            {
                comando = new SqlCommand(find, con);
                con.Open();
                SqlDataReader reader = comando.ExecuteReader();
                hayRegistros     = reader.Read();
                mrca.IdMercado   = Convert.ToInt32(reader[0].ToString());
                mrca.IdZona      = Convert.ToInt32(reader[1].ToString());
                mrca.NombreCorto = reader[2].ToString();
                mrca.NombreLargo = reader[3].ToString();
                mrca.Direccion   = reader[4].ToString();
                mrca.ubigeo      = reader[5].ToString();
                mrca.Observ      = reader[6].ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                con.Close();
            }
            return(mrca);
        }