Ejemplo n.º 1
0
        public JsonResult GetDataRows(int year, int month, int file)
        {
            //string firstname = Request.QueryString["month"];
            //string lastname = Request.QueryString["year"];
            //string lastname1 = Request.QueryString["file"];


            //var products = Product.GetSampleProducts();
            //int pageIndex = Convert.ToInt32(page) - 1;
            //int pageSize = rows;
            //int totalRecords = products.Count();
            //int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
            //int uploadYear = year;
            //int uploadMonth = month;
            //int uploadFile = file;

            //var data = products.OrderBy(x => x.Id)
            //             .Skip(pageSize * (page - 1))
            //             .Take(pageSize).ToList();

            this.SetConnectionDB();
            EVNImporterServices services = new EVNImporterServices(oracleConnection, DBConnection);
            DVKH dataTable = new DVKH();
            var  obj       = (dynamic)null;

            switch (file)
            {
            case 1:
                dataTable.DNT_QMKLTN_HA1820 = services.GetList_DNT_QMKLTN_HA1820(month, year);
                obj = dataTable.DNT_QMKLTN_HA1820.Count > 0 ? dataTable.DNT_QMKLTN_HA1820 : null;
                break;

            case 2:
                dataTable.DNT_QMKLTN_NVK = services.GetList_DNT_QMKLTN_NVK(month, year);
                obj = dataTable.DNT_QMKLTN_NVK.Count > 0 ? dataTable.DNT_QMKLTN_NVK : null;
                break;

            case 3:
                dataTable.DNT_QMKL_QD41 = services.GetList_DNT_QMKL_QD41(month, year);
                obj = dataTable.DNT_QMKL_QD41.Count > 0 ? dataTable.DNT_QMKL_QD41 : null;
                break;

            case 4:
                dataTable.DNT_QMKLTN_QD2081 = services.GetList_DNT_QMKLTN_QD2081(month, year);
                obj = dataTable.DNT_QMKLTN_QD2081.Count > 0 ? dataTable.DNT_QMKLTN_QD2081 : null;
                break;

            case 5:
                dataTable.DNT_THCDIEN_PL71 = services.GetList_DNT_THCDIEN_PL71(month, year);
                obj = dataTable.DNT_THCDIEN_PL71.Count > 0 ? dataTable.DNT_THCDIEN_PL71 : null;
                break;

            case 6:
                dataTable.DNT_THCDIEN_PL72 = services.GetList_DNT_THCDIEN_PL72(month, year);
                obj = dataTable.DNT_THCDIEN_PL72.Count > 0 ? dataTable.DNT_THCDIEN_PL72 : null;
                break;

            default:
                break;
            }
            // var data2 = services.GetList_DNT_QMKLTN_HA1820();
            //var json = new JavaScriptSerializer().Serialize(obj);
            var jsonData = new
            {
                total   = 20,
                page    = 1,
                records = 12,
                rows    = obj
            };

            return(Json(jsonData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Booking(string dtp_from, string dtp_to, string people, string quantity, string pool, string bar, string gym, string rooms, string fullname, string phonenum)
        {
            var    db          = new  QuanLyKhachSanEntities();
            var    PhongThue   = new PHONGTHUE();
            string idPhongThue = new GenerateIDPhongThue().generateID();
            // check phòng

            var phongTrong = db.PHONGs.Where(x => x.LOAIPHONG == rooms && x.TRANGTHAI == "false").FirstOrDefault();

            if (phongTrong == null)
            {
                return(Content("nullRooms"));
            }
            // tạo thông tin khách hàng
            var khachHang = new KHACHHANG();

            khachHang.MAKH  = new GenerateIDPhongThue().generateIDKH();
            khachHang.TENKH = fullname;
            khachHang.SDT   = Convert.ToInt32(phonenum);
            db.KHACHHANGs.Add(khachHang);

            // lưu database
            db.SaveChanges();


            // tạo thống tin cho phòng thuê
            phongTrong.TRANGTHAI = "true";
            PhongThue.MADK       = idPhongThue;
            PhongThue.NGAYDI     = Convert.ToDateTime(dtp_to);
            PhongThue.NGAYDEN    = Convert.ToDateTime(dtp_from);
            PhongThue.SOPHONG    = phongTrong.SOPHONG;
            PhongThue.MAKH       = khachHang.MAKH;

            db.PHONGTHUEs.Add(PhongThue);
            db.SaveChanges();

            // tạo thông tin lưu dịch vụ
            if (pool == "true")
            {
                string idBooking = new GenerateIDPhongThue().generateIDServiceBooking();
                var    DVKH      = new DVKH();
                DVKH.ID   = idBooking;
                DVKH.MADV = "1";
                DVKH.MADK = idPhongThue;
                db.DVKHs.Add(DVKH);
                db.SaveChanges();
            }
            if (bar == "true")
            {
                string idBooking = new GenerateIDPhongThue().generateIDServiceBooking();
                var    DVKH      = new DVKH();
                DVKH.ID   = idBooking;
                DVKH.MADV = "2";
                DVKH.MADK = idPhongThue;
                db.DVKHs.Add(DVKH);
                db.SaveChanges();
            }
            if (gym == "true")
            {
                string idBooking = new GenerateIDPhongThue().generateIDServiceBooking();
                var    DVKH      = new DVKH();
                DVKH.ID   = idBooking;
                DVKH.MADV = "3";
                DVKH.MADK = idPhongThue;
                db.DVKHs.Add(DVKH);
                db.SaveChanges();
            }



            return(Content("true"));
        }