예제 #1
0
        public bool ThemMember(THONGTINMEMBER member)
        {
            //Kiem tra tai khoan nay da ton tai chua
            var taiKhoan = TAIKHOANs.SingleOrDefault(g => g.UserName == member.UserName);

            if (taiKhoan != null)
            {
                return(false);
            }
            else
            {
                try
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        #region ThemTaiKhoanMoi
                        TAIKHOAN newTaiKhoan = new TAIKHOAN();

                        newTaiKhoan.MaTK     = member.MaTK;
                        newTaiKhoan.Avatar   = null;
                        newTaiKhoan.DiaChi   = member.DiaChi;
                        newTaiKhoan.Email    = member.Email;
                        newTaiKhoan.MaTT     = member.MaTT;
                        newTaiKhoan.Password = member.Password;
                        newTaiKhoan.SDT      = member.SDT;
                        newTaiKhoan.UserName = member.UserName;

                        TAIKHOANs.Add(newTaiKhoan);
                        this.SaveChanges();
                        #endregion

                        #region ThemMember
                        THONGTINMEMBERs.Add(member);
                        this.SaveChanges();
                        #endregion
                        ts.Complete();
                    }
                    return(true);
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    //throw;
                }
                return(false);
            }
        }
예제 #2
0
        public bool KiemTraThongTinDangNhap(string userName, string password)
        {
            TAIKHOAN tk = TAIKHOANs.SingleOrDefault(p => p.Password == password && p.UserName == userName);

            if (tk == null)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
예제 #3
0
        public TAIKHOAN LayTaiKhoanTheoMaTK(string MaTK)
        {
            TAIKHOAN tk = TAIKHOANs.SingleOrDefault(p => p.MaTK == MaTK);

            return(tk);
        }
예제 #4
0
        public string LayUserNameTheoMaTK(string MaTK)
        {
            TAIKHOAN taiKhoan = TAIKHOANs.SingleOrDefault(p => p.MaTK == MaTK);

            return(taiKhoan.UserName);
        }