private void DeleteRows(List <DataGridViewRow> rows) { if (rows.Count == 0) { return; } if (MessageBox.Show("确定删除超级密码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK) { List <Maticsoft.Model.SMT_SUPER_PWD> pwds = new List <Maticsoft.Model.SMT_SUPER_PWD>(); foreach (var item in rows) { List <Maticsoft.Model.SMT_SUPER_PWD> models = (List <Maticsoft.Model.SMT_SUPER_PWD>)item.Tag; pwds.AddRange(models); } CtrlWaiting waiting = new CtrlWaiting(() => { try { Maticsoft.BLL.SMT_SUPER_PWD pwdbll = new Maticsoft.BLL.SMT_SUPER_PWD(); foreach (var item in pwds) { pwdbll.Delete(item.ID); } Maticsoft.BLL.SMT_SUPER_PWD pwdBll = new Maticsoft.BLL.SMT_SUPER_PWD(); var models = pwdbll.GetModelList(""); try { UploadPrivate.UploadPwds(models); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "上传密码发生异常:" + ex.Message); log.Error("上传密码发生异常:", ex); } this.Invoke(new Action(() => { foreach (var item in rows) { dgvData.Rows.Remove(item); } })); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "删除超级密码异常:" + ex.Message); log.Error("删除超级密码异常:", ex); } }); waiting.Show(this); } }
private void DoUpload(List <Maticsoft.Model.SMT_SUPER_PWD> pwds) { if (pwds.Count == 0) { WinInfoHelper.ShowInfoWindow(this, "未选择任何可上传密码!"); return; } CtrlWaiting waiting = new CtrlWaiting(() => { try { UploadPrivate.UploadPwds(pwds); } catch (Exception ex) { WinInfoHelper.ShowInfoWindow(this, "上传密码发生异常:" + ex.Message); log.Error("上传密码发生异常1:", ex); } }); waiting.Show(this); }