/// <summary>
 /// Service method to update club member
 /// </summary>
 /// <param name="clubMember">club member</param>
 /// <returns>true / false</returns>
 public bool UpdateClubMember(PersonModel clubMember)
 {
     return this.memberAccess.UpdateClubMember(clubMember);
 }
 //public bool GetClubMemberLockDate(string date, int id)
 //{
 //    //return this.memberAccess.GetClubMemberLockDate(date, id);
 //}
 public bool UpdateClubMemberLockItemFlag(PersonModel person)
 {
     return this.memberAccess.UpdateClubMemberLockItemFlag(person);
 }
        public bool UpdateClubMemberLockItemFlag(PersonModel person)
        {
            var rowsAffected = 0;
            var memberID = person.PersonID;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (SqlConnection conn = new SqlConnection(ConnectionString))
                    {
                        conn.Open();
                        using (SqlCommand cmd = new SqlCommand())
                        {
                            // Set the command object properties
                            cmd.Connection = conn;
                            cmd.CommandText = Scripts.sqlUpdateClubMember;

                            // Add the input parameters to the parameter collection
                            cmd.Parameters.AddWithValue("@FirstName", person.FirstName);
                            cmd.Parameters.AddWithValue("@LastName", person.LastName);
                            cmd.Parameters.AddWithValue("@MiddleInitial", person.MiddleIntial);
                            cmd.Parameters.AddWithValue("@Address", person.Address);
                            cmd.Parameters.AddWithValue("@Phone", person.PhoneNumber);
                            cmd.Parameters.AddWithValue("@ChurchHomeFlag", person.ChurchHome);
                            cmd.Parameters.AddWithValue("@ChurchHomeName", person.ChurchName);
                            cmd.Parameters.AddWithValue("@Opinion", person.Opinion);
                            cmd.Parameters.AddWithValue("@BirthDate", person.DateOfBirth);
                            cmd.Parameters.AddWithValue("@PhoneContactFlag", person.LeaveMessage);
                            cmd.Parameters.AddWithValue("@City", person.City);
                            cmd.Parameters.AddWithValue("@State", person.State);
                            cmd.Parameters.AddWithValue("@Zip", person.Zip);
                            cmd.Parameters.AddWithValue("@ID", person.PersonID);
                            cmd.Parameters.AddWithValue("@DateUpdated", person.DateUpdated);
                            cmd.Parameters.AddWithValue("@ProofGuardianFlag", person.ProofGuardianFlag);
                            cmd.Parameters.AddWithValue("@LockItemDate", person.LockItemsDate);
                            cmd.Parameters.AddWithValue("@LockItemFlag", person.LockItemsFlag);
                            // Open the connection, execute the query and close the connection
                            //cmd.Connection.Open();
                            rowsAffected = cmd.ExecuteNonQuery();
                            //cmd.Connection.Close();

                        }

                        rowsAffected = 1;
                        ts.Complete();
                    }
                }
            }
            catch
            {

            }
            return rowsAffected > 0;
        }
 /// <summary>
 /// Service method to create new member
 /// </summary>
 /// <param name="clubMember">club member model</param>
 /// <returns>true or false</returns>
 public bool RegisterPerson(PersonModel person)
 {
     return this.memberAccess.AddPerson(person);
 }
        /// <summary>
        /// Method to add new member
        /// </summary>
        /// <param name="clubMember">club member model</param>
        /// <returns>true or false</returns>
        //public bool AddClubMember(ClubMemberModel clubMember)
        public bool AddPerson(PersonModel person)
        {
            var rowsAffected = 0;
            var id = 0;
            //SqlTransaction transaction;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    using (SqlConnection conn = new SqlConnection(ConnectionString))
                    {
                        conn.Open();

                        using (SqlCommand cmd = new SqlCommand())
                        {
                            // Set the command object properties
                            cmd.Connection = conn;
                            cmd.CommandText = Scripts.SqlInsertPerson;

                            // Add the input parameters to the parameter collection
                            cmd.Parameters.AddWithValue("@FirstName", person.FirstName);
                            cmd.Parameters.AddWithValue("@LastName", person.LastName);
                            cmd.Parameters.AddWithValue("@MiddleInitial", person.MiddleIntial);
                            cmd.Parameters.AddWithValue("@Address", person.Address);
                            cmd.Parameters.AddWithValue("@Phone", person.PhoneNumber);
                            cmd.Parameters.AddWithValue("@ChurchHomeFlag", person.ChurchHome);
                            cmd.Parameters.AddWithValue("@ChurchHomeName", person.ChurchName);
                            cmd.Parameters.AddWithValue("@Opinion", person.Opinion);
                            cmd.Parameters.AddWithValue("@BirthDate", person.DateOfBirth);
                            cmd.Parameters.AddWithValue("@PhoneContactFlag", person.LeaveMessage);
                            cmd.Parameters.AddWithValue("@City", person.City);
                            cmd.Parameters.AddWithValue("@State", person.State);
                            cmd.Parameters.AddWithValue("@Zip", person.Zip);
                            cmd.Parameters.AddWithValue("@ProofGuardianFlag", person.ProofGuardianFlag);

                            id = (int)(decimal)cmd.ExecuteScalar();
                            rowsAffected = 1;
                        }

                        //throw new Exception("Let see...");

                        foreach (DependentModel dm in person.DependentModelList)
                        {
                            using (SqlCommand cmd = new SqlCommand())
                            {
                                cmd.Connection = conn;
                                cmd.CommandText = Scripts.SqlInsertDependent;

                                // Add the input parameters to the parameter collection
                                cmd.Parameters.AddWithValue("@Name", dm.NameOfChild);
                                cmd.Parameters.AddWithValue("@Relationship", dm.Relationship);
                                cmd.Parameters.AddWithValue("@LivesWith", dm.ChildLivesWith);
                                cmd.Parameters.AddWithValue("@PersonID", id);
                                cmd.Parameters.AddWithValue("@BirthDate", dm.BirthDate);

                                rowsAffected = cmd.ExecuteNonQuery();
                            }
                        }

                        ts.Complete();

                    }
                }
            }
            catch {
            //todo: add error handling

            }
            return rowsAffected > 0;
        }
        /// <summary>
        /// Method to update club member
        /// </summary>
        /// <param name="clubMember">club member</param>
        /// <returns>true / false</returns>
        public bool UpdateClubMember(PersonModel person)
        {
            var rowsAffected = 0;
            var memberID = person.PersonID;
            try
            {
                using (TransactionScope ts = new TransactionScope())
                {

                    using (SqlConnection conn = new SqlConnection(ConnectionString))
                    {
                        conn.Open();
                        using (SqlCommand cmd = new SqlCommand())
                        {
                            // Set the command object properties
                            cmd.Connection = conn;
                            cmd.CommandText = Scripts.sqlUpdateClubMember;

                            // Add the input parameters to the parameter collection
                            cmd.Parameters.AddWithValue("@FirstName", person.FirstName);
                            cmd.Parameters.AddWithValue("@LastName", person.LastName);
                            cmd.Parameters.AddWithValue("@MiddleInitial", person.MiddleIntial);
                            cmd.Parameters.AddWithValue("@Address", person.Address);
                            cmd.Parameters.AddWithValue("@Phone", person.PhoneNumber);
                            cmd.Parameters.AddWithValue("@ChurchHomeFlag", person.ChurchHome);
                            cmd.Parameters.AddWithValue("@ChurchHomeName", person.ChurchName);
                            cmd.Parameters.AddWithValue("@Opinion", person.Opinion);
                            cmd.Parameters.AddWithValue("@BirthDate", person.DateOfBirth);
                            cmd.Parameters.AddWithValue("@PhoneContactFlag", person.LeaveMessage);
                            cmd.Parameters.AddWithValue("@City", person.City);
                            cmd.Parameters.AddWithValue("@State", person.State);
                            cmd.Parameters.AddWithValue("@Zip", person.Zip);
                            cmd.Parameters.AddWithValue("@ID", person.PersonID);
                            cmd.Parameters.AddWithValue("@DateUpdated", person.DateUpdated);
                            cmd.Parameters.AddWithValue("@ProofGuardianFlag", person.ProofGuardianFlag);

                            //SqlParameter planIndexParameter = new SqlParameter("@LockItemDate", SqlDbType.Date);
                            //planIndexParameter.Value = (object)person.LockItemsDate ?? DBNull.Value;
                            //cmd.Parameters.Add(planIndexParameter);

                            cmd.Parameters.AddWithValue("@LockItemDate", (object)person.LockItemsDate ?? DBNull.Value);

                            //cmd.Parameters.AddWithValue("@LockItemDate", person.LockItemsDate);
                            cmd.Parameters.AddWithValue("@LockItemFlag", person.LockItemsFlag);
                            // Open the connection, execute the query and close the connection
                            //cmd.Connection.Open();
                            rowsAffected = cmd.ExecuteNonQuery();
                            //cmd.Connection.Close();

                        }

                        using (SqlCommand cmd = new SqlCommand())
                        {
                            // Set the command object properties
                            cmd.Connection = conn;
                            cmd.CommandText = Scripts.SqlDeleteDependent;

                            // Add the input parameters to the parameter collection
                            cmd.Parameters.AddWithValue("@PersonID", person.PersonID);
                            // Open the connection, execute the query and close the connection
                            rowsAffected = cmd.ExecuteNonQuery();

                        }

                        foreach (DependentModel dm in person.DependentModelList)
                        {
                            using (SqlCommand cmd = new SqlCommand())
                            {
                                cmd.Connection = conn;
                                cmd.CommandText = Scripts.SqlInsertDependent;

                                // Add the input parameters to the parameter collection
                                cmd.Parameters.AddWithValue("@Name", dm.NameOfChild);
                                cmd.Parameters.AddWithValue("@Relationship", dm.Relationship);
                                cmd.Parameters.AddWithValue("@LivesWith", dm.ChildLivesWith);
                                cmd.Parameters.AddWithValue("@PersonID", memberID);
                                cmd.Parameters.AddWithValue("@BirthDate", dm.BirthDate);
                                cmd.Parameters.AddWithValue("@DependentID", dm.DependentID);

                                rowsAffected = cmd.ExecuteNonQuery();
                            }
                        }

                        using (SqlCommand cmd = new SqlCommand())
                        {
                            // Set the command object properties
                            cmd.Connection = conn;
                            cmd.CommandText = Scripts.SqlDeleteItems;

                            // Add the input parameters to the parameter collection
                            cmd.Parameters.AddWithValue("@PersonID", person.PersonID);
                            // Open the connection, execute the query and close the connection
                            rowsAffected = cmd.ExecuteNonQuery();
                        }

                        foreach (ItemModel dm in person.ItemModelList)
                        {
                            using (SqlCommand cmd = new SqlCommand())
                            {
                                cmd.Connection = conn;
                                cmd.CommandText = Scripts.SqlInsertItems;

                                // Add the input parameters to the parameter collection
                                cmd.Parameters.AddWithValue("@Comments", dm.Comments);
                                cmd.Parameters.AddWithValue("@Date", dm.Date);
                                cmd.Parameters.AddWithValue("@Description", dm.Description);
                                cmd.Parameters.AddWithValue("@PersonID", memberID);
                                cmd.Parameters.AddWithValue("@Initials", dm.Initials);

                                //cmd.Parameters.AddWithValue("@DependentID", dm.DependentID);

                                rowsAffected = cmd.ExecuteNonQuery();
                            }
                        }

                        rowsAffected = 1;
                        ts.Complete();
                    }
                }
            }
            catch
            {

            }
            return rowsAffected > 0;
        }
Пример #7
0
        /// <summary>
        /// Click event to handle registration
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">event data</param>
        private void Register_Click(object sender, EventArgs e)
        {
            try
            {

                //string clubMemberId = dgv.SelectedRows[0].Cells[0].Value.ToString();
                // Check if the validation passes
                if (this.ValidateRegistration())
                {
                    List<DependentModel> depList = new List<DependentModel>();
                    //loop through all dependents datagrid view
                    foreach (DataGridViewRow row in dataGridViewDependents.Rows)
                    {
                        if (row.IsNewRow) continue;
                        DependentModel dependentModel = new DependentModel()
                        {
                            DependentID = 0,
                            NameOfChild = row.Cells["NameofChild"].Value.ToString(),
                            BirthDate = Convert.ToDateTime(row.Cells["BirthDate"].Value.ToString()),
                            //BirthDate = Convert.ToDateTime(_datePicker.Value.ToShortDateString()),
                            ChildLivesWith = row.Cells["LivesWith"].Value.ToString(),
                            Relationship = row.Cells["Relationship"].Value.ToString(),
                            PersonID = 0
                        };

                        //this.clubMemberService.RegisterDependent(dependentModel);

                        depList.Add(dependentModel);
                    }

                    string phone = string.Empty;
                    if (!(txtContactNumber.Text == "(   )    -"))
                        phone = txtContactNumber.Text;

                    bool guardianFlag = false;
                    if (rdoGuardian1.Checked)
                        guardianFlag = true;

                    bool churchHomeFlag = false;
                    if (rdoChurchHome1.Checked)
                        churchHomeFlag = true;

                    bool leaveMessageFlag = false;
                    if (rdoLeaveMessage1.Checked)
                        leaveMessageFlag = true;

                    // Assign the values to the model
                    PersonModel clubMemberModel = new PersonModel()
                    {
                        PersonID = 0,
                        FirstName = txtFirstName.Text.Trim(),
                        LastName = txtLastName.Text.Trim(),
                        MiddleIntial = txtMiddleInitial.Text.Trim(),
                        Address = txtAddress.Text.Trim(),
                        PhoneNumber = phone.Trim(),
                        DateOfBirth = dtDateOfBirth.Value,
                        ChurchHome = bool.Parse(rdoChurchHome1.Checked.ToString()),
                        ChurchName = txtAttend.Text.Trim(),
                        Opinion = txtOpinion.Text.Trim(),
                        LeaveMessage = bool.Parse(rdoLeaveMessage1.Checked.ToString()),
                        City = txtCity.Text.Trim(),
                        State = txtState.Text.Trim(),
                        Zip = txtZip.Text.Trim(),
                        ExportFlag = 0,
                        ProofGuardianFlag = bool.Parse(rdoGuardian1.Checked.ToString()),
                        LockItemsFlag = false,
                        DependentModelList = depList
                    };

                    // Call the service method and assign the return status to variable
                    var success = this.clubMemberService.RegisterPerson(clubMemberModel);

                    // if status of success variable is true then display a information else display the error message
                    if (success)
                    {

                        //List<DependentModel> depList = new List<DependentModel>();
                        //loop through all dependents datagrid view
                        //while (success)
                        //{
                        //    foreach (DataGridViewRow row in dataGridViewDependents.Rows)
                        //    {
                        //        if (row.IsNewRow) continue;
                        //        DependentModel dependentModel = new DependentModel()
                        //        {
                        //            DependentID = 0,
                        //            NameOfChild = row.Cells["NameofChild"].Value.ToString(),
                        //            BirthDate = Convert.ToDateTime(row.Cells["Birthdate"].Value.ToString()),
                        //            ChildLivesWith = row.Cells["LivesWith"].Value.ToString(),
                        //            Relationship = row.Cells["Relationship"].Value.ToString(),
                        //            PersonID = 0
                        //        };

                        //        this.clubMemberService.RegisterDependent(dependentModel);

                        //        //depList.Add(dependentModel);
                        //    }
                        //}
                        //success = this.clubMemberService.RegisterDependent(depList);
                        //this.clubMemberService.RegisterDependent()
                        // display the message box
                        MessageBox.Show(
                            Resources.Registration_Successful_Message,
                            Resources.Registration_Successful_Message_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

                        // Reset the screen
                        this.ResetRegistration();
                    }
                    else
                    {
                        // display the error messge
                        MessageBox.Show(
                            Resources.Registration_Error_Message,
                            Resources.Registration_Error_Message_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
                else
                {
                    // Display the validation failed message
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Registration_Error_Message_Title,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }
Пример #8
0
        /// <summary>
        /// Initializes a new instance of the Manage class
        /// </summary>
        public Person(int _memberId, Manage mainForm)
        {
            _manage = mainForm;
            memberId = _memberId;
            this.InitializeComponent();
            this.InitializeResourceString();
            this.InitializeDropDownList();
            this.InitilizeDataGridViewStyle();
            this.clubMemberService = new ClubMemberService();
            this.ResetRegistration();
            this.ResetSearch();

            PersonModel personObject = new PersonModel();
            try
            {
                DataRow dataRow = this.clubMemberService.GetFullClubMemberById(memberId);
                personObject.FirstName = dataRow["FirstName"].ToString();
                personObject.MiddleIntial = dataRow["MI"].ToString();
                personObject.LastName = dataRow["LastName"].ToString();
                personObject.Address = dataRow["Address"].ToString();
                personObject.City = dataRow["City"].ToString();
                personObject.State = dataRow["State"].ToString();
                personObject.Zip = dataRow["Zip"].ToString();
                personObject.PhoneNumber = dataRow["Phone"].ToString();
                personObject.LeaveMessage = Convert.ToBoolean(dataRow["PhoneContactFlag"].ToString());
                personObject.ChurchName = dataRow["ChurchHomeName"].ToString();
                personObject.DateOfBirth = Convert.ToDateTime(dataRow["BirthDate"]);
                personObject.Opinion = dataRow["Opinion"].ToString();
                personObject.ChurchHome = Convert.ToBoolean(dataRow["ChurchHomeFlag"].ToString());
                personObject.ChurchName = dataRow["ChurchHomeName"].ToString();
                personObject.PersonID = Convert.ToInt32(dataRow["PersonID"].ToString());
                personObject.DateUpdated = Convert.ToDateTime(dataRow["DateUpdated"]);
                personObject.ProofGuardianFlag = Convert.ToBoolean(dataRow["ProofGuardianFlag"].ToString());
                //personObject.LockItemsDate = dataRow["LockItemDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dataRow["LockItemDate"]);
                personObject.LockItemsDate = dataRow["MaxDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dataRow["MaxDate"]);
                personObject.LockItemsFlag = Convert.ToBoolean(dataRow["LockItemFlag"].ToString());
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }

            memberId = personObject.PersonID;
            txtFirstName.Text = personObject.FirstName.ToString();
            txtLastName.Text = personObject.LastName.ToString();
            txtMiddleInitial.Text = personObject.MiddleIntial.ToString();
            dtDateOfBirth.Value = Convert.ToDateTime(personObject.DateOfBirth.ToShortDateString());
            txtContactNumber.Text = personObject.PhoneNumber.ToString();
            txtAddress.Text = personObject.Address.ToString();
            txtCity.Text = personObject.City.ToString();
            txtState.Text = personObject.State.ToString();
            txtZip.Text = personObject.Zip.ToString();

            //grab first and last day of previous month
            DateTime today = DateTime.Now;

            int prevMonth = today.AddMonths(-1).Month;
            int year = today.AddMonths(-1).Year;
            int daysInPrevMonth = DateTime.DaysInMonth(year, prevMonth);
            DateTime firstDayPrevMonth = new DateTime(year, prevMonth, 1);
            DateTime lastDayPrevMonth = new DateTime(year, prevMonth, daysInPrevMonth);

            //is maxdate month in today month
            if (personObject.LockItemsDate.HasValue)
            {
                lockItemDate = Convert.ToDateTime(personObject.LockItemsDate.ToString());

                if ((lockItemDate.Month == DateTime.Now.Month) &&
                    (lockItemDate.Year == DateTime.Now.Year))
                {
                    //  Console.WriteLine("{0} {1}", firstDayPrevMonth.ToShortDateString(),
                    //lastDayPrevMonth.ToShortDateString());
                    lockItemFlag = true;
                }

                //var numVisits = this.clubMemberService.GetClubMemberVisits(memberId, lockItemDate.ToShortDateString());
                var numVisits = this.clubMemberService.GetClubMemberVisits(memberId);

                if (numVisits >= 6)
                {
                    lockItemFlag = true;
                }
            }

            //lockItemFlag = personObject.LockItemsFlag;
            //if (!string.IsNullOrEmpty(personObject.LockItemsDate.ToString()))
            //{
            //    lockItemDate = Convert.ToDateTime(personObject.LockItemsDate.ToString());

            //    //var numVisits = this.clubMemberService.GetClubMemberVisits(memberId, lockItemDate.ToShortDateString());
            //    if (numVisits >= 6)
            //    {
            //        lockItemFlag = true;
            //    }

            //    if (!lockItemFlag)
            //    {
            //        var numVisitsInMonth = this.clubMemberService.GetClubMemberVisitsInMonth(memberId, lockItemDate.ToShortDateString());
            //        if (numVisitsInMonth > 0)
            //        {
            //            lockItemFlag = true;
            //        }
            //        else { lockItemFlag = false; }
            //    }

            //    if (numVisits == 0)
            //        lockItemDate = DateTime.Today;

            //    lblNumVisits.Text = numVisits.ToString();
            //}
            //else
            //{
            //    lblNumVisits.Text = "0";
            //}

            rdoChurchHome2.Checked = true;
            if (personObject.ChurchHome)
            {
                rdoChurchHome1.Checked = true;
                rdoChurchHome2.Checked = false;
            }
            txtChurchName.Text = personObject.ChurchName.ToString();
            txtOpinion.Text = personObject.Opinion.ToString() == null ? string.Empty : personObject.Opinion.ToString();
            txtContactNumber.Text = personObject.PhoneNumber.ToString();

            rdoLeaveMessage2.Checked = true;
            if (personObject.LeaveMessage)
            {
                rdoLeaveMessage1.Checked = true;
                rdoLeaveMessage2.Checked = false;
            }

            rdoGuardian2.Checked = true;
            if (personObject.ProofGuardianFlag)
            {
                rdoGuardian1.Checked = true;
                rdoGuardian2.Checked = false;
            }

            DataTable data = this.clubMemberService.GetDependents(memberId);
            this.InitializeUpdate();
            this.LoadDataGridView(data);

            //lblLastVisit.Text = personObject.DateUpdated.ToString();

            //_datePicker.Visible = false;
            //_datePicker.CustomFormat = "dd/MM/yyyy";
            //_datePicker.ValueChanged += _datePicker_ValueChanged;

            //update lockItemFlag
            //if (lockItemFlag)
            //{
            //personObject.LockItemsFlag = lockItemFlag;
            //update flag on database
            this.clubMemberService.UpdateClubMemberLockItemFlag(personObject);
            //}
            //groupBox3.Hide();
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.btnClose_Click);
        }
Пример #9
0
        /// <summary>
        /// Click event to update the data
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">event args</param>
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateUpdate())
                {
                    List<DependentModel> depList = new List<DependentModel>();
                    //loop through all dependents datagrid view
                    foreach (DataGridViewRow row in dataGridViewDependents.Rows)
                    {
                        if (row.IsNewRow) continue;
                        DependentModel dependentModel = new DependentModel()
                        {
                            NameOfChild = row.Cells["Name of Child"].Value.ToString(),
                            BirthDate = Convert.ToDateTime(row.Cells["BirthDate"].Value.ToString()),
                            //BirthDate = Convert.ToDateTime(_datePicker.Value.ToShortDateString()),
                            ChildLivesWith = row.Cells["LivesWith"].Value.ToString(),
                            Relationship = row.Cells["Relationship"].Value.ToString(),
                            PersonID = this.memberId//,
                            //DependentID = Convert.ToInt32(row.Cells["DependentID"].Value.ToString())
                        };
                        depList.Add(dependentModel);
                    }
                    //if
                    //var lockDate = Convert.ToDateTime(row.Cells["LockItemsDate"].Value.ToString());

                    List<ItemModel> itemList = new List<ItemModel>();
                    //loop through all dependents datagrid view
                    foreach (DataGridViewRow row in dataGridViewItems.Rows)
                    {
                        if (row.IsNewRow) continue;

                        //DateTime lockDate = Convert.ToDateTime(_datePicker.Value.ToShortDateString());
                        //if (!(string.IsNullOrEmpty(row.Cells["LockItemsDate"].Value.ToString())))
                        //lockDate = Convert.ToDateTime(row.Cells["LockItemsDate"].Value.ToString());

                        ItemModel itemModel = new ItemModel()
                        {
                            Description = row.Cells["Description"].Value.ToString(),
                            //Date = Convert.ToDateTime(row.Cells["Date"].Value.ToString()),
                            Date = Convert.ToDateTime(row.Cells["Date"].Value.ToString()),
                            //Date = Convert.ToDateTime(_datePicker.Value.ToShortDateString()),
                            Comments = row.Cells["Comments"].Value.ToString(),
                            Initials = row.Cells["Initials"].Value.ToString(),
                            PersonID = this.memberId
                        };
                        itemList.Add(itemModel);
                    }

                    string phone = string.Empty;
                    if (!(txtContactNumber.Text == "(   )    -"))
                        phone = txtContactNumber.Text;

                    //DateTime? start = (txtStartDate.Text == DateTime.MinValue.ToString()) ? null : (DateTime?)txtStartDate.Text;
                    //DBNull.Value
                    // <Nullable>DateTime start = lockItemDate == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(lockItemDate);

                    //DateTime? start = lockItemDate ?? (DateTime?)DBNull.Value;
                    DataRow dataRow = this.clubMemberService.GetFullClubMemberById(memberId);
                    //Person personObject = new Person();
                    DateTime? dt = dataRow["LockItemDate"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dataRow["LockItemDate"]);
                    //personObject.LockItemsFlag = Convert.ToBoolean(dataRow["LockItemFlag"].ToString());

                    if ((!dt.HasValue) && (itemList.Count > 0))
                        dt = DateTime.Today;

                    //if (dt.HasValue)
                    //{
                    //    var date = Convert.ToDateTime(dataRow["LockItemDate"]);
                    //    //if it has been more than a year reset date
                    //    //bool resetLockDate = this.clubMemberService.GetClubMemberLockDate(dt, memberId);
                    //    var matchFound = (date - DateTime.Now).TotalDays > 365;
                    //    dt = DateTime.Today;
                    //}
                    //if (!dt.HasValue)

                    PersonModel clubMemberModel = new PersonModel()
                    {
                        PersonID = this.memberId,
                        FirstName = txtFirstName.Text.Trim(),
                        LastName = txtLastName.Text.Trim(),
                        MiddleIntial = txtMiddleInitial.Text.Trim(),
                        Address = txtAddress.Text.Trim(),
                        PhoneNumber = phone.Trim(),
                        DateOfBirth = dtDateOfBirth.Value,
                        ChurchHome = bool.Parse(rdoChurchHome1.Checked.ToString()),
                        ChurchName = txtChurchName.Text.Trim(),
                        Opinion = txtOpinion.Text.Trim(),
                        LeaveMessage = bool.Parse(rdoLeaveMessage1.Checked.ToString()),
                        City = txtCity.Text.Trim(),
                        State = txtState.Text.Trim(),
                        Zip = txtZip.Text.Trim(),
                        DateUpdated = DateTime.Now,
                        ProofGuardianFlag = bool.Parse(rdoGuardian1.Checked.ToString()),
                        LockItemsDate = dt,//lockItemDate,
                        LockItemsFlag = lockItemFlag,
                        DependentModelList = depList,
                        ItemModelList = itemList
                    };

                    var flag = this.clubMemberService.UpdateClubMember(clubMemberModel);

                    if (flag)
                    {
                        MessageBox.Show(
                            Resources.Update_Successful_Message,
                            Resources.Update_Successful_Message_Title,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information);

                        _manage.PerformRefresh();
                    }
                }
                else
                {
                    MessageBox.Show(
                        this.errorMessage,
                        Resources.Registration_Error_Message_Title,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ex);
            }
        }