public StudABCard02_SiblingForm(UDTSiblingDef data) { InitializeComponent(); _data = data; LoadData(); }
/// <summary> /// 儲存兄弟姊妹 /// </summary> private void SaveSiblingData() { List<UDTSiblingDef> insertData = new List<UDTSiblingDef>(); List<UDTSiblingDef> updateData = new List<UDTSiblingDef>(); foreach (DataGridViewRow dr in dgSibling.Rows) { if (dr.IsNewRow) continue; UDTSiblingDef data = dr.Tag as UDTSiblingDef; if (data == null) { data = new UDTSiblingDef(); data.StudentID = _intStudentID; } // 稱謂 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.SchoolName = ""; else data.SchoolName = dr.Cells[2].Value.ToString(); // 出生年 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; else data.BirthYear = null; } // 備註 if (dr.Cells[4].Value == null) data.Remark = ""; else data.Remark= dr.Cells[4].Value.ToString(); if (string.IsNullOrEmpty(data.UID)) insertData.Add(data); else updateData.Add(data); } if (insertData.Count > 0) UDTTransfer.ABUDTSiblingInsert(insertData); if (updateData.Count > 0) UDTTransfer.ABUDTSiblingUpdate(updateData); }