Exemple #1
0
        public ActionResult SearchGioiTinh(string gioiTinh)
        {
            var tk = Session["TaiKhoan"] as KhachHang;

            if (tk == null)
            {
                return(View("../Login/Index"));
            }
            else
            {
                if (tk.LoaiTK != "Admin")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    ToyContext       db   = new ToyContext();
                    List <KhachHang> list = Session["ListKH"] as List <KhachHang>;
                    if (gioiTinh == "nam")
                    {
                        Session["ListKH"] = list.Where(i => i.GioiTinh == true).ToList();
                    }
                    else if (gioiTinh == "nu")
                    {
                        Session["ListKH"] = list.Where(i => i.GioiTinh == false).ToList();
                    }
                    else
                    {
                        Session["ListKH"] = list;
                    }
                    return(View("Index"));
                }
            }
        }
        public override ToyExpression Reduce(ToyContext context)
        {
            var reduced1 = _operand1.Reduce(context);
            var reduced2 = _operand2.Reduce(context);

            var number1 = reduced1 as ToyNumberValue;
            var number2 = reduced2 as ToyNumberValue;

            if (number1 != null && number2 != null)
            {
                switch (_operator)
                {
                case ToyOperatorType.Add:
                    return(new ToyNumberValue(number1.Value + number2.Value));

                case ToyOperatorType.Sub:
                    return(new ToyNumberValue(number1.Value - number2.Value));

                case ToyOperatorType.Mul:
                    return(new ToyNumberValue(number1.Value * number2.Value));

                case ToyOperatorType.Div:
                    return(new ToyNumberValue(number1.Value / number2.Value));

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            return(new ToyBinaryExpression(_operator, reduced1, reduced2));
        }
Exemple #3
0
        public HomeController(ToyContext context)
        {
            db = context;
            // добавляем начальные данные
            if (db.Types.Count() != 0)
            {
                return;
            }
            var cat = new ToyType {
                Name = "cat"
            };
            var lego = new ToyType {
                Name = "lego"
            };
            var dog = new ToyType {
                Name = "dog"
            };
            var mouse = new ToyType {
                Name = "mouse"
            };
            var doll = new ToyType {
                Name = "doll"
            };

            var toy1 = new Toy {
                Name = "Grumpy Cat", Type = cat, Price = 599
            };
            var toy2 = new Toy {
                Name = "Tom The Cat", Type = cat, Price = 499
            };
            var toy3 = new Toy {
                Name = "Jerry The Mouse", Type = mouse, Price = 599
            };
            var toy4 = new Toy {
                Name = "Mickey Mouse", Type = mouse, Price = 1099
            };
            var toy5 = new Toy {
                Name = "Minnie Mouse", Type = mouse, Price = 399
            };
            var toy6 = new Toy {
                Name = "Barbie", Type = doll, Price = 299
            };
            var toy7 = new Toy {
                Name = "Ken", Type = doll, Price = 1199
            };
            var toy8 = new Toy {
                Name = "Blue Sad Dog", Type = dog, Price = 899
            };
            var toy9 = new Toy {
                Name = "Star Wars", Type = lego, Price = 199
            };
            var toy10 = new Toy {
                Name = "Ninjago", Type = lego, Price = 299
            };

            db.Types.AddRange(cat, dog, lego, mouse, doll);
            db.Toys.AddRange(toy1, toy2, toy3, toy4, toy5, toy6, toy7, toy8, toy9, toy10);
            db.SaveChanges();
        }
        public ActionResult TimKiemSach(string tenSach)
        {
            Session["KM"] = null;
            ToyContext db = new ToyContext();

            Session["Title"]    = "Tìm Kiếm: " + tenSach;
            Session["Products"] = db.Sachs.Where(i => i.flag == true && i.Ten.Contains(tenSach)).ToList();
            return(View("../DanhSachSanPham/Index"));
        }
Exemple #5
0
        // GET: ChiTietSach
        public ActionResult Index(long id)
        {
            ToyContext db   = new ToyContext();
            Sach       sach = db.Sachs.Find(id);

            sach.LuotXem++;
            db.SaveChanges();
            Session["CTSach"] = sach;
            return(View("Index"));
        }
 public ItemController(IToyRepository toyRepository,
                       IProducerRepository producerRepository,
                       ICategoryRepository categoryRepository,
                       IGalleryRepository galleryRepository,
                       IHostingEnvironment environment, ToyContext context)
 {
     _toyRepository      = toyRepository;
     _producerRepository = producerRepository;
     _categoryRepository = categoryRepository;
     _galleryRepository  = galleryRepository;
     _environment        = environment;
     _context            = context;
 }
Exemple #7
0
        public override ToyExpression Reduce(ToyContext context)
        {
            var reduced = _expression.Reduce(context);

            var number = reduced as ToyNumberValue;

            if (number != null)
            {
                return(new ToyNumberValue(-number.Value));
            }

            return(new ToyNegateExpression(reduced));
        }
Exemple #8
0
        public ToysController(ToyContext context)
        {
            db = context;
            if (!db.Toys.Any())
            {
                var toy1 = new Toy {
                    Name = "Grumpy Cat", Material = "cotton", Price = 599
                };
                var toy2 = new Toy {
                    Name = "Tom The Cat", Material = "cotton", Price = 499
                };
                var toy3 = new Toy {
                    Name = "Jerry The Mouse", Material = "synthetics", Price = 599
                };
                var toy4 = new Toy {
                    Name = "Mickey Mouse", Material = "plastic", Price = 1099
                };
                var toy5 = new Toy {
                    Name = "Minnie Mouse", Material = "plastic", Price = 399
                };
                var toy6 = new Toy {
                    Name = "Barbie", Material = "plastic", Price = 299
                };
                var toy7 = new Toy {
                    Name = "Ken", Material = "plastic", Price = 1199
                };
                var toy8 = new Toy {
                    Name = "Blue Sad Dog", Material = "cotton", Price = 899
                };
                var toy9 = new Toy {
                    Name = "Star Wars", Material = "plastic", Price = 199
                };
                var toy10 = new Toy {
                    Name = "Ninjago", Material = "plastic", Price = 299
                };

                var mat1 = new Material {
                    Name = "cotton"
                };
                var mat2 = new Material {
                    Name = "synthetic"
                };
                var mat3 = new Material {
                    Name = "plastic"
                };

                db.Materials.AddRange(mat1, mat2, mat3);
                db.Toys.AddRange(toy1, toy2, toy3, toy4, toy5, toy6, toy7, toy8, toy9, toy10);
                db.SaveChanges();
            }
        }
Exemple #9
0
 // GET: CTHDHome
 public ActionResult Index(long?idHD)
 {
     if (Session["TaiKhoan"] == null)
     {
         return(View("../Login/Index"));
     }
     else
     {
         if (idHD == null)
         {
             return(View("../Home/Index"));
         }
         var cthd = new CTHDDAO();
         var db   = new ToyContext();
         Session["HDHome"] = db.HoaDon.Find(idHD);
         long id = Convert.ToInt64(idHD);
         Session["ListCTHDHome"] = cthd.GetList(id);
         return(View("Index"));
     }
 }
        public ActionResult Giao(long idHD)
        {
            var tk = Session["TaiKhoan"] as KhachHang;

            if (tk == null)
            {
                return(View("../Login/Index"));
            }
            else
            {
                if (tk.LoaiTK != "Admin")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    var db = new ToyContext();
                    db.HoaDon.Find(idHD).TinhTrangDonHang = "Đã Giao Hàng";
                    db.SaveChanges();
                    return(RedirectToAction("Reset", "HoaDon", new { area = "Admin" }));
                }
            }
        }
 public ToyRepository(ToyContext context)
 {
     _context = context;
 }
 public PostRepository(ToyContext context)
 {
     _context = context;
 }
 public HoaDonDAO()
 {
     db = new ToyContext();
 }
Exemple #14
0
 public ChuDeDAO()
 {
     db = new ToyContext();
 }
Exemple #15
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory log, ToyContext context)
        {
            if (env.IsDevelopment())
            {
                log.AddDebug(LogLevel.Information);
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }

            //app.UseIdentity();
            app.UseAuthentication();

            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseSession();

            app.UseMvc(r =>
                       r.MapRoute(
                           name: "default",
                           template: "{controller=blog}/{action=index}/{id?}"
                           ));

            ToyInitializer.Initialize(context);
        }
Exemple #16
0
 public TacGiaDAO()
 {
     db = new ToyContext();
 }
Exemple #17
0
 public KhuyenMaiDAO()
 {
     db = new ToyContext();
 }
        public ActionResult XuatExcel(long idHD)
        {
            var tk = Session["TaiKhoan"] as KhachHang;

            if (tk == null)
            {
                return(View("../Login/Index"));
            }
            else
            {
                if (tk.LoaiTK != "Admin")
                {
                    return(View("../Home/Index"));
                }
                else
                {
                    var db   = new ToyContext();
                    var cthd = new CTHDDAO();
                    var list = cthd.GetList(idHD);
                    try
                    {
                        string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

                        Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
                        Microsoft.Office.Interop.Excel.Workbook    wb    = excel.Workbooks.Add(XlSheetType.xlWorksheet);
                        Microsoft.Office.Interop.Excel.Worksheet   ws    = (Microsoft.Office.Interop.Excel.Worksheet)excel.ActiveSheet;
                        excel.Visible = false;
                        int index   = 2;
                        int process = list.Count;

                        ws.Cells[1, 1] = "Mã Sách";
                        ws.Cells[1, 2] = "Tên Sách";
                        ws.Cells[1, 3] = "Đơn Giá";
                        ws.Cells[1, 4] = "Số Lượng";
                        ws.Cells[1, 5] = "Thành Tiền";
                        double TongTien = 0;
                        foreach (var sinhVien in list)
                        {
                            idHD = sinhVien.IdHoaDon;
                            ws.Cells[index, 1] = sinhVien.IdSach;
                            ws.Cells[index, 2] = sinhVien.Sach.Ten;
                            ws.Cells[index, 3] = sinhVien.Sach.Gia;
                            ws.Cells[index, 4] = sinhVien.SoLuong;
                            ws.Cells[index, 5] = sinhVien.ThanhTien;
                            TongTien           = TongTien + sinhVien.ThanhTien;
                            index += 1;
                        }
                        ws.Cells[index, 4] = "Tổng Tiền";
                        ws.Cells[index, 5] = TongTien;
                        ws.SaveAs(@path + "/HoaDonAdmin" + idHD + ".xlsx",
                                  XlFileFormat.xlWorkbookDefault,
                                  Type.Missing,
                                  Type.Missing,
                                  true, false,
                                  XlSaveAsAccessMode.xlNoChange,
                                  XlSaveConflictResolution.xlLocalSessionChanges,
                                  Type.Missing,
                                  Type.Missing);
                        excel.Quit();
                    }
                    catch (Exception ex) { }
                    return(RedirectToAction("Reset", "HoaDon", new { area = "Admin" }));
                }
            }
        }
 public UsersController(ToyContext context)
 {
     _context = context;
 }
Exemple #20
0
 public HomeDAO()
 {
     db = new ToyContext();
 }
 public GalleryRepository(ToyContext context)
 {
     _context = context;
 }
Exemple #22
0
 public OrderService(ToyContext context)
 {
     this._context = context;
 }
 public ProducerRepository(ToyContext context)
 {
     _context = context;
 }
Exemple #24
0
 public BieuDoDAO()
 {
     db = new ToyContext();
 }
Exemple #25
0
 public NhaCungCapDAO()
 {
     db = new ToyContext();
 }
Exemple #26
0
 public CTHDDAO()
 {
     db = new ToyContext();
 }
Exemple #27
0
 public GenericRepository()
 {
     _context = new ToyContext();
     _set     = _context.Set <Tentity>();
 }
 public MicroPostsController(ToyContext context)
 {
     _context = context;
 }
Exemple #29
0
 public override ToyExpression Reduce(ToyContext context)
 {
     return(this);
 }
Exemple #30
0
 public SachDAO()
 {
     db = new ToyContext();
 }