示例#1
0
        public static DTO.ThanhVien GetThanhVien(string userName, string passWord)
        {
            SqlConnection con = DataProvider.GetConnection();
            SqlCommand    cmd = new SqlCommand("sp_GetThanhVien", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@UserName", SqlDbType.NVarChar, 100).Value = userName;
            cmd.Parameters.Add("@PassWord", SqlDbType.NVarChar, 500).Value = passWord;

            SqlDataReader reader = cmd.ExecuteReader();

            DTO.ThanhVien result = null;

            while (reader.Read())
            {
                result             = new DTO.ThanhVien();
                result.MaThanhVien = int.Parse(reader["MATHANHVIEN"].ToString());
                result.HoTen       = reader["HOTEN"].ToString();
                result.Cmnd        = reader["CMND"].ToString();
                result.NgaySinh    = reader["NGAYSINH"].ToString();
                result.MaChiNhanh  = int.Parse(reader["MACHINHANH"].ToString());
                result.Sdt         = reader["SDT"].ToString();
                result.Email       = reader["EMAIL"].ToString();
                try
                {
                    result.DiemTichLuy = double.Parse(reader["DIEMTICHLUY"].ToString());
                }
                catch
                {
                    result.DiemTichLuy = 0;
                }
                result.MatKhau = reader["MATKHAU"].ToString();
                if (reader["ISDELETED"].ToString().Equals("true"))
                {
                    result.IsDeleted = true;
                }
                else
                {
                    result.IsDeleted = false;
                }
                break;
            }
            DataProvider.CloseConnection(con);
            return(result);
        }
        private void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            string userName = txtUser.Text;
            string passWord = txtPassWord.Password;

            DTO.ThanhVien result = BUS.ThanhVien.GetThanhVien(userName, passWord);
            if (result == null)
            {
                MessageBox.Show("Đăng nhập thất bại", "Thông báo", MessageBoxButton.OK);
            }
            else
            {
                var window = new MainWindow();
                window.setTypeUser(1);
                window.setUserInfo(result);
                window.Show();
                this.Close();
            }
        }
 internal void setUserInfo(DTO.ThanhVien result)
 {
     this.thanhVien       = result;
     customerName.Content = this.thanhVien.HoTen;
     customerPoint.Text   = this.thanhVien.DiemTichLuy.ToString();
 }