protected void SwapRow(int currentIndex, int targetIndex) { var source = this.DataSource as IList; if (source != null) { var currentObj = source[currentIndex]; var targetObj = source[targetIndex]; source[currentIndex] = targetObj; source[targetIndex] = currentObj; this.View.RefreshRow(currentIndex); this.View.RefreshRow(targetIndex); this.View.FocusedRowHandle = targetIndex; } var dataTable = this.DataSource as DataTable; if (dataTable != null) { var currentObj = DataTableHelper.CopyDataRow(dataTable.Rows[currentIndex]); //var targetObj = dataTable.Rows[targetIndex]; dataTable.Rows.RemoveAt(currentIndex); dataTable.Rows.InsertAt(currentObj, targetIndex); this.View.FocusedRowHandle = targetIndex; } }
protected void RemoveInsertRow(int removeIndex, int insertIndex) { var source = this.DataSource as IList; if (source != null) { var obj = source[removeIndex]; source.RemoveAt(removeIndex); source.Insert(insertIndex, obj); RefreshData(); this.View.FocusedRowHandle = insertIndex; } var dataTable = this.DataSource as DataTable; if (dataTable != null) { var obj = DataTableHelper.CopyDataRow(dataTable.Rows[removeIndex]); dataTable.Rows.RemoveAt(removeIndex); dataTable.Rows.InsertAt(obj, insertIndex); this.View.FocusedRowHandle = insertIndex; } }
/// <summary> /// 通过上传excel批量退房 /// 不支持换房 /// </summary> public bool CheckOutBatch(string filePath, out int nSuccess, out DataTable dtErr) { nSuccess = 0; dtErr = null; //读取Excel内容 DataTable dt = _mExcelHelper.GetDataFromExcel(filePath); if (DataTableHelper.IsEmptyDataTable(dt)) { LogManager.GetInstance().ErrorLog("CheckOutBatch,导入的excel表记录为空"); return(false); } int nTotalCnt = dt.Rows.Count; //全部待导入的个数 dtErr = dt.Clone(); var lstDel = new List <DataRow>(); try { foreach (DataRow r in dt.Rows) { var sWorkID = r["工号"].ToString().Trim(); var sIDCardNo = r["身份证号码"].ToString().Trim(); var sReason = r["退房原因"].ToString().Trim(); //排除明显无效的项 var bValid = true; if (string.IsNullOrEmpty(sWorkID) && string.IsNullOrEmpty(sIDCardNo)) { bValid = false; } bValid = bValid && IsValidReason(sReason); if (!bValid) { DataTableHelper.CopyDataRow(dtErr, r); lstDel.Add(r); } } } catch (Exception ex) { LogManager.GetInstance().ErrorLog("CheckOutBatch,关键列不存在", ex); return(false); } foreach (var oDel in lstDel) { dt.Rows.Remove(oDel); } _db = DBO.CreateDatabase(); _connection = _db.CreateConnection(); _connection.Open(); try { foreach (DataRow rImp in dt.Rows) { if (!CheckOutBatch_part(rImp)) { DataTableHelper.CopyDataRow(dtErr, rImp); } else { nSuccess++; } } } finally { _connection.Close(); } return(nSuccess == nTotalCnt); }