예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            stationRepeater.ItemDataBound += new RepeaterItemEventHandler(stationRepeater_ItemDataBound);

            if (!Page.IsPostBack)
            {
                StationTableAdapter stationAdapter = new StationTableAdapter();

                DollarSaverDB.StationDataTable stations = stationAdapter.GetActive();

                DollarSaverDB.StationDataTable activeSiteStations = new DollarSaverDB.StationDataTable();
                foreach (DollarSaverDB.StationRow station in stations)
                {
                    if (station.StationId != 1 && station.IsSiteActive)
                    {
                        activeSiteStations.ImportRow(station);
                    }
                }


                stationRepeater.DataSource = activeSiteStations.Rows;
                stationRepeater.DataBind();

                endYearLabel.Text = DateTime.Now.ToString("yyyy");
            }
        }
예제 #2
0
        private void BindData()
        {
            timerBottomLabel.Text = now.ToString("MM/dd/yyyy hh:mm:ss tt");

            bool inactive = Globals.ConvertToBool(Request.QueryString["inactive"]);

            DollarSaverDB.StationDataTable stations;

            if (inactive)
            {
                mainTimer.Enabled = false;

                activeLinkHolder.Visible       = true;
                inactiveLinkHolder.Visible     = false;
                headerCell.Attributes["class"] = "inactive_header";
                headerCell.InnerText           = "Inactive Stations";

                recentOrderHolder.Visible = false;

                StationTableAdapter stationAdapter = new StationTableAdapter();
                stations = stationAdapter.GetInactive();
            }
            else
            {
                activeLinkHolder.Visible   = false;
                inactiveLinkHolder.Visible = true;

                StationTableAdapter stationAdapter = new StationTableAdapter();
                stations = stationAdapter.GetActive();

                recentOrderHolder.Visible = true;
                OrderTableAdapter            orderAdapter = new OrderTableAdapter();
                DollarSaverDB.OrderDataTable recentOrders = orderAdapter.GetSuperRecent(15);
                recentOrderGrid.DataSource = recentOrders.Rows;
                recentOrderGrid.DataBind();
            }

            if (stations.Count > 0)
            {
                stationHolder.Visible    = true;
                noStationsHolder.Visible = false;

                stationGrid.DataSource = stations.Rows;
                stationGrid.DataBind();
            }
            else
            {
                stationHolder.Visible    = false;
                noStationsHolder.Visible = true;
            }
        }
예제 #3
0
        protected override void  OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            orderGrid.RowCommand += new GridViewCommandEventHandler(orderGrid_RowCommand);
            //orderGrid.PageIndexChanging += new GridViewPageEventHandler(orderGrid_PageIndexChanging);

            searchButton.Click += new EventHandler(searchButton_Click);

            if (!Page.IsPostBack)
            {
                StationTableAdapter            stationAdapter = new StationTableAdapter();
                DollarSaverDB.StationDataTable stations       = stationAdapter.GetActive();

                stationList.DataSource     = stations.Rows;
                stationList.DataTextField  = "ShortName";
                stationList.DataValueField = "Stationid";
                stationList.DataBind();

                stationList.Items.Insert(0, new ListItem("-- All Stations --", "0"));
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.RawUrl.StartsWith("/dollarsaver/index"))
                {
                    //Response.Redirect("~/Default.aspx?station_id=" + StationId);
                    DollarSaverRedirect("~/Default.aspx");
                }


                DateTime currentDate = DateTime.Now;
                currentDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day);

                StationTableAdapter stationAdapter = new StationTableAdapter();

                DollarSaverDB.StationRow station = stationAdapter.GetStation(StationId)[0];
                siteType = (SiteType)station.SiteTypeId;

                CertificateTableAdapter certificateAdapter = new CertificateTableAdapter();


                //stationNameLabel.Text = station.Name;
                if (!station.IsContent1Null())
                {
                    content1Label.Text = station.Content1;
                }

                if (!station.IsContent2Null())
                {
                    content2Label.Text = station.Content2;
                }

                String ImageDir = Request.PhysicalApplicationPath + station.ImageDirUrl;
                if (station.StationSiteType == SiteType.Standard)
                {
                    standardHolder.Visible = true;
                    dealHolder.Visible     = false;

                    signUpTopLink.NavigateUrl = GetUrl(signUpTopLink.NavigateUrl);

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

                    bool dailyHeader = false;
                    if (specialSettingsTable.Count == 1)
                    {
                        dailyHeader = specialSettingsTable[0].DailyHeader;
                    }

                    Image dailyWeeklyImage = new Image();

                    if (dailyHeader)
                    {
                        //dailyWeeklyImage.SkinID = "dailyImage";

                        if (!station.Content.IsDailyDealImageNull() && File.Exists(ImageDir + station.Content.DailyDealImage))
                        {
                            dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.DailyDealImage;
                        }
                        else
                        {
                            dailyWeeklyImage.ImageUrl = "~/images/boxtop_daily.gif";
                        }
                    }
                    else
                    {
                        //dailyWeeklyImage.SkinID = "weeklyImage";
                        if (!station.Content.IsWeeklyDealImageNull() && File.Exists(ImageDir + station.Content.WeeklyDealImage))
                        {
                            dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.WeeklyDealImage;
                        }
                        else
                        {
                            dailyWeeklyImage.ImageUrl = "~/images/boxtop_weekly.gif";
                        }
                    }

                    dailyWeeklyImageHolder.Controls.Add(dailyWeeklyImage);

                    DollarSaverDB.CertificateDataTable daily = certificateAdapter.GetSpecial(StationId, 1);
                    if (daily.Count == 1)
                    {
                        SpecialCert1.DisplayCertificate = daily[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, daily[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert2 = certificateAdapter.GetSpecial(StationId, 2);
                    if (cert2.Count == 1)
                    {
                        SpecialCert2.DisplayCertificate = cert2[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert2[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert3 = certificateAdapter.GetSpecial(StationId, 3);
                    if (cert3.Count == 1)
                    {
                        SpecialCert3.DisplayCertificate = cert3[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert3[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    DollarSaverDB.CertificateDataTable cert4 = certificateAdapter.GetSpecial(StationId, 4);
                    if (cert4.Count == 1)
                    {
                        SpecialCert4.DisplayCertificate = cert4[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, cert4[0].CertificateId, PageHitType.HomePage);
                        }
                    }

                    if (!station.Content.IsOtherDealsImageNull() && File.Exists(ImageDir + station.Content.OtherDealsImage))
                    {
                        otherDealsImage.ImageUrl = station.ImageDirUrl + station.Content.OtherDealsImage;
                    }

                    if (!station.Content.IsLogoImageNull() && File.Exists(ImageDir + station.Content.LogoImage))
                    {
                        logoImage.ImageUrl = station.ImageDirUrl + station.Content.LogoImage;
                    }
                }
                else     // Deal of the Week
                {
                    standardHolder.Visible = false;
                    dealHolder.Visible     = true;

                    if (!Station.IsSiteNameNull() && Station.SiteName != String.Empty)
                    {
                        dotwStationNameLabel.Text = Regex.Replace(Station.SiteName, "<[^>]+>", "");
                    }
                    else
                    {
                        dotwStationNameLabel.Text = "DollarSaver Deal of the Week";
                    }

                    if (!Station.Content.IsDotwSubheaderImageNull() && File.Exists(ImageDir + station.Content.DotwSubheaderImage))
                    {
                        subheaderCell.Style["background-image"] = "url(" + station.ImageDirUrl + station.Content.DotwSubheaderImage + ")";
                    }
                    else
                    {
                        subheaderCell.Style["background-image"] = "url(" + ResolveUrl("~/images/dotw_background.gif") + ")";
                    }

                    DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId);

                    if (certificateTable.Count == 1)
                    {
                        dealOfTheWeek.Deal = certificateTable[0];
                        if (HitCounterEnabled)
                        {
                            LogHit(currentDate, certificateTable[0].CertificateId, PageHitType.HomePage);
                        }
                    }
                }
            }
        }
        void loginButton_Click(object sender, EventArgs e)
        {
            String username = usernameBox.Text.Trim();
            String password = passwordBox.Text;

            //int stationId = Int32.Parse(stationList.SelectedValue);


            StationTableAdapter stationAdapter = new StationTableAdapter();

            String stationCode = stationCodeBox.Text.Trim().ToUpper();

            int stationId = 0;

            if (stationCode != String.Empty)
            {
                DollarSaverDB.StationDataTable stationLookup = stationAdapter.GetByCode(stationCode);

                if (stationLookup.Count != 1 || !stationLookup[0].IsActive)
                {
                    errorMessage = "Incorrect username, password or station";
                    return;
                }

                stationId = stationLookup[0].StationId;
            }


            AdminTableAdapter adminAdapter = new AdminTableAdapter();

            if ((int)adminAdapter.Authenticate(stationId, username, password) == 1)
            {
                DollarSaverDB.AdminRow user = adminAdapter.GetByUsername(stationId, username)[0];

                user.LastAccessDate = DateTime.Now;
                adminAdapter.Update(user);

                int userStationId;
                if (user.Role == AdminRole.Root)
                {
                    userStationId = 0;
                }
                else
                {
                    userStationId = stationId;
                }
                Session["admin_station_id"] = userStationId;

                HttpCookie cookie = Request.Cookies.Get(ADMIN_COOKIE_NAME);

                if (cookie == null)
                {
                    cookie = new HttpCookie(ADMIN_COOKIE_NAME);
                }

                cookie.Expires = DateTime.Now.AddYears(10);
                if (IsDev)
                {
                    cookie.Domain = EnvDomain;
                }
                else
                {
                    cookie.Domain = ".dollarsavershow.com";
                }

                cookie["station_id"]   = userStationId.ToString();
                cookie["station_code"] = stationCode;

                HttpContext.Current.Response.Cookies.Add(cookie);

                FormsAuthentication.SetAuthCookie(user.AdminId.ToString(), true);

                if (user.Role == AdminRole.Root)
                {
                    if (stationId == 0)
                    {
                        Response.Redirect("~/admin/super/", false);
                    }
                    else
                    {
                        Response.Redirect("~/admin/Default.aspx?station_id=" + stationId, false);
                    }
                }
                else
                {
                    Response.Redirect("~/admin/", false);
                }
            }
            else
            {
                errorMessage = "Incorrect username, password or station";
            }
        }
        private void parameterRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                DollarSaverDB.ParameterRow parameter = (DollarSaverDB.ParameterRow)e.Item.DataItem;

                HiddenField paramIdHidden = (HiddenField)e.Item.FindControl("paramIdHidden");
                paramIdHidden.Value = parameter.ParameterId.ToString();

                Label paramNameLabel = (Label)e.Item.FindControl("paramNameLabel");
                paramNameLabel.Text = parameter.Name;

                Label paramTypeLabel = (Label)e.Item.FindControl("paramTypeLabel");
                //paramTypeLabel.Text = parameter.ParameterType.Name;



                PlaceHolder validatorHolder = (PlaceHolder)e.Item.FindControl("validatorHolder");

                RegularExpressionValidator rev;
                RequiredFieldValidator     rfv;



                paramNameLabel.Text = parameter.Name;
                HiddenField  paramValueHidden = (HiddenField)e.Item.FindControl("paramValueHidden");
                Label        paramValueLabel  = (Label)e.Item.FindControl("paramValueLabel");
                TextBox      paramValueBox    = (TextBox)e.Item.FindControl("paramValueBox");
                CheckBox     paramCheckBox    = (CheckBox)e.Item.FindControl("paramCheckBox");
                ListBox      paramList        = (ListBox)e.Item.FindControl("paramList");
                PlaceHolder  timeHolder       = (PlaceHolder)e.Item.FindControl("timeHolder");
                DropDownList hourList         = (DropDownList)e.Item.FindControl("hourList");
                DropDownList minuteList       = (DropDownList)e.Item.FindControl("minuteList");


                switch (parameter.ParameterTypeId)
                {
                case 1:
                    // bit
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = false;
                    paramCheckBox.Visible   = true;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramCheckBox.Checked = true;

                    if (parameter.Description != string.Empty)
                    {
                        paramTypeLabel.Text = " " + parameter.Description;
                    }

                    break;

                case 2:
                    // date
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramValueBox.Columns   = 10;
                    paramValueBox.MaxLength = 12;



                    // default value hacking..
                    if (parameter.Name.ToUpper().Trim() == "START DATE")
                    {
                        DateTime startDate = DateTime.Now;
                        startDate = startDate.AddMonths(-1);
                        startDate = new DateTime(startDate.Year, startDate.Month, 1);

                        paramValueBox.Text = startDate.ToString("MM/dd/yyyy");
                    }
                    else if (parameter.Name.ToUpper().Trim() == "END DATE")
                    {
                        DateTime startDate = DateTime.Now;
                        startDate = startDate.AddMonths(-1);
                        startDate = new DateTime(startDate.Year, startDate.Month, 1);
                        DateTime endDate = startDate.AddMonths(1).AddDays(-1);

                        paramValueBox.Text = endDate.ToString("MM/dd/yyyy");
                    }


                    Image calendarImage = (Image)e.Item.FindControl("calendarImage");
                    calendarImage.Visible  = true;
                    calendarImage.ImageUrl = "~/images/calendar_button.gif";
                    calendarImage.Attributes["OnClick"] = "showCalendarControl('" + paramValueBox.ClientID + "');";
                    //paramValueBox.Attributes["onblur"] = "hideCalendarControl();";

                    rev = GenerateDateREV(paramValueBox);
                    validatorHolder.Controls.Add(rev);

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);

                    paramTypeLabel.Text = " (MM/DD/YYYY)";


                    break;

                case 3:
                    // decimal

                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramValueBox.Columns   = 12;
                    paramValueBox.MaxLength = 20;

                    rev = GenerateDecimalREV(paramValueBox);
                    validatorHolder.Controls.Add(rev);

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);


                    if (parameter.Description != string.Empty)
                    {
                        paramTypeLabel.Text = " " + parameter.Description;
                    }

                    break;

                case 4:
                    // int

                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramValueBox.Columns   = 12;
                    paramValueBox.MaxLength = 20;

                    rev = GenerateIntREV(paramValueBox);
                    validatorHolder.Controls.Add(rev);

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);

                    if (parameter.Description != string.Empty)
                    {
                        paramTypeLabel.Text = " " + parameter.Description;
                    }

                    break;

                case 5:
                    // varchar
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramValueBox.Columns   = 20;
                    paramValueBox.MaxLength = 50;

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);

                    if (parameter.Description != string.Empty)
                    {
                        paramTypeLabel.Text = " " + parameter.Description;
                    }

                    break;

                case 6:
                    // Station
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = false;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = true;
                    timeHolder.Visible      = false;


                    StationTableAdapter            adapter  = new StationTableAdapter();
                    DollarSaverDB.StationDataTable stations = adapter.GetStations();


                    paramList.DataSource     = stations;
                    paramList.DataTextField  = "Name";
                    paramList.DataValueField = "StationId";
                    paramList.DataBind();


                    break;

                case 7:
                    // Char
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = false;

                    paramValueBox.Columns   = 20;
                    paramValueBox.MaxLength = 50;

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);

                    if (parameter.Description != string.Empty)
                    {
                        paramTypeLabel.Text = " " + parameter.Description;
                    }

                    break;

                case 8:
                    // Date and Time
                    paramValueLabel.Visible = false;
                    paramValueBox.Visible   = true;
                    paramCheckBox.Visible   = false;
                    paramList.Visible       = false;
                    timeHolder.Visible      = true;

                    for (int i = 0; i < 24; i++)
                    {
                        hourList.Items.Add(i.ToString("00"));
                    }

                    for (int i = 0; i < 60; i++)
                    {
                        minuteList.Items.Add(i.ToString("00"));
                    }

                    paramValueBox.Columns   = 10;
                    paramValueBox.MaxLength = 12;

                    /*
                     * if(reportToRun.TypeId == 2) { // MAC reports only
                     *  if(parameter.Name.ToUpper().Trim() == "START DATE") {
                     *      DateTime startDate = DateTime.Now;
                     *      while(startDate.DayOfWeek != DayOfWeek.Saturday) {
                     *          startDate = startDate.AddDays(-1);
                     *      }
                     *      paramValueBox.Text = startDate.ToString("MM/dd/yyyy");
                     *  } else if (parameter.Name.ToUpper().Trim() == "END DATE") {
                     *      paramValueBox.Text = DateTime.Now.ToString("MM/dd/yyyy");
                     *  }
                     * }
                     * */

                    Image calendarImage2 = (Image)e.Item.FindControl("calendarImage");
                    calendarImage2.Visible  = true;
                    calendarImage2.ImageUrl = "~/images/calendar_button.gif";
                    calendarImage2.Attributes["OnClick"] = "showCalendarControl('" + paramValueBox.ClientID + "');";
                    //paramValueBox.Attributes["onblur"] = "hideCalendarControl();";

                    rev = GenerateDateREV(paramValueBox);
                    validatorHolder.Controls.Add(rev);

                    rfv = GenerateRFV(paramValueBox);
                    validatorHolder.Controls.Add(rfv);

                    paramTypeLabel.Text = " (MM/DD/YYYY HH:MM)";


                    break;

                default:
                    throw new Exception("ERROR: Unknown Parameter Type");
                }
            }
        }
        void saveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                StationTableAdapter stationAdapter = new StationTableAdapter();

                String name          = nameBox.Text.Trim();
                int    siteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                int    stationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                String phoneNumber   = phoneNumberBox.Text.Trim();
                String address1      = address1Box.Text.Trim();
                String address2      = address2Box.Text.Trim();
                String city          = cityBox.Text.Trim();
                String stateCode     = stateList.SelectedValue;
                String zipCode       = zipCodeBox.Text.Trim();
                int    timeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                //bool affectedByDST = daylightSavingsBox.Checked;
                String stationUrl = stationUrlBox.Text.Trim();
                String siteName   = siteNameBox.Text.Trim();
                String content1   = content1Box.Text.Trim();
                String content2   = content2Box.Text.Trim();
                //bool isActive = isActiveBox.Checked;

                if (name == String.Empty)
                {
                    ErrorMessage = "Name is required";
                    return;
                }


                if (phoneNumber == String.Empty)
                {
                    ErrorMessage = "Phone Number is required";
                    return;
                }

                if (address1 == String.Empty)
                {
                    ErrorMessage = "Address 1 is required";
                    return;
                }

                if (city == String.Empty)
                {
                    ErrorMessage = "City is required";
                    return;
                }

                if (zipCode == String.Empty)
                {
                    ErrorMessage = "Zip Code is required";
                    return;
                }

                if (stationUrl != String.Empty)
                {
                    stationUrl = stationUrlStart.SelectedValue + stationUrl;

                    // come up with a better validation...
                    if (!Uri.IsWellFormedUriString(stationUrl, UriKind.Absolute))
                    {
                        ErrorMessage = "Please enter a valid Station Website";
                        return;
                    }
                }

                if (stationUrl.Length > 500)
                {
                    stationUrl = stationUrl.Substring(0, 500);
                }

                /*
                 * if (content1 == String.Empty) {
                 *  ErrorMessage = "Content 1 is required";
                 *  return;
                 * }*/

                if (content1.Length > 1000)
                {
                    content1 = content1.Substring(0, 1000);
                }


                /*
                 * if (content2 == String.Empty) {
                 *  ErrorMessage = "Content 2 is required";
                 *  return;
                 * }*/

                if (content2.Length > 1000)
                {
                    content2 = content2.Substring(0, 1000);
                }

                siteName = siteName.Replace("<br />", "");

                if (siteName.Length > 500)
                {
                    siteName = siteName.Substring(0, 500);
                }

                String siteNameCheck = Regex.Replace(siteName, "<[^>]+>", "").Replace("&nbsp;", "").Trim();

                if (siteNameCheck == String.Empty)   // only leftover formatting in site name
                {
                    siteName = String.Empty;
                }

                if (Station != null)
                {
                    Station.Name          = name;
                    Station.SiteTypeId    = Int32.Parse(siteTypeList.SelectedValue);
                    Station.StationTypeId = Int32.Parse(stationTypeList.SelectedValue);
                    Station.PhoneNumber   = phoneNumber;
                    Station.Address1      = address1;
                    Station.Address2      = address2;
                    Station.City          = city;
                    Station.StateCode     = stateList.SelectedValue;
                    Station.ZipCode       = zipCode;
                    Station.TimeZoneId    = Int32.Parse(timeZoneList.SelectedValue);
                    //Station.AffectedByDST = daylightSavingsBox.Checked;
                    if (stationUrl != String.Empty)
                    {
                        Station.StationUrl = stationUrl;
                    }
                    else
                    {
                        Station.SetStationUrlNull();
                    }

                    if (siteName != String.Empty)
                    {
                        Station.SiteName = siteName;
                    }
                    else
                    {
                        Station.SetSiteNameNull();
                    }

                    Station.Content1 = content1;
                    Station.Content2 = content2;
                    //Station.IsActive = isActiveBox.Checked;
                    Station.IsSiteActive = isSiteActiveBox.Checked;

                    stationAdapter.Update(Station);
                    InfoMessage = "Station Updated";
                }
                else
                {
                    if (IsSuperAdmin)
                    {
                        String code = codeBox.Text.Trim().ToUpper();

                        if (code == String.Empty)
                        {
                            ErrorMessage = "Code is required";
                            return;
                        }

                        if (code.Length < 3 || code.Length > 20)
                        {
                            ErrorMessage = "Code must be between 3 and 20 characters";
                            return;
                        }

                        DollarSaverDB.StationDataTable stationCodeLookup = stationAdapter.GetByCode(code);

                        if (stationCodeLookup.Count == 1 && (Station == null || stationCodeLookup[0].StationId != Station.StationId))
                        {
                            InfoMessage = "Code is already in use";
                            return;
                        }

                        int stationId = Convert.ToInt32(stationAdapter.InsertPK(name, code, stationTypeId, siteTypeId, phoneNumber, address1, address2,
                                                                                city, stateCode, zipCode, timeZoneId, false, DateTime.Now, DateTime.Now, true,
                                                                                content1, content2, Globals.ConvertToNull(stationUrl), Globals.ConvertToNull(siteName), isSiteActiveBox.Checked, null));

                        Station = stationAdapter.GetStation(stationId)[0];

                        CategoryTableAdapter categoryAdapter = new CategoryTableAdapter();
                        categoryAdapter.Insert(stationId, null, "Restaurants & Food", 1);
                        categoryAdapter.Insert(stationId, null, "Things To Do", 2);
                        categoryAdapter.Insert(stationId, null, "Home & Garden", 3);
                        categoryAdapter.Insert(stationId, null, "Health & Beauty", 4);
                        categoryAdapter.Insert(stationId, null, "Retail", 5);
                        categoryAdapter.Insert(stationId, null, "Automotive", 6);

                        StationContentTableAdapter stationContentTableAdapter = new StationContentTableAdapter();
                        stationContentTableAdapter.Insert(stationId, null, null, null, null, null, null, null, null, null);

                        DealSettingsTableAdapter dealSettingsAdapter = new DealSettingsTableAdapter();
                        dealSettingsAdapter.Insert(stationId, 1, 8, 4, 10);

                        SpecialSettingsTableAdapter specialSettingAdapter = new SpecialSettingsTableAdapter();
                        specialSettingAdapter.Insert(stationId, true);

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.StationDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.StationDirUrl);
                        }

                        if (!Directory.Exists(Request.PhysicalApplicationPath + Station.ImageDirUrl))
                        {
                            Directory.CreateDirectory(Request.PhysicalApplicationPath + Station.ImageDirUrl);
                        }
                    }
                }

                RedirectToHomePage();
            }
        }