public bool Eliminar(SqlConnection cnBD, SqlTransaction trx, ModuloXClienteBE obe) { bool rpta = false; string msjError = ""; using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Ajustes_ModuloXCliente_Eliminar]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Transaction = trx; cmd.Parameters.Add("@Id", SqlDbType.Int).Value = obe.Id; cmd.Parameters.Add("@UsrCreador", SqlDbType.VarChar, 50).Value = obe.UsrModificador; int counterMarker = 0; object objRes = cmd.ExecuteScalar(); int.TryParse(objRes.ToString(), out counterMarker); if (counterMarker > 0) { rpta = true; } else { msjError = objRes.ToString(); rpta = false; } } return(rpta); }
public async Task <IHttpActionResult> Eliminar(int Id, int IdCliente, string UsrModificador) { try { ModuloXClienteBL oModuloXClienteBL = new ModuloXClienteBL(IdCliente); ModuloXClienteBE obe = new ModuloXClienteBE(); obe.Id = Id; obe.UsrModificador = UsrModificador; bool rpta = false; rpta = oModuloXClienteBL.Eliminar(obe); if (rpta) { return(Ok(Models.Util.GetBodyResponse(200, "OK"))); } else { return(Ok(Models.Util.GetBodyResponse(300, "OcurriĆ³ un error al actualizar."))); } } catch (Exception ex) { //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex); return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }
public bool Actualizar(ModuloXClienteBE obe) { bool rpta = false; SqlTransaction sqltrans; using (SqlConnection con = new SqlConnection(strCnxRule)) { con.Open(); sqltrans = con.BeginTransaction(); rpta = oModuloXClienteDA.Actualizar(con, sqltrans, obe); if (rpta) { sqltrans.Commit(); } else { sqltrans.Rollback(); } } return(rpta); }
public async Task <IHttpActionResult> Actualizar(ModuloXClienteBE obe) { try { ModuloXClienteBL oModuloXClienteBL = new ModuloXClienteBL(obe.IdCliente); bool rpta = false; rpta = oModuloXClienteBL.Actualizar(obe); if (rpta) { return(Ok(Models.Util.GetBodyResponse(200, "OK"))); } else { return(Ok(Models.Util.GetBodyResponse(300, "OcurriĆ³ un error al actualizar."))); } } catch (Exception ex) { //LogSA.GrabarLogError("SOL TR", model.user, "EditarTareas", ex); return(Ok(Models.Util.GetBodyResponse(400, ex.Message))); } }
public List <ModuloXClienteBE> ListarDatosIniciales(SqlConnection cnBD, string Usuario) { List <ModuloXClienteBE> lobe = new List <ModuloXClienteBE>(); ModuloXClienteBE obe = new ModuloXClienteBE(); ListaComboBE obem = new ListaComboBE(); using (SqlCommand cmd = new SqlCommand("[dbo].[USP_Ajustes_ModuloXCliente_Lista]", cnBD)) { cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 0; cmd.Parameters.Add("@Usuario", SqlDbType.VarChar, 50).Value = Usuario; using (SqlDataReader drd = cmd.ExecuteReader()) { if (drd.HasRows) { int pos_Id = drd.GetOrdinal("Id"); int pos_IdCliente = drd.GetOrdinal("IdCliente"); int pos_Cliente = drd.GetOrdinal("Cliente"); int pos_RUC = drd.GetOrdinal("RUC"); int pos_Estado = drd.GetOrdinal("Estado"); int pos_UsrCreador = drd.GetOrdinal("UsrCreador"); int pos_FchCreacion = drd.GetOrdinal("FchCreacion"); int pos_UsrModificador = drd.GetOrdinal("UsrModificador"); int pos_FchModificacion = drd.GetOrdinal("FchModificacion"); lobe = new List <ModuloXClienteBE>(); while (drd.Read()) { obe = new ModuloXClienteBE(); obe.Id = drd.GetInt32(pos_Id); obe.IdCliente = drd.GetInt32(pos_IdCliente); obe.DesCliente = drd.GetString(pos_Cliente); obe.RUC = drd.GetString(pos_RUC); obe.Estado = drd.GetBoolean(pos_Estado); obe.UsrCreador = drd.GetString(pos_UsrCreador); obe.FchCreacion = drd.GetString(pos_FchCreacion); obe.UsrModificador = drd.GetString(pos_UsrModificador); obe.FchModificacion = drd.GetString(pos_FchModificacion); obe.loModulos = new List <ListaComboBE>(); lobe.Add(obe); } } drd.NextResult(); if (drd.HasRows) { int pos_Id = drd.GetOrdinal("IdMenu"); int pos_Nombre = drd.GetOrdinal("Menu"); int pos_IdModuloXCliente = drd.GetOrdinal("IdMenuCliente"); while (drd.Read()) { obem = new ListaComboBE(); int idModuloXCliente = drd.GetInt32(pos_IdModuloXCliente); obem.codigo = drd.GetInt32(pos_Id); obem.descripcion = drd.GetString(pos_Nombre); int index = lobe.FindIndex(det => det.Id == idModuloXCliente); if (index != -1) { lobe[index].loModulos.Add(obem); } } } } } return(lobe); }