/// <summary> /// 更新家长数据 /// </summary> /// <returns></returns> private string UpdateData() { string result = string.Empty; List <int> successRowIndex = new List <int>(); XF.Model.Base_Family model; foreach (int index in lstUpdate) { model = new XF.Model.Base_Family(); model.FamilyID = zDataConverter.ToInt(xfDataGridView1.Rows[index].Cells[ColFamilyID.Name].Value); model.FamilyCode = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColFamilyCode.Name].Value); model.FamilyName = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColFamilyName.Name].Value); model.CourseCount = zDataConverter.ToDecimal(xfDataGridView1.Rows[index].Cells[ColCourseCount.Name].Value); model.Phone = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColPhone.Name].Value); model.OpenId = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColOpenId.Name].Value); model.Description = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColDescription.Name].Value); if (bll.Update(model)) { successRowIndex.Add(index); } else { result += MessageText.SQL_ERROR_UPDATE + MessageText.KEY_ENTER; } } foreach (int rowIndex in successRowIndex) { lstUpdate.Remove(rowIndex); } return(result); }
/// <summary> /// 新增家长数据 /// </summary> /// <returns></returns> private string AddData() { string result = string.Empty; List <int> successRowIndex = new List <int>(); XF.Model.Base_Family model; foreach (int index in lstInsert) { model = new XF.Model.Base_Family(); model.FamilyCode = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColFamilyCode.Name].Value); model.FamilyName = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColFamilyName.Name].Value); model.CourseCount = zDataConverter.ToDecimal(xfDataGridView1.Rows[index].Cells[ColCourseCount.Name].Value); model.Phone = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColPhone.Name].Value); model.OpenId = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColOpenId.Name].Value); model.Description = zDataConverter.ToString(xfDataGridView1.Rows[index].Cells[ColDescription.Name].Value); int ret = bll.Add(model); if (ret == PhysicalConstants.SQL_Existed) { result += string.Format(MessageText.SQL_ERROR_FAMILY_EXIST, index + 1) + MessageText.KEY_ENTER; } else { xfDataGridView1.Rows[index].Cells[ColFamilyID.Name].Value = ret; successRowIndex.Add(index); } } foreach (int rowIndex in successRowIndex) { lstInsert.Remove(rowIndex); } return(result); }