Exemple #1
0
 public static string add_RolXPerfil(RolXPerfil d)
 {
     return "{" +
         '"' + "IdRolXPerfil" + '"' + ": " + d.IdRolXPerfil.ToString() + ',' +
         '"' + "IdPerfil" + '"' + ": " + d.IdPerfil.ToString() + ',' +
         '"' + "IdRol" + '"' + ": " + d.IdRol.ToString() + ',' +
         '"' + "FechaAsignacion" + '"' + ": " + '"' + Utils.dateToJson(d.FechaAsignacion) + '"' +
         "}";
 }
Exemple #2
0
        public List<RolXPerfil> selectAll_RolXPerfil()
        {
            try
            {
                List<RolXPerfil> rxps = new List<RolXPerfil>();
                RolXPerfil rxp;

                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter();
                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        return rxps;
                    }

                    SqlCommand sqlCmd = new SqlCommand("ROL_X_PERFIL_SELECT_ALL", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sda.SelectCommand = sqlCmd;
                    sda.Fill(dt);
                    SqlConn.Close();
                    sqlCmd.Dispose();
                    sda.Dispose();
                }

                DataRow[] rows = dt.Select();

                for (int i = 0; i < rows.Length; i++)
                {
                    rxp = Utils.rolXPerfil_parse(rows[i]);
                    rxps.Add(rxp);
                }

                return rxps;
            }
            catch (Exception ex)
            {
                RolXPerfil r = new RolXPerfil();

                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_LISTAR,
                    Servicio = Constantes.SelectAll_RolXPerfil,
                    Input = "",
                    Descripcion = ex.ToString(),
                    Clase = r.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                return new List<RolXPerfil>();
            }
        }
Exemple #3
0
        public static RolXPerfil rolXPerfil_parse(DataRow r)
        {
            RolXPerfil rxp = new RolXPerfil();
            rxp.IdRolXPerfil = Int32.Parse(r["idRolXPerfil"].ToString());
            rxp.IdRol = Int32.Parse(r["idRol"].ToString());
            rxp.IdPerfil = Int32.Parse(r["idPerfil"].ToString());
            rxp.FechaAsignacion = DateTime.ParseExact(r["fechaAsignacion"].ToString(), "M/d/yyyy h:mm:ss ttt", null);

            return rxp;
        }
Exemple #4
0
        public ResponseBD add_RolXPerfil(RolXPerfil rxp)
        {
            try
            {
                ResponseBD response = new ResponseBD();

                string ConnString = ConfigurationManager.ConnectionStrings["barabaresConnectionString"].ConnectionString;
                using (SqlConnection SqlConn = new SqlConnection(ConnString))
                {
                    try
                    {
                        SqlConn.Open();
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.ToString());
                        response.Flujo = Constantes.FALLA;
                        response.Mensaje = "Error al abrir la conexión a BD";
                        return response;
                    }

                    SqlCommand sqlCmd = new SqlCommand("ROL_X_PERFIL_INSERT", SqlConn);
                    sqlCmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter flujo = new SqlParameter("@opsFlujo", SqlDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output,
                        Size = 10

                    };

                    SqlParameter mensaje = new SqlParameter("@opsMsj", SqlDbType.VarChar)
                    {
                        Direction = ParameterDirection.Output,
                        Size = 100
                    };

                    sqlCmd.Parameters.Add("@ipdFechaAsignacion", SqlDbType.DateTime).Value = rxp.FechaAsignacion;
                    sqlCmd.Parameters.Add("@ipnIdPerfil", SqlDbType.Int).Value = rxp.IdPerfil;
                    sqlCmd.Parameters.Add("@ipnIdRol", SqlDbType.Int).Value = rxp.IdRol;
                    sqlCmd.Parameters.Add(flujo);
                    sqlCmd.Parameters.Add(mensaje);

                    sqlCmd.ExecuteNonQuery();

                    response.Flujo = flujo.Value.ToString();
                    response.Mensaje = mensaje.Value.ToString();

                    SqlConn.Close();

                }

                return response;
            }
            catch (Exception ex)
            {
                LogBarabares b = new LogBarabares()
                {
                    Accion = Constantes.LOG_CREAR,
                    Servicio = Constantes.Add_RolXPerfil,
                    Input = "", //TODO
                    Descripcion = ex.ToString(),
                    Clase = (rxp == null) ? "null" : rxp.GetType().Name,
                    Aplicacion = Constantes.ENTORNO_SERVICIOS,
                    Estado = Constantes.FALLA,
                    Ip = "",
                    IdUsuario = 1 //TODO: obtener usuario de la sesión

                };

                Utils.add_LogBarabares(b);

                ResponseBD response = new ResponseBD();
                response.Flujo = Constantes.FALLA;
                response.Mensaje = "Error al abrir la conexión a BD";
                return response;
            }
        }