public DataTable buscar(Dclientes clientes)
        {
            DataTable     dtresultado = new DataTable("clientes");
            SqlConnection sqlcon      = new SqlConnection();

            try
            {
                sqlcon.ConnectionString = claseconexion.cnn;
                SqlCommand sqlcmd = new SqlCommand();
                sqlcmd.Connection  = sqlcon;
                sqlcmd.CommandText = "buscar";
                sqlcmd.CommandType = CommandType.StoredProcedure;

                SqlParameter parid = new SqlParameter();
                parid.ParameterName = "@id";
                parid.SqlDbType     = SqlDbType.Int;
                parid.Value         = clientes.Id;
                sqlcmd.Parameters.Add(parid);


                //instancia al adaptador entre el sist y la bd

                SqlDataAdapter sqltaco = new SqlDataAdapter(sqlcmd);
                sqltaco.Fill(dtresultado);
            }
            catch
            {
                dtresultado = null;
            }
            return(dtresultado);
        }
        public Dclientes(int xid, string xnom, string xap, string xdoc, string xtelf, string xcorr)
        {
            Dclientes obj = new Dclientes();

            obj.Id        = xid;
            obj.Nombre    = xnom;
            obj.Apellidos = xap;
            obj.Doc       = xdoc;
            obj.Telefono  = xtelf;
            obj.Correo    = xcorr;
        }
        public string eliminar(Dclientes clientes)
        {
            string rpta = "";

            SqlConnection sqlcon = new SqlConnection();

            sqlcon.ConnectionString = claseconexion.cnn;

            try
            {
                sqlcon.Open();

                SqlCommand sqlcmd = new SqlCommand();
                sqlcmd.CommandText = "eliminar";
                sqlcmd.Connection  = sqlcon;
                sqlcmd.CommandType = CommandType.StoredProcedure;


                SqlParameter parid = new SqlParameter();
                parid.ParameterName = "@id";
                parid.SqlDbType     = SqlDbType.Int;
                parid.Value         = clientes.Id;
                sqlcmd.Parameters.Add(parid);



                rpta = sqlcmd.ExecuteNonQuery() == 1 ? "ok" : "no se elimino nada ";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (sqlcon.State == ConnectionState.Open)
                {
                    sqlcon.Close();
                }
            }

            return(rpta);
        }
        public string insertar(Dclientes clientes)
        {
            string rpta = "";

            SqlConnection sqlcon = new SqlConnection();


            try
            {
                sqlcon.ConnectionString = claseconexion.cnn;
                sqlcon.Open();

                SqlCommand sqlcmd = new SqlCommand();

                sqlcmd.CommandText = "insertar";
                sqlcmd.Connection  = sqlcon;
                sqlcmd.CommandType = CommandType.StoredProcedure;


                SqlParameter parid = new SqlParameter();
                parid.ParameterName = "@id";
                parid.SqlDbType     = SqlDbType.Int;
                parid.Direction     = ParameterDirection.Output;
                sqlcmd.Parameters.Add(parid);

                SqlParameter parnom = new SqlParameter();
                parnom.ParameterName = "@nombre";
                parnom.SqlDbType     = SqlDbType.VarChar;
                parnom.Size          = 20;
                parnom.Value         = clientes.Nombre;
                sqlcmd.Parameters.Add(parnom);

                SqlParameter parapll = new SqlParameter();
                parapll.ParameterName = "@apell";
                parapll.SqlDbType     = SqlDbType.VarChar;
                parapll.Size          = 20;
                parapll.Value         = clientes.Apellidos;
                sqlcmd.Parameters.Add(parapll);


                SqlParameter pardoc = new SqlParameter();
                pardoc.ParameterName = "@doc";
                pardoc.SqlDbType     = SqlDbType.VarChar;
                pardoc.Size          = 8;
                pardoc.Value         = clientes.Doc;
                sqlcmd.Parameters.Add(pardoc);

                SqlParameter partelf = new SqlParameter();
                partelf.ParameterName = "@telefono";
                partelf.SqlDbType     = SqlDbType.VarChar;
                partelf.Size          = 9;
                partelf.Value         = clientes.Telefono;
                sqlcmd.Parameters.Add(partelf);

                SqlParameter parcorr = new SqlParameter();
                parcorr.ParameterName = "@correo";
                parcorr.SqlDbType     = SqlDbType.VarChar;
                parcorr.Size          = 20;
                parcorr.Value         = clientes.Correo;
                sqlcmd.Parameters.Add(parcorr);

                rpta = sqlcmd.ExecuteNonQuery() == 1? "ok" :"no se inserto nada ";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (sqlcon.State == ConnectionState.Open)
                {
                    sqlcon.Close();
                }
            }

            return(rpta);
        }