예제 #1
0
        public DataTable BuscarServicio(DServicios Servicio)
        {
            DataTable     DtMostrar   = new DataTable("servicios");
            SqlConnection sqlconexion = new SqlConnection();

            try
            {
                sqlconexion.ConnectionString = Conexion.Conectar;
                SqlCommand sqlcmd = new SqlCommand();
                sqlcmd.Connection  = sqlconexion;
                sqlcmd.CommandText = "Servicio_Buscar";
                sqlcmd.CommandType = CommandType.StoredProcedure;

                SqlParameter parTextoBuscar = new SqlParameter();
                parTextoBuscar.ParameterName = "@BuscarServicio";
                parTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                parTextoBuscar.Size          = 20;
                parTextoBuscar.Value         = Servicio.TextoBuscar;
                sqlcmd.Parameters.Add(parTextoBuscar);

                SqlDataAdapter sqldata = new SqlDataAdapter(sqlcmd);
                sqldata.Fill(DtMostrar);
            }
            catch (Exception ex)
            {
                DtMostrar = null;
            }
            return(DtMostrar);
        }
예제 #2
0
        public DataTable BuscarServicios(DServicios servicios)
        {
            DataTable     DtResultado = new DataTable("SERVICIOS");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conexion.Cn;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "SER_BUSCAR_NOMBRE";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParTextoBuscar = new SqlParameter();
                ParTextoBuscar.ParameterName = "@TEXTOBUSCAR";
                ParTextoBuscar.SqlDbType     = SqlDbType.VarChar;
                ParTextoBuscar.Size          = 50;
                ParTextoBuscar.Value         = servicios.SER_NOMBRE;
                SqlCmd.Parameters.Add(ParTextoBuscar);



                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception ex)
            {
                string msm = Convert.ToString(ex);
                DtResultado = null;
            }
            return(DtResultado);
        }
예제 #3
0
        public string EliminarServicio(DServicios servicios)
        {
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conexion.Cn;
                SqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "SER_ELIMINAR";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParHabid = new SqlParameter();
                ParHabid.ParameterName = "@SER_ID";
                ParHabid.SqlDbType     = SqlDbType.Int;
                ParHabid.Value         = servicios.SER_ID;
                SqlCmd.Parameters.Add(ParHabid);

                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se elimino la Habitacion correctamente";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }
예제 #4
0
        //METODO CON PARAMETROS

        public string InsertarServicio(DServicios servicios)
        {
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = Conexion.Cn;
                SqlCon.Open();
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "SER_INSERTAR";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParHabid = new SqlParameter();
                ParHabid.ParameterName = "@SER_ID";
                ParHabid.SqlDbType     = SqlDbType.Int;
                ParHabid.Direction     = ParameterDirection.Output;
                SqlCmd.Parameters.Add(ParHabid);

                SqlParameter ParNom = new SqlParameter();
                ParNom.ParameterName = "@SER_NOMBRE";
                ParNom.SqlDbType     = SqlDbType.VarChar;
                ParNom.Size          = 50;
                ParNom.Value         = servicios.SER_NOMBRE;
                SqlCmd.Parameters.Add(ParNom);

                SqlParameter ParDes = new SqlParameter();
                ParDes.ParameterName = "@SER_DESCRIPCION";
                ParDes.SqlDbType     = SqlDbType.VarChar;
                ParDes.Size          = 50;
                ParDes.Value         = servicios.SER_DESCRIPCION;
                SqlCmd.Parameters.Add(ParDes);

                SqlParameter ParPrecio = new SqlParameter();
                ParPrecio.ParameterName = "@SER_PRECIO";
                ParPrecio.SqlDbType     = SqlDbType.Money;
                ParPrecio.Value         = servicios.SER_PRECIO;
                SqlCmd.Parameters.Add(ParPrecio);


                rpta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se agrego EL HOTEL correctamente";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }
예제 #5
0
        public string Insertar(DServicios Servicio)
        {
            string        rpta        = "";
            SqlConnection Sqlconexion = new SqlConnection();

            try
            {
                //abrir conexion
                Sqlconexion.ConnectionString = Conexion.Conectar;
                Sqlconexion.Open();
                //conexion al procedimiento almacenado
                SqlCommand sqlcmd = new SqlCommand();
                sqlcmd.Connection  = Sqlconexion;
                sqlcmd.CommandText = "Servicio_Insertar";
                sqlcmd.CommandType = CommandType.StoredProcedure;

                //conexion con variables del SP
                SqlParameter parSer_id = new SqlParameter();
                parSer_id.ParameterName = "@idServicio";
                parSer_id.SqlDbType     = SqlDbType.Int;
                parSer_id.Direction     = ParameterDirection.Output;
                sqlcmd.Parameters.Add(parSer_id);


                SqlParameter parSer_servicio = new SqlParameter();
                parSer_servicio.ParameterName = "@servicio";
                parSer_servicio.SqlDbType     = SqlDbType.VarChar;
                parSer_servicio.Size          = 50;
                parSer_servicio.Value         = Servicio.Ser_Servicio;
                sqlcmd.Parameters.Add(parSer_servicio);

                SqlParameter parSer_costo = new SqlParameter();
                parSer_costo.ParameterName = "@ser_costo";
                parSer_costo.SqlDbType     = SqlDbType.Money;
                parSer_costo.Value         = Servicio.Ser_Costo;
                sqlcmd.Parameters.Add(parSer_costo);


                rpta = sqlcmd.ExecuteNonQuery() == 1 ? "OK" : "NO SE REALIZO EL REGISTRO";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (Sqlconexion.State == ConnectionState.Open)
                {
                    Sqlconexion.Close();
                    Sqlconexion.Dispose();
                }
            }
            return(rpta);
        }
예제 #6
0
        public string Eliminar(DServicios Servicio)
        {
            string        rpta        = "";
            SqlConnection Sqlconexion = new SqlConnection();

            try
            {
                //abrir conexion
                Sqlconexion.ConnectionString = Conexion.Conectar;
                Sqlconexion.Open();
                //conexion al procedimiento almacenado
                SqlCommand sqlcmd = new SqlCommand();
                sqlcmd.Connection  = Sqlconexion;
                sqlcmd.CommandText = "Servicio_eliminar";
                sqlcmd.CommandType = CommandType.StoredProcedure;

                //conexion con variables del SP
                SqlParameter parSer_id = new SqlParameter();
                parSer_id.ParameterName = "@idservicio";
                parSer_id.SqlDbType     = SqlDbType.Int;
                parSer_id.Value         = Servicio.Ser_Id;
                sqlcmd.Parameters.Add(parSer_id);


                rpta = sqlcmd.ExecuteNonQuery() == 1 ? "OK" : "NO SE ELIMINO EL REGISTRO";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (Sqlconexion.State == ConnectionState.Open)
                {
                    Sqlconexion.Close();
                    Sqlconexion.Dispose();
                }
            }
            return(rpta);
        }