Skip to footer content
Iron Academy Logo
C# Application
C# Application

Other Categories

Building the Create Team Form in C# – Lesson 12 Explained (Tim Corey)

Tim Corey
48m 03s

In this article, we’re going to take a deeper look at C# application development through Tim Corey’s “C# App Start To Finish Lesson 12 – Create Team Form Part 1”. Tim walks us through the process of building a real-world form step-by-step, showing how to break complex UI tasks into smaller, manageable chunks. By following his approach, you’ll gain a clearer understanding of how to design and implement functional Windows Forms applications using clean patterns and practical development strategies.

Breaking Down Complexity

Tim begins by emphasizing a key mindset for developers: don’t get overwhelmed by complexity. He explains that the form may look complicated at first, but the solution is to break it into smaller chunks. Tim says that once you isolate manageable parts, the problem becomes much easier to solve. This philosophy is central to his teaching style and helps beginners stay focused and confident during development.

Understanding the Create Team Form

Tim shows the “Create Team” form and notes that it contains multiple UI components such as buttons, lists, and tables. He points out that the Add New Member section is essentially its own form, similar to the “Create Prize” form built in earlier lessons. This separation of functionality is crucial because it allows the developer to implement one section at a time without getting lost in the complexity of the entire form.

Clarifying the Purpose: Add New Person

Tim explains that the “Add New Member” section is technically adding a person, not a team member. In the database, the people table contains fields like first name, last name, email, and cell phone. A team member is simply represented by a person ID and team ID. Tim notes that even though it’s technically adding a person, it makes sense to call it “Add New Member” because it fits the form’s purpose.

Creating the Button Event

Tim demonstrates how to create the button event for the “Create Member” button. He explains that you can double-click the button or use the properties panel to create the event. He also explains how naming conventions affect event names, and why consistent naming is important to avoid confusion later. Tim stresses that naming should be done before creating events to avoid extra manual changes.

The Logic Inside the Event

Tim outlines the steps that the button event must perform:

  1. Validate the form

  2. Create a Person model

  3. Save the person to the database or text file

  4. Clear the form

He compares this workflow to the earlier “Create Prize” form, showing that the same pattern applies. Tim explains that reusing patterns like this is what makes development faster and more reliable.

Form Validation

Tim builds a validation method named ValidateForm() and explains why naming consistency matters. He suggests that validation can be simple or complex, depending on needs. For now, Tim keeps it basic: all four fields must contain text. He discusses how validation could later be improved to check email formats or phone number length, but for this lesson, basic validation is enough to move forward.

Creating and Saving the Person Model

Tim shows how to create a PersonModel from the form fields and then pass it to the global connection for saving. He explains that the process is the same as the prize form: validate → create model → save → clear. Tim emphasizes that reusing patterns like this is what makes development faster and more reliable.

Implementing the CreatePerson Method

Tim introduces the interface update required for the new method CreatePerson(PersonModel model) in the IDataConnection interface. He explains that adding this method will cause compile errors in all existing classes that implement the interface. Tim highlights that this is a good thing because it forces you to implement the new method properly across all connectors.

Creating the SQL Store Procedure

Tim switches to SQL to create the stored procedure spPeople_Insert. He carefully maps parameters like FirstName, LastName, EmailAddress, and CellPhoneNumber, ensuring correct data types and sizes. Tim explains that accurate types matter to prevent errors and ensure data integrity.

He also explains how to capture the newly created ID using SCOPE_IDENTITY() and pass it back to the application. This step is crucial for maintaining consistent IDs in the database and application model.

Testing the SQL Connector

Tim tests the SQL connector by running the form and inserting a person into the database. He opens a query window and verifies that the data appears correctly in the dbo.People table. Tim notes that testing frequently is important to catch issues early and confirm that the system works as expected.

Implementing the Text Connector

Tim then moves to implement the Text Connector version of the same functionality. He explains that the code structure is similar, but now it uses CSV files instead of SQL. He creates a new file constant called PersonModels.csv and adds methods to convert CSV data into PersonModel objects.

Tim also discusses the importance of data formatting and how comma-separated values can cause issues if commas exist inside data fields. He suggests using different separators or validating input to avoid problems.

Creating ConvertToPersonModels Method

Tim writes the method ConvertToPersonModels() to parse CSV lines into PersonModel objects. He shows how to split lines, map values into model properties, and add them to a list. Tim emphasizes that the mapping order must match the CSV column order.

Saving to the CSV File

Tim creates the SaveToPeopleFile() method to save a list of PersonModel objects back to the CSV file. He explains how to build string lines with comma-separated values and write them to the file. Tim highlights the importance of using the correct file path to ensure data is saved properly.

Final Testing and Results

Tim tests the text connector by adding multiple members and verifying the CSV file updates correctly. He confirms that IDs increment properly and that all data fields are saved. Tim notes that the process is now complete for this chunk of the form.

Conclusion & Next Steps

Tim concludes the lesson by explaining that this section is now complete. The next step will be to wire up the team member lists and finalize the team creation. Tim reminds learners that this process becomes easier over time as patterns are repeated and reused, which is what makes senior developers seem fast—they reuse proven patterns.

Hero Worlddot related to Building the Create Team Form in C# – Lesson 12 Explained (Tim Corey)
Hero Affiliate related to Building the Create Team Form in C# – Lesson 12 Explained (Tim Corey)

Earn More by Sharing What You Love

Do you create content for developers working with .NET, C#, Java, Python, or Node.js? Turn your expertise into extra income!

Iron Support Team

We're online 24 hours, 5 days a week.
Chat
Email
Call Me