private void btnSave_Click(object sender, EventArgs e)
        {
            SetData();

            this.DialogResult = System.Windows.Forms.DialogResult.OK;

            List <UDTRelativeDef> dataList = new List <UDTRelativeDef>();

            dataList.Add(_data);

            if (string.IsNullOrEmpty(_data.UID))
            {
                UDTTransfer.ABUDTRelativeInsert(dataList);
            }
            else
            {
                UDTTransfer.ABUDTRelativeUpdate(dataList);
            }

            this.Close();
        }
        /// <summary>
        /// 儲存直系血親
        /// </summary>
        private void SaveRelativeData()
        {
            List <UDTRelativeDef> insertDataList = new List <UDTRelativeDef>();
            List <UDTRelativeDef> updateDataList = new List <UDTRelativeDef>();

            foreach (DataGridViewRow dr in dgRelative.Rows)
            {
                if (dr.IsNewRow)
                {
                    continue;
                }
                UDTRelativeDef data = dr.Tag as UDTRelativeDef;

                if (data == null)
                {
                    data           = new UDTRelativeDef();
                    data.StudentID = _intStudentID;
                    data.IsAlive   = null;
                }

                // 稱謂
                if (dr.Cells[0].Value == null)
                {
                    data.Title = "";
                }
                else
                {
                    data.Title = dr.Cells[0].Value.ToString();
                }

                // 姓名
                if (dr.Cells[1].Value == null)
                {
                    data.Name = "";
                }
                else
                {
                    data.Name = dr.Cells[1].Value.ToString();
                }

                // 存歿
                if (dr.Cells[2].Value == null)
                {
                    data.IsAlive = true;
                }
                else
                {
                    if (dr.Cells[2].Value.ToString() == "存")
                    {
                        data.IsAlive = true;
                    }
                    else if (dr.Cells[2].Value.ToString() == "歿")
                    {
                        data.IsAlive = false;
                    }
                    else
                    {
                        data.IsAlive = null;
                    }
                }

                // 出生年
                if (dr.Cells[3].Value == null)
                {
                    data.BirthYear = null;
                }
                else
                {
                    int sy;
                    if (int.TryParse(dr.Cells[3].Value.ToString(), out sy))
                    {
                        data.BirthYear = sy;
                    }
                }

                // 職業
                if (dr.Cells[4].Value == null)
                {
                    data.Job = "";
                }
                else
                {
                    data.Job = dr.Cells[4].Value.ToString();
                }

                // 工作機構
                if (dr.Cells[5].Value == null)
                {
                    data.Institute = "";
                }
                else
                {
                    data.Institute = dr.Cells[5].Value.ToString();
                }

                // 職稱
                if (dr.Cells[6].Value == null)
                {
                    data.JobTitle = "";
                }
                else
                {
                    data.JobTitle = dr.Cells[6].Value.ToString();
                }

                // 教育程度
                if (dr.Cells[7].Value == null)
                {
                    data.EduDegree = "";
                }
                else
                {
                    data.EduDegree = dr.Cells[7].Value.ToString();
                }

                // 電話
                if (dr.Cells[8].Value == null)
                {
                    data.Phone = "";
                }
                else
                {
                    data.Phone = dr.Cells[8].Value.ToString();
                }

                //原國籍
                if (dr.Cells[9].Value == null)
                {
                    data.National = "";
                }
                else
                {
                    data.National = dr.Cells[9].Value.ToString();
                }

                if (string.IsNullOrEmpty(data.UID))
                {
                    insertDataList.Add(data);
                }
                else
                {
                    updateDataList.Add(data);
                }
            }

            // UDT
            if (insertDataList.Count > 0)
            {
                UDTTransfer.ABUDTRelativeInsert(insertDataList);
            }

            if (updateDataList.Count > 0)
            {
                UDTTransfer.ABUDTRelativeUpdate(updateDataList);
            }
        }