/// <summary> /// 新增学员数据 /// </summary> /// <returns></returns> private string AddStudentData() { string result = string.Empty; List <int> successRowIndex = new List <int>(); XF.Model.Base_Student model; int familyRowIndex = xfDataGridView1.CurrentCell.RowIndex; foreach (int index in lstStudentInsert) { model = new XF.Model.Base_Student(); model.StudentCode = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentCode.Name].Value); model.StudentName = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentName.Name].Value); model.NickName = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColNickName.Name].Value); model.Birthday = Convert.ToDateTime(zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColBirthday.Name].Value)); model.TeacherID = zDataConverter.ToInt(xfDataGridView2.Rows[index].Cells[ColTeacher.Name].Value); model.AdviserID = zDataConverter.ToInt(xfDataGridView2.Rows[index].Cells[ColAdviser.Name].Value); model.Birthdate = Convert.ToDateTime(zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColBirthdate.Name].Value));; model.Description = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentDescription.Name].Value); model.FamilyID = zDataConverter.ToInt(xfDataGridView1.Rows[familyRowIndex].Cells[ColFamilyID.Name].Value); int ret = bllStudent.Add(model); if (ret == PhysicalConstants.SQL_Existed) { result += string.Format(MessageText.SQL_ERROR_STUDENT_EXIST, index + 1) + MessageText.KEY_ENTER; } else { xfDataGridView2.Rows[index].Cells[ColStudentID.Name].Value = ret; successRowIndex.Add(index); } } foreach (int rowIndex in successRowIndex) { lstStudentInsert.Remove(rowIndex); } return(result); }
/// <summary> /// 更新学员数据 /// </summary> /// <returns></returns> private string UpdateStudentData() { string result = string.Empty; List <int> successRowIndex = new List <int>(); XF.Model.Base_Student model; int familyRowIndex = xfDataGridView1.CurrentCell.RowIndex; foreach (int index in lstStudentUpdate) { model = new XF.Model.Base_Student(); model.StudentID = zDataConverter.ToInt(xfDataGridView2.Rows[index].Cells[ColStudentID.Name].Value); model.StudentCode = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentCode.Name].Value); model.StudentName = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentName.Name].Value); model.NickName = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColNickName.Name].Value); model.Birthday = Convert.ToDateTime(zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColBirthday.Name].Value)); model.TeacherID = zDataConverter.ToInt(xfDataGridView2.Rows[index].Cells[ColTeacher.Name].Value); model.AdviserID = zDataConverter.ToInt(xfDataGridView2.Rows[index].Cells[ColAdviser.Name].Value); model.Birthdate = Convert.ToDateTime(zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColBirthdate.Name].Value));; model.Description = zDataConverter.ToString(xfDataGridView2.Rows[index].Cells[ColStudentDescription.Name].Value); model.FamilyID = zDataConverter.ToInt(xfDataGridView1.Rows[familyRowIndex].Cells[ColFamilyID.Name].Value); if (bllStudent.Update(model)) { successRowIndex.Add(index); } else { result += MessageText.SQL_ERROR_UPDATE + MessageText.KEY_ENTER; } } foreach (int rowIndex in successRowIndex) { lstStudentUpdate.Remove(rowIndex); } return(result); }