Exemplo n.º 1
0
 private void tbBirthDate_Leave(object sender, EventArgs e)
 {
     try
     {
         DateTime tmp = Convert.ToDateTime(tbBirthDate.Text);
         if (tmp > CCFBGlobal.FBNullDateValue && tmp < DateTime.Today)
         {
             tbBirthDate.Text      = tmp.ToShortDateString();
             tbBirthDate.ForeColor = Color.Black;
             lblDateError.Visible  = false;
             tbAge.Text            = CCFBGlobal.calcAge(tmp, DateTime.Today).ToString();
             FillBirthDateGrid(tbBirthDate.Text);
             btnSaveClient.Enabled = (lblDupHHError.Visible == false &&
                                      lblDateError.Visible == false &&
                                      lblDupHHMError.Visible == false);
         }
         else
         {
             tbBirthDate.ForeColor = Color.DarkRed;
             lblDateError.Visible  = true;
         }
     }
     catch
     {
         tbBirthDate.ForeColor = Color.DarkRed;
         lblDateError.Visible  = true;
         //if (MessageBox.Show("Invalid date entered", "Date Vailidation",
         //    MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry)
         //{
         //    tbBirthDate.Focus();
         //}
     }
     showlvwControl(2);
     clearHelpText();
 }
Exemplo n.º 2
0
        /// <summary>
        /// Calculates the Ages of each Household Member and sets those values in the form and in the database
        /// </summary>
        public bool calcAllHHMemAges(DateTime BaseDate)
        {
            int[] AgeGroupsTotals = new int[6] {
                0, 0, 0, 0, 0, 0
            };
            DateTime BirthDay;

            if (clsHH.UseFamilyList == true)
            {
                for (int i = 0; i < clsHHmem.RowCount; i++)
                {
                    HHMemberItem clsHHMemberItem = new HHMemberItem(clsHHmem.DSet.Tables[0].Rows[i], clsHHmem.DSet.Tables[0].Columns, null, null);
                    int          newAge          = 0;
                    if (clsHHMemberItem.Inactive == false && clsHHMemberItem.NotCounted == false)
                    {
                        newAge = clsHHMemberItem.Age;
                        if (clsHHMemberItem.UseAge == false || (clsHHMemberItem.BirthDate.ToShortDateString() != CCFBGlobal.OURNULLDATE &&
                                                                clsHHMemberItem.BirthDate.ToShortDateString() != CCFBGlobal.OUROTHERNULLDATE))
                        {
                            BirthDay = clsHHMemberItem.BirthDate;
                            if (BirthDay != null && BirthDay.ToShortDateString() != "" && BirthDay != DateTime.MaxValue)
                            {
                                newAge = CCFBGlobal.calcAge(BirthDay, BaseDate);
                                clsHHMemberItem.Age = newAge;
                            }
                        }
                        clsHHMemberItem.AgeGroup = clsHHmem.GetEFAPAgeGroup(newAge);
                        AgeGroupsTotals[clsHHMemberItem.AgeGroup]++;
                    }
                }
                int totalFamily = AgeGroupsTotals[CCFBGlobal.ageGroup_Infant]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Youth]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Teen]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Adult]
                                  + AgeGroupsTotals[CCFBGlobal.ageGroup_Senior];

                if (clsHH.Infants != AgeGroupsTotals[CCFBGlobal.ageGroup_Infant] ||
                    clsHH.Youth != AgeGroupsTotals[CCFBGlobal.ageGroup_Youth] ||
                    clsHH.Teens != AgeGroupsTotals[CCFBGlobal.ageGroup_Teen] ||
                    clsHH.Eighteens != AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen] ||
                    clsHH.Adults != AgeGroupsTotals[CCFBGlobal.ageGroup_Adult] ||
                    clsHH.Seniors != AgeGroupsTotals[CCFBGlobal.ageGroup_Senior] ||
                    clsHH.TotalFamily != totalFamily)
                {
                    clsHH.Infants     = AgeGroupsTotals[CCFBGlobal.ageGroup_Infant];
                    clsHH.Youth       = AgeGroupsTotals[CCFBGlobal.ageGroup_Youth];
                    clsHH.Teens       = AgeGroupsTotals[CCFBGlobal.ageGroup_Teen];
                    clsHH.Eighteens   = AgeGroupsTotals[CCFBGlobal.ageGroup_Eighteen];
                    clsHH.Adults      = AgeGroupsTotals[CCFBGlobal.ageGroup_Adult];
                    clsHH.Seniors     = AgeGroupsTotals[CCFBGlobal.ageGroup_Senior];
                    clsHH.TotalFamily = totalFamily;
                    return(true);
                }
            }
            return(false);
        }
        private void addHHMember(int hhid)
        {
            newRow = clsClient.clsHHmem.DSet.Tables[0].NewRow();

            foreach (TextBox tb in Controls.OfType <TextBox>())
            {
                if (tb.Enabled == true)
                {
                    newRow[tb.Tag.ToString()] = tb.Text;
                }
            }

            if (chkEnterAge.Checked == true)
            {
                newRow["BirthDate"] = calcBirthdateFromAge();
                newRow["UseAge"]    = true;
            }
            else
            {
                newRow["Age"]    = CCFBGlobal.calcAge(DateTime.Parse(tbBirthDate.Text), DateTime.Today);
                newRow["UseAge"] = false;
            }
            newRow["AgeGroup"]                = clsClient.clsHHmem.GetEFAPAgeGroup(Convert.ToInt32(newRow["Age"]));
            newRow["HouseholdID"]             = clsClient.clsHH.ID;
            newRow["HeadHH"]                  = false;
            newRow["NotIncludedInClientList"] = false;
            newRow["Inactive"]                = false;
            newRow["SpecialDiet"]             = 0;
            newRow["WorksInArea"]             = 0;
            newRow["VolunteersAtFoodBank"]    = false;
            newRow["SpecialDiet"]             = false;
            newRow["UserFlag0"]               = false;
            newRow["UserFlag1"]               = false;
            newRow["CSFP"]       = false;
            newRow["CSFPRoute"]  = 0;
            newRow["IsDisabled"] = false;
            newRow["Inactive"]   = false;
            newRow["Language"]   = 0;
            newRow["UserFlag0"]  = 0;
            newRow["UserFlag1"]  = 0;
            newRow["CreatedBy"]  = CCFBGlobal.currentUser_Name;
            newRow["Created"]    = DateTime.Now;

            clsClient.clsHHmem.DSet.Tables[0].Rows.Add(newRow);

            if (clsClient.clsHHmem.insertMember() == true)
            {
                createNewHHMDemographics();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads the Students Listview with the School Age Members
        /// </summary>
        private void loadHHMems(bool clearRows)
        {
            DateTime        d;
            Color           CellForeColor;
            DataGridViewRow dvr;

            if (clearRows == true)
            {
                dgvHHMembers.Rows.Clear();
            }

            int rowCount      = 0;
            int calculatedAge = 0;
            int bMonth        = 0;
            int curMonth      = DateTime.Today.Month;

            for (int i = 0; i < clsClient.clsHHmem.RowCount; i++)
            {
                clsClient.clsHHmem.SetRecord(i);
                if (clsClient.clsHHmem.Inactive == false)
                {
                    calculatedAge = CCFBGlobal.calcAge(clsClient.clsHHmem.Birthdate, DateTime.Today);
                    if (calculatedAge != clsClient.clsHHmem.Age)
                    {
                        clsClient.clsHHmem.Age = calculatedAge;
                    }
                    if (clsClient.clsHHmem.SchSupply == true | (clsClient.clsHHmem.Age >= 5 && clsClient.clsHHmem.Age <= 18))
                    {
                        if (clsClient.clsHHmem.Grade < 0)
                        {
                            bMonth = clsClient.clsHHmem.Birthdate.Month;
                            if (bMonth < curMonth || bMonth >= 9)
                            {
                                clsClient.clsHHmem.Grade = calculatedAge - 5;
                            }
                            else
                            {
                                clsClient.clsHHmem.Grade = calculatedAge - 4;
                            }
                            if (clsClient.clsHHmem.Grade > 12)
                            {
                                clsClient.clsHHmem.Grade = 12;
                            }
                        }
                        dgvHHMembers.Rows.Add();
                        if ((bool)clsClient.clsHHmem.DSet.Tables[0].Rows[i]["SchSupply"])
                        {
                            CellForeColor = Color.Maroon;
                        }
                        else
                        {
                            CellForeColor = Color.Black;
                        }
                        dvr     = dgvHHMembers.Rows[rowCount];
                        dvr.Tag = clsClient.clsHHmem.ID.ToString();
                        FillGridMembersCell(dvr, "clmSchSupply", "SchSupply", true, CellForeColor, i, false);
                        //                    FillGridMembersCell(dvr, "clmHeadHH", "HeadHH", true, CellForeColor, i);
                        dvr.Cells["clmName"].Value = clsClient.clsHHmem.Name;

                        FillGridMembersCell(dvr, "clmGrade", "Grade", false, CellForeColor, i, false);
                        FillGridMembersCell(dvr, "clmAge", "Age", false, CellForeColor, i, true);
                        FillGridMembersCell(dvr, "clmGender", "Sex", false, CellForeColor, i, true);
                        dvr.Cells["clmSchool"].Value = clsClient.clsHHmem.SchSupplySchool.ToString();
                        //dvr.Cells["clmSchool"].Value = CCFBGlobal.LongNameFromId(CCFBGlobal.parmTbl_SchSupplySchool, clsClient.clsHHmem.SchSupplySchool);

                        string tmp = "";
                        if (clsClient.clsHHmem.DSet.Tables[0].Rows[i]["SchSupplyDelivered"].ToString() != "")
                        {
                            d = (DateTime)clsClient.clsHHmem.DSet.Tables[0].Rows[i]["SchSupplyDelivered"];
                            if (d > CCFBGlobal.FBNullDateValue)
                            {
                                tmp = d.ToShortDateString();
                            }
                        }
                        dvr.Cells["clmDelivered"].Value = tmp;
                        dvr.Cells["clmDelivered"].Tag   = "SchSupplyDelivered";
                        FillGridMembersCell(dvr, "clmHMID", "ID", false, CellForeColor, i, true);
                        rowCount++;
                    }
                }
            }
        }