示例#1
0
 /// <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();
 }
示例#2
0
 /// <summary>
 /// 列表双击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dgvInfos_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     tabControl1.SelectedIndex = 1;
     UserInfoOperation userInfo = new UserInfoOperation();
     if (e.RowIndex < 0) return;
     txtKey.Text = dgvInfos.Rows[e.RowIndex].Cells["key"].Value.ToString();
     txtName.Text = dgvInfos.Rows[e.RowIndex].Cells["name"].Value.ToString();
     txtPw.Text = userInfo.GetStr(dgvInfos.Rows[e.RowIndex].Cells["type"].Value.ToString(), dgvInfos.Rows[e.RowIndex].Cells["pw"].Value.ToString(), UserInfoOperation.CryptMode.Decrypt);
     txtID.Text = dgvInfos.Rows[e.RowIndex].Cells["id"].Value.ToString();
     selType.SelectedItem = dgvInfos.Rows[e.RowIndex].Cells["type"].Value.ToString();
 }