public cp_proveedor_microempresa_Info GetInfo(string Ruc)
        {
            try
            {
                cp_proveedor_microempresa_Info info = new cp_proveedor_microempresa_Info();

                using (SqlConnection connection = new SqlConnection(ConexionesERP.GetConnectionString()))
                {
                    connection.Open();
                    string     query         = "select Ruc, Nombre from cp_proveedor_microempresa where Ruc ='" + Ruc + "'";
                    SqlCommand command       = new SqlCommand(query, connection);
                    var        ValidateValue = command.ExecuteScalar();
                    if (ValidateValue == null)
                    {
                        return(null);
                    }

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        info = new cp_proveedor_microempresa_Info
                        {
                            Ruc    = reader["Ruc"].ToString(),
                            Nombre = reader["Nombre"].ToString(),
                        };
                    }
                    reader.Close();
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 2
0
        public cp_proveedor_microempresa_Info GetInfo(string Ruc)
        {
            try
            {
                cp_proveedor_microempresa_Info info = new cp_proveedor_microempresa_Info();

                string Conexion = ConexionERP.GetConnectionString();

                using (SqlConnection connection = new SqlConnection(Conexion))
                {
                    connection.Open();

                    string     Query       = "SELECT Ruc,Nombre FROM cp_proveedor_microempresa WHERE Ruc = '" + Ruc + "'";
                    SqlCommand command     = new SqlCommand(Query, connection);
                    var        returnValue = command.ExecuteScalar();
                    if (returnValue == null)
                    {
                        return(null);
                    }

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        info.Ruc    = reader[0].ToString();
                        info.Nombre = reader[1].ToString();
                    }
                    reader.Close();
                }

                return(info);
            }
            catch (Exception)
            {
                throw;
            }
        }