Ejemplo n.º 1
0
        public static void initComboMonAnTheoPhanLoai(ComboBox cb_loaiMonAn, ComboBox cb)
        {
            ArrayList ds = new ArrayList();

            ds = PhanLoaiMonAnBUS.layDanhSachMonAnTheoPhanLoaiMonAn((LoaiMonAnDTO)cb_loaiMonAn.SelectedItem, GlobalVariables.maNhaHang);
            cb.Items.Clear();
            if (ds.Count == 0)
            {
                cb.Text    = "Không có";
                cb.Enabled = false;
                return;
            }
            cb.Enabled = true;
            PhanLoaiMonAnDTO plMA = new PhanLoaiMonAnDTO();

            plMA.MonAn          = new MonAnDTO();
            plMA.MonAn.TenMonAn = "Tất cả";
            plMA.MonAn.MaMonAn  = 0;

            cb.Items.Add(plMA);
            for (int i = 0; i < ds.Count; i++)
            {
                plMA = new PhanLoaiMonAnDTO();
                plMA = (PhanLoaiMonAnDTO)ds[i];
                cb.Items.Add(plMA);
            }
            cb.SelectedIndex = 0;
        }
Ejemplo n.º 2
0
        public static ArrayList layDanhSachMonAnTheoPhanLoaiMonAn(LoaiMonAnDTO loaiMonAn, int maNhaHang)
        {
            DbCommand command = DataAccessCode.CreateCommand();

            command.CommandText = "dbo.LayDanhSachMonAnTheoPhanLoaiMonAn";
            DbParameter param = command.CreateParameter();

            param.ParameterName = "@MaNhaHang";
            param.Value         = maNhaHang;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            param = command.CreateParameter();
            param.ParameterName = "@MaLoaiMonAn";
            param.Value         = loaiMonAn.MaLoaiMonAn;
            param.DbType        = DbType.Int32;
            command.Parameters.Add(param);

            DataTable dt   = DataAccessCode.ExecuteSelectCommand(command);
            ArrayList list = new ArrayList();

            if (dt != null)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    PhanLoaiMonAnDTO plMA = new PhanLoaiMonAnDTO();
                    plMA.LoaiMonAn.MaLoaiMonAn = Convert.ToInt32(dt.Rows[i]["MaLoaiMonAn"]);
                    plMA.MonAn.MaMonAn         = Convert.ToInt32(dt.Rows[i]["MaMonAn"]);
                    plMA.MonAn.TenMonAn        = dt.Rows[i]["TenMonAn"].ToString();
                    plMA.NhaHang.MaNhaHang     = maNhaHang;
                    list.Add(plMA);
                }
            }
            return(list);
        }