示例#1
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();
            }
        }
示例#2
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();
                }
            }
        }