Ejemplo n.º 1
0
    protected void DsMonAnThuocLoaiMonBatKy()
    {
        int pageSize = 5;

        if (Request["results"] != null)
        {
            pageSize = int.Parse((string)Request["results"]);
        }

        int pageNum    = 1;
        int startIndex = 0;

        if (Request["startIndex"] != null)
        {
            startIndex = int.Parse((string)Request["startIndex"]);
            pageNum    = (startIndex / pageSize) + 1;
        }

        MonAnBUS  mon_anBUS = new MonAnBUS();
        ArrayList dsMonAn   = new ArrayList();
        int       index     = 0;
        int       loaimon   = -1;

        if (Session["LoaiNguoiDung"].ToString() == "NhanVien")
        {
            loaimon = int.Parse((string)Request["LoaiMon"]);
        }
        else
        {
            loaimon = int.Parse(Session["LoaiMon"].ToString());
        }
        dsMonAn = mon_anBUS.LayDSMonAnThuocLoaiMonBatKy(loaimon);
        int n = dsMonAn.Count;

        XL_THE Kq = new XL_THE("DANH_SACH");

        if (Session["LoaiNguoiDung"].ToString() == "NhanVien") //co phan trang
        {
            index = startIndex;
            n     = startIndex + pageSize;
            n     = (n < dsMonAn.Count) ? n : dsMonAn.Count;

            XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("totalRecords", dsMonAn.Count.ToString());
            Kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
        }



        for (int i = index; i < n; i++)
        {
            XL_THE Kq1 = new XL_THE("MonAn");

            MonAnDTO MonAn = (MonAnDTO)dsMonAn[i];
            if (MonAn.Trang_thai_hien_thi == false)
            {
                continue;
            }
            XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("Ma_mon", MonAn.Ma_mon.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Ten_mon", MonAn.Ten_mon);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Hinh_anh_minh_hoa", MonAn.Hinh_anh_minh_hoa);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Mo_ta", MonAn.Mo_ta);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Diem_binh_chon", MonAn.Diem_binh_chon.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Don_vi_tinh", MonAn.Don_vi_tinh);

            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Gia", MonAn.Gia.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Ma_loai_mon", MonAn.Ma_loai_mon.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Tinh_trang", MonAn.Tinh_trang.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
            Thuoc_tinh = new XL_THUOC_TINH("Trang_thai_hien_thi", MonAn.Trang_thai_hien_thi.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Kq.Danh_sach_the.Add(Kq1);
        }

        XL_CHUOI.XuatXML(Response, Kq.Chuoi());
    }
Ejemplo n.º 2
0
    protected void DsMonAnThuocLoaiMon()
    {
        // Xử lý request
        int pageSize = 5;

        if (Request["results"] != null)
        {
            pageSize = int.Parse((string)Request["results"]);
        }

        int pageNum    = 1;
        int startIndex = 0;

        if (Request["startIndex"] != null)
        {
            startIndex = int.Parse((string)Request["startIndex"]);
            pageNum    = (startIndex / pageSize) + 1;
        }

        MonAnBUS  mon_anBUS = new MonAnBUS();
        ArrayList dsMonAn   = new ArrayList();
        int       index     = 0;
        int       loaimon   = -1;

        if (Session["LoaiNguoiDung"] == "NhanVien" || Session["LoaiNguoiDung"] == "QuanLy")
        {
            loaimon = int.Parse((string)Request["LoaiMon"]);
        }
        else
        {
            loaimon = int.Parse(Session["LoaiMon"].ToString());
        }

        dsMonAn = mon_anBUS.LayDSMonAnThuocLoaiMonBatKy(loaimon);
        int n = dsMonAn.Count;

        XL_THE Kq = new XL_THE("DANH_SACH");

        if (Session["LoaiNguoiDung"] == "NhanVien" || Session["LoaiNguoiDung"] == "QuanLy") //co phan trang
        {
            index = startIndex;
            n     = startIndex + pageSize;
            n     = (n < dsMonAn.Count) ? n : dsMonAn.Count;

            XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("totalRecords", dsMonAn.Count.ToString());
            Kq.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);
        }

        LoaiMonDTO lmDto = (new LoaiMonBUS()).ChiTietLoaiMon(loaimon);   //chu íu lấy tên loại món

        for (int i = index; i < n; i++)
        {
            XL_THE Kq1 = new XL_THE("MonAn");

            MonAnDTO MonAn = (MonAnDTO)dsMonAn[i];
//             if (MonAn.Trang_thai_hien_thi == false)
//                 continue;
            XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("MaMonAn", MonAn.Ma_mon.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("TenMonAn", MonAn.Ten_mon);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("LoaiMonAn", lmDto.Ten_loai_mon);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("MoTa", MonAn.Mo_ta);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("HinhAnhMinhHoa", MonAn.Hinh_anh_minh_hoa);
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("Gia", MonAn.Gia.ToString());
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("TrangThaiHienThi", MonAn.Trang_thai_hien_thi ? "1" : "0");
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Thuoc_tinh = new XL_THUOC_TINH("TinhTrang", MonAn.Tinh_trang ? "1": "0");
            Kq1.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            Kq.Danh_sach_the.Add(Kq1);
        }

        XL_CHUOI.XuatXML(Response, Kq.Chuoi());
    }