/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tsBtnDel_Click(object sender, EventArgs e) { if (Alert.confirm(LibCommon.Const.DELETE_USER_INFO, LibCommon.Const.NOTES, MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { //获取登录用户记录条数 //int n = LoginFormBLL.GetRecordCountFromTable(); int n = this.fpUserLoginInformation.ActiveSheet.Rows.Count - _fpTitleRowCount; //从数据末尾删除数据 for (int i = n - 1; i >= 0; i--) { if (this.fpUserLoginInformation.ActiveSheet.Cells[2 + i, 0].CellType is FarPoint.Win.Spread.CellType.CheckBoxCellType) { if (this.fpUserLoginInformation.ActiveSheet.Cells[2 + i, 0].Value != null) { if ((bool)this.fpUserLoginInformation.ActiveSheet.Cells[2 + i, 0].Value) { this.fpUserLoginInformation.ActiveSheet.Rows.Remove(2 + i, 1); //删除一行数据后,在数据末尾加一行 //this.fpUserLoginInformation.ActiveSheet.Rows.Add(n - 1 + 2, 1); //this.fpUserLoginInformation.ActiveSheet.Rows[n - 1 + 2].BackColor = Color.Red;//显示颜色直观显示追加行位置 } } } } //遍历 记录用户信息的数组,删除数据库中的数据 foreach (string str in _userSel) { var userLogin = UserLogin.FindOneByLoginName(str); userLogin.Delete(); } fpUserLoginInformation.Refresh(); this.fpUserLoginInformation.ActiveSheet.SetActiveCell(UserLogin.Count() + 1, 0); //清除所有选择数据 _userSel.Clear(); //设置删除按钮是否启用 this.tsBtnDel.Enabled = false; //设置修改按钮是否启用 this.tsBtnModify.Enabled = false; //记录当前farpoint的记录条数 _fpRowsCount = this.fpUserLoginInformation.ActiveSheet.Rows.Count; } }