public int ThemMonAn(MonAnDTO monan, String strTag)
    {
        int Kq = 0; //mã người dùng

        Connect();

        SqlCommand cmd = new SqlCommand("spThemMonAn", cnn);

        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.Add("@tenmon", SqlDbType.NVarChar);
        cmd.Parameters.Add("@hinhanhminhhoa", SqlDbType.NVarChar);
        cmd.Parameters.Add("@mota", SqlDbType.Text);
        cmd.Parameters.Add("@diembinhchon", SqlDbType.Int);
        cmd.Parameters.Add("@donvitinh", SqlDbType.NVarChar);
        cmd.Parameters.Add("@gia", SqlDbType.Money);
        cmd.Parameters.Add("@maloaimon", SqlDbType.Int);
        cmd.Parameters.Add("@tinhtrang", SqlDbType.Bit);
        cmd.Parameters.Add("@trangthaihienthi", SqlDbType.Bit);

        cmd.Parameters["@tenmon"].Value           = monan.Ten_mon;
        cmd.Parameters["@hinhanhminhhoa"].Value   = monan.Hinh_anh_minh_hoa;
        cmd.Parameters["@mota"].Value             = monan.Mo_ta;
        cmd.Parameters["@diembinhchon"].Value     = monan.Diem_binh_chon;
        cmd.Parameters["@donvitinh"].Value        = monan.Don_vi_tinh;
        cmd.Parameters["@gia"].Value              = monan.Gia;
        cmd.Parameters["@maloaimon"].Value        = monan.Ma_loai_mon;
        cmd.Parameters["@tinhtrang"].Value        = monan.Tinh_trang;
        cmd.Parameters["@trangthaihienthi"].Value = monan.Trang_thai_hien_thi;

        cmd.Parameters.Add("@mamon", SqlDbType.Int);
        cmd.Parameters["@mamon"].Direction = ParameterDirection.Output;

        try
        {
            cmd.ExecuteNonQuery();
            int mamon = int.Parse(cmd.Parameters["@mamon"].Value.ToString());
            Kq = mamon;
            Disconnect();

            String[]    dsTag       = TagDAO.XuLyChuoiTag(strTag);
            TagDTO      tagDTO      = new TagDTO();
            TagMonAnDTO tagmonanDTO = new TagMonAnDTO();
            tagmonanDTO.Ma_mon = mamon;

            for (int i = 0; i < dsTag.Length; ++i)
            {
                tagDTO.Ten_tag = dsTag[i];
                int matag = (new TagDAO()).ThemTag(tagDTO);

                tagmonanDTO.Ma_tag = matag;
                (new TagMonAnDAO()).ThemTagMonAn(tagmonanDTO);
            }
        }
        catch (SqlException ex)
        {
            Disconnect();
            throw ex;
        }

        return(Kq);
    }
示例#2
0
    private void LayCTDonHang()
    {
        int maDonHang = int.Parse(Request["MaDonHang"]);

        XL_THE kq = new XL_THE("DanhSachCTDonHang");

        CTDonHangBUS ctdhbus = new CTDonHangBUS();

        CTDonHangDTO[] arrCtdhDto = ctdhbus.DanhSachCTDonHang(maDonHang);
        foreach (CTDonHangDTO ctdh in arrCtdhDto)
        {
            XL_THE the = new XL_THE("CTDonHang");

            // mã chi tiết đơn hàng
            XL_THUOC_TINH Thuoc_tinh = new XL_THUOC_TINH("MaCTDonHang", ctdh.Ma_ct_don_hang.ToString());
            the.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);


            string loai = "";
            string ten  = "";
            switch (ctdh.Loai_item)
            {
            case 0:     // món ăn
                loai = "Món ăn";
                MonAnBUS maBus = new MonAnBUS();
                MonAnDTO ma    = maBus.ChiTietMonAn(ctdh.Ma_item);

                if (ma != null)
                {
                    ten = ma.Ten_mon;
                }
                else
                {
                    ten = "Món ăn này không tồn tại";
                }
                break;

            case 1:     // thực đơn
                loai = "Thực đơn";
                ThucDonBUS tdBus = new ThucDonBUS();
                ThucDonDTO tdDto = tdBus.ChiTietThucDon(ctdh.Ma_item);
                if (tdDto != null)
                {
                    ten = tdDto.Ten_thuc_don;
                }
                else
                {
                    ten = "Thực đơn này không tồn tại";
                }
                break;

            case 2:     // thực đơn cá nhân
                loai = "Thực đơn cá nhân";
                ThucDonCaNhanBUS tdcnBus = new ThucDonCaNhanBUS();
                ThucDonCaNhanDTO tdcnDto = tdcnBus.ChiTietThucDonCaNhan(ctdh.Ma_item);
                if (tdcnDto != null)
                {
                    ten = tdcnDto.Ten_thuc_don;
                }
                else
                {
                    ten = "Thực đơn cá nhân này không tồn tại";
                }
                break;
            }

            // Tên món hoặc tên thực đơn
            Thuoc_tinh = new XL_THUOC_TINH("Ten", ten);
            the.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            // Loại đơn hàng
            Thuoc_tinh = new XL_THUOC_TINH("LoaiItem", loai);
            the.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            // Số lượng
            Thuoc_tinh = new XL_THUOC_TINH("SoLuong", ctdh.So_luong.ToString());
            the.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            // Thành tiền
            Thuoc_tinh = new XL_THUOC_TINH("ThanhTien", ctdh.Thanh_tien.ToString());
            the.Danh_sach_thuoc_tinh.Add(Thuoc_tinh);

            kq.Danh_sach_the.Add(the);
        }

        XL_CHUOI.XuatXML(Response, kq.Chuoi());
    }
示例#3
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());
    }
示例#4
0
    public int ThemMonAn(MonAnDTO monan, String strTag)
    {
        MonAnBUS monanBUS = new MonAnBUS();

        return(monanBUS.ThemMonAn(monan, strTag));
    }
示例#5
0
    protected void TimKiem()
    {
        MonAnBUS  monanBUS = new MonAnBUS();
        ArrayList arr      = (ArrayList)Session["info"];

        MonAnDTO[] dsMonAn;
        if (arr.Count == 1)
        {
            string ten_mon = arr[0].ToString();
            dsMonAn = monanBUS.TimKiemMonAnTheoTen(ten_mon);
        }
        else
        {
            string ten_mon     = "";
            int    ma_loai_mon = -1;
            string tag         = "";
            double gia_min     = -1;
            double gia_max     = -1;

            if (arr[0].ToString() != "null")
            {
                ten_mon = arr[0].ToString();
            }
            if (arr[1].ToString() != "null")
            {
                ma_loai_mon = int.Parse(arr[1].ToString());
            }
            if (arr[2].ToString() != "null")
            {
                tag = arr[2].ToString();
            }
            if (arr[3].ToString() != "null")
            {
                gia_min = double.Parse(arr[3].ToString());
            }
            if (arr[4].ToString() != "null")
            {
                gia_max = double.Parse(arr[4].ToString());
            }

            dsMonAn = monanBUS.TimKiemMonAnNangCao(ten_mon, ma_loai_mon, tag, gia_min, gia_max);
        }

        XL_THE Kq = new XL_THE("DANH_SACH");

        for (int i = 0; i < dsMonAn.Length; i++)
        {
            XL_THE Kq1 = new XL_THE("MonAn");

            MonAnDTO MonAn = 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());
    }
示例#6
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());
    }
示例#7
0
        public bool Xoa(MonAnDTO ma)
        {
            bool re = nlDAL.Xoa(ma);

            return(re);
        }
示例#8
0
        public bool Sua(MonAnDTO ma)
        {
            bool re = nlDAL.Sua(ma);

            return(re);
        }
示例#9
0
        public bool Them(MonAnDTO ma)
        {
            bool re = nlDAL.Them(ma);

            return(re);
        }
 public static ArrayList layDanhSachNguyenLieuTheoMonAn(MonAnDTO monAn)
 {
     return(MonAnDAO.layDanhSachNguyenLieuTheoMonAn(monAn));
 }
示例#11
0
    public int ThemMonAn(MonAnDTO monan, String strTag)
    {
        MonAnDAO monanDAO = new MonAnDAO();

        return(monanDAO.ThemMonAn(monan, strTag));
    }