Ejemplo n.º 1
0
        private void btnXN_Click(object sender, EventArgs e)
        {
            ServiceLoginClient client = new ServiceLoginClient();
            IList <LoginDTO>   list   = client.Login(labUser.Text, frmMain.MaHoa(txtMKC.Text));

            if (list.Count == 0)
            {
                MessageBox.Show("Mật khẩu cũ không đúng!", "Lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMKC.Text = "";
                txtMKC.Focus();
            }
            else
            {
                ServiceHeThongClient client1 = new ServiceHeThongClient();
                HeThongDTO           htDTO   = new HeThongDTO();
                htDTO.Username   = labUser.Text;
                htDTO.Password   = frmMain.MaHoa(txtMKMoiAgain.Text);
                htDTO.Manhanvien = frmMain.m_maNV;
                if (client1.updateHeThong(htDTO) == 0)
                {
                    MessageBox.Show("Đổi mật khẩu không thành công!");
                }
                else
                {
                    MessageBox.Show("Đổi mật khẩu thành công!");
                    this.Close();
                }
            }
        }
 private void btnXN_Click(object sender, EventArgs e)
 {
     ServiceLoginClient client = new ServiceLoginClient();
     IList<LoginDTO> list = client.Login(labUser.Text, frmMain.MaHoa(txtMKC.Text));
     if (list.Count == 0)
     {
         MessageBox.Show("Mật khẩu cũ không đúng!", "Lỗi!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         txtMKC.Text = "";
         txtMKC.Focus();
     }
     else
     {
         ServiceHeThongClient client1 = new ServiceHeThongClient();
         HeThongDTO htDTO = new HeThongDTO();
         htDTO.Username = labUser.Text;
         htDTO.Password = frmMain.MaHoa(txtMKMoiAgain.Text);
         htDTO.Manhanvien = frmMain.m_maNV;
         if (client1.updateHeThong(htDTO) == 0)
         {
             MessageBox.Show("Đổi mật khẩu không thành công!");
         }
         else
         {
             MessageBox.Show("Đổi mật khẩu thành công!");
             this.Close();
         }
     }
 }
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (lsvnguoidung.SelectedItems.Count <= 0)
            {
                return;
            }
            if (lsvnguoidung.SelectedItems[0].SubItems[2].Text == "")
            {
                btnThem_Click(sender, e);
            }
            else
            {
                if (kiemtrauser())
                {
                    htDTO = new HeThongDTO();

                    htDTO.Manhanvien = txtMaNV.Text;
                    htDTO.Username   = txtuser.Text;
                    if (txtPass.Text != "")
                    {
                        htDTO.Password = frmMain.MaHoa(txtPass.Text);
                    }
                    else
                    {
                        HeThongDTO ht = client.getListHeThongByID(txtMaNV.Text);
                        htDTO.Password = ht.Password;
                    }
                    if (client.updateHeThong(htDTO) == 1)
                    {
                        show_nguoidung();
                    }
                    else
                    {
                        MessageBox.Show("Tên User đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        txtuser.SelectAll();
                        txtuser.Focus();
                    }
                }
            }
        }