Ejemplo n.º 1
0
        private void EditFamilyBtn_Click(object sender, EventArgs e)
        {
            int rowNum = NotOnWardList.CurrentCell.RowIndex;
            DataRow dr = WardList.dtNotOnWardList.Rows[rowNum];

            Add_Family addFamilyForm = new Add_Family(dr);
            addFamilyForm.MyParentForm = this;

            if (addFamilyForm.ShowDialog() == DialogResult.OK)
            {
                //add edited info to table then save file

                if  (WardList.dtNotOnWardList.Rows.Count !=0)
                {
                   WardList.dtNotOnWardList.Rows[rowNum]["lastName"]= addFamilyForm.lastName;
                   WardList.dtNotOnWardList.Rows[rowNum]["hoh1"] = addFamilyForm.hoh1;
                   WardList.dtNotOnWardList.Rows[rowNum]["hoh2"] = addFamilyForm.hoh2;
                   WardList.dtNotOnWardList.Rows[rowNum]["address"] = addFamilyForm.address;
                   WardList.dtNotOnWardList.Rows[rowNum]["status"] = addFamilyForm.status;
                   // Do I need to use an update command to make the table current ???

                   //save file
                   WardList.saveNotOnWardListToFile();
                }
            }
        }
Ejemplo n.º 2
0
        private void AddFamilyBtn_Click(object sender, EventArgs e)
        {
            Add_Family addFamilyForm = new Add_Family();
            addFamilyForm.MyParentForm = this;

            if (addFamilyForm.ShowDialog() == DialogResult.OK)
            {
                //add info to table then save file

                //add new row to data table for this family
                DataRow dr = WardList.dtNotOnWardList.NewRow(); //dr gets all columns of dt
                //Last Name
                dr["lastName"] = addFamilyForm.lastName;
                //hoh1
                dr["hoh1"] = addFamilyForm.hoh1;
                //hoh2
                dr["hoh2"] = addFamilyForm.hoh2;
                //address
                dr["address"] = addFamilyForm.address;
                //status
                dr["status"] = addFamilyForm.status;

                //add row to table
                WardList.dtNotOnWardList.Rows.Add(dr);
                string tmpStr = WardList.dtNotOnWardList.Rows.Count.ToString();
                lblNumFamsNotOnList.Text = "Number of Families: " + tmpStr;

                //save file
                WardList.saveNotOnWardListToFile();
            }
        }
Ejemplo n.º 3
0
        public string[] matchPropertyToNames(string[] stringsToFind)
        {
            string[] returnStrings = new string[MAX_NUM_MATCHED_NAMES_RETURNED];
            int i = 0;
            string address;
            //DataRow currentRow = dtOnWardList.NewRow();
            //DataColumn dc = new DataColumn dtOnWardList.Columns["address"];
            //DataColumn dc = dtOnWardList.Columns["address"];
            //initialize return string
            for (i = 0; i < MAX_NUM_MATCHED_NAMES_RETURNED; i++)
            {
                returnStrings[i] = "";
            }
            //format the search strings
            for (i = 0; i < stringsToFind.Length; i++)
            {
                stringsToFind[i] = stringsToFind[i].Replace(" ", "").ToLower();
            }
            i = 0;
            //search  dtOnWardList
            foreach (DataRow dr in dtOnWardList.Rows)
            {
                address = dr["address"].ToString().Replace(" ", "").ToLower();
                if (address.Contains(stringsToFind[0])
                    && address.Contains(stringsToFind[1]))
                {
                    //found a match
                    if (i < MAX_NUM_MATCHED_NAMES_RETURNED)
                    {
                        returnStrings[i++] = dr["lastName"].ToString();
                    }
                }
            }
            //search dtNotOnWardList
            //get status values from the addFamilyForm
            Add_Family addFamilyForm = new Add_Family();

            foreach (DataRow dr in dtNotOnWardList.Rows)
            {
                address = dr["address"].ToString().Replace(" ","").ToLower();
                if(address.Contains(stringsToFind[0])
                    && address.Contains(stringsToFind[1]))
                {
                    //found a match
                    if(i < MAX_NUM_MATCHED_NAMES_RETURNED)
                    {
                        if (dr["status"].ToString() == addFamilyForm.statusValues[0])
                        {
                            returnStrings[i++] = "*" + dr["lastName"].ToString();
                        }
                        else if(dr["status"].ToString() == addFamilyForm.statusValues[1])
                        {
                            returnStrings[i++] = "~" + dr["lastName"].ToString();
                        }
                    }
                }
            }
            addFamilyForm.Close();
            return returnStrings;
        }