Club Manager : Create MemberShipPlan : Model

MemberShip Plan Manager

So what are all the properties of MemberShipPlan that we require:

  • MemberShip : Name of MemberShip e.g. Gold, Platinum
  • Description : A brief description of the plan
  • MonthlyFee : Fee of the plan if paid monthly.
  • QuarterlyFee : Fee of the plan if paid quarterly.
  • HalfYearlyFee : Fee of the plan if paid half yearly.
  • AnnualFee : Fee of the plan if paid annually.

Please note that in general fee is paid monthly, quarterly, Semi-Annually or Annually so we are storing them in individual properties. But we will also accept the fee for 2, 4, 5, 7, 8, 10, 11 months if user wants to.

Apart from above we also need to maintain if the plan is active or not, and some unique id for the Plan which can later be referred. So some more properties:

  • _id : Plan ID3
  • IsActive : If plan is active or not.

3We use _id everywhere as object identifier.

  1. Now let us add a new Class Library project in Model solution folder with name ClubManager.Model.
  2. After adding the project delete Class1.cs from the new created project and add a new class MemberShipPlan.cs.
  3. Now add all the properties discussed about Model above in the class file.
  4. Override ToString() and return Name as this is what we would like to see whenever we call MemberShipPlanObject.ToString()
  5. Organize the file using regions for easy navigation.
Add New Class Library
Add New Class Library

Find below complete code:
ClubManager.Model.MemberShipPlan.cs

namespace ClubManager.Model
{
    ///
 
    /// Member Ship Plan
    ///
    public class MemberShipPlan { #region Properties ///
    /// Name of MemberShip e.g. Gold, Platinum ///
 
    public string MemberShip { get; set; } ///
    /// A brief description of the plan ///
 
    public string Description { get; set; } ///
    /// Fee of the plan if paid monthly. ///
 
    public double MonthlyFee { get; set; } ///
    /// Fee of the plan if paid quarterly. ///
 
    public double QuarterlyFee { get; set; } ///
    /// Fee of the plan if paid half yearly. ///
 
    public double HalfYearlyFee { get; set; } ///
    /// Fee of the plan if paid annually. ///
 
    public double AnnualFee { get; set; } ///
    /// MemberShip Plan ID ///
 
    public string _id { get; set; } ///
    /// If plan is active or not. ///
 
    public bool IsActive { get; set; } 
    #endregion Properties 
 
    #region Overridden Methods 
    /// String representation of the Member Ship Plan
    /// Name of the Plan 
    public override string ToString() { return this.MemberShip; } 
    #endregion Overridden Methods 
    }
}

So our Model for MemberShipPlan is now ready and we can design our UI to Create New MemberShipPlan. But wait how should user invoke New MemberShipPlan.

Since it is a windows application we will be having a menu bar containing all the menu options and one of them would be New Plan under MemberShipPlan. So let us go ahead.

  • First of all Add a New Item -> MDI Parent Form named frmMain to our ClubManager Project.
  • Delete Form1.cs as we are not going to use this empty form.
  • Open Program.cs and change Application.Run(new Form1()); to Application.Run(new frmMain());
  • When you view frmMain in designer view you will see a lot of menu items viz File, Edit, View, etc which we do not require at all. So delete them one by one.
  • You should also delete all the icons from toolStrip just below MenuItem.
  • Once empty let us Create a New Menu Item “Membership Plan” and under it create another item “New Plan”. Great we have created menu item.
Add MDI Parent Form
Add MDI Parent Form

Now double click New Plan to create click handler and it will bring you to code behind which currently is containing a lot of code and most of them we do not require. So delete them one by one and in the end it will have only below code :
ClubManager.frmMain.cs

using System;
using System.Windows.Forms;
 
namespace ClubManager
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
 
        private void newPlanToolStripMenuItem_Click(object sender, EventArgs e)
        {
        }
    }
}

Browse this commit on Github

One thought on “Club Manager : Create MemberShipPlan : Model

Leave a Reply