public ActionResult Home(string Id)
        {
            var list = db.tblRooms.Where(x => x.R_Active == true).ToList();

            ViewData["list_room"] = list;
            var list_acount = db.tbl_User.Where(x => x.U_Status == true).ToList();

            ViewData["list_acount"] = list_acount;
            var list_shift = db.tbl_Loai_Ca_Lam_Viec.ToList();

            ViewData["list_work_shift"] = list_shift;
            var list_categoryhome = db.tblCategories.Where(x => x.C_Active == true).ToList();

            ViewData["list_cate"]    = list_categoryhome;
            ViewData["list_service"] = db.tblServices.Where(x => x.S_Active == true).ToList();
            var list_employee = db.map_employee().Where(x => x.E_Active == 0).ToList();

            ViewData["list_employee"] = list_employee;
            var list_category_oder = db.LEPVC().ToList();

            ViewData["list_category_oder"] = list_category_oder;
            var list_service_oder = db.Order_Admin_Service_0().ToList();

            ViewData["list_service_oder"] = list_service_oder;
            var list_employeestaff_oder = db.Order_Admin_Employee_0().ToList();

            ViewData["list_employeestaff_oder"] = list_employeestaff_oder;
            var list_magiam = db.tblOrders.ToList();

            ViewData["list_employeestaff_oder"] = list_employeestaff_oder;

            List <chart_staff_employee> list_chart = new List <chart_staff_employee> {
            };
            var staff = db.tblEmployees.Where(x => x.E_Active == 0 && x.TypeEmployeeId == 2).Take(6).ToArray();//Thuộc bộ phận ID = 2

            foreach (var item_e in staff)
            {
                var chart_staff = new chart_staff_employee();
                chart_staff.name = item_e.E_Name;
                chart_staff.href = item_e.E_Image;
                foreach (var item_e2 in db.NumberOfServings().Where(x => x.E_Name == item_e.E_Name).ToList())
                {
                    chart_staff.steps = (double)item_e2.totalmoney;
                }
                list_chart.Add(chart_staff);
            }
            ViewBag.chart = list_chart;//view json endcode list_chart
            //doanh thu thang
            List <chart_year> list_chart_year_mouth = new List <chart_year> {
            };
            var thang = DateTime.Now.Month + 1;

            for (var i = 1; i < thang; i++)
            {
                double dichvu      = 0;
                double dichvukhac  = 0;
                double phucvu      = 0;
                double phong       = 0;
                var    chart_mouth = new chart_year();
                foreach (var item3 in db.DOANH_THU_NAM().Where(x => x.DayNew.GetValueOrDefault().Month == i && x.TypeOder == "service").ToArray())
                {
                    dichvu += (double)item3.Money;
                }
                foreach (var item3 in db.DOANH_THU_NAM().Where(x => x.DayNew.GetValueOrDefault().Month == i && x.TypeOder == "categori").ToArray())
                {
                    dichvukhac += (double)item3.Money;
                }
                foreach (var item3 in db.DOANH_THU_NAM().Where(x => x.DayNew.GetValueOrDefault().Month == i && x.TypeOder == "Employee").ToArray())
                {
                    phucvu += (double)item3.Money;
                }
                foreach (var item3 in db.DOANH_THU_NAM().Where(x => x.DayNew.GetValueOrDefault().Month == i && x.TypeOder == "Room").ToArray())
                {
                    phong += (double)item3.Money;
                }
                double Tong = 0;
                Tong = dichvu + dichvukhac + phucvu + phong;

                chart_mouth.country = "Tháng" + i.ToString();
                chart_mouth.visits  = Tong;

                list_chart_year_mouth.Add(chart_mouth);
            }
            ViewBag.chartt = list_chart_year_mouth;

            var list_oder = db.Bill().ToList();
            List <Rom_bill_view> list_roomm = new List <Rom_bill_view> {
            };

            foreach (var item in list_oder)
            {
                if (list_roomm == null)
                {
                    var item1 = new Rom_bill_view();
                    var list1 = new List <Rom_bill_view>();
                    item1.E_Name          = item.E_Name;
                    item1.FirtDayCheckin  = item.FirtDayCheckin;
                    item1.FirtHourCheckin = item.FirtHourCheckin;
                    item1.Id              = item.Id;
                    item1.LastDayCheckin  = item.LastDayCheckin;
                    item1.LastHourCheckin = item.LastHourCheckin;
                    item1.NhanVienID      = item.NhanVienID;
                    item1.Note            = item.Note;
                    item1.O_number        = item.O_number;
                    item1.Total           = item.Total;
                    item1.Room            = "";
                    if (item.phantramgiam > 0)
                    {
                        item1.Total = item1.Total - item.phantramgiam * item1.Total / 100;
                    }
                    foreach (var item2 in db.tblOrderDetails.Where(x => x.OrderId == item.Id && x.TypeOder == "Room").ToList())
                    {
                        var room = db.tblRooms.Find(item2.EmployeeId);
                        if (item1.Room == "")
                        {
                            item1.Room = room.R_Name;
                        }
                        else
                        {
                            item1.Room = item1.Room + "," + room.R_Name;
                        }
                    }
                    list1.Add(item1);
                }
                else
                {
                    var item1 = new Rom_bill_view();
                    var list1 = (List <Rom_bill_view>)list_roomm;
                    item1.E_Name          = item.E_Name;
                    item1.FirtDayCheckin  = item.FirtDayCheckin;
                    item1.FirtHourCheckin = item.FirtHourCheckin;
                    item1.Id              = item.Id;
                    item1.LastDayCheckin  = item.LastDayCheckin;
                    item1.LastHourCheckin = item.LastHourCheckin;
                    item1.NhanVienID      = item.NhanVienID;
                    item1.Note            = item.Note;
                    item1.O_number        = item.O_number;
                    item1.Total           = item.Total;
                    if (item.phantramgiam > 0)
                    {
                        item1.Total = item1.Total - item.phantramgiam * item1.Total / 100;
                    }

                    item1.Room = "";
                    foreach (var item2 in db.tblOrderDetails.Where(x => x.OrderId == item.Id && x.TypeOder == "Room").ToList())
                    {
                        var room = db.tblRooms.Find(item2.EmployeeId);
                        if (item1.Room == "")
                        {
                            item1.Room = room.R_Name;
                        }
                        else
                        {
                            item1.Room = item1.Room + "," + room.R_Name;
                        }
                    }
                    list1.Add(item1);
                }
            }
            ViewData["list_roomm"] = list_roomm;

            DateTime tungay, denngay;

            if (Id == null)
            {
                denngay = DateTime.Now;
                tungay  = denngay.AddDays(-30);
            }
            else
            {
                var ma = Id.Split('|');
                denngay = Convert.ToDateTime(ma[1]);
                tungay  = Convert.ToDateTime(ma[0]);
            }
            ViewData["list_oder"] = tungay.ToString("yyyy-MM-dd") + "|" + denngay.ToString("yyyy-MM-dd");
            //tungay = tungay.AddDays(-1);
            //denngay = denngay.AddDays(1);
            var list_history_oder = db.tblOrders.ToList().Where(x => x.DayNew >= tungay && x.DayNew <= denngay).ToList();

            ViewData["list_history_oder"] = list_history_oder;
            return(View());
        }
        public ActionResult Index()
        {
            var list_oder = db.Bill().ToList();
            List <Rom_bill_view> list_roomm = new List <Rom_bill_view> {
            };

            foreach (var item in list_oder)
            {
                if (list_roomm == null)
                {
                    var item1 = new Rom_bill_view();
                    var list1 = new List <Rom_bill_view>();
                    item1.E_Name          = item.E_Name;
                    item1.FirtDayCheckin  = item.FirtDayCheckin;
                    item1.FirtHourCheckin = item.FirtHourCheckin;
                    item1.Id              = item.Id;
                    item1.LastDayCheckin  = item.LastDayCheckin;
                    item1.LastHourCheckin = item.LastHourCheckin;
                    item1.NhanVienID      = item.NhanVienID;
                    item1.Note            = item.Note;
                    item1.O_number        = item.O_number;
                    item1.Total           = item.Total;
                    item1.Room            = "";
                    foreach (var item2 in db.tblOrderDetails.Where(x => x.OrderId == item.Id && x.TypeOder == "Room").ToList())
                    {
                        var room = db.tblRooms.Find(item2.EmployeeId);
                        if (item1.Room == "")
                        {
                            item1.Room = room.R_Name;
                        }
                        else
                        {
                            item1.Room = item1.Room + "," + room.R_Name;
                        }
                    }
                    list1.Add(item1);
                }
                else
                {
                    var item1 = new Rom_bill_view();
                    var list1 = (List <Rom_bill_view>)list_roomm;
                    item1.E_Name          = item.E_Name;
                    item1.FirtDayCheckin  = item.FirtDayCheckin;
                    item1.FirtHourCheckin = item.FirtHourCheckin;
                    item1.Id              = item.Id;
                    item1.LastDayCheckin  = item.LastDayCheckin;
                    item1.LastHourCheckin = item.LastHourCheckin;
                    item1.NhanVienID      = item.NhanVienID;
                    item1.Note            = item.Note;
                    item1.O_number        = item.O_number;
                    item1.Total           = item.Total;
                    item1.Room            = "";
                    foreach (var item2 in db.tblOrderDetails.Where(x => x.OrderId == item.Id && x.TypeOder == "Room").ToList())
                    {
                        var room = db.tblRooms.Find(item2.EmployeeId);
                        if (item1.Room == "")
                        {
                            item1.Room = room.R_Name;
                        }
                        else
                        {
                            item1.Room = item1.Room + "," + room.R_Name;
                        }
                    }
                    list1.Add(item1);
                }
            }
            ViewData["list_roomm"] = list_roomm;
            var list_history_oder = db.tblOrders.ToList();

            ViewData["list_history_oder"] = list_history_oder;
            return(View());
        }