protected void Page_Load(object sender, EventArgs e) { Global Gl = new Global(); if (IsPostBack) { Message.Text = ""; DateTime DateValue; string ValinnV = Convert.ToString(Vellir.SelectedValue); string InnslDags = Dagsetning.Text; if (ValinnV != GamliVollur.Text) { MotADO ado = new MotADO(); ado.GeymaVallarupplys(ValinnV); Stadur.Text = ado.ValinnStadur; UtiEdaInni.Text = ado.ValidUtiInni; if (UtiEdaInni.Text == "0") { UtiEdaInni.Text = "Utanhúss"; } if (UtiEdaInni.Text == "1") { UtiEdaInni.Text = "Innanhúss"; } if (UtiEdaInni.Text == "2") { UtiEdaInni.Text = "Utan- eða Innanhúss"; } GamliVollur.Text = ValinnV.ToString(); } if (InnslDags != GamlaDags.Text) { string[] separators = { ".", "/", " " }; string[] words = InnslDags.Split(separators, StringSplitOptions.RemoveEmptyEntries); if (words[0].Length == 1) { words[0] = "0" + words[0]; } if (words[1].Length == 1) { words[1] = "0" + words[1]; } if (words[2].Length == 1) { words[2] = "200" + words[2]; } else if (words[2].Length == 2) { words[2] = "20" + words[2]; } InnslDags = words[0] + "." + words[1] + "." + words[2]; // if (words[0].Length > if (InnslDags.Length == 8) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + "." + InnslDags.Substring(4, 4); HeitiMots.Focus(); } else if (InnslDags.Length == 7) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + "." + InnslDags.Substring(3, 4); } else if (InnslDags.Length == 6) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + ".20" + InnslDags.Substring(4, 2); } else if (InnslDags.Length == 5) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + ".20" + InnslDags.Substring(3, 2); } else if (InnslDags.Length == 4) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + "." + DateTime.Now.ToString("yyyy"); } else if (InnslDags.Length == 3) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + "." + DateTime.Now.ToString("yyyy"); } else if (InnslDags.Length == 2) { InnslDags = InnslDags + "." + DateTime.Now.ToString("MM.yyyy"); } else if (InnslDags.Length == 1) { InnslDags = "0" + InnslDags + "." + DateTime.Now.ToString("MM.yyyy"); } if (!DateTime.TryParse(InnslDags, out DateValue)) { Message.Text = "Dagsetning " + InnslDags + " er ekki í lagi."; } else { InnslDags = DateValue.ToShortDateString(); } Dagsetning.Text = InnslDags; GamlaDags.Text = InnslDags; HeitiMots.Focus(); } } else //Not Postback - Page Load { AccessLevelText = Session["CurrentAccessLevel"].ToString(); if ((AccessLevelText == "0") || (AccessLevelText == "") || (AccessLevelText == null)) { NewCompetitorButton.Visible = false; YourCompetitors.Visible = false; AddNewCompetitorsBtn.Visible = false; SetupEvents.Visible = false; Vista.Visible = false; HeitiMots.ReadOnly = true; EnsktHeiti.ReadOnly = true; Dagsetning.ReadOnly = true; //Vellir.ReadOnly = true; Stadur.ReadOnly = true; UtiEdaInni.ReadOnly = true; Motshaldari.ReadOnly = true; Yfirdomari.ReadOnly = true; SkranGjaldPrGrein.ReadOnly = true; SkranGjPrBodhl.ReadOnly = true; SkranGjPrGreinU18.ReadOnly = true; SkranGjPrBodhlU18.ReadOnly = true; } if (Gl.GetCompetitionCode() != "") { { CompetitionCode.Text = Gl.GetCompetitionCode(); CompCode2.Text = CompetitionCode.Text; CompCode4.Text = CompetitionCode.Text; CompCode7.Text = CompetitionCode.Text; AthleticCompetitionCRUD AthlCompCRUD = new AthleticCompetitionCRUD(); Athl_Competition AthlComp = new Athl_Competition(); AthlComp = AthlCompCRUD.GetCompetitionRec(Gl.GetCompetitionCode()); HeitiMots.Text = AthlComp.Name; EnsktHeiti.Text = AthlComp.ensktheitiamoti; Dagsetning.Text = AthlComp.Date.ToShortDateString(); Gl.SetGlobalValue("CompetitionName", AthlComp.Name); Gl.SetGlobalValue("EnglishCompetitionName", AthlComp.ensktheitiamoti); Gl.SetOutdoorsOrIndoors(AthlComp.OutdoorsOrIndoors.ToString()); Int16 VenueIndex = 0; System.Data.Objects.ObjectParameter Indx = new System.Data.Objects.ObjectParameter("Indx", typeof(Int32)); AthleticsEntities1 AthlEnt = new AthleticsEntities1(); AthlEnt.IndexCompetitionVenue(AthlComp.keppnisvollur, Indx); if (Int16.TryParse(Indx.Value.ToString(), out VenueIndex) == false) { VenueIndex = 0; } //VenueIndex = ReturnIndexOfVenue(AthlComp.keppnisvollur); if (VenueIndex > 0) { Vellir.SelectedIndex = VenueIndex; } Stadur.Text = AthlComp.Location; if (AthlComp.CompetitonType == 0) { CompetitionEventsHdr.Text = HeitiMots.Text + " - Keppnisgreinar hlaups:"; } else { CompetitionEventsHdr.Text = HeitiMots.Text + " - Keppnisgreinar móts:"; } if (AthlComp.OutdoorsOrIndoors == 0) { UtiEdaInni.Text = "Utanhúss"; } else { UtiEdaInni.Text = "Innanhúss"; } Motshaldari.Text = AthlComp.Organizer; Yfirdomari.Text = AthlComp.Judge; SkranGjaldPrGrein.Text = string.Format("{0:N2}", AthlComp.skraningargjaldprgrein); //AthlComp.skraningargjaldprgrein.ToString(); SkranGjPrBodhl.Text = string.Format("{0:N2}", AthlComp.Skráningargjld_f__boðhlaup); //.ToString(); SkranGjPrGreinU18.Text = string.Format("{0:N2}", AthlComp.Skráningargj__yngri_en_18_ára); SkranGjPrBodhlU18.Text = string.Format("{0:N2}", AthlComp.Skráningargj__f_boðhl_y_18_ára); if (AthlComp.Reikna_unglingastig == 1) { ReiknaUnglStig.Text = "Já"; } else { ReiknaUnglStig.Text = "Nei"; } if (AthlComp.Reikna_IAAF_stig == 1) { ReiknaIAAFStig.Text = "Já"; } else { ReiknaIAAFStig.Text = "Nei"; } Gl.SetCompetitionCode(AthlComp.Code); Gl.SetCompetitionName(AthlComp.Name); Gl.SetCompetionYear(AthlComp.Date.Year); if (AthlComp.keppnisvollur != "") { Gl.SetCompetitionVenue(AthlComp.keppnisvollur + ", " + AthlComp.Location); } else { Gl.SetCompetitionVenue(AthlComp.Location); } Int32 NoOfDates = 0; ListItem newItem = new ListItem(); newItem = new ListItem(); newItem.Text = "Allir dagar"; newItem.Value = "%"; EventDateFilterDropDown.Items.Add(newItem); //AthleticsEntities1 AthlEnt = new AthleticsEntities1(); var DatesInCompetition = AthlEnt.ReturnCompetitionEventDates(Gl.GetCompetitionCode()); foreach (var result in DatesInCompetition) { NoOfDates = NoOfDates + 1; newItem = new ListItem(); newItem.Text = Convert.ToString(result); // "Dagur 1"; // Convert.ToString(result.Dags); newItem.Value = Convert.ToString(result) + "%"; // "D1%"; // Convert.ToString(result.Dags) + "%"; EventDateFilterDropDown.Items.Add(newItem); } if (NoOfDates <= 1) { EventDateFilterLabel.Visible = false; EventDateFilterDropDown.Visible = false; } else { EventDateFilterLabel.Visible = true; EventDateFilterDropDown.Visible = true; } } HeitiMots.Focus(); NyrKeppandiTbl.Visible = false; } else { string SelNafn; SelNafn = Gl.GetSelNafn(); if (SelNafn != "") { KennitText.Text = Gl.GetSelKt(); NafnText.Text = SelNafn; FaedArText.Text = Gl.GetSelFar(); FelagText.Text = Gl.GetSelFel(); Gl.SetSelComp("", "", "", "", "", "", "", ""); } } } }
protected void Page_Load(object sender, EventArgs e) { CopyEventsFromPrevComp.Visible = false; //DEBUG if (Session["CurrentUserName"] == null) { CurrentUserID = ""; } else { CurrentUserID = Session["CurrentUserName"].ToString(); } CurrCompCode = gl.GetCompetitionCode(); string CompCodeText = Request.QueryString.Get("Code"); NewCompetition = false; if ((CompCodeText != "") && (CompCodeText != null)) { gl.SetCompetitionCode(CompCodeText); CurrCompCode = CompCodeText; if (CurrCompCode == "NYTT") { NewCompetition = true; } } System.Data.Objects.ObjectParameter CurrAccessLevel = new System.Data.Objects.ObjectParameter("CurrentAccessLevel", "0"); System.Data.Objects.ObjectParameter CurrCanEnterScores = new System.Data.Objects.ObjectParameter("CanEnterScores", "0"); AthlEnt.GetAccessLevel(CurrentUserID, CurrCompCode, CurrAccessLevel, CurrCanEnterScores); AccessLevelint = Convert.ToInt32(CurrAccessLevel.Value); CanEnterScores = Convert.ToInt32(CurrCanEnterScores.Value); //--AccessLevel //-- //--0 = Queries Only //--1 = Club Representative //--2 = Administrator //--3 = Selected Competition Only // //-- CanEnterScores 0 = No, 1 = Yes if (IsPostBack) { Message.Text = ""; DateTime DateValue; string ValinnV = Convert.ToString(Vellir.SelectedValue); string InnslDags = Dagsetning.Text; if (ValinnV != GamliVollur.Text) { MotADO ado = new MotADO(); ado.GeymaVallarupplys(ValinnV); Stadur.Text = ado.ValinnStadur; UtiEdaInni.Text = ado.ValidUtiInni; if (UtiEdaInni.Text == "0") { UtiEdaInni.Text = "Utanhúss"; } if (UtiEdaInni.Text == "1") { UtiEdaInni.Text = "Innanhúss"; } if (UtiEdaInni.Text == "2") { UtiEdaInni.Text = "Utan- eða Innanhúss"; } GamliVollur.Text = ValinnV.ToString(); } if (InnslDags != GamlaDags.Text) { string[] separators = { ".", "/", " " }; string[] words = InnslDags.Split(separators, StringSplitOptions.RemoveEmptyEntries); if (words[0].Length == 1) { words[0] = "0" + words[0]; } if (words[1].Length == 1) { words[1] = "0" + words[1]; } if (words[2].Length == 1) { words[2] = "200" + words[2]; } else if (words[2].Length == 2) { words[2] = "20" + words[2]; } InnslDags = words[0] + "." + words[1] + "." + words[2]; // if (words[0].Length > if (InnslDags.Length == 8) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + "." + InnslDags.Substring(4, 4); HeitiMots.Focus(); } else if (InnslDags.Length == 7) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + "." + InnslDags.Substring(3, 4); } else if (InnslDags.Length == 6) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + ".20" + InnslDags.Substring(4, 2); } else if (InnslDags.Length == 5) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + ".20" + InnslDags.Substring(3, 2); } else if (InnslDags.Length == 4) { InnslDags = InnslDags.Substring(0, 2) + "." + InnslDags.Substring(2, 2) + "." + DateTime.Now.ToString("yyyy"); } else if (InnslDags.Length == 3) { InnslDags = "0" + InnslDags.Substring(0, 1) + "." + InnslDags.Substring(1, 2) + "." + DateTime.Now.ToString("yyyy"); } else if (InnslDags.Length == 2) { InnslDags = InnslDags + "." + DateTime.Now.ToString("MM.yyyy"); } else if (InnslDags.Length == 1) { InnslDags = "0" + InnslDags + "." + DateTime.Now.ToString("MM.yyyy"); } if (!DateTime.TryParse(InnslDags, out DateValue)) { Message.Text = "Dagsetning " + InnslDags + " er ekki í lagi."; } else { InnslDags = DateValue.ToShortDateString(); NoOfDays = 1; } Dagsetning.Text = InnslDags; GamlaDags.Text = InnslDags; HeitiMots.Focus(); } if (CompetitionDate2.Text != "") { if (!DateTime.TryParse(CompetitionDate2.Text, out DateValue)) { Message.Text = "Dagsetning 2 " + CompetitionDate2.Text + " er ekki í lagi."; } else { AthlComp.Date2 = DateValue; NoOfDays = 2; } } else { AthlComp.Date2 = Convert.ToDateTime("1753-01-01 00:00:00.000"); CompetitionDate3.Text = ""; CompetitionDate4.Text = ""; } if (CompetitionDate3.Text != "") { if (!DateTime.TryParse(CompetitionDate3.Text, out DateValue)) { Message.Text = "Dagsetning 3 " + CompetitionDate3.Text + " er ekki í lagi."; } else { AthlComp.Date3 = DateValue; NoOfDays = 3; } } else { AthlComp.Date3 = Convert.ToDateTime("1753-01-01 00:00:00.000"); CompetitionDate4.Text = ""; } if (CompetitionDate4.Text != "") { if (!DateTime.TryParse(CompetitionDate4.Text, out DateValue)) { Message.Text = "Dagsetning 4 " + CompetitionDate4.Text + " er ekki í lagi."; } else { AthlComp.dagsetning4 = DateValue; NoOfDays = 4; } } else { AthlComp.dagsetning4 = Convert.ToDateTime("1753-01-01 00:00:00.000"); } AthlComp.tegundstigakeppni = gl.TryConvertStringToInt32(TegundStigakeppni.SelectedValue.ToString()); } else //Not Postback - Page Load { //AccessLevelText = Session["CurrentAccessLevel"].ToString(); //if ((AccessLevelText == "0") || (AccessLevelText == "") || (AccessLevelText == null)) if ((AccessLevelint != 1) && (AccessLevelint != 2)) //Access is NOT Club Repesentative and NOT Administrator, Competition Creator or CompetitionUpdateAccess = Administrator { //NewCompetitorButton.Visible = false; //YourCompetitors.Visible = false; //AddNewCompetitorsBtn.Visible = false; SetupEvents.Visible = false; // Vista.Visible = false; HeitiMots.ReadOnly = true; EnsktHeiti.ReadOnly = true; Dagsetning.ReadOnly = true; Vellir.Enabled = false; Stadur.ReadOnly = true; UtiEdaInni.ReadOnly = true; Motshaldari.ReadOnly = true; Yfirdomari.ReadOnly = true; SkranGjaldPrGrein.ReadOnly = true; SkranGjPrBodhl.ReadOnly = true; SkranGjPrGreinU18.ReadOnly = true; SkranGjPrBodhlU18.ReadOnly = true; CompStatus.Enabled = false; TegundStigakeppni.Enabled = false; ReiknaIAAFStig.Enabled = false; ReiknaUnglStig.Enabled = false; Message.Text = "Þú hefur ekki leyfi til að breyta uppsetningu mótsins"; Vista.Visible = false; } else { Message.Text = ""; } if ((gl.GetCompetitionCode() != "") && (gl.GetCompetitionCode() != "NYTT") && (NewCompetition == false)) { { //SetupEvents.Visible = true; CompetitionCode.Text = gl.GetCompetitionCode(); //CompCode2.Text = CompetitionCode.Text; //CompCode4.Text = CompetitionCode.Text; //CompCode7.Text = CompetitionCode.Text; AthleticCompetitionCRUD AthlCompCRUD = new AthleticCompetitionCRUD(); AthlComp = AthlCompCRUD.GetCompetitionRec(gl.GetCompetitionCode()); HeitiMots.Text = AthlComp.Name; EnsktHeiti.Text = AthlComp.ensktheitiamoti; Dagsetning.Text = AthlComp.Date.ToShortDateString(); gl.SetGlobalValue("CompetitionName", AthlComp.Name); gl.SetGlobalValue("EnglishCompetitionName", AthlComp.ensktheitiamoti); UtiEdaInni.Text = AthlComp.OutdoorsOrIndoors.ToString(); gl.SetOutdoorsOrIndoors(UtiEdaInni.Text); Int16 VenueIndex = 0; System.Data.Objects.ObjectParameter Indx = new System.Data.Objects.ObjectParameter("Indx", typeof(Int32)); AthlEnt.IndexCompetitionVenue(AthlComp.keppnisvollur, Indx); if (Int16.TryParse(Indx.Value.ToString(), out VenueIndex) == false) { VenueIndex = 0; } //VenueIndex = ReturnIndexOfVenue(AthlComp.keppnisvollur); if (VenueIndex > 0) { Vellir.SelectedIndex = VenueIndex; } Stadur.Text = AthlComp.Location; if (UtiEdaInni.Text == "0") { UtiEdaInni.Text = "Utanhúss"; } if (UtiEdaInni.Text == "1") { UtiEdaInni.Text = "Innanhúss"; } CompStatus.SelectedIndex = AthlComp.Staða_móts; TegundStigakeppni.SelectedValue = AthlComp.tegundstigakeppni.ToString(); Motshaldari.Text = AthlComp.Organizer; Yfirdomari.Text = AthlComp.Judge; Motsstjori.Text = AthlComp.Director; SkranGjaldPrGrein.Text = string.Format("{0:N2}", AthlComp.skraningargjaldprgrein); //AthlComp.skraningargjaldprgrein.ToString(); SkranGjPrBodhl.Text = string.Format("{0:N2}", AthlComp.Skráningargjld_f__boðhlaup); //.ToString(); SkranGjPrGreinU18.Text = string.Format("{0:N2}", AthlComp.Skráningargj__yngri_en_18_ára); SkranGjPrBodhlU18.Text = string.Format("{0:N2}", AthlComp.Skráningargj__f_boðhl_y_18_ára); //if (AthlComp.Reikna_unglingastig == 1) //{ // ReiknaUnglStig.Text = "Já"; //} //else //{ // ReiknaUnglStig.Text = "Nei"; //} ReiknaUnglStig.SelectedValue = AthlComp.Reikna_unglingastig.ToString(); //if (AthlComp.Reikna_IAAF_stig == 1) //{ // ReiknaIAAFStig.Text = "Já"; //} //else //{ // ReiknaIAAFStig.Text = "Nei"; //} ReiknaIAAFStig.SelectedValue = AthlComp.Reikna_IAAF_stig.ToString(); gl.SetCompetitionCode(AthlComp.Code); gl.SetCompetitionName(AthlComp.Name); gl.SetCompetionYear(AthlComp.Date.Year); if (AthlComp.keppnisvollur != "") { gl.SetCompetitionVenue(AthlComp.keppnisvollur + ", " + AthlComp.Location); } else { gl.SetCompetitionVenue(AthlComp.Location); } Int32 NoOfDates = 0; ListItem newItem = new ListItem(); newItem = new ListItem(); newItem.Text = "Allir dagar"; newItem.Value = "%"; //AthleticsEntities1 AthlEnt = new AthleticsEntities1(); var DatesInCompetition = AthlEnt.ReturnCompetitionEventDates(gl.GetCompetitionCode()); foreach (var result in DatesInCompetition) { NoOfDates = NoOfDates + 1; newItem = new ListItem(); newItem.Text = Convert.ToString(result); // "Dagur 1"; // Convert.ToString(result.Dags); newItem.Value = Convert.ToString(result) + "%"; // "D1%"; // Convert.ToString(result.Dags) + "%"; } if (AthlComp.Date2 > Convert.ToDateTime("1900.01.01")) { CompetitionDate2.Visible = true; CompetitionDate2.Text = AthlComp.Date2.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture); } if (AthlComp.Date3 > Convert.ToDateTime("1900.01.01")) { CompetitionDate3.Visible = true; CompetitionDate3.Text = AthlComp.Date3.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture); } if (AthlComp.dagsetning4 > Convert.ToDateTime("1900.01.01")) { CompetitionDate4.Visible = true; CompetitionDate4.Text = AthlComp.dagsetning4.ToString("dd.MM.yyyy", CultureInfo.InvariantCulture); } } HeitiMots.Focus(); } else { string SelNafn; SelNafn = gl.GetSelNafn(); SetupEvents.Visible = false; CopyEventsFromPrevComp.Visible = false; UpdateEventSetup.Visible = false; CompStatus.SelectedIndex = 1; Vista.Text = "Stofna"; } } }