/// <summary> /// 删除按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDel_Click(object sender, EventArgs e) { if (MessageBox.Show(this, "您确定要删除选择的密码信息吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No) return; UserInfoEntity userInfo = new UserInfoEntity(); UserInfoOperation oprUserinfo = new UserInfoOperation(); try { for (int i = 0; i < dgvInfos.Rows.Count; i++) { if (dgvInfos.Rows[i].Cells["cb"].Value != null && dgvInfos.Rows[i].Cells["cb"].Value.ToString() == "1") { userInfo.ID = Convert.ToInt32(dgvInfos.Rows[i].Cells["id"].Value); oprUserinfo.Delete(userInfo); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } ClearInput(); Search(); }
/// <summary> /// 保存按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { UserInfoOperation oprUserinfo = new UserInfoOperation(); UserInfoEntity userInfo = new UserInfoEntity(); try { userInfo.Key = txtKey.Text; userInfo.Name = txtName.Text; userInfo.Pw = oprUserinfo.GetStr(selType.SelectedItem.ToString(), txtPw.Text, UserInfoOperation.CryptMode.Encrypt); userInfo.Type = selType.SelectedItem.ToString(); if (txtID.Text == "") { userInfo.ID = GetMaxID(); oprUserinfo.Insert(userInfo); } else { userInfo.ID = Convert.ToInt32(txtID.Text); oprUserinfo.Update(userInfo); } } catch (Exception ex) { MessageBox.Show(ex.Message); } ClearInput(); Search(); }
/// <summary> /// 插入密码数据 /// </summary> /// <param name="userInfo"></param> public void Insert(UserInfoEntity userInfo) { o.userInfo = userInfo; o.Insert(); }
/// <summary> /// 删除密码数据 /// </summary> /// <param name="userInfo"></param> public void Delete(UserInfoEntity userInfo) { o.userInfo = userInfo; o.Del(); }
/// <summary> /// 更新密码数据 /// </summary> /// <param name="userInfo"></param> public void Update(UserInfoEntity userInfo) { o.userInfo = userInfo; o.Update(); }
/// <summary> /// 查找密码数据 /// </summary> /// <param name="userInfo"></param> public void Search(UserInfoEntity userInfo) { o.userInfo = userInfo; o.Search(); }