Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int fn_insertaActualizaPaginas(int ai_codigoPagina, int ai_codigoPerfil, bool ab_estaActivo)
- {
- int li_respuesta = 0;
- try
- {
- using (TransactionScope ts = new TransactionScope())
- {
- SqlConnection con = new SqlConnection(Metodo.dameConexionBDD);
- con.Open();
- {
- String sql = " BEGIN " +
- " MERGE SI_MENU_PERFIL AS Target " +
- " USING ( SELECT @CODIGO_PUS CODIGO_PUS, " +
- " @CODIGO_PAG CODIGO_PAG, " +
- " @ESTAACTIVO_MPE ESTAACTIVO_MPE " +
- " ) AS Source " +
- " ON (Target.CODIGO_PUS = Source.CODIGO_PUS AND Target.CODIGO_PAG = Source.CODIGO_PAG) " +
- " WHEN MATCHED THEN " +
- " UPDATE SET Target.ESTAACTIVO_MPE = Source.ESTAACTIVO_MPE " +
- " WHEN NOT MATCHED BY TARGET THEN " +
- " INSERT (CODIGO_PUS, CODIGO_PAG, ESTAACTIVO_MPE) " +
- " VALUES (Source.CODIGO_PUS, Source.CODIGO_PAG, Source.ESTAACTIVO_MPE); " +
- " END ";
- SqlCommand cmd = new SqlCommand(sql, con);
- cmd.CommandType = CommandType.Text;
- cmd.Parameters.Add("@CODIGO_PUS", SqlDbType.Int).Value= ai_codigoPerfil;
- cmd.Parameters.Add("@CODIGO_PAG", SqlDbType.Int).Value= ai_codigoPagina;
- cmd.Parameters.Add("@ESTAACTIVO_MPE", SqlDbType.Bit).Value= ab_estaActivo;
- li_respuesta = Convert.ToInt32(cmd.ExecuteNonQuery());
- if (ai_codigoPagina > 0)
- li_respuesta = ai_codigoPagina;
- }
- con.Close();
- ts.Complete();
- }
- }
- catch (Exception err)
- {
- throw err;
- }
- return li_respuesta;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement