Пример #1
0
        public FacturaEn buscar_proveedor_xRuc(string ruc)
        {
            try
            {
                FacturaEn emp = new FacturaEn();

                using (SqlConnection cn = new SqlConnection(objCn.conex("SISE")))
                {
                    cn.Open();
                    SqlCommand cmd = new SqlCommand("usp_tbSunat_buscar", cn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@ruc", ruc);
                    SqlDataReader dr;
                    dr = cmd.ExecuteReader();

                    if (dr.HasRows == true)
                    {
                        while (dr.Read())
                        {
                            emp.razonSocial = dr["razon_social"].ToString();
                            emp.direccion   = dr["direccion"].ToString();
                        }
                    }
                }
                return(emp);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Пример #2
0
        public object fun_ejecutar_script(string bd, string sp, string tipo = "text")
        {
            ConexionDAO objCn = new ConexionDAO();

            using (SqlConnection cn = new SqlConnection(objCn.conex(bd)))
            {
                cn.Open();
                SqlCommand cmd = new SqlCommand(sp, cn);
                cmd.CommandType = (tipo == "text") ? CommandType.Text : CommandType.StoredProcedure;
                object x = cmd.ExecuteScalar();
                return(x);
            }
        }
 public int registrar_reparacion_cab(ReparacionEn rep)
 {
     try
     {
         int idReparacion = 0;
         using (SqlConnection cn = new SqlConnection(objCn.conex("activos")))
         {
             cn.Open();
             SqlCommand cmd = new SqlCommand("usp_ReparacionCabecera_ins", cn);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@idGuia", rep.idGuia);
             cmd.Parameters.AddWithValue("@total", rep.total);
             cmd.Parameters.AddWithValue("@observ", rep.observ);
             idReparacion = int.Parse(cmd.ExecuteScalar().ToString());
         }
         return(idReparacion);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Пример #4
0
        public DataTable fun_ejecutar_script_dt(string bd, string sp, string tipo = "text")
        {
            ConexionDAO objCn = new ConexionDAO();

            using (SqlConnection cn = new SqlConnection(objCn.conex(bd)))
            {
                cn.Open();
                SqlDataAdapter da = new SqlDataAdapter(sp, cn);
                if (tipo == "text")
                {
                    da.SelectCommand.CommandType = CommandType.Text;
                }
                else
                {
                    da.SelectCommand.CommandType = CommandType.StoredProcedure;
                }

                DataTable dt = new DataTable();
                da.Fill(dt);
                return(dt);
            }
        }