public DataTable Consultar_Id_Tipos(D_Sala ID) { DataTable Dtresultado = new DataTable(); sqlconex = new SqlConnection(); try { sqlconex.ConnectionString = Conexion.Conexion_bd; sqlcmd = new SqlCommand(); sqlcmd.Connection = sqlconex; sqlcmd.CommandText = "[SALA_ID]"; sqlcmd.CommandType = CommandType.StoredProcedure; SqlParameter parid = new SqlParameter(); parid.ParameterName = "@id"; parid.SqlDbType = SqlDbType.Int; parid.Value = ID._Codigo; sqlcmd.Parameters.Add(parid); SqlDataAdapter sqldate = new SqlDataAdapter(sqlcmd); sqldate.Fill(Dtresultado); } catch (Exception) { Dtresultado = null; } return(Dtresultado); }
public string CAMBIO_ESTADO_TIPOS_SALA(D_Sala estado) { sqlconex = new SqlConnection(); try { sqlconex.ConnectionString = Conexion.Conexion_bd; sqlconex.Open(); sqlcmd = new SqlCommand(); sqlcmd.Connection = sqlconex; sqlcmd.CommandText = "[SALA_Cambio_Estado]"; sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.AddWithValue("@Codigo", estado._Codigo); sqlcmd.Parameters.AddWithValue("@Estado", estado._Estado); result = sqlcmd.ExecuteNonQuery() >= 1 ? "OK" : "No se cambio el estado"; } catch (Exception ex) { result = ex.Message; } finally { if (sqlconex.State == ConnectionState.Open) { sqlconex.Close(); } } return(result); }
public string ELIMINAR_SALA(D_Sala eliminar) { string rpta = ""; SqlConnection SqlCon = new SqlConnection(); try { SqlCon.ConnectionString = Conexion.Conexion_bd; SqlCon.Open(); SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "[SALA_Eliminar]"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.Parameters.AddWithValue("@Codigo", eliminar._Codigo); rpta = SqlCmd.ExecuteNonQuery() >= 1 ? "OK" : "No se elimino registro"; } catch (Exception ex) { rpta = ex.Message; } finally { if (SqlCon.State == ConnectionState.Open) { SqlCon.Close(); } } return(rpta); }
public string REGISTRAR_SALA(D_Sala lista) { try { sqlconex = new SqlConnection(); sqlcmd = new SqlCommand(); sqlconex.ConnectionString = Conexion.Conexion_bd; sqlconex.Open(); sqltrans = sqlconex.BeginTransaction(); sqlcmd.Connection = sqlconex; sqlcmd.Transaction = sqltrans; sqlcmd.CommandText = "SALA_Registrar"; sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.AddWithValue("@CodigoTipo", lista.codigo_tipoSala); sqlcmd.Parameters.AddWithValue("@Nombre", lista._Nombre); sqlcmd.Parameters.AddWithValue("@Descripcion", lista._Descripcion); sqlcmd.Parameters.AddWithValue("@Estado", lista._Estado); result = sqlcmd.ExecuteNonQuery() >= 1 ? "OK" : "No se puede registrar"; if (result.Equals("OK")) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } catch (Exception ex) { result = ex.Message; } finally { if (sqlconex.State == ConnectionState.Open) { sqlconex.Close(); } } return(result); }
public string EDITAR_SALA(D_Sala editar) { try { sqlconex = new SqlConnection(); sqlcmd = new SqlCommand(); sqlconex.ConnectionString = Conexion.Conexion_bd; sqlconex.Open(); sqltrans = sqlconex.BeginTransaction(); sqlcmd.Connection = sqlconex; sqlcmd.Transaction = sqltrans; sqlcmd.CommandText = "[SALA_Editar]"; sqlcmd.CommandType = CommandType.StoredProcedure; sqlcmd.Parameters.AddWithValue("@Codigo", editar._Codigo); sqlcmd.Parameters.AddWithValue("@Nombre", editar._Nombre); sqlcmd.Parameters.AddWithValue("@Descripcion", editar._Descripcion); sqlcmd.Parameters.AddWithValue("@CodigoTipo", editar._CODIGOTIPOSALA); result = sqlcmd.ExecuteNonQuery() >= 1 ? "OK" : "No se puede editar"; if (result.Equals("OK")) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } catch (Exception ex) { result = ex.Message; } finally { if (sqlconex.State == ConnectionState.Open) { sqlconex.Close(); } } return(result); }