private void CaiDat() { using (var BL = new BanLapTopEntities()) { this.FontFamily = new FontFamily((from i in BL.CaiDats select i.font).SingleOrDefault()); if ((from i in BL.CaiDats select i.Back).SingleOrDefault() == "Dark") { this.Background = new SolidColorBrush(Color.FromRgb(46, 46, 46)); } else if ((from i in BL.CaiDats select i.Back).SingleOrDefault() == "Light") { this.Background = Brushes.WhiteSmoke; } if ((from i in BL.CaiDats select i.FullScreen).SingleOrDefault() == "Full") { this.WindowStyle = WindowStyle.None; } else if ((from i in BL.CaiDats select i.FullScreen).SingleOrDefault() == "Windows") { this.WindowStyle = WindowStyle.SingleBorderWindow; } } }
private void Load() { using (var BLT = new BanLapTopEntities()) { var User = (from n in BLT.TaiKhoans where n.IdNguoiDung == IdAdmin select n).FirstOrDefault(); if (User != null) { ImgAd.ToolTip = User.HoTen; txtNameUsers.Text = User.HoTen; byte[] bitImage = User.Avatar; if (bitImage != null) { ImgAd.Fill = new ImageBrush(ToImage(bitImage)); } else { ImgAd.Fill = new ImageBrush(new BitmapImage(new Uri("pack://application:,,,/Image/User.png", UriKind.Absolute))); } } } TongDoanhThu Pro = new TongDoanhThu(); txtTitle.Text = "Thống Kê"; UserView.Children.Clear(); UserView.Children.Add(Pro); }
private void DelTableTemp() { using (var LT = new BanLapTopEntities()) { LT.Database.ExecuteSqlCommand("TRUNCATE TABLE DonHangTemp"); } }
private int MaDonHangNext() { using (var BH = new BanLapTopEntities()) { int Name = (from t in BH.HoaDons select t.MaHoaDon).Count(); return(Name + 1); } }
//Lay Tong ten Khach Hang private string NameUser(string IdUser) { using (var BH = new BanLapTopEntities()) { string Name = (from t in BH.TaiKhoans where t.IdNguoiDung == IdUser select t.HoTen).FirstOrDefault(); return(Name); } }
//Lay hinh San Pham private string ImageProduct(int MaSP) { using (var BH = new BanLapTopEntities()) { string Name = (from t in BH.SanPhams where t.MaSP == MaSP select t.HinhSP).FirstOrDefault(); return(Name); } }
private decimal GiaSP(int MaSP) { using (var T = new BanLapTopEntities()) { var t = (from h in T.SanPhams where h.MaSP == MaSP select h.GiaSP).SingleOrDefault(); return(t); } }
public TiemKiem() { InitializeComponent(); var dc = new BanLapTopEntities(); var sql = from p in dc.SanPhams from c in dc.HangSanXuats where c.MaHangSX == p.MaHangSX select p; lst.ItemsSource = sql.ToList(); lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(lst.ItemsSource); }
private bool TonTaiHang(int MaSP) { using (var T = new BanLapTopEntities()) { int t = (from h in T.DonHangTemps where h.MaSP == MaSP select h).Count(); if (t > 0) { return(true); } } return(false); }
private void Load() { using (var BH = new BanLapTopEntities()) { var LoaiSP = (from i in BH.LoaiSanPhams where i.ConKinhDoanh != false select new { i.MaLoaiSP, i.TenLoaiSP }); cbLoaiSP.ItemsSource = LoaiSP.ToList(); var HangSX = (from i in BH.HangSanXuats where i.ConKinhDoanh != false select new { i.MaHangSX, i.TenHangSX }); cbHangSX.ItemsSource = HangSX.ToList(); } }
private void Load() { BLT = new BanLapTopEntities(); var GioHang = (from h in BLT.DonHangTemps select h); if (GioHang.Count() == 0) { ListGioHang.ItemsSource = null; txtSLSP.Text = "0"; txtTTien.Text = "0 VNĐ"; } else { ListGioHang.ItemsSource = GioHang.ToList(); txtSLSP.Text = (from h in BLT.DonHangTemps select h.SoLuongMua).Sum().ToString(); txtName.Text = (from h in BLT.DonHangTemps select h.TenKhachHang).FirstOrDefault(); var Okane = (from h in BLT.DonHangTemps select h.ThanhTien).Sum().ToString(); txtTTien.Text = string.Format("{0:0,0 VNĐ}", double.Parse(Okane)); } var DonHang = (from h in BLT.HoaDons where h.MaKhachHang == IdKhachHang orderby h.NgayLap descending select h); if (DonHang.Count() == 0) { ListDonHang.ItemsSource = null; ListDonHang.Visibility = Visibility.Collapsed; } else { ListDonHang.ItemsSource = DonHang.ToList(); ListDonHang.Visibility = Visibility.Visible; } }
private void Load() { using (var BLT = new BanLapTopEntities()) { var Pro = (from h in BLT.HangSanXuats where h.ConKinhDoanh != false select h); if (Pro.Count() == 0) { ListGioHang.ItemsSource = null; } else { ListGioHang.ItemsSource = Pro.ToList(); } } }
private void Load() { using (var BLT = new BanLapTopEntities()) { var Pro = (from h in BLT.HoaDons orderby h.NgayLap descending select h); if (Pro.Count() == 0) { ListGioHang.ItemsSource = null; } else { ListGioHang.ItemsSource = Pro.ToList(); } } }
private int LayMaSP(object sender, RoutedEventArgs e) { Button temp = sender as Button; SanPham D = temp.DataContext as SanPham; int Id = D.MaSP; BLT = new BanLapTopEntities(); int NumberView = (from h in BLT.SanPhams where h.MaSP == Id select h.LuotXem).SingleOrDefault() + 1; BLT = new BanLapTopEntities(); var sql = BLT.SanPhams.Where(m => m.MaSP == Id).FirstOrDefault(); sql.LuotXem = NumberView; BLT.SaveChanges();//lưu thây đổi lượt xem return(Id); }
private void Loads() { using (var BL = new BanLapTopEntities()) { if ((from i in BL.CaiDats select i.Back).SingleOrDefault() == "Dark") { radLight.IsChecked = false; } else if ((from i in BL.CaiDats select i.Back).SingleOrDefault() == "Light") { radLight.IsChecked = true; } if ((from i in BL.CaiDats select i.FullScreen).SingleOrDefault() == "Full") { radFull.IsChecked = true; } else if ((from i in BL.CaiDats select i.FullScreen).SingleOrDefault() == "Windows") { radFull.IsChecked = false; } } }
private void Submit_Click(object sender, RoutedEventArgs e) { if (textBoxUser.Text.Length == 0) { errormessage.Text = "Please Enter a Username "; textBoxUser.Focus(); return; } else if (textBoxUser.Text.Length < 4) { errormessage.Text = "Please Enter a Username Length >= 5 character!"; textBoxUser.Focus(); return; } BanLapTopEntities BLT = new BanLapTopEntities(); int DK = BLT.TaiKhoans.Where(m => m.IdNguoiDung == textBoxUser.Text).Count(); if (DK > 0) { errormessage.Text = "The username already exists!"; textBoxUser.Focus(); return; } //---------- if (textBoxLastName.Text.Length == 0) { errormessage.Text = "Please Enter at your full name !"; textBoxLastName.Focus(); return; } else if (textBoxLastName.Text.Length < 5) { errormessage.Text = "Enter a valid your name!"; textBoxLastName.Focus(); return; } //------------- if (textBoxEmail.Text.Length == 0) { errormessage.Text = "Please Enter an email !"; textBoxEmail.Focus(); return; } else if (!Regex.IsMatch(textBoxEmail.Text, @"^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$")) { errormessage.Text = "Enter a valid email."; textBoxEmail.Select(0, textBoxEmail.Text.Length); textBoxEmail.Focus(); return; } //---------- if (passwordBox1.Password.Length == 0) { errormessage.Text = "Please Enter password !"; passwordBox1.Focus(); return; } if (passwordBoxConfirm.Password.Length == 0) { errormessage.Text = "Please Enter Confirm password."; passwordBoxConfirm.Focus(); return; } if (passwordBox1.Password != passwordBoxConfirm.Password) { errormessage.Text = "Confirm password must be same as password."; passwordBoxConfirm.Focus(); return; } if (textBoxAddress.Text.Length == 0) { errormessage.Text = "Please Enter Address...."; textBoxAddress.Focus(); return; } string Username = textBoxUser.Text; string lastname = textBoxLastName.Text; string email = textBoxEmail.Text; string password = md5(passwordBox1.Password); string address = ""; address = textBoxAddress.Text; errormessage.Text = ""; var TK = new TaiKhoan { IdNguoiDung = Username, PassND = password, HoTen = lastname, Email = email, DiaChi = address, MaLoaiTK = 0 }; using (var BanHang = new Models.BanLapTopEntities()) { int n = BanHang.TaiKhoans.Where(m => m.IdNguoiDung == TK.IdNguoiDung).Count(); if (n > 0) { errormessage.Text = "Username is Exist"; } else { BanHang.TaiKhoans.Add(TK); if (BanHang.SaveChanges() > 0) { MessageBox.Show("Success!"); Reset(); } else { MessageBox.Show("Error Please record"); } } } }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { bool FA = false; TimeLoad = new DispatcherTimer(); TimeLoad.Tick += new EventHandler(TimeLoad_Clock); TimeLoad.Interval = new TimeSpan(0, 0, 1); TimeLoad.Start(); txtTile.Text = "Kết Quả Tìm Kiếm Theo \""; if (!string.IsNullOrEmpty(DieuKien)) { var BLT = new BanLapTopEntities(); var DSX = BLT.SanPhams .Where(DieuKien) .Where("ConKinhDoanh != false"); SourceFill = DSX; var db = this.FindResource("dbForWd") as Models.Page; int totalPage; db.CurPage = 1; db.Products = GetSearchQuery(db.CurPage, Models.Page.PageSize, out totalPage); db.TotalPage = totalPage; ButtunPage(totalPage); } else { if (!string.IsNullOrWhiteSpace(Tile)) { decimal Gold = 5000000; decimal search; if (decimal.TryParse(Tile, out search)) { var BH = new Models.BanLapTopEntities(); var sql = (from timkiem in BH.SanPhams where timkiem.GiaSP >= search where timkiem.GiaSP <= search + Gold where timkiem.ConKinhDoanh != false select timkiem); SourceFill = sql; var db = this.FindResource("dbForWd") as Models.Page; int totalPage; db.CurPage = 1; db.Products = GetSearchQuery(db.CurPage, Models.Page.PageSize, out totalPage); db.TotalPage = totalPage; ButtunPage(totalPage); decimal tem = search + Gold; txtTile.Text += " Giá Từ " + Tile + " VNĐ ー> " + tem; FA = true; } else { var BH = new Models.BanLapTopEntities(); var sql = (from timkiem in BH.SanPhams from tk in BH.LoaiSanPhams from tk1 in BH.HangSanXuats where (timkiem.MaLoaiSP == tk.MaLoaiSP && timkiem.MaHangSX == tk1.MaHangSX && timkiem.TenSP.Contains(Tile)) || (timkiem.MaLoaiSP == tk.MaLoaiSP && timkiem.MaHangSX == tk1.MaHangSX && tk.TenLoaiSP.Contains(Tile)) || (timkiem.MaHangSX == tk1.MaHangSX && timkiem.MaLoaiSP == tk.MaLoaiSP && tk1.TenHangSX.Contains(Tile)) where timkiem.ConKinhDoanh != false select timkiem); SourceFill = sql; var db = this.FindResource("dbForWd") as Models.Page; int totalPage; db.CurPage = 1; db.Products = GetSearchQuery(db.CurPage, Models.Page.PageSize, out totalPage); db.TotalPage = totalPage; ButtunPage(totalPage); } } } if (FA == true) { txtTile.Text += " VNĐ\""; } else { txtTile.Text += Tile + "\""; } }