コード例 #1
0
        private void BindData()
        {
            //DealTableAdapter dealAdapter = new DealTableAdapter();
            //DollarSaverDB.DealDataTable deals = dealAdapter.GetByStation(StationId);

            CertificateTableAdapter certificateAdapter = new CertificateTableAdapter();

            DollarSaverDB.CertificateDataTable certificates = certificateAdapter.GetActive(StationId);

            certificates.DefaultView.Sort = "OnSaleDate DESC";

            //certificates = (DollarSaverDB.CertificateDataTable) certificates.DefaultView.ToTable();

            if (certificates.Count > 0)
            {
                //startDate = deals[0].StartDate;

                DollarSaverDB.CertificateDataTable c = new DollarSaverDB.CertificateDataTable();

                foreach (DataRow row in certificates.DefaultView.ToTable().Rows)
                {
                    c.ImportRow(row);
                }

                dealHolder.Visible   = true;
                noDealHolder.Visible = false;
                //dealGrid.DataSource = ((DollarSaverDB.CertificateDataTable)certificates.DefaultView.ToTable()).Rows;
                dealGrid.DataSource = c.Rows;

                dealGrid.DataBind();
            }
            else
            {
                dealHolder.Visible   = false;
                noDealHolder.Visible = true;
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            saveButton.Click   += new EventHandler(saveButton_Click);
            cancelButton.Click += new EventHandler(cancelButton_Click);


            if (Station.SiteTypeId != (int)SiteType.Standard)
            {
                Response.Redirect("~/admin/Default.aspx");
            }

            specialTable = specialAdapter.GetStationSpecial(StationId, 1);
            if (specialTable.Count == 1)
            {
                specialOne = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 2);
            if (specialTable.Count == 1)
            {
                specialTwo = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 3);
            if (specialTable.Count == 1)
            {
                specialThree = specialTable[0];
            }
            specialTable = specialAdapter.GetStationSpecial(StationId, 4);
            if (specialTable.Count == 1)
            {
                specialFour = specialTable[0];
            }

            if (!Page.IsPostBack)
            {
                CategoryTableAdapter            categoryAdapter = new CategoryTableAdapter();
                DollarSaverDB.CategoryDataTable categories      = categoryAdapter.GetPrimaryCategoriesByStation(StationId);

                CertificateTableAdapter            certificateAdapter = new CertificateTableAdapter();
                DollarSaverDB.CertificateDataTable certificates       = certificateAdapter.GetActive(StationId);

                //certificates.DefaultView.Sort

                SpecialSettingsTableAdapter            specialSettingsAdapter = new SpecialSettingsTableAdapter();
                DollarSaverDB.SpecialSettingsDataTable specialSettingsTable   = specialSettingsAdapter.GetSpecialSettings(StationId);

                if (specialSettingsTable.Count == 1)
                {
                    if (specialSettingsTable[0].DailyHeader)
                    {
                        dailyWeeklyList.SelectedValue = "1";
                    }
                    else
                    {
                        dailyWeeklyList.SelectedValue = "2";
                    }
                }

                // Daily/Weekly Special 1

                /*
                 * specialOneCategoryList.DataSource = categories;
                 * specialOneCategoryList.DataTextField = "Name";
                 * specialOneCategoryList.DataValueField = "CategoryId";
                 * specialOneCategoryList.DataBind();
                 */

                specialOneCertificateList.DataSource     = certificates.Rows;
                specialOneCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialOneCertificateList.DataValueField = "CertificateId";
                specialOneCertificateList.DataBind();


                if (specialOne != null)
                {
                    if (!specialOne.IsCertificateIdNull())
                    {
                        //specialOneCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialOne.CertificateId) != null)
                        {
                            specialOneCertificateList.SelectedValue = specialOne.CertificateId.ToString();
                        }
                    }

                    /*
                     * else if (!specialOne.IsCategoryIdNull()) {
                     *  specialOneCategoryBox.Checked = true;
                     *
                     *  specialOneCategoryList.SelectedValue = specialOne.CategoryId.ToString();
                     * } else {
                     *  specialOneRandomBox.Checked = true;
                     * }
                     */
                }

                // Special 2
                specialTwoCategoryList.DataSource     = categories;
                specialTwoCategoryList.DataTextField  = "Name";
                specialTwoCategoryList.DataValueField = "CategoryId";
                specialTwoCategoryList.DataBind();

                specialTwoCertificateList.DataSource     = certificates.Rows;
                specialTwoCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialTwoCertificateList.DataValueField = "CertificateId";
                specialTwoCertificateList.DataBind();

                if (specialTwo != null)
                {
                    if (!specialTwo.IsCertificateIdNull())
                    {
                        specialTwoCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialTwo.CertificateId) != null)
                        {
                            specialTwoCertificateList.SelectedValue = specialTwo.CertificateId.ToString();
                        }
                    }
                    else if (!specialTwo.IsCategoryIdNull())
                    {
                        specialTwoCategoryBox.Checked = true;

                        specialTwoCategoryList.SelectedValue = specialTwo.CategoryId.ToString();
                    }
                    else
                    {
                        specialTwoRandomBox.Checked = true;
                    }
                }


                // Special 3
                specialThreeCategoryList.DataSource     = categories;
                specialThreeCategoryList.DataTextField  = "Name";
                specialThreeCategoryList.DataValueField = "CategoryId";
                specialThreeCategoryList.DataBind();

                specialThreeCertificateList.DataSource     = certificates.Rows;
                specialThreeCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialThreeCertificateList.DataValueField = "CertificateId";
                specialThreeCertificateList.DataBind();

                if (specialThree != null)
                {
                    if (!specialThree.IsCertificateIdNull())
                    {
                        specialThreeCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialThree.CertificateId) != null)
                        {
                            specialThreeCertificateList.SelectedValue = specialThree.CertificateId.ToString();
                        }
                    }
                    else if (!specialThree.IsCategoryIdNull())
                    {
                        specialThreeCategoryBox.Checked = true;

                        specialThreeCategoryList.SelectedValue = specialThree.CategoryId.ToString();
                    }
                    else
                    {
                        specialThreeRandomBox.Checked = true;
                    }
                }

                // Special 4
                specialFourCategoryList.DataSource     = categories;
                specialFourCategoryList.DataTextField  = "Name";
                specialFourCategoryList.DataValueField = "CategoryId";
                specialFourCategoryList.DataBind();

                specialFourCertificateList.DataSource     = certificates.Rows;
                specialFourCertificateList.DataTextField  = "AdvertiserAndCertificate";
                specialFourCertificateList.DataValueField = "CertificateId";
                specialFourCertificateList.DataBind();

                if (specialFour != null)
                {
                    if (!specialFour.IsCertificateIdNull())
                    {
                        specialFourCertificateBox.Checked = true;

                        if (certificates.FindByCertificateId(specialFour.CertificateId) != null)
                        {
                            specialFourCertificateList.SelectedValue = specialFour.CertificateId.ToString();
                        }
                    }
                    else if (!specialFour.IsCategoryIdNull())
                    {
                        specialFourCategoryBox.Checked = true;

                        specialFourCategoryList.SelectedValue = specialFour.CategoryId.ToString();
                    }
                    else
                    {
                        specialFourRandomBox.Checked = true;
                    }
                }
            }
        }