private void UpdateCrew()
 {
     Crew objData = new Crew();
     objData = CurrentCrew;
     objData.Name = uiTextBoxName.Text;
     objData.StaffNo = Convert.ToInt32(uiTextBoxStaffNo.Text);
     objData.LicenseNo = uiTextBoxLicenseNo.Text;
     if (uiRadDatePickerCompetenecycheck.SelectedDate != null)
         objData.Competenecycheck = uiRadDatePickerCompetenecycheck.SelectedDate.Value;
     if (uiRadDatePickerMLEF.SelectedDate != null)
         objData.MEDICALLICENSEEXPIRYFrom = uiRadDatePickerMLEF.SelectedDate.Value;
     if (uiRadDatePickerMLET.SelectedDate != null)
         objData.MEDICALLICENSEEXPIRYTo = uiRadDatePickerMLET.SelectedDate.Value;
     if (uiRadDatePickerInstructorRenewal.SelectedDate != null)
         objData.InstructorRenewal = uiRadDatePickerInstructorRenewal.SelectedDate.Value;
     if (uiRadDatePickerTransitionCourse.SelectedDate != null)
         objData.TRANSITIONCOURSE = uiRadDatePickerTransitionCourse.SelectedDate.Value;
     if (uiRadDatePickerRecurrent12.SelectedDate != null)
         objData.RECURRENT12 = uiRadDatePickerRecurrent12.SelectedDate.Value;
     if (uiRadDatePickerRecurrent24.SelectedDate != null)
         objData.RECURRENT24 = uiRadDatePickerRecurrent24.SelectedDate.Value;
     if (uiRadDatePickerSMS.SelectedDate != null)
         objData.SMS = uiRadDatePickerSMS.SelectedDate.Value;
     if (uiRadDatePickerSecurity.SelectedDate != null)
         objData.Security = uiRadDatePickerSecurity.SelectedDate.Value;
     objData.Save();
 }
        protected void uiRadGridCrew_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditCrew")
            {
                Crew objData = new Crew();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                CurrentCrew = objData;
                FillCrewData();
                uiPanelEdit.Visible = true;
                uiPanelViewAll.Visible = false;

            }

            else if (e.CommandName == "DeleteCrew")
            {
                Crew objData = new Crew();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                if (Membership.GetUser(objData.Username) != null)
                {
                    Membership.DeleteUser(objData.Username);
                }

                objData.MarkAsDeleted();
                objData.Save();

                SearchCrew();
            }
        }
        private void AddNewCrew()
        {
            MembershipCreateStatus obj;
            MembershipUser objUser = Membership.CreateUser(uiTextBoxUserName.Text, uiTextBoxPassword.Text, "*****@*****.**", null, null, true, out obj);
            bool success = true;
            switch (obj)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    uiLabelError.Text = "duplicate username";
                    uiLabelError.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    uiLabelError.Text = "invalid password. password must be (6) characters or more.";
                    uiLabelError.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.ProviderError:
                case MembershipCreateStatus.UserRejected:
                    uiLabelError.Text = "an error occurred. please try again.";
                    uiLabelError.Visible = true;
                    success = false;
                    break;
                default:
                    break;
            }
            if (!Roles.IsUserInRole(uiTextBoxUserName.Text, "CabinCrew") && success)
            {
                Roles.AddUserToRole(uiTextBoxUserName.Text, "CabinCrew");
            }

            if (success)
            {
                Crew objData = new Crew();
                objData.AddNew();
                objData.Name = uiTextBoxName.Text;
                objData.Username = uiTextBoxUserName.Text;
                objData.StaffNo = Convert.ToInt32(uiTextBoxStaffNo.Text);
                objData.LicenseNo = uiTextBoxLicenseNo.Text;
                if(uiRadDatePickerCompetenecycheck.SelectedDate != null)
                    objData.Competenecycheck = uiRadDatePickerCompetenecycheck.SelectedDate.Value;
                if (uiRadDatePickerMLEF.SelectedDate != null)
                    objData.MEDICALLICENSEEXPIRYFrom = uiRadDatePickerMLEF.SelectedDate.Value;
                if (uiRadDatePickerMLET.SelectedDate != null)
                    objData.MEDICALLICENSEEXPIRYTo = uiRadDatePickerMLET.SelectedDate.Value;
                if (uiRadDatePickerInstructorRenewal.SelectedDate != null)
                    objData.InstructorRenewal = uiRadDatePickerInstructorRenewal.SelectedDate.Value;
                if (uiRadDatePickerTransitionCourse.SelectedDate != null)
                    objData.TRANSITIONCOURSE = uiRadDatePickerTransitionCourse.SelectedDate.Value;
                if (uiRadDatePickerRecurrent12.SelectedDate != null)
                    objData.RECURRENT12 = uiRadDatePickerRecurrent12.SelectedDate.Value;
                if (uiRadDatePickerRecurrent24.SelectedDate != null)
                    objData.RECURRENT24 = uiRadDatePickerRecurrent24.SelectedDate.Value;
                if (uiRadDatePickerSMS.SelectedDate != null)
                    objData.SMS = uiRadDatePickerSMS.SelectedDate.Value;
                if (uiRadDatePickerSecurity.SelectedDate != null)
                    objData.Security = uiRadDatePickerSecurity.SelectedDate.Value;
                objData.Save();
            }
        }