コード例 #1
0
    protected void CancelEventButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        int    eventId = Convert.ToInt32(IdHiddenField.Value);
        string notes   = NotesTextBox.Text.Trim();

        try
        {
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();

            scheduleService.CancelEvent(eventId, notes, loginInfo.UserId);

            CancelButton_Click(BackButton, new EventArgs());
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #2
0
    protected void CompleteEventButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        int    eventId         = Convert.ToInt32(IdHiddenField.Value);
        string mailingListFile = string.Empty;
        string remarks         = RemarksTextBox.Text.Trim();
        int    mailingCount    = Convert.ToInt32(MailingCountTextBox.Text);

        try
        {
            // Get the upload location.
            string path = Server.MapPath("~/Members/MailingLists");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            // Validate mailing list file.
            if (MailingListFileUpload.HasFile)
            {
                if (!(MailingListFileUpload.FileName.ToLower().EndsWith(".xls") ||
                      MailingListFileUpload.FileName.ToLower().EndsWith(".csv")))
                {
                    ErrorMessageLabel.Text    = "Enter a valid Mailing List File (.xls and .csv only).";
                    ErrorMessageLabel.Visible = true;

                    return;
                }
            }

            // Upload the file.
            if (MailingListFileUpload.HasFile)
            {
                mailingListFile = eventId + "_" + MailingListFileUpload.FileName;

                MailingListFileUpload.SaveAs(path + "\\" + mailingListFile);
            }

            // Save the data.
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();

            scheduleService.CompleteEvent(eventId, mailingListFile, remarks,
                                          mailingCount, loginInfo.UserId);

            CancelButton_Click(BackButton, new EventArgs());
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int      farmId    = Convert.ToInt32(coll.Get("farmId"));
        DateTime startDate = Convert.ToDateTime(coll.Get("start_date"));

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            FarmIdHiddenField.Value    = farmId.ToString();
            StartDateHiddenField.Value = startDate.ToString("MM/dd/yyyy");

            try
            {
                // Get the farm details and display.
                FarmService.FarmService farmService = serviceLoader.GetFarm();
                FarmService.FarmInfo    farm        = farmService.GetFarmDetail(farmId);

                FarmNameLabel.Text     = farm.FarmName;
                PlotCountLabel.Text    = farm.PlotCount.ToString();
                ContactCountLabel.Text = farm.ContactCount.ToString();
                int planId = farm.MailingPlan.MailingPlanId;
                PlanIdHiddenField.Value = planId.ToString();
                MailingPlanLabel.Text   = farm.MailingPlan.Title;
                CreatedOnLabel.Text     = farm.CreateDate.ToString("MM/dd/yyyy");

                // Get the scheduled events and display.
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                IList <ScheduleService.ScheduleEventInfo> events =
                    scheduleService.GetPlanEvents(planId, startDate);

                EventsDataGrid.DataSource = events;
                EventsDataGrid.DataBind();
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        if (!IsPostBack)
        {
            // Get the query string values.
            NameValueCollection coll = Request.QueryString;

            int    agentId    = Convert.ToInt32(coll.Get("aId"));
            string eventType  = coll.Get("rType");
            string planStatus = coll.Get("mPlan");
            string startDate  = string.Empty;
            string endDate    = string.Empty;

            if (coll.Get("sDate") != "" && coll.Get("sDate") != null)
            {
                startDate = coll.Get("sDate");
            }

            if (coll.Get("eDate") != "" && coll.Get("eDate") != null)
            {
                endDate = coll.Get("eDate");
            }

            // Set the report viewer control's size.
            ReportViewerControl.ReportWidth  = 875;
            ReportViewerControl.ReportHeight = 615;

            // Get the report data.
            try
            {
                ScheduleService.ScheduleService             scheduleService = serviceLoader.GetSchedule();
                IList <ScheduleService.ScheduleSummaryInfo> schedules       =
                    scheduleService.GetSchedulesReportSummary(agentId, eventType,
                                                              planStatus, startDate, endDate);

                ReportViewerControl.DataSource     = schedules;
                ReportViewerControl.DataSourceName = "ScheduleSummaryInfo";
                ReportViewerControl.ReportPath     = "Members/Reports/ScheduleManagementReport.rdlc";
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #5
0
    private void DisplayMailingPlans(int agentId, ScheduleService.PlanType planType)
    {
        try
        {
            ScheduleService.ScheduleService      scheduleService = serviceLoader.GetSchedule();
            IList <ScheduleService.ScheduleInfo> schedules       =
                scheduleService.GetMailingPlans(agentId, planType);

            if (schedules.Count == 0)
            {
                ActivePlansDataGrid.AllowPaging = false;
            }
            else
            {
                if (schedules.Count > ActivePlansDataGrid.PageSize)
                {
                    ActivePlansDataGrid.AllowPaging = true;
                }
                else
                {
                    ActivePlansDataGrid.AllowPaging = false;
                }

                ActivePlansDataGrid.CurrentPageIndex =
                    Convert.ToInt32(PageNumberHiddenField.Value);
            }

            ActivePlansDataGrid.DataSource = schedules;
            ActivePlansDataGrid.DataBind();

            if (schedules.Count == 0)
            {
                NoRecordsTable.Visible = true;
            }
            else
            {
                NoRecordsTable.Visible = false;
            }
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        if (!IsPostBack)
        {
            // Get the query string values.
            NameValueCollection coll = Request.QueryString;

            int    agentId   = Convert.ToInt32(coll.Get("aId"));
            string planType  = coll.Get("pType");
            string eventType = coll.Get("eType");
            string startDate = coll.Get("sDate");
            string endDate   = coll.Get("eDate");

            // Set the report viewer control's size.
            ReportViewerControl.ReportWidth  = 875;
            ReportViewerControl.ReportHeight = 615;

            // Get the report data.
            try
            {
                string urlPath = Request.Url.OriginalString;

                urlPath = urlPath.Substring(0, urlPath.IndexOf("Members/")) +
                          "Members/UserData/";

                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                IList <ScheduleService.ScheduleSummaryInfo> schedules =
                    scheduleService.GetScheduleEventsReportSummary(agentId,
                                                                   planType, eventType, startDate, endDate, urlPath);

                ReportViewerControl.DataSource     = schedules;
                ReportViewerControl.DataSourceName = "ScheduleSummaryInfo";
                ReportViewerControl.ReportPath     = "Members/Reports/ScheduleEventsReport.rdlc";
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #7
0
    protected void MessageTypeDropDownList_Changed(object sender, EventArgs e)
    {
        try
        {
            int messageType = Convert.ToInt32(MessageTypeDropDownList.SelectedValue);

            if (messageType == (int)MessageType.Standard)
            {
                MessageService.MessageService messageService =
                    serviceLoader.GetMessage();

                MessageDropDownList.DataSource =
                    messageService.GetStandardMessageList(true, string.Empty, string.Empty);

                MessageDropDownList.DataValueField = "MessageId";
                MessageDropDownList.DataTextField  = "ShortDesc";
            }
            else
            {
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();

                MessageDropDownList.DataSource =
                    scheduleService.GetActiveCustomMessages(Convert.ToInt32(AgentIdHiddenField.Value));

                MessageDropDownList.DataValueField = "MessageId";
                MessageDropDownList.DataTextField  = "MessageTextShort";
            }

            MessageDropDownList.DataBind();

            MessageDropDownList.Items.Insert(0, new ListItem("<Select a Message>", "-1"));

            MessageDropDownList_Changed(MessageDropDownList, new EventArgs());
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #8
0
    protected void FirmUpButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        // Get the required data.
        int      farmId    = Convert.ToInt32(FarmIdHiddenField.Value);
        int      planId    = Convert.ToInt32(PlanIdHiddenField.Value);
        DateTime startDate = Convert.ToDateTime(StartDateHiddenField.Value);
        int      userId    = loginInfo.UserId;

        try
        {
            // Save the data.
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();

            scheduleService.FirmUp(farmId, planId, startDate, userId);

            try
            {
                Util.Schedule.SendEmailAsFirmedUp(FarmNameLabel.Text,
                                                  MailingPlanLabel.Text, startDate, loginInfo.FirstName,
                                                  loginInfo.LastName, Request.ApplicationPath);
            }
            catch (Exception ex)
            {
                log.Error("Unknown Error", ex);
            }

            string queryString = "?farmId=" + FarmIdHiddenField.Value;

            Response.Redirect("~/Members/ViewFarm.aspx" + queryString, true);
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #9
0
    protected void MessageDropDownList_Changed(object sender, EventArgs e)
    {
        try
        {
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();
            int messageId = Convert.ToInt32(MessageDropDownList.SelectedValue);

            if (messageId == -1)
            {
                MessageImagePanel.Visible = false;
                MessageTextPanel.Visible  = true;
                MessageTextLiteral.Text   = string.Empty;
            }
            else
            {
                ScheduleService.MessageInfo message = scheduleService.GetMessage(messageId,
                                                                                 Convert.ToInt32(AgentIdHiddenField.Value));

                if (message.IsImage)
                {
                    MessageTextPanel.Visible  = false;
                    MessageImagePanel.Visible = true;
                    MessageTextImage.ImageUrl = "/website/CustomMessage/" + message.FileName;
                }
                else
                {
                    MessageImagePanel.Visible = false;
                    MessageTextPanel.Visible  = true;
                    MessageTextLiteral.Text   = message.MessageText;
                }
            }
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #10
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        int    eventId      = Convert.ToInt32(IdHiddenField.Value);
        string postalTariff = PostalTariffDropDownList.SelectedValue;
        string notes        = string.Empty;

        if (NotesReadOnlyPanel.Visible)
        {
            notes = NotesLabel.Text.Trim();
        }
        else
        {
            notes = NotesTextBox.Text.Trim();
        }

        try
        {
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();

            scheduleService.UpdatePostalTariff(eventId, postalTariff, notes,
                                               loginInfo.UserId);

            CancelButton_Click(SaveButton, new EventArgs());
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #11
0
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        // Get the logged in account information.
        RegistrationService.LoginInfo loginInfo =
            (RegistrationService.LoginInfo)Session["loginInfo"];

        int farmId    = Convert.ToInt32(FarmIdHiddenField.Value);
        int plotId    = Convert.ToInt32(IdHiddenField.Value);
        int eventId   = Convert.ToInt32(EventIdHiddenField.Value);
        int messageId = Convert.ToInt32(MessageDropDownList.SelectedValue);

        try
        {
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();

            if (Convert.ToInt32(PrevMessageIdHiddenField.Value) == 0)
            {
                scheduleService.InsertEventEntry(farmId, plotId, eventId, messageId,
                                                 loginInfo.UserId);
            }
            else
            {
                scheduleService.UpdateEventEntry(farmId, plotId, eventId, messageId,
                                                 loginInfo.UserId);
            }

            CancelButton_Click(CancelButton, new EventArgs());
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        if (!IsPostBack)
        {
            // Get the query string values.
            NameValueCollection coll = Request.QueryString;

            int eventId = Convert.ToInt32(coll.Get("eId"));

            // Set the report viewer control's size.
            ReportViewerControl.ReportWidth  = 875;
            ReportViewerControl.ReportHeight = 615;

            // Get the report data.
            try
            {
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                IList <ScheduleService.ScheduleEventMailingLabelInfo> mailingLabels =
                    scheduleService.GetMailingLabels(eventId);

                ReportViewerControl.DataSource     = mailingLabels;
                ReportViewerControl.DataSourceName = "ScheduleEventMailingLabelInfo";
                ReportViewerControl.ReportPath     = "Members/Reports/EventMailingLabelsReport.rdlc";
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId    = Convert.ToInt32(coll.Get("aId"));
        string agentName  = coll.Get("aName");
        int    planType   = Convert.ToInt32(coll.Get("ptype"));
        int    pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            // Get the schedule event contacts and display.
            try
            {
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                IList <ScheduleService.ScheduleEventContactInfo> contacts =
                    scheduleService.GetScheduleEventContacts(id);

                EventNumberLabel.Text = contacts[0].EventNumber.ToString();
                EventDateLabel.Text   = contacts[0].EventDate;
                FarmLabel.Text        = contacts[0].FarmName;
                MailingPlanLabel.Text = contacts[0].PlanName;
                StartDateLabel.Text   = contacts[0].StartDate;
                EndDateLabel.Text     = contacts[0].EndDate;

                ContactsGrid.DataSource = contacts;
                ContactsGrid.DataBind();

                Session["SCHEDULE_EVENT_CONTACTS"] = contacts;
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #14
0
    protected void ExportButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the event identifier.
            int eventId = Convert.ToInt32(IdHiddenField.Value);

            // Get the list of contacts of the event.
            ScheduleService.ScheduleService scheduleService =
                serviceLoader.GetSchedule();
            IList <ScheduleService.ScheduleEventContactInfo> contacts =
                scheduleService.GetScheduleEventContacts(eventId);

            // Specify the source and desitination files.
            string path           = Server.MapPath("~/Members/UserData/");
            string sourceFileName = path + "Templates\\EventContactListTemplate.xls";
            string destFileName   = path + Util.GetFileName(contacts[0].FarmName) + "_Contacts.xls";

            // Create the target file by coping the template file.
            File.Copy(sourceFileName, destFileName, true);

            // Open a connection with the property settings specified.
            string connectionString = "Data Source=" + destFileName + ";" +
                                      "Provider=Microsoft.Jet.OLEDB.4.0;" +
                                      "Extended Properties=Excel 8.0;";

            using (OleDbConnection connection = new OleDbConnection(connectionString))
            {
                connection.Open();

                // Get schema information from the data source.
                DataTable schemaTable = connection.GetOleDbSchemaTable(
                    OleDbSchemaGuid.Tables,
                    new object[] { null, null, null, "TABLE" });
                string sheet = schemaTable.Rows[0]["Table_Name"].ToString();

                // Fill the [Event Details] sheet.
                string queryString = "INSERT INTO [" + sheet + "] ([Event Number], " +
                                     "[Event Date], [Farm], " +
                                     "[Mailing Plan], [Start Date], " +
                                     "[End Date]) " +
                                     "VALUES ('" + contacts[0].EventNumber.ToString() + "', " +
                                     "'" + contacts[0].EventDate + "', '" + contacts[0].FarmName.Replace("'", "''") + "', " +
                                     "'" + contacts[0].PlanName + "', '" + contacts[0].StartDate + "', " +
                                     "'" + contacts[0].EndDate + "')";

                OleDbCommand command = new OleDbCommand(queryString, connection);
                command.ExecuteNonQuery();

                // Fill the contacts in the respective [Plot #] sheets.
                int plotId      = 0;
                int plotCounter = 0;

                foreach (ScheduleService.ScheduleEventContactInfo entry in contacts)
                {
                    if (entry.PlotId != plotId)
                    {
                        plotCounter++;

                        plotId = entry.PlotId;
                        sheet  = Util.GetExcelSheetName(plotCounter.ToString() + "_" + entry.PlotName);

                        queryString = "CREATE TABLE [" + sheet + "] " +
                                      "([Contact ID] TEXT(255), [First Name] TEXT(255), " +
                                      "[Last Name] TEXT(255), [Address 1] TEXT(255), " +
                                      "[Address 2] TEXT(255), [City] TEXT(255), " +
                                      "[State] TEXT(255), [Zip] TEXT(255), " +
                                      "[Country] TEXT(255))";

                        command = new OleDbCommand(queryString, connection);
                        command.ExecuteNonQuery();
                    }

                    // Create an SQL statement to execute against the data source.
                    queryString = "INSERT INTO [" + sheet + "$] ([Contact ID], " +
                                  "[First Name], [Last Name], " +
                                  "[Address 1], [Address 2], " +
                                  "[City], [State], " +
                                  "[Zip], [Country]) " +
                                  "VALUES ('" + entry.ContactId.ToString() + "', " +
                                  "'" + entry.FirstName + "', '" + entry.LastName + "', " +
                                  "'" + entry.Address1 + "', '" + entry.Address2 + "', " +
                                  "'" + entry.City + "', '" + entry.State + "', " +
                                  "'" + entry.Zip + "', '" + entry.Country + "')";

                    command = new OleDbCommand(queryString, connection);
                    command.ExecuteNonQuery();
                }
            }

            // Open the target file.
            string fileLocation = destFileName.Substring(
                destFileName.IndexOf("Members\\UserData\\")).Replace("\\", "/");

            if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "Startup"))
            {
                String script = "<script language=\"javascript\">";
                script += "window.open('../" + fileLocation + "');";
                script += "</script>";

                ClientScript.RegisterStartupScript(this.GetType(), "Startup", script);
            }
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
コード例 #15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       eventId    = Convert.ToInt32(coll.Get("eId"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId   = Convert.ToInt32(coll.Get("aId"));
        string agentName = coll.Get("aName");
        string mode      = string.Empty;

        if (coll.Get("mode") != "" && coll.Get("mode") != null)
        {
            mode = coll.Get("mode");
        }
        int planType   = Convert.ToInt32(coll.Get("ptype"));
        int pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventIdHiddenField.Value    = eventId.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            ModeHiddenField.Value       = mode;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            try
            {
                // Get the schedule event entry details and display.
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntry(eventId, id);

                EventNumberLabel.Text = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text   = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");
                PlotLabel.Text        = schedule.Events[0].Entries[0].PlotName;

                // Get the design details for the event entry.
                ScheduleService.DesignInfo design =
                    scheduleService.GetDesign(eventId);

                int    index         = design.LowResolutionFile.LastIndexOf(".");
                string pageImagePath = ConfigurationManager.AppSettings["ApprovedDesignRoot"] +
                                       "\\ExtractedPages\\" +
                                       design.LowResolutionFile.Substring(0, index) +
                                       "_Page.jpg";

                if (!File.Exists(pageImagePath))
                {
                    pageImagePath = ConfigurationManager.AppSettings["ApprovedDesignRoot"] +
                                    "\\ExtractedPages\\dummy_page.jpg";

                    ErrorMessageLabel.Text    = "The preview message is not available. Please try again after some time or contact your administrator.";
                    ErrorMessageLabel.Visible = true;
                }

                float      zoomFactor;
                RectangleF messageRectangleActual;
                Util.CalculateMessageActual(design.MessageRectangle, design.Size,
                                            pageImagePath, out zoomFactor, out messageRectangleActual);

                pageImagePath = pageImagePath.Substring(pageImagePath.IndexOf("\\Members\\ApprovedDesignPages"));
                pageImagePath = pageImagePath.Replace("\\", "/");

                DesignImage.ImageUrl = "~" + pageImagePath;

                DesignTextLayer.Style.Add("left", messageRectangleActual.X.ToString() + "px");
                DesignTextLayer.Style.Add("top", messageRectangleActual.Y.ToString() + "px");
                DesignTextLayer.Style.Add("width", messageRectangleActual.Width.ToString() + "px");
                DesignTextLayer.Style.Add("height", messageRectangleActual.Height.ToString() + "px");
                DesignTextLayer.Style.Add("clip", "rect(0px " + messageRectangleActual.Width.ToString() + "px " + messageRectangleActual.Height.ToString() + "px 0px)");

                DesignText.Style.Add("zoom", zoomFactor.ToString());
                if (Session["MessagePreviewType"].ToString() == "text")
                {
                    DesignText.InnerHtml = Session["MessagePreviewText"].ToString();
                }
                else
                {
                    MessageImage.ImageUrl = Session["MessagePreviewText"].ToString();
                    MessageImage.Visible  = true;
                }

                if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "Startup"))
                {
                    String scriptString = "<script language=JavaScript>";
                    scriptString += "var ctrlPrefix = 'ctl00_ctl00_ContentPlaceHolder1_ContentPlaceHolder1_';";
                    scriptString += "var left = document.getElementById(ctrlPrefix + 'DesignImageLayer').offsetLeft;";
                    scriptString += "var top = document.getElementById(ctrlPrefix + 'DesignImageLayer').offsetTop;";
                    scriptString += "var leftOffset = document.getElementById(ctrlPrefix + 'DesignTextLayer').offsetLeft;";
                    scriptString += "var topOffset = document.getElementById(ctrlPrefix + 'DesignTextLayer').offsetTop;";
                    scriptString += "document.getElementById(ctrlPrefix + 'DesignTextLayer').style.left = left + leftOffset;";
                    scriptString += "document.getElementById(ctrlPrefix + 'DesignTextLayer').style.top = top + topOffset;";
                    scriptString += "</script>";

                    ClientScript.RegisterStartupScript(this.GetType(), "Startup", scriptString);
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId    = Convert.ToInt32(coll.Get("aId"));
        string agentName  = coll.Get("aName");
        int    planType   = Convert.ToInt32(coll.Get("ptype"));
        int    pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            try
            {
                // Get the schedule event details and display.
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntries(id);

                EventNumberLabel.Text = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text   = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");
                string designFile = schedule.Events[0].DesignFile;
                DesignHyperLink.Text        = designFile.Substring(designFile.IndexOf("_") + 1);
                DesignHyperLink.NavigateUrl = "~/Members/UserData/" +
                                              AgentIdHiddenField.Value + "/" + designFile;
                DesignHyperLink.Target = "_blank";
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Completed)
                {
                    StatusLabel.Text = schedule.Events[0].Status.Name +
                                       " on " + schedule.Events[0].CompletedOn.ToString("MM/dd/yyyy hh:mm tt");
                }
                else
                {
                    StatusLabel.Text = schedule.Events[0].Status.Name;
                }
                ProductTypeHiddenField.Value           = schedule.Events[0].ProductType.Name;
                ProductTypeLabel.Text                  = schedule.Events[0].ProductType.Name;
                PostalTariffDropDownList.SelectedValue = schedule.Events[0].PostalTariff;
                if (schedule.Events[0].Status.LookupId != (int)ScheduleEventStatus.Scheduled)
                {
                    PostalTariffDropDownList.Enabled = false;
                }
                if (schedule.Events[0].OrderValue == 0)
                {
                    TotalChargesPanel.Visible = false;
                }
                else
                {
                    TotalChargesPanel.Visible = true;
                    TotalChargesLabel.Text    = schedule.Events[0].OrderValue.ToString("####.#0");

                    if (schedule.Events[0].RefundAmount == 0)
                    {
                        RefundAmountPanel.Visible = false;
                    }
                    else
                    {
                        RefundAmountPanel.Visible = true;
                        RefundAmountLabel.Text    = schedule.Events[0].RefundAmount.ToString("####.#0");
                    }
                }

                // Set the notes panel based on the status of the event and role of the user.
                if ((schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled) &&
                    (loginInfo.Role != RegistrationService.UserRole.Agent))
                {
                    NotesReadOnlyPanel.Visible  = false;
                    NotesReadWritePanel.Visible = true;
                    NotesTextBox.Text           = schedule.Events[0].Notes;
                }
                else
                {
                    NotesReadWritePanel.Visible = false;
                    NotesReadOnlyPanel.Visible  = true;
                    NotesLabel.Text             = schedule.Events[0].Notes;
                }

                // Display plot's information.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled)
                {
                    PastEventDetailsDataGrid.Visible      = false;
                    FutureEventDetailsDataGrid.Visible    = true;
                    FutureEventDetailsDataGrid.DataSource = schedule.Events[0].Entries;
                    FutureEventDetailsDataGrid.DataBind();
                }
                else
                {
                    FutureEventDetailsDataGrid.Visible  = false;
                    PastEventDetailsDataGrid.Visible    = true;
                    PastEventDetailsDataGrid.DataSource = schedule.Events[0].Entries;
                    PastEventDetailsDataGrid.DataBind();
                }

                if (schedule.Events[0].Entries.Length == 0)
                {
                    NoRecordsTable.Visible = true;
                }
                else
                {
                    NoRecordsTable.Visible = false;
                }

                // Set the printer remarks panel based on the status of the event and role of
                // the user.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.InProgress)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Printer)
                    {
                        PrinterRemarksPanel.Visible = true;
                    }
                    else
                    {
                        PrinterRemarksPanel.Visible = false;
                    }
                }
                else if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Completed)
                {
                    PrinterRemarksPanel.Visible   = true;
                    PrinterRemarksRWPanel.Visible = false;
                    PrinterRemarksROPanel.Visible = true;

                    // Display Data.
                    string file = schedule.Events[0].MailingListFile;
                    MailingListFileHyperLink.Text        = file.Substring(file.IndexOf("_") + 1);
                    MailingListFileHyperLink.NavigateUrl = "~/Members/MailingLists/" + file;
                    MailingListFileHyperLink.Target      = "_blank";
                    MailingCountLabel.Text = schedule.Events[0].MailingCount.ToString();
                    RemarksLabel.Text      = schedule.Events[0].Remarks;

                    if (schedule.Events[0].RefundAmount == 0)
                    {
                        ExceptionReportedPanel.Visible = false;
                    }
                    else
                    {
                        ExceptionReportedPanel.Visible = true;

                        if (schedule.Events[0].ExceptionReported)
                        {
                            ExceptionReportedImage.ImageUrl = "~/Images/tick.gif";
                        }
                        else
                        {
                            ExceptionReportedImage.ImageUrl = "~/Images/cross.gif";
                        }
                    }
                }
                else
                {
                    PrinterRemarksPanel.Visible = false;
                }

                // Set the action buttons based on the role and status.
                if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.Scheduled)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Agent)
                    {
                        ReadWriteButtonsPanel.Visible = true;
                    }
                    else
                    {
                        CancelEventButtonsPanel.Visible = true;
                    }
                }
                else if (schedule.Events[0].Status.LookupId == (int)ScheduleEventStatus.InProgress)
                {
                    if (loginInfo.Role == RegistrationService.UserRole.Printer)
                    {
                        CompleteEventButtonsPanel.Visible = true;
                    }
                    else
                    {
                        ReadOnlyButtonsPanel.Visible = true;
                    }
                }
                else
                {
                    ReadOnlyButtonsPanel.Visible = true;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["loginInfo"] == null || Session["loginInfo"] == "")
        {
            Response.Redirect("../userLogin.aspx?Message=SessionExpired");
        }

        RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"];
        bool          isAgent       = (loginInfo.Role == RegistrationService.UserRole.Agent);
        ServiceAccess serviceLoader = ServiceAccess.GetInstance();

        // ************Populate the Farm Data************

        FarmService.FarmService farmService = serviceLoader.GetFarm();
        int  farmCount    = 0;
        int  plotCount    = 0;
        long contactCount = 0;

        if (isAgent)
        {
            FarmService.FarmInfo[] farmInfo = farmService.GetFarmSummary(loginInfo.UserId);
            farmCount = farmInfo.Length;
            for (int i = 0; i < farmCount; i++)
            {
                plotCount    = plotCount + farmInfo[i].PlotCount;
                contactCount = contactCount + farmInfo[i].ContactCount;
            }
        }
        else
        {
            farmCount    = farmService.TotalActiveFarmCount();
            plotCount    = farmService.TotalActivePlotCount();
            contactCount = farmService.TotalActiveContactCount();
        }

        FarmPlotLabel.Text = farmCount.ToString() + " Farms / " + plotCount + " Plots";
        ContactLabel.Text  = contactCount.ToString() + " Contacts";

        // ************Populate Messages Data************
        MessageService messageService = serviceLoader.GetMessage();

        StandardMessagesLabel.Text = messageService.GetStandardMessageList(isAgent, string.Empty, string.Empty).Length + " messages";

        if (isAgent)
        {
            CustomMessagesLabel.Text = messageService.GetCustomMessageList(loginInfo.UserId).Length + " messages";
        }
        else
        {
            CustomMessagesLabel.Text = messageService.GetCustomMessageList(0).Length + " messages";
        }


        // ************Populate design Data************
        DesignService.DesignService designService = serviceLoader.GetDesign();

        if (isAgent)
        {
            IList <DesignService.DesignInfo> designs =
                designService.GetList(loginInfo.UserId);

            DesignService.DesignInfo design   = new DesignService.DesignInfo();
            DesignService.DesignInfo brochure = new DesignService.DesignInfo();

            foreach (DesignService.DesignInfo designInfo in designs)
            {
                if (designInfo.Category.Name == "PowerKard")
                {
                    design = designInfo;
                }
                else
                {
                    brochure = designInfo;
                }
            }

            PowerKardStatusLabel.Text = design.Status.Name.ToString();
            BrochureStatusLabel.Text  = brochure.Status.Name.ToString();
        }
        else
        {
            object[]  designStatusArray;
            DataTable designStatusTable = new DataTable();
            designStatusArray = designService.GetSummary();
            designStatusTable = Util.GetDataTable(designStatusArray);

            if (designStatusTable != null)
            {
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[0][3] + " - " + designStatusTable.Rows[0][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[1][3] + " - " + designStatusTable.Rows[1][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text + designStatusTable.Rows[4][3] + " - " + designStatusTable.Rows[4][4] + ",";
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Substring(0, PowerKardStatusLabel.Text.Length - 1);

                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Uploaded", "Upd");
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Submitted", "Sub");
                PowerKardStatusLabel.Text = PowerKardStatusLabel.Text.Replace("Approved", "App");

                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[5][3] + " - " + designStatusTable.Rows[5][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[6][3] + " - " + designStatusTable.Rows[6][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text + designStatusTable.Rows[9][3] + " - " + designStatusTable.Rows[9][4] + ",";
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Substring(0, BrochureStatusLabel.Text.Length - 1);

                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Uploaded", "Upd");
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Submitted", "Sub");
                BrochureStatusLabel.Text = BrochureStatusLabel.Text.Replace("Approved", "App");

                WelcomeHelpPanel.Visible = true;
            }
        }
        // ************Populate Inventory Data************

        ProductService.ProductService    productService = serviceLoader.GetProduct();
        ProductService.ProductItemInfo[] productItemInfo;

        if (isAgent)
        {
            productItemInfo = productService.GetInventoryTotalCount(loginInfo.UserId);
        }
        else
        {
            productItemInfo = productService.GetInventoryTotalCount(0);
        }

        if (productItemInfo.Length < 1)
        {
            InventoryLabel.Text = "PowerKards:0<br>Brochures:0";
        }

        InventoryRepeater.DataSource = productItemInfo;
        InventoryRepeater.DataBind();

        // ************Populate Schedule Management Data************
        ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule();

        object[]  SchedulePlansArray;
        DataTable SchedulePlansTable = new DataTable();

        if (isAgent)
        {
            SchedulePlansArray = scheduleService.GetSummaryOfUser(loginInfo.UserId);
        }
        else
        {
            SchedulePlansArray = scheduleService.GetSummary();
        }

        SchedulePlansTable = Util.GetDataTable(SchedulePlansArray);

        if (SchedulePlansTable != null)
        {
            ActivePlansLabel.Text = SchedulePlansTable.Rows[0][0].ToString() + ": " + SchedulePlansTable.Rows[0][1].ToString();
            if (Convert.ToInt32(SchedulePlansTable.Rows[1][1].ToString()) > 0)
            {
                DelayedPlansLabel.Text = SchedulePlansTable.Rows[1][0].ToString() + ": " + SchedulePlansTable.Rows[1][1].ToString();
            }
        }

        //********* Populate User Management Info **********

        if (isAgent)
        {
            UserManagementPanel.Visible = false;
        }
        else
        {
            object[]  usersArray;
            DataTable usersTable = new DataTable();
            RegistrationService.RegistrationService registrationService = ServiceAccess.GetInstance().GetRegistration();

            usersArray = registrationService.GetApprovalRequiredUsers();
            usersTable = Util.GetDataTable(usersArray);
            RegistrationService.UserRole userRole;
            if (usersTable != null)
            {
                if (usersTable.Rows.Count < 1)
                {
                    UsersLabel.Text = "No Users waiting for approval";
                }
                else
                {
                    for (int i = 0; i < usersTable.Rows.Count; i++)
                    {
                        userRole        = (RegistrationService.UserRole)((Convert.ToInt32(usersTable.Rows[i][0].ToString()) - 1));
                        UsersLabel.Text = UsersLabel.Text + userRole.ToString() + " : " + usersTable.Rows[i][1].ToString() + "<br>";
                    }
                }
            }
        }
    }
コード例 #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id        = Convert.ToInt32(coll.Get("id"));
        EventType eventType = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        else
        {
            if (coll.Get("ptype") != "" && coll.Get("ptype") != null)
            {
                if (Convert.ToInt32(coll.Get("ptype")) == 1)
                {
                    eventType = EventType.Past;
                }
            }
        }
        int    agentId    = Convert.ToInt32(coll.Get("aId"));
        string agentName  = coll.Get("aName");
        int    planType   = Convert.ToInt32(coll.Get("ptype"));
        int    pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        // Set the screen elements based on the type of events that are displayed.
        string queryString = "?id=" + id.ToString() +
                             "&aId=" + agentId.ToString() +
                             "&aName=" + agentName +
                             "&et=" + (Convert.ToInt32(eventType) == 0 ? "1" : "0") +
                             "&ptype=" + planType.ToString() +
                             "&pg=" + pageNumber.ToString();

        if (eventType == EventType.Future)
        {
            SetHyperLink(FutureEventsHyperLink, "");
            SetHyperLink(PastEventsHyperLink, "~/Members/ViewEvents.aspx" + queryString);
        }
        else
        {
            SetHyperLink(PastEventsHyperLink, "");
            SetHyperLink(FutureEventsHyperLink, "~/Members/ViewEvents.aspx" + queryString);
        }

        LegendTitleLabel.Text = "List of " + eventType.ToString() + " Events";

        if (!IsPostBack)
        {
            // Get the logged in account information.
            RegistrationService.LoginInfo loginInfo =
                (RegistrationService.LoginInfo)Session["loginInfo"];

            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            // Get the schedule details and display.
            try
            {
                ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo    schedule        = scheduleService.GetEvents(id);

                FarmLabel.Text        = schedule.FarmName;
                MailingPlanLabel.Text = schedule.Plan.Title;
                StartDateLabel.Text   = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text     = schedule.EndDate.ToString("MM/dd/yyyy");

                IList <ScheduleService.ScheduleEventInfo> events =
                    new List <ScheduleService.ScheduleEventInfo>();

                foreach (ScheduleService.ScheduleEventInfo eve in schedule.Events)
                {
                    if (eventType == EventType.Future)
                    {
                        if (eve.EventDate >= DateTime.Today)
                        {
                            events.Add(eve);
                        }
                    }
                    else
                    {
                        if (eve.EventDate < DateTime.Today)
                        {
                            events.Add(eve);
                        }
                    }
                }

                if (eventType == EventType.Future)
                {
                    FutureEventsDataGrid.Visible    = true;
                    FutureEventsDataGrid.DataSource = events;
                    FutureEventsDataGrid.DataBind();
                    PastEventsDataGrid.Visible = false;
                }
                else
                {
                    PastEventsDataGrid.Visible    = true;
                    PastEventsDataGrid.DataSource = events;
                    PastEventsDataGrid.DataBind();
                    FutureEventsDataGrid.Visible = false;
                }

                if (events.Count == 0)
                {
                    NoRecordsTable.Visible = true;
                }
                else
                {
                    NoRecordsTable.Visible = false;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ErrorMessageLabel.Visible = false;

        // Get the query string values.
        NameValueCollection coll = Request.QueryString;

        int       id         = Convert.ToInt32(coll.Get("id"));
        int       eventId    = Convert.ToInt32(coll.Get("eId"));
        int       scheduleId = Convert.ToInt32(coll.Get("sId"));
        EventType eventType  = EventType.Future;

        if (coll.Get("et") != "" && coll.Get("et") != null)
        {
            eventType = (EventType)Convert.ToInt32(coll.Get("et"));
        }
        int    agentId   = Convert.ToInt32(coll.Get("aId"));
        string agentName = coll.Get("aName");
        string mode      = string.Empty;

        if (coll.Get("mode") != "" && coll.Get("mode") != null)
        {
            mode = coll.Get("mode");
        }
        int planType   = Convert.ToInt32(coll.Get("ptype"));
        int pageNumber = Convert.ToInt32(coll.Get("pg"));

        // Display the agent name if one exists.
        if (agentName != "")
        {
            AgentNameLabel.Text = "Agent Name: " + agentName + "&nbsp;";
        }

        if (!IsPostBack)
        {
            // Set the required query string varables into hidden fields.
            IdHiddenField.Value         = id.ToString();
            EventIdHiddenField.Value    = eventId.ToString();
            ScheduleIdHiddenField.Value = scheduleId.ToString();
            EventTypeHiddenField.Value  = Convert.ToInt32(eventType).ToString();
            AgentIdHiddenField.Value    = agentId.ToString();
            AgentNameHiddenField.Value  = agentName;
            ModeHiddenField.Value       = mode;
            PlanTypeHiddenField.Value   = planType.ToString();
            PageNumberHiddenField.Value = pageNumber.ToString();

            // Get the schedule event entry details and display.
            try
            {
                ScheduleService.ScheduleService scheduleService =
                    serviceLoader.GetSchedule();
                ScheduleService.ScheduleInfo schedule =
                    scheduleService.GetEventEntry(eventId, id);

                EventNumberLabel.Text   = schedule.Events[0].EventNumber.ToString();
                EventDateLabel.Text     = schedule.Events[0].EventDate.ToString("MM/dd/yyyy");
                FarmIdHiddenField.Value = schedule.FarmId.ToString();
                FarmLabel.Text          = schedule.FarmName;
                MailingPlanLabel.Text   = schedule.Plan.Title;
                StartDateLabel.Text     = schedule.StartDate.ToString("MM/dd/yyyy");
                EndDateLabel.Text       = schedule.EndDate.ToString("MM/dd/yyyy");

                PlotLabel.Text = schedule.Events[0].Entries[0].PlotName;
                PrevMessageIdHiddenField.Value =
                    schedule.Events[0].Entries[0].Message.MessageId.ToString();

                if (coll.Get("fm") != "" && coll.Get("fm") != null && coll.Get("fm") == "pmp")
                {
                    if (Session["MessagePreviewTextId"].ToString().Length >= 6)
                    {
                        MessageTypeDropDownList.SelectedValue =
                            Session["MessagePreviewTypeId"].ToString();
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                        MessageDropDownList.SelectedValue =
                            Session["MessagePreviewTextId"].ToString();
                        MessageDropDownList_Changed(MessageDropDownList, new EventArgs());
                    }
                    else
                    {
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                    }
                }
                else
                {
                    if (schedule.Events[0].Entries[0].Message.MessageId != 0)
                    {
                        if (schedule.Events[0].Entries[0].Message.MessageType ==
                            ScheduleService.MessageType.Standard)
                        {
                            MessageTypeDropDownList.SelectedValue = "1";
                        }
                        else
                        {
                            MessageTypeDropDownList.SelectedValue = "2";
                        }
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                        MessageDropDownList.SelectedValue =
                            schedule.Events[0].Entries[0].Message.MessageId.ToString();
                        MessageDropDownList_Changed(MessageDropDownList, new EventArgs());
                    }
                    else
                    {
                        MessageTypeDropDownList_Changed(MessageTypeDropDownList, new EventArgs());
                    }
                }

                if (mode == "view")
                {
                    MessageTypeDropDownList.Enabled = false;
                    MessageDropDownList.Enabled     = false;
                    SaveButton.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
                ErrorMessageLabel.Visible = true;

                log.Error("Unknown Error", ex);
            }
        }
    }
コード例 #20
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            try
            {
                int farmId = 0;
                if ((Request.QueryString["farmId"] != "") && (Request.QueryString["farmId"] != null))
                {
                    int.TryParse(Request.QueryString["farmId"], out farmId);
                }

                if (farmId == 0)
                {
                    Response.Redirect("~/Members/FarmManagement.aspx");
                }

                // Get the common web service instance.

                ServiceAccess                   serviceLoader   = ServiceAccess.GetInstance();
                FarmService.FarmService         farmService     = serviceLoader.GetFarm();
                ScheduleService.ScheduleService scheduleService = serviceLoader.GetSchedule();

                IList <FarmService.MailingPlanInfo> mailingPlans = farmService.GetMailingPlanList();
                MailingPlanDropDownList.DataSource     = mailingPlans;
                MailingPlanDropDownList.DataValueField = "MailingPlanId";
                MailingPlanDropDownList.DataTextField  = "Title";
                MailingPlanDropDownList.DataBind();

                FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId);
                farm.UserId             = farmService.GetUserIdForFarm(farmId);
                UserIdHiddenField.Value = farm.UserId.ToString();
                if (!IsAgentRole)
                {
                    ForAgentLiteral.Visible = true;
                    RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration();
                    RegistrationService.RegistrationInfo    regInfo    = regservice.GetDetails(farm.UserId);
                    ForAgentLiteral.Text            = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + "&nbsp;";
                    ForAgentUserIdHiddenField.Value = farm.UserId.ToString();
                }
                else
                {
                    ForAgentLiteral.Visible = false;
                }


                FarmIdHiddenField.Value = farm.FarmId.ToString();
                PlotIdHiddenField.Value = farm.Plots[0].PlotId.ToString();
                FarmNameTextBox.Text    = farm.FarmName;
                MailingPlanDropDownList.SelectedValue = farm.MailingPlan.MailingPlanId.ToString();
                if (farm.Plots[0].ContactCount > 0)
                {
                    ContactListFileRequiredFieldValidator.Enabled = false;
                }
                if (farm.Firmup)
                {
                    MailingPlanDropDownList.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
            }
        }
    }