Exemplo n.º 1
0
 /// <summary>
 /// 获得列表
 /// </summary>
 /// <returns></returns>
 public List<Model.Users> GetList()
 {
     string sql = "select * from users order by uname";
     List<Users> list = null;
     DataTable dt = SqlHelper.GetDataSet(sql).Tables[0];
     if (dt.Rows.Count > 0)
     {
         list = new List<Users>();
         Users user = null;
         foreach (DataRow row in dt.Rows)
         {
             user = new Users();
             LoadEntity(user, row);
             list.Add(user);
         }
     }
     return list;
 }
Exemplo n.º 2
0
 /// <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;
     UsersBLL bll = new UsersBLL();
     Users userInfo = new Users();
     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")
             {
                 bll.Delete(Convert.ToInt32(dgvInfos.Rows[i].Cells["id"].Value));
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     ClearInput();
     Search();
 }
Exemplo n.º 3
0
 /// <summary>
 /// 保存按钮事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (CheckData())
     {
         UsersBLL ubll = new UsersBLL();
         Users userInfo = new Users();
         EncryptBLL ebll = new EncryptBLL();
         try
         {
             userInfo.Key = txtKey.Text;
             userInfo.UName = txtName.Text;
             userInfo.Pw = ebll.GetEncryptStr(txtPw.Text);
             userInfo.Type = ebll.GetName();
             if (txtID.Text == "")
             {
                 ubll.Add(userInfo);
             }
             else
             {
                 userInfo.ID = Convert.ToInt32(txtID.Text);
                 ubll.Update(userInfo);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
         ClearInput();
         Search();
     }
 }
Exemplo n.º 4
0
 private void LoadEntity(Users user, DataRow row)
 {
     if (row["ID"] != null)
     {
         user.ID = Convert.ToInt32(row["ID"]);
     }
     if (row["Key"] != null)
     {
         user.Key = row["Key"].ToString();
     }
     if (row["UName"] != null)
     {
         user.UName = row["UName"].ToString();
     }
     if (row["Pw"] != null)
     {
         user.Pw = row["Pw"].ToString();
     }
     if (row["Type"] != null)
     {
         user.Type = row["Type"].ToString();
     }
     if (row["RegTime"] != null)
     {
         user.RegTime = Convert.ToDateTime(row["RegTime"]);
     }
 }