Exemple #1
0
 //---------------------------------------Søgning
 #region Søgning + datasource switching
 protected void LinkButtonSearch_Click(object sender, EventArgs e)
 {
     GridViewEvents.DataSourceID = null;
     GridViewEvents.DataSource   = SqlDataSourceEventsSearch;
     GridViewEvents.DataBind();
     LinkButtonCancelSearch.Visible = true;
 }
Exemple #2
0
 protected void LinkButtonCancelSearch_Click(object sender, EventArgs e)
 {
     GridViewEvents.DataSourceID = null;
     GridViewEvents.DataSource   = SqlDataSourceEvents;
     GridViewEvents.DataBind();
     TextBoxSearch.Text             = "";
     LinkButtonCancelSearch.Visible = false;
 }
Exemple #3
0
 //Opdaterer gridviews ved ændringer
 #region gridviewstyring
 protected void OnSqlChanged(Object source, SqlDataSourceStatusEventArgs e)
 {
     if (GetRights().Contains("AdminEvents"))
     {
         GridViewEvents.DataBind();
     }
     else
     {
         GridViewEgneEvents.DataBind();
     }
 }
Exemple #4
0
    protected void ApproveDeny(string Command, string Id)
    {
        //opret et SqlCommand object
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
        SqlCommand    cmd  = new SqlCommand(Command, conn);

        cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value = Id;

        // åben forbindelsen til databasen
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        GridViewEvents.DataBind();
    }
Exemple #5
0
    //Hjælpemetode til at godkende/afvise en event
    //Return: Void
    //Input: string Bin - Binær: Godkendes eller afvises
    //       string Id - Id'et på eventen der skal godkendes eller afvises
    protected void ApproveDeny(string Bin, string Id)
    {
        //opret et SqlCommand object
        SqlCommand cmd = new SqlCommand("UPDATE Events SET Godkendt = @Bin WHERE Id = @Id", conn);

        cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value  = Id;
        cmd.Parameters.Add("@Bin", SqlDbType.NVarChar).Value = Bin;

        // åben forbindelsen til databasen
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();
        GridViewEvents.DataBind();
        FormViewEventDetaljer.DataBind();
    }
    private void populateGridViewEvents()
    {
        SqlConnection conn = null;

        try
        {
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SportEventTrackerDB"].ConnectionString);
            conn.Open();

            string cmdText = "SELECT ";
            cmdText += "(th.TeamName + ' - ' + tg.TeamName) as EventName, ";
            cmdText += "e.EventStart as EventDate, ";
            cmdText += "e.EventStart as EventTime, ";
            cmdText += "(CONVERT(varchar, e.EventHostResult) + ' : ' + CONVERT(varchar, e.EventGuestResult)) as EventResult, ";
            cmdText += "e.SportID ";
            cmdText += "FROM Event e ";
            cmdText += "JOIN Team th ON e.HostID = th.TeamID ";
            cmdText += "JOIN Team tg ON e.GuestID = tg.TeamID ";
            cmdText += "JOIN Sport s ON e.SportID = s.SportID ";
            cmdText += "WHERE e.Active = 1";

            cmdText += checkSportFilter();

            SqlCommand    cmd    = new SqlCommand(cmdText, conn);
            SqlDataReader reader = cmd.ExecuteReader();

            GridViewEvents.DataSource = reader;
            GridViewEvents.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            conn.Close();
        }
    }
Exemple #7
0
    protected void LinkButtonSlet_Click(object sender, EventArgs e)
    {
        LinkButton btn = (LinkButton)sender as LinkButton;
        //opret et SqlCommand object
        SqlCommand cmd = new SqlCommand("UPDATE Events SET Slettet = 1 WHERE Id = @Id", conn);

        cmd.Parameters.Add("@Id", SqlDbType.NVarChar).Value = btn.CommandArgument;

        // åben forbindelsen til databasen
        conn.Open();
        cmd.ExecuteNonQuery();
        conn.Close();

        SletFiler(Convert.ToInt32(btn.CommandArgument));
        if (GetRights().Contains("AdminEvents"))
        {
            GridViewEvents.DataBind();
        }
        else
        {
            GridViewEgneEvents.DataBind();
        }
    }
Exemple #8
0
    protected void GridViewEvents_OnRowCommand(object sender, GridViewCommandEventArgs e)
    {
        //// Only handle our custom commands here!
        if (e.CommandName.Equals("Handle") || e.CommandName.Equals("Position") || e.CommandName.Equals("DownloadRecording"))
        {
            int         index   = Convert.ToInt32(e.CommandArgument);
            GridViewRow gvRow   = ((GridView)sender).Rows[index];
            Int32       eventID = (Int32)GridViewEvents.DataKeys[index].Value;

            using (braceletEntities context = new braceletEntities())
            {
                switch (e.CommandName)
                {
                case "Handle":
                    Event ev = context.Events.Where(o => o.ID == eventID).First();
                    ev.Status = (byte)CommonNames.EventStatus.Handled;
                    ev.Note   = ((TextBox)gvRow.FindControl("TextBoxHandle")).Text;
                    context.SaveChanges();
                    GridViewEvents.DataBind();
                    GridViewPanel.Update();
                    break;

                case "Position":
                    Event evSelected = context.Events.Where(o => o.ID == eventID).First();
                    GMapHolder.Visible = true;

                    // Set selected row
                    GridView gv = (GridView)sender;
                    gv.SelectedIndex = index;

                    // Add GUI controls
                    GMap.addGMapUI(new GMapUI());

                    // Set center point
                    if (evSelected.PositionLatitude != null && evSelected.PositionLongitude != null)
                    {
                        GMap.setCenter(new GLatLng(evSelected.PositionLatitude.Value, evSelected.PositionLongitude.Value));
                    }

                    // Set zoom level
                    GMap.GZoom = 15;

                    // Add center marker
                    GMap.resetMarkers();
                    if (evSelected.PositionLatitude != null && evSelected.PositionLongitude != null)
                    {
                        GMap.addGMarker(new GMarker(new GLatLng(evSelected.PositionLatitude.Value, evSelected.PositionLongitude.Value)));
                    }
                    break;

                case "DownloadRecording":
                    if (HttpContext.Current.User.IsInRole("Administrator"))
                    {
                        Recording rec = context.Recordings.Where(o => o.EventID == eventID).FirstOrDefault();

                        if (rec != null)
                        {
                            FileStream fStream = null;
                            try
                            {
                                String fileName = "C:\\BraceletRecordings\\" + rec.FileName;

                                HttpResponse r = HttpContext.Current.Response;
                                Response.ContentType = "audio/mpeg";
                                Response.AppendHeader("Content-Disposition", "attachment; filename=" + rec.FileName);
                                fStream = new FileStream(fileName, FileMode.Open);
                                fStream.CopyTo(Response.OutputStream);
                                Response.End();
                            }
                            catch (IOException ex)
                            {
                                throw new IOException("Cannot find the selected recording.", ex);
                            }
                            finally
                            {
                                // Always close the fileStream
                                if (fStream != null)
                                {
                                    fStream.Close();
                                }
                            }
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        } // End of If(e.commandName.Equals("..") || ...)
    }