示例#1
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteCompetitorInComp")
            {
                AccessLevelText = Session["CurrentAccessLevel"].ToString();
                if ((AccessLevelText == "1") || (AccessLevelText == "2"))
                {
                    Global      gl           = new Global();
                    int         index        = Convert.ToInt32(e.CommandArgument);
                    GridViewRow CurrentRow   = GridView1.Rows[index];
                    string      CompCode     = GridView1.DataKeys[0].Value.ToString();
                    int         IndexOfBibno = gl.GetColumnIndexByName(CurrentRow, "rasnumer");
                    int         BibNo        = Convert.ToInt32(CurrentRow.Cells[IndexOfBibno].Text);

                    if ((CompCode != "") & (BibNo > 0))
                    {
                        AthleticCompetitionCRUD       AthlCompCRUD = new AthleticCompetitionCRUD();
                        Athl_CompetitorsInCompetition Competitor   = new Athl_CompetitorsInCompetition();
                        Competitor = AthlCompCRUD.GetCompetitorInComp(CompCode, BibNo);
                        AthlCompCRUD.DeleteCompetitorInCompetition(Competitor);
                        GridView1.DataBind();
                    }
                }
            }

            if (e.CommandName == "RegisterEvents")
            {
                AccessLevelText = Session["CurrentAccessLevel"].ToString();
                if ((AccessLevelText == "1") || (AccessLevelText == "2"))
                {
                    Global      gl           = new Global();
                    int         index        = Convert.ToInt32(e.CommandArgument);
                    GridViewRow CurrentRow   = GridView1.Rows[index];
                    string      CompCode     = GridView1.DataKeys[0].Value.ToString();
                    int         IndexOfBibno = gl.GetColumnIndexByName(CurrentRow, "rasnumer");
                    int         BibNo        = Convert.ToInt32(CurrentRow.Cells[IndexOfBibno].Text);

                    if ((CompCode != "") & (BibNo > 0))
                    {
                        AthleticCompetitionCRUD       AthlCompCRUD = new AthleticCompetitionCRUD();
                        Athl_CompetitorsInCompetition Competitor   = new Athl_CompetitorsInCompetition();
                        Competitor = AthlCompCRUD.GetCompetitorInComp(CompCode, BibNo);
                        Int32 YearOfBirth;
                        YearOfBirth = Competitor.faedingarar;
                        Int32 CompetitorAge = gl.GetCompetitionYear() - YearOfBirth;

                        gl.SetSelComp(CompCode, Competitor.kennitala, Competitor.nafn, Competitor.kyn.ToString(),
                                      Competitor.faedingarar.ToString(), Competitor.felag, CompetitorAge.ToString(), "0");
                        gl.SetBibNumber(BibNo);

                        Response.Redirect("RegisterCompetitorInEvent.aspx");
                    }
                }
            }
        }
示例#2
0
        protected void SelectButton_Click(object sender, EventArgs e)
        {
            Global gl = new Global();
            AthleticCompetitionCRUD       AthlCRUD              = new AthleticCompetitionCRUD();
            Athl_CompetitionEvents        AthlCompEvent         = new Athl_CompetitionEvents();
            Athl_CompetitorsInCompetition AthlCompInCompetition = new Athl_CompetitorsInCompetition();
            //Int32 EvLineNo = Convert.ToInt32(gl.GetCompetitionEventNo());
            string      EventLineNoText = Request.QueryString.Get("Event");
            Int32       EvLineNo        = Convert.ToInt32(EventLineNoText);
            GridViewRow CurrRow;
            Int32       Index = 0;
            bool        Res   = false;
            Int32       BibNo = 0;

            AthlCompEvent = AthlCRUD.GetCompetitionEvent(CompCode.Text, EvLineNo);
            CheckBox SelectedCandidate;

            for (int i = 0; i < Candidates.Rows.Count; i++)
            {
                SelectedCandidate = (CheckBox)Candidates.Rows[i].FindControl("ValinChk");
                if (SelectedCandidate.Checked)
                {
                    CurrRow = Candidates.Rows[i];
                    Index   = gl.GetColumnIndexByName(CurrRow, "rasnumer");
                    Res     = int.TryParse(CurrRow.Cells[Index].Text, out BibNo);
                    if (Res == false)
                    {
                        BibNo = -1;
                    }
                    if (BibNo > 0)
                    {
                        AthlCompInCompetition = AthlCRUD.GetCompetitorInComp(CompCode.Text, BibNo);
                        AthlCRUD.RegisterCompetitorInEvent(CompCode.Text, AthlCompEvent, BibNo, AthlCompInCompetition, 1, 999);
                    }
                }
            }
            Response.Redirect("UpdateEventResults.aspx?Event=" + EventLineNoText);
        }
示例#3
0
        protected void RegEventsForComp_Click(object sender, EventArgs e)
        {
            Athl_CompetitorsInEvent       AthlCompetitorInEvRec = new Athl_CompetitorsInEvent();
            Athl_CompetitionEvents        AthlCompEvent         = new Athl_CompetitionEvents();
            Athl_CompetitorsInCompetition AthlCompetitorInComp  = new Athl_CompetitorsInCompetition();
            AthleticCompetitionCRUD       AthlCompCRUD          = new AthleticCompetitionCRUD();
            AthleticsEntities1            AthlEnt = new AthleticsEntities1();

            Int32       i;
            CheckBox    SelectedEvent;
            GridViewRow CurrRow;
            Int32       SelCellIndex = -1;
            Global      gl           = new Global();
            Int32       EventLine;
            bool        Res;
            string      CurrentUserID = Session["CurrentUserName"].ToString();

            AthlCompetitorInComp = AthlCompCRUD.InitCompetitorInComp();
            for (i = 0; i < AvailableEvents.Rows.Count; i++)
            {
                SelectedEvent = (CheckBox)AvailableEvents.Rows[i].FindControl("ValinChk");
                if (SelectedEvent.Checked)
                {
                    CurrRow = AvailableEvents.Rows[i];
                    if (SelCellIndex < 0)
                    {
                        SelCellIndex = gl.GetColumnIndexByName(CurrRow, "EventLine");
                    }
                    Res = int.TryParse(CurrRow.Cells[SelCellIndex].Text, out EventLine);
                    if (Res == false)
                    {
                        EventLine = -1;
                    }
                    else
                    {
                        if (AthlCompetitorInComp.rasnumer == 0)
                        {
                            AthlCompetitorInComp = AthlCompCRUD.GetCompetitorInComp(gl.GetCompetitionCode(), gl.GetBibNumber());
                        }

                        AthlCompetitorInEvRec = AthlCompCRUD.GetCompetitorInEvent(gl.GetCompetitionCode(), gl.GetBibNumber(), EventLine);
                        if (AthlCompetitorInEvRec == null)
                        {
                            AthlCompetitorInEvRec = AthlCompCRUD.InitCompetitorInEvent();
                        }
                        if (AthlCompetitorInEvRec.rasnumer == null)
                        {
                            AthlCompetitorInEvRec.rasnumer = 0;
                        }
                        if (AthlCompetitorInEvRec.rasnumer == 0)
                        {
                            AthlCompEvent = AthlCompCRUD.GetCompetitionEvent(gl.GetCompetitionCode(), EventLine);

                            AthlCompCRUD.RegisterCompetitorInEvent(gl.GetCompetitionCode(), AthlCompEvent, gl.GetBibNumber(), AthlCompetitorInComp,
                                                                   1, 999);
                            AthlEnt.InsertToLogFile(CurrentUserID, "Skráning í grein (b)", gl.GetCompetitionCode(), AthlCompetitorInComp.keppendanumer, AthlCompEvent.grein + ";" +
                                                    AthlCompEvent.kyn.ToString() + AthlCompEvent.flokkur);
                        }
                        else
                        if (AthlCompetitorInEvRec.rasnumer > 0)
                        {
                            AthlEnt.DeleteCompetitorInEvent(AthlCompetitorInEvRec.mot, AthlCompetitorInEvRec.greinarnumer, AthlCompetitorInEvRec.rasnumer);
                        }
                    }
                }
                //else
                //{
                //   if
                //}
            }

            //  Response.Redirect("~/NyttMot.aspx?Comp=" + gl.GetCompetitionCode());

            Response.Redirect("CompetitorsForUser.aspx");
        }
示例#4
0
        protected void InsertSelected_Click(object sender, EventArgs e)
        {
            if (RegistrationAction.SelectedValue.ToString() == "0")
            {
                string strMsg = "Þú verður að tilgreina hvort þú viljir flytja valda keppendur yfir í félagið þitt!";
                Response.Write("<script>alert('" + strMsg + "')</script>");
                //string Jascript = "<script language="\""javascript\" type=\"text/javascript\">alert('" + strMsg + "');</script>";
                //Response.Write(Jascript);
                return;
            }
            Int32    i;
            Int32    SelCellIndex;
            Int32    CompetitionYear;
            string   CompetitorCode;
            CheckBox SelectedCompetitor;
            Global   gl       = new Global();
            string   CompCode = gl.GetCompetitionCode();
            AthleticCompetitionCRUD       AthlCompCRUD         = new AthleticCompetitionCRUD();
            Athl_CompetitorsInCompetition AthlCompetitorInComp = new Athl_CompetitorsInCompetition();
            AthleticsEntities1            AthlEnt = new AthleticsEntities1();

            GridViewRow CurrRow;
            bool        WasOkToMove = false;
            string      Kennit      = "";
            string      CurrentClub = "";
            string      ErrorMsgText;
            string      UseThisClub = SelectedClub.SelectedValue.ToString();
            string      MoveToClub;

            if (RegistrationAction.SelectedValue.ToString() == "2") //(ChangeClubsCheckBox.Checked == true)
            {
                MoveToClub = UseThisClub;
            }
            else
            {
                MoveToClub = "";
            }
            CompetitionYear = Convert.ToInt32(gl.GetCompetitionYear());
            for (i = 0; i < SelectCompetitorGridView.Rows.Count; i++)  //Mens Events
            {
                SelectedCompetitor = (CheckBox)SelectCompetitorGridView.Rows[i].FindControl("ValinChk");
                if (SelectedCompetitor.Checked)
                {
                    ((CheckBox)SelectCompetitorGridView.Rows[i].FindControl("ValinChk")).Checked = false;

                    CurrRow        = SelectCompetitorGridView.Rows[i];
                    SelCellIndex   = gl.GetColumnIndexByName(CurrRow, "Félag");
                    CurrentClub    = CurrRow.Cells[SelCellIndex].Text;
                    SelCellIndex   = gl.GetColumnIndexByName(CurrRow, "CompetitorCode");
                    CompetitorCode = CurrRow.Cells[SelCellIndex].Text;

                    if ((CompetitorCode == "") || (CompetitorCode == "&nbsp;"))
                    {
                        SelCellIndex = gl.GetColumnIndexByName(CurrRow, "Kennitala");
                        Kennit       = CurrRow.Cells[SelCellIndex].Text;
                        if (Kennit != "")
                        {
                            string ClubForNewCompetitor = UseThisClub;
                            if (MoveToClub != "")
                            {
                                ClubForNewCompetitor = MoveToClub;
                            }
                            ObjectParameter NewCompetitorNo;
                            NewCompetitorNo = new ObjectParameter("CompetitorCodeOut", "");

                            AthlEnt.RegisterCompetitorFromNatReg(Kennit, ClubForNewCompetitor, NewCompetitorNo);
                            CompetitorCode = NewCompetitorNo.Value.ToString();
                        }
                    }

                    AthlCompetitorInComp = AthlCompCRUD.CopyCompetitorToCompetition(CompetitorCode, CompCode, CompetitionYear, MoveToClub, out WasOkToMove, out ErrorMsgText);

                    if ((WasOkToMove == false) && ((ErrorMsgText == "") == false))
                    {
                        Response.Write("<script>alert('" + ErrorMsgText + "')</script>");
                        return;
                    }
                    AthlCompCRUD.InsertCompetitorInCompetition(AthlCompetitorInComp);
                }
            }

            Response.Redirect("SelectedCompetitionCompetitors.aspx?Code=" + CompCode);
        }
示例#5
0
        protected void SelectCompetitorGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            Global Gl = new Global();

            AthleticCompetitionCRUD       AthlCompCRUD         = new AthleticCompetitionCRUD();
            Athl_CompetitorsInCompetition AthlCompetitorInComp = new Athl_CompetitorsInCompetition();
            string CompetitorCode;
            bool   WasOkToMove      = false;
            string ErrorMessageText = "";

            GridViewRow CurrRow = SelectCompetitorGridView.SelectedRow;
            Int32       IndexForCompetitorCode = Gl.GetColumnIndexByName(CurrRow, "CompetitorCode");

            CompetitorCode = CurrRow.Cells[IndexForCompetitorCode].Text;
            string ChangeToClub = "";

            if (RegistrationAction.SelectedValue.ToString() == "1") //(ChangeClubsCheckBox.Checked == true)
            {
                ChangeToClub = SelectedClub.SelectedValue.ToString();
            }
            else
            {
                ChangeToClub = "";
            }

            AthlCompetitorInComp = AthlCompCRUD.CopyCompetitorToCompetition(CompetitorCode, Gl.GetCompetitionCode(), Gl.GetCompetitionYear(),
                                                                            ChangeToClub, out WasOkToMove, out ErrorMessageText);
            if (WasOkToMove == false)
            {
                ErrorMsgBox.Text = ErrorMessageText;
            }
            //AthlCompetitorInComp = AthlCompCRUD.InitCompetitorInComp();

            //AthlCompetitorInComp.mot = Gl.GetCompetitionCode();
            //AthlCompetitorInComp.rasnumer = Gl.ReturnNextBibno(AthlCompetitorInComp.mot);
            //string KeppNo = SelectCompetitorGridView.SelectedRow.Cells[1].Text;
            //KeppNo = HttpUtility.HtmlDecode(KeppNo);
            //AthlCompetitorInComp.keppendanumer = KeppNo;
            //if (SelectCompetitorGridView.SelectedRow.Cells[2].Text == "Karl")
            //{
            //    AthlCompetitorInComp.kyn = 1;
            //}
            //else
            //{
            //    AthlCompetitorInComp.kyn = 2;
            //}
            //AthlCompetitorInComp.kennitala = SelectCompetitorGridView.SelectedRow.Cells[3].Text;
            //string Name = SelectCompetitorGridView.SelectedRow.Cells[4].Text;
            //Name = HttpUtility.HtmlDecode(Name);
            //AthlCompetitorInComp.nafn = Name;
            //AthlCompetitorInComp.faedingarar = Convert.ToInt16(SelectCompetitorGridView.SelectedRow.Cells[5].Text);
            //AthlCompetitorInComp.aldurkeppanda = Convert.ToInt32(SelectCompetitorGridView.SelectedRow.Cells[6].Text);
            //string Club = SelectCompetitorGridView.SelectedRow.Cells[7].Text;
            //Club = HttpUtility.HtmlDecode(Club);
            //AthlCompetitorInComp.felag = Club;
            ////string NoOfPerf = SelectCompetitorGridView.SelectedRow.Cells[8].Text;
            //AthlCompetitorInComp.faedingardagur = Convert.ToDateTime(SelectCompetitorGridView.SelectedRow.Cells[9].Text);
            //string Land = SelectCompetitorGridView.SelectedRow.Cells[10].Text;
            //Land = HttpUtility.HtmlDecode(Land);
            //AthlCompetitorInComp.land = Land;

            AthlCompCRUD.InsertCompetitorInCompetition(AthlCompetitorInComp);

            //Gl.SetSelComp(CompCode, Kennitala, Name, Gender, YearOfBirth, Club, Age, NoOfPerf);

            Response.Redirect("~/CompetitorsForUser.aspx");
        }
        protected void UpdateDatabase()
        {
            AthleticCompetitionCRUD AthlCRUD = new AthleticCompetitionCRUD();
            Global gl = new Global();
            Athl_CompetitorsInEvent       AthlCompInEvent          = new Athl_CompetitorsInEvent();
            Athl_CompetitorsInEvent       AthlCompInEventForDelete = new Athl_CompetitorsInEvent();
            Athl_CompetitionEvents        CompEvent         = new Athl_CompetitionEvents();
            Athl_CompetitorsInCompetition CompetitorsInComp = new Athl_CompetitorsInCompetition();

            CompetitorsInComp.rasnumer = -1;
            AthleticsEntities1 AthlEnt  = new AthleticsEntities1();
            string             CompCode = gl.GetCompetitionCode();
            Int32  EventLin             = 0;
            Int32  FjLin     = gl.GetNoOfArrayElements();
            Int32  BibNumber = 0;
            string EventType = gl.GetEventType();

            string[] CheckBoxParts     = new string[10];
            string[] CheckBoxValues    = new string[50];
            string[] TextBoxIDs        = new string[50];
            bool     NeedToRefreshPage = false;
            string   CurrentUserID     = Session["CurrentUserName"].ToString();

            foreach (Control item in PH1.Controls)
            {
                if (item is CheckBox)
                {
                    CheckBox Cb         = (CheckBox)PH1.FindControl(item.ID);
                    string   CheckBoxID = Cb.ID;
                    CheckBoxParts = CheckBoxID.Split('_');  //Chkb_BibNo_EventLineNo_TickedOrNot
                    bool CheckboxIsTicked  = Convert.ToBoolean(Cb.Checked);
                    bool CheckBoxWasTicked = CheckBoxParts[3] == "1";
                    if ((CheckboxIsTicked == true) && (CheckBoxWasTicked == false))
                    {
                        BibNumber       = Convert.ToInt32(CheckBoxParts[1]);
                        EventLin        = Convert.ToInt32(CheckBoxParts[2]);
                        AthlCompInEvent = AthlCRUD.InitCompetitorInEvent();
                        CompEvent       = AthlCRUD.GetCompetitionEvent(CompCode, EventLin);
                        if (CompetitorsInComp.rasnumer != BibNumber)
                        {
                            CompetitorsInComp = AthlCRUD.GetCompetitorInComp(CompCode, BibNumber);
                        }
                        AthlCRUD.RegisterCompetitorInEvent(CompCode, CompEvent, BibNumber, CompetitorsInComp, 0, 9999);
                        AthlEnt.InsertToLogFile(CurrentUserID, "Skráning í grein", CompCode, CompetitorsInComp.keppendanumer, CompEvent.grein + ";" + CompEvent.kyn.ToString() + ";" +
                                                CompEvent.flokkur);
                        NeedToRefreshPage = true;
                    }
                    if ((CheckboxIsTicked == false) && (CheckBoxWasTicked == true))
                    {
                        BibNumber = Convert.ToInt32(CheckBoxParts[1]);
                        EventLin  = Convert.ToInt32(CheckBoxParts[2]);
                        if (CompetitorsInComp.rasnumer != BibNumber)
                        {
                            CompetitorsInComp = AthlCRUD.GetCompetitorInComp(CompCode, BibNumber);
                        }
                        CompEvent = AthlCRUD.GetCompetitionEvent(CompCode, EventLin);
                        AthlCompInEventForDelete = AthlCRUD.GetCompetitorInEvent(CompCode, BibNumber, EventLin);
                        AthlCRUD.DeleteCompetitorInEvRec(AthlCompInEventForDelete);
                        AthlEnt.InsertToLogFile(CurrentUserID, "Afskráning í grein", CompCode, CompetitorsInComp.keppendanumer, CompEvent.grein + ";" + CompEvent.kyn.ToString() + ";" +
                                                CompEvent.flokkur);

                        NeedToRefreshPage = true;
                    }
                }
            }
            if (NeedToRefreshPage == true)
            {
                Response.Redirect("ClubCompetitorsWithReg.aspx");
            }
        }
示例#7
0
        protected void RelaysGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            Global Gl = new Global();

            AthleticsEntities1 AthlEnt = new AthleticsEntities1();

            string CommandN   = e.CommandName;
            string CommandArg = e.CommandArgument.ToString();

            string[] EventNoAndBib = CommandArg.Split(';');

            if (CommandN == "DeleteTeam")
            {
                //                <script type="text/javascript">
                //    function myTestFunction()
                //    {
                //        if (confirm('Do you want to proceed ?'))
                //        {
                //            return true;
                //        }
                //        else
                //        {
                //            return false;
                //        }
                //    }
                //</script>

                //            ScriptManager.RegisterStartupScript(this, typeof(string), "confirm",
                //            "myTestFunction();", true);
                //Hér vantar confirm  Yes No !!!

                AthlEnt.DeleteCompetitorInEvent(CompCode.Text, Convert.ToInt32(EventNoAndBib[0]), Convert.ToInt32(EventNoAndBib[1]));
                //Eyða þarf Skipan boðhlaupssveitar hér
                AthlEnt.DeleteCompetitorInComp(CompCode.Text, CommandArg[1]);
                Response.Redirect("RegisterRelay.aspx");
            }

            if (CommandN == "Runners")
            {
                Gl.SetCompetitionCode(CompCode.Text);
                Gl.SetGlobalValue("EventLineNo", EventNoAndBib[0]);
                Gl.SetGlobalValue("SelectedClub", ClubDropDown.SelectedValue.ToString());
                Gl.SetGlobalValue("RelayTeamName", EventNoAndBib[2]);
                Gl.SetGlobalValue("CompetitorBibNo", EventNoAndBib[1]);
                Response.Redirect("RelayTeamNames.aspx");
            }

            Int32 EventLineNo = Convert.ToInt32(EventNoAndBib[0]);       //e.CommandArgument);
            AthleticCompetitionCRUD       AthlCRUD        = new AthleticCompetitionCRUD();
            Athl_CompetitionEvents        AthlEvent       = new Athl_CompetitionEvents();
            Athl_Competition              AthlCompetition = new Athl_Competition();
            Athl_CompetitorsInCompetition AthlCompInComp  = new Athl_CompetitorsInCompetition();
            Athl_CompetitorsInEvent       AthlCompInEv    = new Athl_CompetitorsInEvent();


            var RelayInfoDs = AthlEnt.PrepareToRegisterNewRelayTeam(
                CompCode.Text, EventLineNo, ClubDropDown.SelectedValue.ToString());

            ///     NewBibNoOut, GenderOut, TeamNameOut, YearOfBirthOut);
            Int32  NewBibNo          = 0;
            Int32  Gender            = 0;
            string TeamName          = "";
            Int32  YearOfBirth       = 0;
            Int32  LastLineNoInEvent = 0;

            foreach (var RelayInfoRec in RelayInfoDs)
            {
                NewBibNo          = Convert.ToInt32(RelayInfoRec.NewBibNoOut.ToString());
                Gender            = Convert.ToInt32(RelayInfoRec.GenderOut.ToString());
                TeamName          = RelayInfoRec.TeamNameOut.ToString();
                YearOfBirth       = Convert.ToInt32(RelayInfoRec.YearOfBirthOut.ToString());
                LastLineNoInEvent = Convert.ToInt32(RelayInfoRec.LastLineNoInEvent.ToString());
            }


            AthlEvent       = AthlCRUD.GetCompetitionEvent(CompCode.Text, EventLineNo);
            AthlCompetition = AthlCRUD.GetCompetitionRec(CompCode.Text);

            AthlCompInComp                = AthlCRUD.InitCompetitorInComp();
            AthlCompInComp.mot            = CompCode.Text;
            AthlCompInComp.rasnumer       = NewBibNo;
            AthlCompInComp.kyn            = Gender;
            AthlCompInComp.nafn           = TeamName;
            AthlCompInComp.faedingarar    = YearOfBirth;
            AthlCompInComp.felag          = ClubDropDown.SelectedValue.ToString();
            AthlCompInComp.aldurkeppanda  = AthlCompetition.Date.Year - YearOfBirth;
            AthlCompInComp.bodhlaupssveit = 1;
            AthlCRUD.InsertCompetitorInCompetition(AthlCompInComp);

            AthlCompInEv = AthlCRUD.InitCompetitorInEvent();

            AthlCompInEv.mot          = CompCode.Text;
            AthlCompInEv.greinarnumer = EventLineNo;
            AthlCompInEv.rasnumer     = NewBibNo;
            AthlCompInEv.nafn         = TeamName;
            AthlCompInEv.faedingarar  = YearOfBirth;
            AthlCompInEv.felag        = ClubDropDown.SelectedValue.ToString();
            AthlCRUD.RegisterCompetitorInEvent(CompCode.Text, AthlEvent, NewBibNo, AthlCompInComp, 0, 0);

            Response.Redirect("RegisterRelay.aspx?Club=" + ClubDropDown.SelectedValue.ToString());
        }
示例#8
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //StaðaM 3=Lokað f skrán, 5=Lokið
            //CurrAccL 2=Admin,3=Can Edit Sheets, 4=Comp Admin

            string          UserAcclevelToCompetition = "";
            ObjectParameter NewUserAccessTxt;

            NewUserAccessTxt = new ObjectParameter("NewUserAccessTxt", typeof(global::System.String));

            AthlEnt.GetUserAccessToCompetition(CompCode.Text, CurrentUserName.Text, NewUserAccessTxt);
            UserAcclevelToCompetition = NewUserAccessTxt.Value.ToString();

            AccessLevelText = Session["CurrentAccessLevel"].ToString();
            if ((AthlComp.Staða_móts != 2) && ((AccessLevelText == "0") || (AccessLevelText == "1")))
            {
                if ((UserAcclevelToCompetition != "3") && (UserAcclevelToCompetition != "4"))
                {
                    ErrorMessage.Text = "Lokað er fyrir skráningu á þetta mót";
                    return;
                }
            }
            ErrorMessage.Text = "";
            if (e.CommandName == "DeleteCompetitorInComp")
            {
                AccessLevelText = Session["CurrentAccessLevel"].ToString();
                if ((AccessLevelText == "1") || (AccessLevelText == "2"))
                {
                    Global      gl           = new Global();
                    int         index        = Convert.ToInt32(e.CommandArgument);
                    GridViewRow CurrentRow   = GridView1.Rows[index];
                    string      CompCode     = GridView1.DataKeys[0].Value.ToString();
                    int         IndexOfBibno = gl.GetColumnIndexByName(CurrentRow, "rasnumer");
                    int         BibNo        = Convert.ToInt32(CurrentRow.Cells[IndexOfBibno].Text);

                    if ((CompCode != "") & (BibNo > 0))
                    {
                        ObjectParameter NoOfRegistrations = new ObjectParameter("NoOfRegistrations", typeof(global::System.Int32));
                        AthlEnt.NoOfRegistrationsInEvetns(CompCode, BibNo, NoOfRegistrations);

                        Int32 NoOfRegistrationsInEv = Convert.ToInt32(NoOfRegistrations.Value.ToString());
                        if (NoOfRegistrationsInEv > 0)
                        {
                            ErrorMessage.Text = "Þú getur ekki eytt keppandanum vegna þess að hann er ennþá skráður í grein(ar).";
                        }
                        else
                        {
                            AthleticCompetitionCRUD       AthlCompCRUD = new AthleticCompetitionCRUD();
                            Athl_CompetitorsInCompetition Competitor   = new Athl_CompetitorsInCompetition();
                            Competitor = AthlCompCRUD.GetCompetitorInComp(CompCode, BibNo);
                            AthlCompCRUD.DeleteCompetitorInCompetition(Competitor);
                            GridView1.DataBind();
                            string CurrentUser = Session["CurrentUserName"].ToString();
                            AthlEnt.InsertToLogFile(CurrentUser, "Afskráning í mót", CompCode, Competitor.keppendanumer, "");
                        }
                    }
                }
            }

            if (e.CommandName == "RegisterEvents")
            {
                AccessLevelText = Session["CurrentAccessLevel"].ToString();
                if ((AccessLevelText == "1") || (AccessLevelText == "2"))
                {
                    Global      gl           = new Global();
                    int         index        = Convert.ToInt32(e.CommandArgument);
                    GridViewRow CurrentRow   = GridView1.Rows[index];
                    string      CompCode     = GridView1.DataKeys[0].Value.ToString();
                    int         IndexOfBibno = gl.GetColumnIndexByName(CurrentRow, "rasnumer");
                    int         BibNo        = Convert.ToInt32(CurrentRow.Cells[IndexOfBibno].Text);

                    if ((CompCode != "") & (BibNo > 0))
                    {
                        AthleticCompetitionCRUD       AthlCompCRUD = new AthleticCompetitionCRUD();
                        Athl_CompetitorsInCompetition Competitor   = new Athl_CompetitorsInCompetition();
                        Competitor = AthlCompCRUD.GetCompetitorInComp(CompCode, BibNo);
                        Int32 YearOfBirth;
                        YearOfBirth = Competitor.faedingarar;
                        Int32 CompetitorAge = gl.GetCompetitionYear() - YearOfBirth;

                        gl.SetSelComp(CompCode, Competitor.kennitala, Competitor.nafn, Competitor.kyn.ToString(),
                                      Competitor.faedingarar.ToString(), Competitor.felag, CompetitorAge.ToString(), "0");
                        gl.SetBibNumber(BibNo);

                        Response.Redirect("RegisterCompetitorInEvent.aspx");
                    }
                }
            }
            if (e.CommandName == "SetGuestYesNo")
            {
                AccessLevelText = Session["CurrentAccessLevel"].ToString();
                if ((AccessLevelText == "1") || (AccessLevelText == "2"))
                {
                    Global      gl           = new Global();
                    int         index        = Convert.ToInt32(e.CommandArgument);
                    GridViewRow CurrentRow   = GridView1.Rows[index];
                    string      CompCode     = GridView1.DataKeys[0].Value.ToString();
                    int         IndexOfBibno = gl.GetColumnIndexByName(CurrentRow, "rasnumer");
                    int         BibNo        = Convert.ToInt32(CurrentRow.Cells[IndexOfBibno].Text);

                    if ((CompCode != "") & (BibNo > 0))
                    {
                        AthleticsEntities1 AthlEnt1 = new AthleticsEntities1();
                        AthlEnt1.ToggleGuestForCompetitorInCompetition(CompCode, BibNo);
                        gl.SetGlobalValue("ShowForClub", SelectClubDropDown.SelectedValue.ToString());
                        Response.Redirect("CompetitorsForUser.aspx");
                    }
                }
            }
        }
示例#9
0
        protected void InsertCompetitors_Click(object sender, EventArgs e)
        {
            Int32                         i;
            Int32                         SelCellIndex;
            Int32                         CompetitionYear;
            string                        MoveToClub = "";
            bool                          WasOkToMove;
            string                        ErrorText;
            string                        CompetitorCode;
            CheckBox                      SelectedEvent;
            Global                        gl                   = new Global();
            AthleticsEntities1            AthlEnt              = new AthleticsEntities1();
            AthleticCompetitionCRUD       AthlCompCRUD         = new AthleticCompetitionCRUD();
            Athl_CompetitorsInCompetition AthlCompetitorInComp = new Athl_CompetitorsInCompetition();
            GridViewRow                   CurrRow;

            CompetitionYear = gl.GetCompetitionYear();
            for (i = 0; i < SelectedCompetitors.Rows.Count; i++)  //Mens Events
            {
                SelectedEvent = (CheckBox)SelectedCompetitors.Rows[i].FindControl("ValinChk");
                if (SelectedEvent.Checked)
                {
                    ((CheckBox)SelectedCompetitors.Rows[i].FindControl("ValinChk")).Checked = false;

                    //AthlCompetitorInComp = AthlCompCRUD.InitCompetitorInComp();

                    //AthlCompetitorInComp.mot = gl.GetCompetitionCode();
                    //AthlCompetitorInComp.rasnumer = gl.ReturnNextBibno(AthlCompetitorInComp.mot);
                    CurrRow        = SelectedCompetitors.Rows[i];
                    SelCellIndex   = gl.GetColumnIndexByName(CurrRow, "CompetitorCode");
                    CompetitorCode = CurrRow.Cells[SelCellIndex].Text;

                    //string KeppNo = SelectedCompetitors.SelectedRow.Cells[SelRowIndex].Text;

                    CompetitorCode = CurrRow.Cells[SelCellIndex].Text;

                    ObjectParameter IsRegisteredParameter;
                    IsRegisteredParameter = new ObjectParameter("IsRegistered", typeof(global::System.Int32));

                    AthlEnt.CompetitorIsAlreadyRegisteredInCompetition(CompCode.Text, CompetitorCode, IsRegisteredParameter);

                    Int32 CompetitorIsAlreadyRegistered = Convert.ToInt32(IsRegisteredParameter.Value.ToString());
                    if (CompetitorIsAlreadyRegistered == 0)
                    {
                        AthlCompetitorInComp = AthlCompCRUD.CopyCompetitorToCompetition(CompetitorCode, CompCode.Text, CompetitionYear, MoveToClub, out WasOkToMove, out ErrorText);
                    }
//CopyCompetitorToCompetition(string CompetitorCode, string CompetitonCode, Int32 CompetitionYear, string MoveToClub,
//           out bool WasOkToMove, out string ReasonText)
                    //KeppNo = HttpUtility.HtmlDecode(KeppNo);
                    //AthlCompetitorInComp.keppendanumer = KeppNo;
                    //if (SelectedCompetitors.SelectedRow.Cells[2].Text == "Karl")
                    //{
                    //    AthlCompetitorInComp.kyn = 1;
                    //}
                    //else
                    //{
                    //    AthlCompetitorInComp.kyn = 2;
                    //}
                    //AthlCompetitorInComp.kennitala = SelectedCompetitors.SelectedRow.Cells[3].Text;
                    //string Name = SelectedCompetitors.SelectedRow.Cells[4].Text;
                    //Name = HttpUtility.HtmlDecode(Name);
                    //AthlCompetitorInComp.nafn = Name;
                    //AthlCompetitorInComp.faedingarar = Convert.ToInt16(SelectedCompetitors.SelectedRow.Cells[5].Text);
                    //AthlCompetitorInComp.aldurkeppanda = Convert.ToInt32(SelectedCompetitors.SelectedRow.Cells[6].Text);
                    //string Club = SelectedCompetitors.SelectedRow.Cells[7].Text;
                    //Club = HttpUtility.HtmlDecode(Club);
                    //AthlCompetitorInComp.felag = Club;
                    ////string NoOfPerf = SelectCompetitorGridView.SelectedRow.Cells[8].Text;
                    //AthlCompetitorInComp.faedingardagur = Convert.ToDateTime(SelectedCompetitors.SelectedRow.Cells[9].Text);
                    //string Land = SelectedCompetitors.SelectedRow.Cells[10].Text;
                    //Land = HttpUtility.HtmlDecode(Land);
                    //AthlCompetitorInComp.land = Land;

                    AthlCompCRUD.InsertCompetitorInCompetition(AthlCompetitorInComp);
                    AthlEnt.InsertToLogFile(CurrentUserName.Text, "Skráning í mót", CompCode.Text, AthlCompetitorInComp.keppendanumer, "");

                    //       AthlCompEvents = AthlCompCRUD.InitCompetitionEvent();
                    //       AthlCompEvents.mot = gl.GetCompetitionCode();
                }
            }
            SelectedCompetitors.DataBind();

            //Response.Redirect("NyttMot.aspx?Comp=" + gl.GetCompetitionCode());
        }