public MemberMaintenanceForm(Form caller) : base(caller) { // Constructor for create mode InitializeComponent(); member = new Member(); context = new SportsFacBookingEntities(); create = true; BirthDay_Date_TextBox.Hide(); BirthDay_Month_TextBox.Hide(); Birthday_year_Textbox.Hide(); Title_TextBox.Hide(); Extend_ExpiryDate_Button.Hide(); GetJoinDate(); GetExpiryDate(); JoinDate_TextBox.ReadOnly = true; ExpiryDate_TextBox.ReadOnly = true; // Fill birth year combobox for (int i = DateTime.Today.Year - 18; i > DateTime.Today.Year - 100; i--) { BirthDate_Year_Combobox.Items.Add(i); } }
public MemberMaintenanceForm(Form caller, int memberID) : this(caller) { // Constructor for edit mode member = context.Members.First(x => x.MemberID == memberID); create = false; Create_Membership_Label.Text = "Edit Member's Details"; MemberName_TextBox.ReadOnly = true; JoinDate_TextBox.ReadOnly = true; ExpiryDate_TextBox.ReadOnly = true; Title_TextBox.ReadOnly = true; Birthday_year_Textbox.ReadOnly = true; BirthDay_Month_TextBox.ReadOnly = true; BirthDay_Date_TextBox.ReadOnly = true; Title_ComboBox.Hide(); BirthDate_Date_Combobox.Hide(); BirthDate_Month_Combobox.Hide(); BirthDate_Year_Combobox.Hide(); Reset_Button.Hide(); BirthDay_Date_TextBox.Show(); BirthDay_Month_TextBox.Show(); Birthday_year_Textbox.Show(); Title_TextBox.Show(); Extend_ExpiryDate_Button.Show(); Create_Button.Text = "Save"; //Fill Member's Details Title_TextBox.Text = member.Salutation.ToUpper(); Title_ComboBox.Text = member.Salutation.ToUpper(); MemberName_TextBox.Text = member.MemberName; Address_TextBox.Text = member.Address; Email_TextBox.Text = member.Email; Emergency_Contact_Name_TextBox.Text = member.EmergencyContactName; Emergency_Contact_Number_TextBox.Text = member.EmergencyContactPhone; PhoneNumber_TextBox.Text = member.PhoneNumber; if (Title_TextBox.Text == "MR") { Male_RadioButton.Checked = true; } else { Female_RadioButton.Checked = true; } BirthDay_Date_TextBox.Text = member.Birthday.Day.ToString(); BirthDate_Date_Combobox.Text = member.Birthday.Day.ToString(); BirthDay_Month_TextBox.Text = member.Birthday.Month.ToString(); BirthDate_Month_Combobox.Text = member.Birthday.Month.ToString(); Birthday_year_Textbox.Text = member.Birthday.Year.ToString(); BirthDate_Year_Combobox.Text = member.Birthday.Year.ToString(); JoinDate_TextBox.Text = member.JoinDate.Date.ToString("dd/MM/yyyy"); ExpiryDate_TextBox.Text = member.ExpiryDate.Date.ToString("dd/MM/yyyy"); }