コード例 #1
0
        private void btnSaveClient_Click(object sender, EventArgs e)
        {
            if (tbAge.Text.Trim() == "" && tbBirthDate.Text.Trim() == "")
            {
                MessageBox.Show("Cannot Save When Both Age And Birthdate Are Blank", modedescription);
            }
            else if (lblDateError.Visible == true && chkEnterAge.Checked == false)
            {
                MessageBox.Show("Cannot Save With Invalid Birthdate", modedescription);
                tbBirthDate.Focus();
            }
            else
            {
                string hhName = tbLastName.Text.Trim() + ", " + tbFirstName.Text.Trim();
                newHHID = 0;

                clsHH.openWhere("Name='" + CCFBGlobal.SQLApostrophe(tbLastName.Text.Trim()) + ", " + CCFBGlobal.SQLApostrophe(tbFirstName.Text.Trim()) + "'");
                if (clsHH.ISValid == true && CCFBPrefs.AllowDuplicateHHNames == false)
                {
                    MessageBox.Show("Name " + hhName + "\r\nAlready Exists In Household Table as ID = " + clsHH.ID.ToString(),
                                    modedescription, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    if (clsHHM.nameExists(CCFBGlobal.SQLApostrophe(tbFirstName.Text.Trim()), CCFBGlobal.SQLApostrophe(tbLastName.Text.Trim()), tbBirthDate.Text, true) == false || CCFBPrefs.AllowDuplicateHHNames == true || newHHMID > 0)
                    {
                        newRow = clsHH.DSet.Tables[0].NewRow();

                        newRow["Name"]     = hhName;
                        newRow["Inactive"] = 0;
                        if (cboIDType.SelectedValue != null)
                        {
                            newRow["IdType"] = cboIDType.SelectedValue;
                        }
                        else
                        {
                            newRow["IdType"] = 0;
                        }
                        newRow["ClientType"] = cboClientType.SelectedValue;
                        if (cboPhoneType.SelectedValue == null)
                        {
                            newRow["PhoneType"] = 0;
                        }
                        else
                        {
                            newRow["PhoneType"] = cboPhoneType.SelectedValue;
                        }
                        newRow["Phone"]          = tbPhone.Text;
                        newRow["EthnicSpeaking"] = cboSpecialLang.SelectedValue;
                        switch (CCFBPrefs.UseFamilyList)
                        {
                        case CCFBPrefs.UseFamilyListCode.Normally:
                            newRow["UseFamilyList"] = true; break;

                        case CCFBPrefs.UseFamilyListCode.Sometimes:
                            newRow["UseFamilyList"] = false; break;

                        case CCFBPrefs.UseFamilyListCode.Always:
                            newRow["UseFamilyList"] = true; break;

                        case CCFBPrefs.UseFamilyListCode.Never:
                            newRow["UseFamilyList"] = false; break;

                        default:
                            break;
                        }
                        newRow["Inactive"]  = false;
                        newRow["UserFlag0"] = false;
                        newRow["UserFlag1"] = false;
                        newRow["UserFlag2"] = false;
                        newRow["UserFlag3"] = false;
                        newRow["UserFlag4"] = false;
                        newRow["UserFlag5"] = false;
                        newRow["UserFlag6"] = false;
                        newRow["UserFlag7"] = false;
                        newRow["UserFlag8"] = false;
                        newRow["UserFlag9"] = false;
                        newRow["UserNum0"]  = 0;
                        newRow["UserNum1"]  = 0;
                        newRow["Infants"]   = 0;
                        newRow["Youth"]     = 0;
                        newRow["Teens"]     = 0;
                        newRow["Eighteen"]  = 0;
                        newRow["Adults"]    = 0;
                        newRow["Seniors"]   = 0;

                        switch (clsHHM.GetEFAPAgeGroup(Convert.ToInt32(tbAge.Text)))
                        {
                        case 0:
                        { newRow["Infants"] = 1; break; }

                        case 1:
                        { newRow["Youth"] = 1; break; }

                        case 2:
                        { newRow["Teens"] = 1; break; }

                        case 3:
                        { newRow["Eighteen"] = 1; break; }

                        case 4:
                        { newRow["Adults"] = 1; break; }

                        case 5:
                        { newRow["Seniors"] = 1; break; }
                        }

                        newRow["TotalFamily"] = 1;
                        if (cboIDType.SelectedIndex < 0)
                        {
                            newRow["NeedToVerifyId"] = true;
                        }
                        else
                        {
                            if (cboIDType.SelectedValue.ToString() == "0")
                            {
                                newRow["NeedToVerifyId"] = true;
                            }
                            else
                            {
                                newRow["NeedToVerifyId"] = false;
                            }

                            newRow["DateIDVerified"] = dateIdVerified;
                        }
                        newRow["SupplOnly"]              = false;
                        newRow["IncludeOnLog"]           = true;
                        newRow["Disabled"]               = 0;
                        newRow["SpecialDiet"]            = false;
                        newRow["NoCommodities"]          = chkNoCommodities.Checked;
                        newRow["NeedCommoditySignature"] = false;
                        newRow["IncludeOnLog"]           = false;
                        newRow["AutoAlert"]              = false;
                        newRow["FirstSvcThisYear"]       = CCFBGlobal.FBNullDateValue;
                        newRow["SecondServiceThisMonth"] = false;
                        newRow["InCityLimits"]           = chkInCityLimits.Checked;
                        newRow["Homeless"]               = chkHomeless.Checked;
                        newRow["LatestService"]          = "01/01/1900";
                        newRow["AnnualIncome"]           = 0;
                        newRow["BabyServices"]           = chkBabyServices.Checked;
                        newRow["BabySvcDescr"]           = tbBabySvcDescr.Text;
                        newRow["SurveyComplete"]         = 0;
                        newRow["NbrCSFP"]                = 0;
                        newRow["Address"]                = tbeAddress.Text;
                        newRow["AptNbr"]                 = tbeApt.Text;
                        newRow["City"]                   = tbeCity.Text;
                        newRow["State"]                  = tbeState.Text;
                        newRow["Zipcode"]                = tbeZipCode.Text;
                        newRow["CreatedBy"]              = CCFBGlobal.dbUserName;
                        newRow["Created"]                = DateTime.Now;
                        newRow["BarCode"]                = 0;
                        newRow["TEFAPSignDate"]          = DateTime.Now.ToShortDateString();
                        newRow["SingleHeadHH"]           = chkSingleHeadHH.Checked;
                        newRow["NeedIncomeVerification"] = true;
                        newRow["IncomeVerifiedDate"]     = CCFBGlobal.FBNullDateValue;
                        newRow["ServiceMethod"]          = 0;
                        newRow["HDRoute"]                = 0;
                        newRow["HDBuilding"]             = 0;
                        newRow["HDProgram"]              = 0;
                        newRow["HUDCategory"]            = 0;
                        newRow["HDItem"]                 = 0;
                        newRow["DriverNotes"]            = "";
                        newRow["AlertText"]              = "";
                        newRow["Transportation"]         = 0;
                        newRow["SchSupplyPickupPerson"]  = "";
                        newRow["SchSupplyRegDate"]       = CCFBGlobal.FBNullDateValue;
                        newRow["SchSupplyFlag"]          = 0;
                        newRow["SchSupplyRegistration"]  = 0;

                        clsHH.DSet.Tables[0].Rows.Add(newRow);
                        clsHH.insert();
                        clsHH.openWhere("Name='" + CCFBGlobal.SQLApostrophe(hhName) + "' AND CREATED >='" + DateTime.Today.ToShortDateString() + "'");
                        newHHID = clsHH.ID;
                        addHHMember(newHHID);
                        this.Visible = false;
                    }
                    else
                    {
                        MessageBox.Show(tbFirstName.Text + " " + tbLastName.Text + "\r\nAlready Exists In Household Members Table",
                                        modedescription, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        tbFirstName.Focus();
                    }
                }
            }
        }