private void Registration_Load( object sender, EventArgs e ) { if (Properties.Settings.Default.TourRegList_Width > 0) { this.Width = Properties.Settings.Default.TourRegList_Width; } if (Properties.Settings.Default.TourRegList_Height > 0) { this.Height = Properties.Settings.Default.TourRegList_Height; } if (Properties.Settings.Default.TourRegList_Location.X > 0 && Properties.Settings.Default.TourRegList_Location.Y > 0) { this.Location = Properties.Settings.Default.TourRegList_Location; } if (Properties.Settings.Default.TourRegList_Sort.Length > 0) { mySortCommand = Properties.Settings.Default.TourRegList_Sort; } else { mySortCommand = "SkierName ASC, AgeGroup ASC"; Properties.Settings.Default.TourRegList_Sort = mySortCommand; } String[] curList = { "SkierName", "AgeGroup", "ReadyToSki", "SlalomReg", "TrickReg", "JumpReg", "SlalomGroup", "TrickGroup", "JumpGroup", "EntryDue", "EntryPaid", "PaymentMethod", "JumpHeight", "TrickBoat", "AwsaMbrshpPaymt" }; sortDialogForm = new SortDialogForm(); sortDialogForm.ColumnListArray = curList; filterDialogForm = new Common.FilterDialogForm(); filterDialogForm.ColumnListArray = curList; // Retrieve data from database mySanctionNum = Properties.Settings.Default.AppSanctionNum; if (mySanctionNum == null) { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); //this.Close(); } else { if (mySanctionNum.Length < 6) { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); //this.Close(); } else { //Retrieve selected tournament attributes DataTable curTourDataTable = getTourData(); if (curTourDataTable.Rows.Count > 0) { myTourRow = curTourDataTable.Rows[0]; if ( myTourRow["SlalomRounds"] == DBNull.Value ) { myTourRow["SlalomRounds"] = 0; } if ( myTourRow["TrickRounds"] == DBNull.Value ) { myTourRow["TrickRounds"] = 0; } if ( myTourRow["JumpRounds"] == DBNull.Value ) { myTourRow["JumpRounds"] = 0; } if ( Convert.ToInt16( myTourRow["SlalomRounds"] ) == 0 ) { SlalomReg.Visible = false; SlalomGroup.Visible = false; RegCountSlalomLabel.Visible = false; SlalomRegCount.Visible = false; } if ( Convert.ToInt16( myTourRow["TrickRounds"] ) == 0 ) { TrickReg.Visible = false; TrickGroup.Visible = false; RegCountTrickLabel.Visible = false; TrickRegCount.Visible = false; } if ( Convert.ToInt16( myTourRow["JumpRounds"] ) == 0 ) { JumpReg.Visible = false; JumpGroup.Visible = false; RegCountJumpLabel.Visible = false; JumpRegCount.Visible = false; } myTourRegAddDialog = new TourRegAddMember(); myEditRegMemberDialog = new EditRegMember(); myTourEventReg = new TourEventReg(); myTourRegRowIdx = 0; loadTourRegView(); } else { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); } } } isDataModified = false; }
private bool importMemberData( bool inNcwsa ) { bool curReturn = true, curTeamHeaderActive = false, curNcwsa = inNcwsa, curTourRegFmt = false; string inputBuffer, myfileName, MemberId; string[] inputCols; string[] inputColsSaved = null; char[] tabDelim = new char[] { '\t' }; DateTime curFileDate; SqlCeCommand sqlStmt = null; StreamReader myReader; DialogResult msgResp; int numCk = 0, idxMemberId = 0, idx2010FmtCheck = 18 ; int curInputLineCount = 0; myTourEventReg = new TourEventReg(); myMemberIdValidate = new MemberIdValidate(); myCountMemberInput = 0; myCountMemberAdded = 0; myCountMemberUpdate = 0; myCountTourRegAdded = 0; myCountSlalomAdded = 0; myCountTrickAdded = 0; myCountJumpAdded = 0; //Choose an input file to be processed String curPath = Properties.Settings.Default.ExportDirectory; OpenFileDialog myFileDialog = new OpenFileDialog(); myFileDialog.InitialDirectory = curPath; myFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; myFileDialog.FilterIndex = 2; try { if ( myFileDialog.ShowDialog() == DialogResult.OK ) { myfileName = myFileDialog.FileName; if ( myfileName == null ) { return false; } else { myProgressInfo.setProgessMsg( "File selected " + myfileName ); myProgressInfo.Show(); myProgressInfo.Refresh(); //Prepare database interaction combonents for processing SqlCeConnection myDbConn = new global::System.Data.SqlServerCe.SqlCeConnection(); //Get file date and prepare to read input data curFileDate = File.GetLastWriteTime( myfileName ); try { curInputLineCount = 0; myReader = new StreamReader( myfileName ); while ( ( inputBuffer = myReader.ReadLine() ) != null ) { curInputLineCount++; } myReader.Close(); myProgressInfo.setProgressMin( 1 ); myProgressInfo.setProgressMax( curInputLineCount ); } catch ( Exception ex ) { MessageBox.Show( "Error: Could not read file" + myFileDialog.FileName + "\n\nError: " + ex.Message ); return false; } curInputLineCount = 0; myReader = new StreamReader( myfileName ); try { //Open database connection myDbConn.ConnectionString = Properties.Settings.Default.waterskiConnectionStringApp; myDbConn.Open(); #region Process each input file data row while ( ( inputBuffer = myReader.ReadLine() ) != null ) { curInputLineCount++; myProgressInfo.setProgressValue( curInputLineCount ); //Initialize SQL statement variable for database processing sqlStmt = myDbConn.CreateCommand(); //Check input row to ensure it is a data row if ( inputBuffer.ToLower().IndexOf( "end-of-list" ) > -1 || inputBuffer.ToLower().IndexOf( "end of list" ) > -1 || inputBuffer.ToLower().IndexOf( "end_of_list" ) > -1 || inputBuffer.ToLower().IndexOf( "endoflist" ) > -1 ) { break; } else { inputCols = inputBuffer.Split( tabDelim ); if ( inputCols.Length > 8 ) { //Check first line of input file to analyze the file format supplied if ( curInputLineCount == 1 && curNcwsa == false ) { if ( inputCols.Length > 25 ) { if ( inputCols[26].ToLower().IndexOf( "membership status" ) > -1 ) { curTourRegFmt = true; } else if ( inputCols[25].ToLower().IndexOf( "membership status" ) > -1 ) { curTourRegFmt = true; } else if ( inputCols[12].ToLower().IndexOf( "membership status" ) > -1 ) { curNcwsa = true; } } else if (inputCols.Length > 12) { if (inputCols[12].ToLower().IndexOf( "membership status" ) > -1) { curNcwsa = true; } } } else { if ( inputCols[idxMemberId].Trim().Length > 10 ) { MemberId = inputCols[idxMemberId].Substring( 0, 3 ) + inputCols[idxMemberId].Substring( 4, 2 ) + inputCols[idxMemberId].Substring( 7, 4 ); } else { MemberId = "---"; } //If a valid member id is detected in the first column //assume valid record available for input if ( int.TryParse( MemberId.Substring( 0, 3 ), out numCk ) ) { curTeamHeaderActive = false; if (curNcwsa) { inputColsSaved = new String[inputCols.Length]; curReturn = procMemberInput( sqlStmt, inputCols, MemberId, curFileDate, curTourRegFmt, curNcwsa, inputColsSaved ); } else { curReturn = procMemberInput( sqlStmt, inputCols, MemberId, curFileDate, curTourRegFmt, curNcwsa, null ); } if ( curReturn ) { if (curNcwsa && inputColsSaved != null) { if ( inputColsSaved[0] != null ) { curReturn = procMemberInput( sqlStmt, inputColsSaved, MemberId, curFileDate, curTourRegFmt, curNcwsa, null ); } } } else { msgResp = MessageBox.Show( "Error encountered on last record./n Do you want to continue processing?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1 ); if ( msgResp == DialogResult.Yes ) { curReturn = true; } else { curReturn = false; break; } } } else { if ( inputCols[idxMemberId].ToLower().Equals( "end-of-list" ) || inputCols[idxMemberId].ToLower().Equals( "end of list" ) || inputCols[idxMemberId].ToLower().Equals( "end_of_list" ) || inputCols[idxMemberId].ToLower().Equals( "endoflist" ) ) { break; } else if ( ( inputCols[0].ToLower().IndexOf( "team header" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "teamheader" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "team-header" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "team_header" ) > -1 ) ) { curTeamHeaderActive = true; curReturn = procTeamHeaderInput( sqlStmt, inputCols, inNcwsa ); } else if ( inputCols[idxMemberId].ToLower().Equals( "tourn name:" ) ) { curTeamHeaderActive = false; String curInputSanctionId = inputCols[6]; if ( curInputSanctionId.Length > 6 ) { curInputSanctionId = curInputSanctionId.Substring( 0, 6 ); } if ( !( curInputSanctionId.Equals( mySanctionNum ) ) ) { String dialogMsg = "Sanction number on import file is " + inputCols[6] + "\n Current tournament being scored is " + mySanctionNum + "\n\n Do you still want to continue?"; msgResp = MessageBox.Show( dialogMsg, "Database Copy", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ); if ( msgResp == DialogResult.No ) { break; } } } else { if ( curTeamHeaderActive ) { curReturn = procTeamHeaderInput( sqlStmt, inputCols, inNcwsa ); } } } } } else { if ( inputCols.Length > 3 ) { if ( ( inputCols[0].ToLower().IndexOf( "team header" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "teamheader" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "team-header" ) > -1 ) || ( inputCols[0].ToLower().IndexOf( "team_header" ) > -1 ) ) { curTeamHeaderActive = true; curReturn = procTeamHeaderInput( sqlStmt, inputCols, inNcwsa ); } } } } } MessageBox.Show( "Info: Member import processed" + "\nMember records read: " + myCountMemberInput + "\nmyCountMemberAdded: " + myCountMemberAdded + "\nmyCountMemberUpdate: " + myCountMemberUpdate + "\nmyCountTourRegAdded: " + myCountTourRegAdded + "\nmyCountSlalomAdded: " + myCountSlalomAdded + "\nmyCountTrickAdded: " + myCountTrickAdded + "\nmyCountJumpAdded: " + myCountJumpAdded ); #endregion } catch ( Exception ex ) { String ExcpMsg = ex.Message; if ( sqlStmt != null ) { ExcpMsg += "\n" + sqlStmt.CommandText; } MessageBox.Show( "Error: Performing SQL operations" + "\n\nError: " + ExcpMsg ); } finally { myDbConn.Close(); myReader.Close(); myReader.Dispose(); } } } else { return false; } } catch ( Exception ex ) { MessageBox.Show( "Error: Could not read file" + myFileDialog.FileName + "\n\nError: " + ex.Message ); return false; } return true; }
private void EditRegMember_Load( object sender, EventArgs e ) { if ( Properties.Settings.Default.EditRegMember_Width > 0 ) { this.Width = Properties.Settings.Default.EditRegMember_Width; } if ( Properties.Settings.Default.EditRegMember_Height > 0 ) { this.Height = Properties.Settings.Default.EditRegMember_Height; } if ( Properties.Settings.Default.EditRegMember_Location.X > 0 && Properties.Settings.Default.EditRegMember_Location.Y > 0 ) { this.Location = Properties.Settings.Default.EditRegMember_Location; } mySanctionNum = Properties.Settings.Default.AppSanctionNum; if ( mySanctionNum == null ) { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); } else { if ( mySanctionNum.Length < 6 ) { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); } else { //Retrieve selected tournament attributes myDbConn = new global::System.Data.SqlServerCe.SqlCeConnection(); myDbConn.ConnectionString = Properties.Settings.Default.waterskiConnectionStringApp; DataTable curTourDataTable = getTourData(); if (curTourDataTable.Rows.Count > 0) { myTourRow = curTourDataTable.Rows[0]; AgeAsOfLabel.Text = AgeAsOfLabel.Text.Substring( 0, AgeAsOfLabel.Text.Length - 2 ) + mySanctionNum.Substring( 0, 2 ); myFedDropdownList = new FedDropdownList(); myMemberStatusDropdownList = new MemberStatusDropdownList(); myTourEventReg = new TourEventReg(); myMemberIdValidate = new MemberIdValidate(); editFederation.DataSource = myFedDropdownList.DropdownList; editFederation.DisplayMember = "ItemName"; editFederation.ValueMember = "ItemValue"; editMemberStatus.DataSource = myMemberStatusDropdownList.DropdownList; editMemberStatus.DisplayMember = "ItemName"; editMemberStatus.ValueMember = "ItemValue"; editGenderSelect.addClickEvent( editGenderSelect_Click ); if ( myMemberViewRow == null ) { this.Text = "Edit Member Registration"; editMemberDataLoad( myMemberId, myAgeGroup ); } else { this.Text = "Add Registration for Member"; editMemberDataLoad(); } } else { MessageBox.Show( "An active tournament must be selected from the Administration menu Tournament List option" ); } } } }