protected bool ImportFromExcelToModify(DataSet ds) { try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nModify = 0; int nNoExist = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { string PersonCode = dr["PersonCode"].ToString().Trim(); //判断是否存在 if (!KPI_PersonDal.PersonCodeExists(PersonCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nNoExist += 1; continue; } //main tag string keyid = KPI_PersonDal.GetPersonID(PersonCode); KPI_PersonEntity mEntity = new KPI_PersonEntity(); mEntity.PersonID = keyid; mEntity.PositionID = KPI_PositionDal.GetPositionID(dr["PositionName"].ToString().Trim()); mEntity.PersonCode = PersonCode; mEntity.PersonName = dr["PersonName"].ToString().Trim(); mEntity.PersonDesc = dr["PersonDesc"].ToString().Trim(); mEntity.PersonIsValid = dr["PersonIsValid"].ToString().Trim(); mEntity.PersonNote = dr["PersonNote"].ToString().Trim(); KPI_PersonDal.Update(mEntity); nModify += 1; } } string strInfor = "标签点总数为:{0}个, 修改成功:{1}个,不存在标签点: {2}个。"; strInfor = string.Format(strInfor, nAll, nModify, nNoExist); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); return(true); } catch (Exception ee) { // MessageBox.popupClientMessage(this.Page, ee.Message, "call();"); return(false); } }
protected bool ImportFromExcelToDelete(DataSet ds) { try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nDelete = 0; int nEmpty = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { string PersonCode = dr["PersonCode"].ToString().Trim(); //判断是否存在 if (!KPI_PersonDal.PersonCodeExists(PersonCode, "")) { //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); nEmpty += 1; continue; } else { //main tag //string RealID = KPI_PersonDal.GetRealID(PersonCode); KPI_PersonEntity mEntity = new KPI_PersonEntity(); mEntity.PersonID = KPI_PersonDal.GetPersonID(PersonCode); KPI_PersonDal.Delete(mEntity); nDelete += 1; } } } string strInfor = "标签点总数为:{0}个, 删除成功:{1}个,空标签点: {2}个。"; strInfor = string.Format(strInfor, nAll, nDelete, nEmpty); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); return(true); } catch (Exception ee) { // MessageBox.popupClientMessage(this.Page, ee.Message, "call();"); return(false); } }