public List <TB_CausaRaizBE> ListarTB_CausaRaizO_Act() { string conexion = MiConexion.GetCnx(); List <TB_CausaRaizBE> lTB_CausaRaizBE = null; SqlConnection con = new SqlConnection(conexion); con.Open(); SqlCommand cmd = new SqlCommand("sp_ListarTB_CausaRaiz_Act", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataReader drd = cmd.ExecuteReader(CommandBehavior.SingleResult); if (drd != null) { lTB_CausaRaizBE = new List <TB_CausaRaizBE>(); int posCausaRaiz_id = drd.GetOrdinal("CausaRaiz_id"); int posCausaRaiz_desc = drd.GetOrdinal("CausaRaiz_desc"); TB_CausaRaizBE obeCausaRaizBE = null; while (drd.Read()) { obeCausaRaizBE = new TB_CausaRaizBE(); obeCausaRaizBE.CausaRaiz_id = drd.GetInt16(posCausaRaiz_id); obeCausaRaizBE.CausaRaiz_desc = drd.GetString(posCausaRaiz_desc); lTB_CausaRaizBE.Add(obeCausaRaizBE); } drd.Close(); } con.Close(); return(lTB_CausaRaizBE); }
public int InsertarTB_CausaRaiz(TB_CausaRaizBE _TB_CausaRaizBE) { int IdCausaRaiz = -1; cnx.ConnectionString = MiConexion.GetCnx(); cmd.Connection = cnx; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_InsertarTB_CausaRaiz"; cmd.CommandType = CommandType.StoredProcedure; SqlParameter par1; try { par1 = cmd.Parameters.Add(new SqlParameter("@CausaRaiz_desc", SqlDbType.VarChar, 800)); par1.Direction = ParameterDirection.Input; cmd.Parameters["@CausaRaiz_desc"].Value = _TB_CausaRaizBE.CausaRaiz_desc; SqlParameter par4 = cmd.Parameters.Add("@@identity", SqlDbType.Int); par4.Direction = ParameterDirection.ReturnValue; cnx.Open(); int n = cmd.ExecuteNonQuery(); if (n > 0) { IdCausaRaiz = (int)par4.Value; } } catch (SqlException x) { IdCausaRaiz = -1; } catch (Exception x) { IdCausaRaiz = -1; } finally { if (cnx.State == ConnectionState.Open) { cnx.Close(); } cmd.Parameters.Clear(); } return(IdCausaRaiz); }
public bool ActualizarTB_CausaRaiz(TB_CausaRaizBE _TB_CausaRaizBE) { cnx.ConnectionString = MiConexion.GetCnx(); cmd.Connection = cnx; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "sp_ActualizarTB_CausaRaiz"; SqlParameter par1; bool _vcod; try { par1 = cmd.Parameters.Add(new SqlParameter("@CausaRaiz_id", SqlDbType.Int)); par1.Direction = ParameterDirection.Input; cmd.Parameters["@CausaRaiz_id"].Value = _TB_CausaRaizBE.CausaRaiz_id; par1 = cmd.Parameters.Add(new SqlParameter("@CausaRaiz_desc", SqlDbType.VarChar, 800)); par1.Direction = ParameterDirection.Input; cmd.Parameters["@CausaRaiz_desc"].Value = _TB_CausaRaizBE.CausaRaiz_desc; cnx.Open(); cmd.ExecuteNonQuery(); _vcod = true; } catch (SqlException x) { _vcod = false; } catch (Exception x) { _vcod = false; } finally { if (cnx.State == ConnectionState.Open) { cnx.Close(); } cmd.Parameters.Clear(); } return(_vcod); }
public int InsertarTB_CausaRaiz(TB_CausaRaizBE _TB_CausaRaizBE) { return(_TB_CausaRaizADO.InsertarTB_CausaRaiz(_TB_CausaRaizBE)); }
public bool ActualizarTB_CausaRaiz(TB_CausaRaizBE _TB_CausaRaizBE) { return(_TB_CausaRaizADO.ActualizarTB_CausaRaiz(_TB_CausaRaizBE)); }