Beispiel #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int userId = 0;
            string where = "";
            if (Request.QueryString["userId"] != null)
            {
                int.TryParse(Request.QueryString["userId"], out userId);
            }
            if (Request.QueryString["where"] != null)
            {
                where = Request.QueryString["where"];
            }
            ReportViewerUserControl1.ReportHeight = 580;
            ReportViewerUserControl1.ReportWidth  = 800;

            try
            {
                // Get the common web service instance.
                ServiceAccess                    serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService          farmService   = serviceLoader.GetFarm();
                FarmService.FarmDataReportInfo[] data          = farmService.GetFarmDataReportData(userId, where);
                ReportViewerUserControl1.DataSource     = data;
                ReportViewerUserControl1.DataSourceName = "FarmDataReportInfo";
                ReportViewerUserControl1.ReportPath     = "Members/Reports/FarmDataReport.rdlc";
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR WHILE LOADING FARM DATA REPORT:", exception);
            }
        }
    }
Beispiel #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if ((Request.QueryString["plotId"] == "") && (Request.QueryString["plotId"] == null))
     {
         ErrorLiteral.Text = "Improper Parameter.";
     }
     else
     {
         int plotId = 0;
         int.TryParse(Request.QueryString["plotId"].ToString(), out plotId);
         try
         {
             ServiceAccess                 serviceLoader = ServiceAccess.GetInstance();
             FarmService.FarmService       farmService   = serviceLoader.GetFarm();
             RegistrationService.LoginInfo loginInfo     = (RegistrationService.LoginInfo)Session["loginInfo"];
             String fileName = farmService.ExportContactListToExcel(loginInfo.UserId, plotId);
             Response.Redirect("~/Members/UserData/" + loginInfo.UserId.ToString() + "/" + fileName);
         }
         catch (Exception exception)
         {
             log.Error("UNKNOWN ERROR WHILE EXPORTING CONTACT LIST:", exception);
             ErrorLiteral.Text = "Error: Unable to Export Contact List to Excel File";
         }
     }
 }
    protected void Agent_Changed(object sender, EventArgs e)
    {
        // Populate farms into dropdown list.
        try
        {
            PlotDropDownList.Items.Clear();
            PlotDropDownList.Items.Insert(0, new ListItem("<All Plots>", "0"));

            int agentId = Convert.ToInt32(AgentDropDownList.SelectedValue);

            FarmService.FarmService farmService = serviceLoader.GetFarm();

            FarmDropDownList.DataSource     = farmService.GetFarmSummary(agentId);
            FarmDropDownList.DataValueField = "FarmId";
            FarmDropDownList.DataTextField  = "FarmName";
            FarmDropDownList.DataBind();

            FarmDropDownList.Items.Insert(0, new ListItem("<All Farms>", "0"));
        }
        catch (Exception ex)
        {
            ErrorMessageLabel.Text    = "Unable to process the request. Please contact your administrator.";
            ErrorMessageLabel.Visible = true;

            log.Error("Unknown Error", ex);
        }
    }
Beispiel #4
0
    protected void DeleteFarmButton_Click(object sender, EventArgs e)
    {
        bool isError = false;

        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            int farmId = 0;
            int.TryParse(FarmIdHiddenField.Value.ToString(), out farmId);
            farmService.DeleteFarmPlot(farmId, LoginUserId);
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE DELETING FARM:", exception);
            isError = true;
            if (exception.Message.Contains("Farm is Firmed Up. Cannot Delete this Farm"))
            {
                ErrorLiteral.Text = "Error: " + FarmNameLabel.Text + " farm is currently Firmed Up. It is not possible to delete any Firmed Up mailing plan or Farm. If you still want to delete it, please speak to Customer Service 1-800-Mailing";
            }
            else
            {
                ErrorLiteral.Text = "Unknown Error Deleting Farm. Please Contact Administrator";
            }
        }
        if (!isError)
        {
            Response.Redirect("~/Members/FarmManagement.aspx");
        }
    }
Beispiel #5
0
 protected void SelectedAgentButton_Click(object sender, EventArgs e)
 {
     if (AgentListDropDownList.SelectedIndex > 0)
     {
         SearchCriteriaPane.Visible = true;
         AgentListErrorLiteral.Text = "";
     }
     else
     {
         AgentListErrorLiteral.Text = "Please Select an Agent.";
         return;
     }
     try
     {
         // Get the common web service instance.
         ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
         FarmService.FarmService farmService   = serviceLoader.GetFarm();
         FarmDropDownList.DataSource     = farmService.GetFarmListForUser(GetAgentId());
         FarmDropDownList.DataValueField = "FarmId";
         FarmDropDownList.DataTextField  = "FarmName";
         FarmDropDownList.DataBind();
         FarmDropDownList.Items.Insert(0, new ListItem("All Farms", "0"));
         PlotDropDownList.Items.Add(new ListItem("All Plots", "0"));
     }
     catch (Exception exception)
     {
         log.Error("UNKNOWN ERROR IN SEARCH FARM AGENT SELECTION:", exception);
         ErrorLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
     }
 }
Beispiel #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadConditionData();
            try
            {
                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                AgentListPanel.Visible = true;
                CommonService commonService = serviceLoader.GetCommon();
                AgentListDropDownList.DataSource     = commonService.GetAgentsList();
                AgentListDropDownList.DataValueField = "UserId";
                AgentListDropDownList.DataTextField  = "UserName";
                AgentListDropDownList.DataBind();
                AgentListDropDownList.Items.Insert(0, "All Agents");

                IList <FarmService.MailingPlanInfo> mailingPlans = farmService.GetMailingPlanList();
                MailingPlanDropDownList.DataSource     = mailingPlans;
                MailingPlanDropDownList.DataValueField = "MailingPlanId";
                MailingPlanDropDownList.DataTextField  = "Title";
                MailingPlanDropDownList.DataBind();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR WHILE LOADIN FARM DATA REPORT CRITERIA:", exception);
            }
        }
    }
Beispiel #7
0
 protected void FarmDropDownList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (FarmDropDownList.SelectedValue.ToString().Equals("0"))
     {
         PlotDropDownList.Items.Clear();
         PlotDropDownList.Items.Add(new ListItem("All Plots", "0"));
     }
     else
     {
         try
         {
             int farmId = 0;
             farmId = int.Parse(FarmDropDownList.SelectedValue.ToString());
             // Get the common web service instance.
             ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
             FarmService.FarmService farmService   = serviceLoader.GetFarm();
             PlotDropDownList.DataSource     = farmService.GetPlotListForFarm(farmId);
             PlotDropDownList.DataValueField = "PlotId";
             PlotDropDownList.DataTextField  = "PlotName";
             PlotDropDownList.DataBind();
             PlotDropDownList.Items.Insert(0, new ListItem("All Plots", "0"));
         }
         catch (Exception exception)
         {
             log.Error("UNKNOWN ERROR IN SEARCH FARM FARM SELECTION CHANGED:", exception);
             ErrorLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
         }
     }
 }
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        try
        {
            ServiceAccess                   serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService         farmService   = serviceLoader.GetFarm();
            IList <FarmService.ContactInfo> contacts      = (IList <FarmService.ContactInfo>)Session["Contacts"];
            Session.Remove("Contacts");
            FarmService.PlotInfo plot = new FarmService.PlotInfo();

            plot.PlotId       = Convert.ToInt32(PlotIdHiddenField.Value.ToString());
            plot.PlotName     = PlotNameTextBox.Text;
            plot.FarmId       = Convert.ToInt32(FarmIdHiddenField.Value.ToString());
            plot.LastModifyBy = LoginUserId;
            plot.Contacts     = (FarmService.ContactInfo[])contacts;
            farmService.UpdatePlot(plot);
            Response.Redirect(GetRedirectURL());
        }
        catch (Exception exception)
        {
            if (exception.Message.Contains("You are changing Primary Plot Name which will change the Farm name. A Farm by this name already exists. Please provide a differnt Plot name."))
            {
                ErrorLiteral.Text = "You are changing Primary Plot Name which will change the Farm name. A Farm by this name already exists. Please provide a differnt Plot name.";
            }
            else
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }
Beispiel #9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int plotId = 0;

            if ((Request.QueryString["plotId"] != "") && (Request.QueryString["plotId"] != null))
            {
                int.TryParse(Request.QueryString["plotId"], out plotId);
            }

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

            PlotIdHiddenField.Value = plotId.ToString();

            try
            {
                // Get the common web service instance.
                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                int userId = farmService.GetUserIdForPlot(plotId);
                UserIdHiddenField.Value = userId.ToString();

                if (!IsAgentRole)
                {
                    ForAgentPanel.Visible           = true;
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                    ForAgentUserNameLabel.Text      = farmService.GetUserName(userId);
                }
                else
                {
                    ForAgentPanel.Visible = false;
                }

                //Getting Archived Plot Header Details
                FarmService.PlotInfo plot = farmService.GetArchivedPlotSummaryDetails(plotId);

                //Getting Parent Farm Details
                FarmService.FarmInfo farm = farmService.GetArchivedFarmSummaryDetails(plot.FarmId);

                PlotNameLabel.Text      = farm.FarmName + " / " + plot.PlotName;
                ContactCountLabel.Text  = plot.ContactCount.ToString();
                CreateDateLabel.Text    = plot.CreateDate.ToShortDateString();
                FarmIdHiddenField.Value = plot.FarmId.ToString();

                FarmService.ContactInfo[] contacts = farmService.GetArchivedContactListForPlot(plotId);
                ContactListGridView.DataSource = contacts;
                ContactListGridView.DataBind();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR LOADING ARCHIVE CONTACT LIST:", exception);
                MessageLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
            }
        }
    }
Beispiel #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            //Check for Admin Login
            if (!IsPostBack)
            {
                ReportViewerUserControl1.ReportHeight = 580;
                ReportViewerUserControl1.ReportWidth  = 800;
                if (IsAgentRole)
                {
                    AgentListPanel.Visible = false;
                    //Populate Report
                    FarmService.FarmDetailsReportInfo[] details = farmService.ReportForFarmDetails(GetAgentId());

                    //ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("FarmDetailsReportInfo", details));
                    ReportViewerUserControl1.DataSource     = details;
                    ReportViewerUserControl1.DataSourceName = "FarmDetailsReportInfo";
                    ReportViewerUserControl1.ReportPath     = "Members/Reports/FarmPlotContactListReport.rdlc";
                }
                else
                {
                    AgentListPanel.Visible = true;
                    CommonService commonService = serviceLoader.GetCommon();
                    AgentListDropDownList.DataSource     = commonService.GetAgentsList();
                    AgentListDropDownList.DataValueField = "UserId";
                    AgentListDropDownList.DataTextField  = "UserName";
                    AgentListDropDownList.DataBind();
                    AgentListDropDownList.Items.Insert(0, "Select an Agent");
                }
            }
            else
            {
                if (!IsAgentRole)
                {
                    if (AgentListDropDownList.SelectedIndex > 0)
                    {
                        //Populate Report
                        FarmService.FarmDetailsReportInfo[] details = farmService.ReportForFarmDetails(GetAgentId());
                        //ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("FarmDetailsReportInfo", details));
                        //ReportViewer1.LocalReport.Refresh();

                        ReportViewerUserControl1.DataSource     = details;
                        ReportViewerUserControl1.DataSourceName = "FarmDetailsReportInfo";
                        ReportViewerUserControl1.ReportPath     = "Members/Reports/FarmPlotContactListReport.rdlc";
                    }
                }
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE LOADING FARM PLOT REPORT:", exception);
            ErrorLiteral.Text = "UNKNOWN ERROR: Contact Administrator";
        }
    }
Beispiel #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get the common web service instance.
        ServiceAccess serviceLoader = ServiceAccess.GetInstance();

        FarmService.FarmService             farmService = serviceLoader.GetFarm();
        FarmService.FarmDetailsReportInfo[] details     = farmService.ReportForFarmDetails(100001);

        ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("FarmDetailsReportInfo", details));
    }
    protected void DeleteContactButton_Click(object sender, EventArgs e)
    {
        bool isError = false;

        try
        {
            //Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            farmService.DeleteContact(Convert.ToInt64(ContactIdHiddenField.Value.ToString()), LoginUserId);
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE DELETE CONTACT:", exception);
            isError = true;
            if (exception.Message.Contains("This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Contact Cannot be deleted"))
            {
                ErrorLiteral.Text = "Error: This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Contact Cannot be deleted.";
            }
            else
            {
                ErrorLiteral.Text = "UNKNOWN ERROR WHILE DELETE CONTACT: Contact Administrator";
            }
        }
        if (!isError)
        {
            int contactCount = int.Parse(ContactCountHiddenField.Value.ToString());

            if (ParentPageHiddenField.Value.ToString() == "")
            {
                if (contactCount < 2)
                {
                    if (DefaultPlotFlagHiddenField.Value.ToString().Equals("true"))
                    {
                        Response.Redirect("~/Members/FarmManagement.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/Members/ViewFarm.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
                    }
                }
                else
                {
                    Response.Redirect("~/Members/ViewPlot.aspx?plotId=" + PlotIdHiddenField.Value.ToString());
                }
            }
            else
            if (ParentPageHiddenField.Value.ToString().Equals("SearchFarmData.aspx"))
            {
                Response.Redirect("~/Members/" + ParentPageHiddenField.Value.ToString() + "?accessType=old");
            }
        }
    }
Beispiel #13
0
    protected void SearchContactsButton_Click(object sender, EventArgs e)
    {
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            string where = GenerateSearchCondition();
            FarmService.FarmDetailsReportInfo[] farms = farmService.GetSearchFarmData(where);
            SearchFarmResultGridView.DataSource = farms;
            SearchFarmResultGridView.DataBind();

            //Disable actions on deleted Contacts
            for (int i = 0; i < SearchFarmResultGridView.Rows.Count; i++)
            {
                if (farms[SearchFarmResultGridView.Rows[i].DataItemIndex].Deleted)
                {
                    SearchFarmResultGridView.Rows[i].Cells[1].Enabled = false;
                }
            }

            if (IsPrinterRole)
            {
                SearchFarmResultGridView.Columns[0].Visible = false;
                SearchFarmResultGridView.Columns[1].Visible = false;
                DeleteButton.Visible = false;
            }

            SearchCriteriaPane.Visible = false;
            SearchResultPane.Visible   = true;
            ResultCountLiteral.Text    = "Farm data results - " + farms.Length + " Contacts found.";
            if (farms.Length == 0)
            {
                NoSearchResultPane.Visible = true;
            }
            else
            {
                NoSearchResultPane.Visible = false;
            }
            if (!IsAgentRole)
            {
                AgentListPanel.Visible = false;
                ForAgentLiteral.Text   = AgentListDropDownList.SelectedValue.ToString() + " / " + AgentListDropDownList.SelectedItem.Text;
            }
            MessageLiteral.Text                = "";
            Session["SearchFarmDataWhere"]     = where;
            Session["SearchFarmDataPageIndex"] = "1";
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR IN SEARCH FARM RESULT FETCHING:", exception);
            ErrorLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
        }
    }
Beispiel #14
0
    protected void RestoreFarmButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            for (int i = 0; i < FarmGridView.Rows.Count; i++)
            {
                GridViewRow row       = FarmGridView.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("FarmIdCheckBox")).Checked;
                if (isChecked)
                {
                    int farmId = int.Parse(((CheckBox)row.FindControl("FarmIdCheckBox")).ToolTip);
                    farmService.RestoreFarmPlot(farmId, LoginUserId);
                }
            }

            FarmService.FarmInfo[] farmList;
            farmList = farmService.GetArchivedFarmSummary(GetAgentId());
            FarmGridView.DataSource = farmList;
            FarmGridView.DataBind();
            if (farmList.Length == 0)
            {
                NoFarmDataPanel.Visible = true;
            }
            else
            {
                NoFarmDataPanel.Visible = false;
                for (int i = 0; i < FarmGridView.Rows.Count; i++)
                {
                    if (farmList[i].Deleted == true)
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Red;
                    }
                    else if (farmList[i].PlotCount == 0)
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Green;
                    }
                    else
                    {
                        FarmGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                    }
                }
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE RESTORE FARM:", exception);
            MessageLiteral.Text = "Error: Unable to Restore Farm";
        }
    }
Beispiel #15
0
    protected void PlotListGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        ServiceAccess serviceLoader = ServiceAccess.GetInstance();

        FarmService.FarmService farmService = serviceLoader.GetFarm();

        int farmId = Convert.ToInt32(FarmIdHiddenField.Value);

        FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId);

        FillPlotGrid(farm.Plots, e.NewPageIndex);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;

            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");
            }

            FarmIdHiddenField.Value = farmId.ToString();
            try
            {
                // Get the common web service instance.

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

                FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId);
                FarmNameLabel.Text         = farm.FarmName;
                MailingPlanLabel.Text      = farm.MailingPlan.Title;
                CreateDateLabel.Text       = farm.CreateDate.ToShortDateString();
                FarmContactCountLabel.Text = farm.ContactCount.ToString();
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
            }
        }
    }
Beispiel #17
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);
            }
        }
    }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;
            try
            {
                // Get the common web service instance.
                int userId = 0;

                if ((Request.QueryString["userId"] != "") && (Request.QueryString["userId"] != null))
                {
                    int.TryParse(Request.QueryString["userId"], out userId);
                }

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

                UserIdHiddenField.Value = userId.ToString();
                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();

                if (!IsAgentRole)
                {
                    ForAgentLiteral.Visible = true;
                    RegistrationService.RegistrationService regservice = serviceLoader.GetRegistration();
                    RegistrationService.RegistrationInfo    regInfo    = regservice.GetDetails(userId);
                    ForAgentLiteral.Text            = "Selected Agent: " + regInfo.UserName + " / " + regInfo.FirstName + " " + regInfo.LastName + "&nbsp;";
                    ForAgentUserIdHiddenField.Value = userId.ToString();
                }
                else
                {
                    ForAgentLiteral.Visible = false;
                }

                IList <FarmService.MailingPlanInfo> mailingPlans = farmService.GetMailingPlanList();
                MailingPlanDropDownList.DataSource     = mailingPlans;
                MailingPlanDropDownList.DataValueField = "MailingPlanId";
                MailingPlanDropDownList.DataTextField  = "Title";
                MailingPlanDropDownList.DataBind();
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
            }
        }
    }
Beispiel #19
0
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        bool isError = false;

        try
        {
            ServiceAccess                   serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService         farmService   = serviceLoader.GetFarm();
            IList <FarmService.ContactInfo> contacts      = (IList <FarmService.ContactInfo>)Session["Contacts"];
            Session.Remove("Contacts");
            FarmService.FarmInfo farm = new FarmService.FarmInfo();
            farm.FarmName    = FarmNameTextBox.Text;
            farm.MailingPlan = new FarmService.MailingPlanInfo();
            farm.MailingPlan.MailingPlanId = int.Parse(MailingPlanDropDownList.SelectedValue);
            farm.LastModifyBy          = LoginUserId;
            farm.Plots                 = new FarmService.PlotInfo[1];
            farm.Plots[0]              = new FarmService.PlotInfo();
            farm.Plots[0].PlotId       = 0;
            farm.Plots[0].PlotName     = FarmNameTextBox.Text;
            farm.Plots[0].Contacts     = (FarmService.ContactInfo[])contacts;
            farm.Plots[0].LastModifyBy = LoginUserId;
            farm.UserId                = GetAgentId();
            farmService.CreateFarmPlot(farm);
        }
        catch (Exception exception)
        {
            if (exception.Message.Contains("No Contacts processed. Farm cannot be Empty."))
            {
                ErrorLiteral.Text = "No Contacts processed. Farm cannot be Empty.";
            }
            else
            {
                log.Error("UNKNOWN ERROR WHILE CREATING Farm:", exception);
                ErrorLiteral.Text = "UNKNOWN ERROR WHILE CREATING Farm. Please Contact Administrator";
            }
            isError = true;
        }
        if (!isError)
        {
            Response.Redirect("~/Members/FarmManagement.aspx");
        }
    }
Beispiel #20
0
    protected void ContactListGridView_PageIndexChanging(object sender,
                                                         GridViewPageEventArgs e)
    {
        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            int plotId = 0;
            int.TryParse(PlotIdHiddenField.Value, out plotId);
            FarmService.ContactInfo[] contacts = farmService.GetContactListForPlot(plotId);
            ContactListGridView.DataSource = contacts;
            ContactListGridView.PageIndex  = e.NewPageIndex;
            ContactListGridView.DataBind();

            //Validation related Data stored in Hidden Field
            if (farmService.IsDefaultPlot(plotId))
            {
                DefaultContactHiddenField.Value = "true";
                MoveToButton.Enabled            = true;
                //Move to for single contact in a default plot disabled

                /*if (contacts.Length < 2)
                 *  MoveToButton.Enabled = false;
                 * else
                 *  MoveToButton.Enabled = true;*/
            }
            else
            {
                DefaultContactHiddenField.Value = "false";
                MoveToButton.Enabled            = true;
            }

            ContactCountHiddenField.Value = contacts.Length.ToString();
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR:", exception);
        }
    }
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        bool isError = false;

        try
        {
            ServiceAccess                   serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService         farmService   = serviceLoader.GetFarm();
            IList <FarmService.ContactInfo> contacts      = (IList <FarmService.ContactInfo>)Session["Contacts"];
            Session.Remove("Contacts");
            FarmService.PlotInfo plot = new FarmService.PlotInfo();

            plot.PlotId       = 0;
            plot.PlotName     = PlotNameTextBox.Text;
            plot.FarmId       = Convert.ToInt32(FarmIdHiddenField.Value.ToString());
            plot.Contacts     = (FarmService.ContactInfo[])contacts;
            plot.LastModifyBy = LoginUserId;
            farmService.CreatePlot(plot);
        }
        catch (Exception exception)
        {
            if (exception.Message.Contains("Plot Name already in use. Please provide a new Plot Name"))
            {
                ErrorLiteral.Text = "Plot Name already in use. Please provide a new Plot Name";
            }
            else if (exception.Message.Contains("No Contacts processed. Plot cannot be Empty."))
            {
                ErrorLiteral.Text = "No Contacts processed. Plot cannot be Empty.";
            }
            else
            {
                ErrorLiteral.Text = "UNKNOWN ERROR WHILE CREATING A PLOT. Please Contact Administrator";
                log.Error("UNKNOWN ERROR WHILE CREATING A PLOT:", exception);
            }
            isError = true;
        }
        if (!isError)
        {
            Response.Redirect("~/Members/ViewFarm.aspx?farmId=" + Request.QueryString["farmId"]);
        }
    }
Beispiel #22
0
 protected void SelectedAgentButton_Click(object sender, EventArgs e)
 {
     try
     {
         // Get the common web service instance.
         ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
         FarmService.FarmService farmService   = serviceLoader.GetFarm();
         FarmService.FarmInfo[]  farmList;
         farmList = farmService.GetArchivedFarmSummary(GetAgentId());
         FarmGridView.DataSource = farmList;
         FarmGridView.DataBind();
         if (farmList.Length == 0)
         {
             NoFarmDataPanel.Visible = true;
         }
         else
         {
             NoFarmDataPanel.Visible = false;
             for (int i = 0; i < FarmGridView.Rows.Count; i++)
             {
                 if (farmList[i].Deleted == true)
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Red;
                 }
                 else if (farmList[i].PlotCount == 0)
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.Green;
                 }
                 else
                 {
                     FarmGridView.Rows[i].ForeColor = System.Drawing.Color.DarkKhaki;
                 }
             }
         }
     }
     catch (Exception exception)
     {
         log.Error("UNKNOWN ERROR:", exception);
         ErrorLiteral.Text = "UNKNOWN ERROR. Contact Administrator";
     }
 }
Beispiel #23
0
    protected void ContactListGridView_PageIndexChanging(object sender,
                                                         GridViewPageEventArgs e)
    {
        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();
            int plotId = int.Parse(PlotIdHiddenField.Value.ToString());
            FarmService.ContactInfo[] contacts = farmService.GetArchivedContactListForPlot(plotId);
            ContactListGridView.DataSource = contacts;
            ContactListGridView.PageIndex  = e.NewPageIndex;
            ContactListGridView.DataBind();
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR IN ARCHIVE CONTACT LIST PAGINATION:", exception);
            MessageLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
        }
    }
Beispiel #24
0
    protected void ContactListGridView_PageIndexChanging(object sender,
                                                         GridViewPageEventArgs e)
    {
        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            int plotId = 0;
            int.TryParse(PlotIdHiddenField.Value, out plotId);
            ContactListGridView.DataSource = farmService.GetContactListForPlot(plotId);
            ContactListGridView.PageIndex  = e.NewPageIndex;
            ContactListGridView.DataBind();
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR:", exception);
        }
    }
Beispiel #25
0
    protected void SearchFarmResultGridView_PageIndexChanging(object sender,
                                                              GridViewPageEventArgs e)
    {
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            string where = "";
            if (Session["SearchFarmDataWhere"] != null)
            {
                where = Session["SearchFarmDataWhere"].ToString();
            }
            else
            {
                where = GenerateSearchCondition();
            }

            FarmService.FarmDetailsReportInfo[] farms = farmService.GetSearchFarmData(where);
            SearchFarmResultGridView.DataSource = farms;
            SearchFarmResultGridView.PageIndex  = e.NewPageIndex;
            SearchFarmResultGridView.DataBind();

            //Disable actions on deleted Contacts
            for (int i = 0; i < SearchFarmResultGridView.Rows.Count; i++)
            {
                if (farms[SearchFarmResultGridView.Rows[i].DataItemIndex].Deleted)
                {
                    SearchFarmResultGridView.Rows[i].Cells[1].Enabled = false;
                }
            }
            MessageLiteral.Text = "";
            Session["SearchFarmDataPageIndex"] = e.NewPageIndex.ToString();
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR IN SEARCH FARM RESULT FETCHING:", exception);
            ErrorLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPrinterRole)
        {
            CreateFarmButton.Visible      = false;
            ArchivedFarmHyperLink.Visible = false;
        }

        if (!Page.IsPostBack)
        {
            try
            {
                // Get the common web service instance.

                ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
                FarmService.FarmService farmService   = serviceLoader.GetFarm();
                if (IsAgentRole)
                {
                    AgentListPanel.Visible = false;
                    FillFarmGrid(0);
                }
                else
                {
                    AgentListPanel.Visible = true;
                    CommonService commonService = serviceLoader.GetCommon();
                    AgentListDropDownList.DataSource     = commonService.GetAgentsList();
                    AgentListDropDownList.DataValueField = "UserId";
                    AgentListDropDownList.DataTextField  = "UserName";
                    AgentListDropDownList.DataBind();
                    AgentListDropDownList.Items.Insert(0, "Select an Agent");
                }
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR WHILE LOADING FARM MANAGEMENT:", exception);
                ErrorLiteral.Text = "UNKNOWN ERROR. Contact Administrator";
            }
        }
    }
Beispiel #27
0
    protected void DeletePlotButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            int plotId = 0;
            int.TryParse(PlotIdHiddenField.Value, out plotId);

            farmService.DeletePlotContact(plotId, LoginUserId);
            int farmId = 0;
            int.TryParse(FarmIdHiddenField.Value.ToString(), out farmId);
            int plotCount = farmService.GetPlotCountForFarm(farmId);
            if (plotCount == 0)
            {
                Response.Redirect("~/Members/FarmManagement.aspx");
            }
            else
            {
                Response.Redirect("~/Members/ViewFarm.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE DELETING PLOT:", exception);
            if (exception.Message.Contains("This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Plot Cannot be deleted"))
            {
                MessageLiteral.Text = "Error: Farm is currently Firmed Up. It is not possible to delete any Firmed Up mailing plan or Farm. If you still want to delete it, please speak to Customer Service 1-800-Mailing";
            }

            else
            {
                MessageLiteral.Text = "Error: Unable to delete Plot";
            }
        }
    }
    protected void ApproveButton_Click(object sender, EventArgs e)
    {
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            IList <FarmService.ContactInfo> contacts = (IList <FarmService.ContactInfo>)Session["Contacts"];
            Session.Remove("Contacts");
            FarmService.FarmInfo farm = new FarmService.FarmInfo();
            farm.FarmId      = Convert.ToInt32(FarmIdHiddenField.Value);
            farm.FarmName    = FarmNameTextBox.Text;
            farm.MailingPlan = new FarmService.MailingPlanInfo();
            farm.MailingPlan.MailingPlanId = int.Parse(MailingPlanDropDownList.SelectedValue);
            farm.LastModifyBy          = LoginUserId;
            farm.Plots                 = new FarmService.PlotInfo[1];
            farm.Plots[0]              = new FarmService.PlotInfo();
            farm.Plots[0].PlotId       = Convert.ToInt32(PlotIdHiddenField.Value);
            farm.Plots[0].PlotName     = FarmNameTextBox.Text;
            farm.Plots[0].LastModifyBy = LoginUserId;
            farm.Plots[0].Contacts     = (FarmService.ContactInfo[])contacts;
            farm.UserId                = GetAgentId();
            farmService.UpdateFarmPlot(farm);
            Response.Redirect(GetRedirectURL());
        }
        catch (Exception exception)
        {
            if (exception.Message.Contains("You are changing Farm Name and this will change the name of Primary Plot.This name already existing in its Plot lists. Please Provide a different Farm name."))
            {
                ErrorLiteral1.Text = "You are changing Farm Name and this will change the name of Primary Plot.This name already existing in its Plot lists. Please Provide a different Farm name.";
            }
            else
            {
                ErrorLiteral1.Text = "UNKNOWN ERROR! PLEASE CONTACT ADMINISTRATOR";
                log.Error("UNKNOWN ERROR WHILE APPROVING THE CONTACT LISTS IN MODIFY FARM:", exception);
            }
        }
    }
    private void FillFarmGrid(int pageNumber)
    {
        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            FarmService.FarmInfo[] farms = farmService.GetFarmSummary(GetAgentId());
            FarmGridView.DataSource = farms;
            FarmGridView.PageIndex  = pageNumber;
            FarmGridView.DataBind();

            if (farms.Length == 0)
            {
                NoFarmDataPanel.Visible = true;
            }
            else
            {
                NoFarmDataPanel.Visible = false;

                if (IsPrinterRole)
                {
                    for (int i = 0; i < FarmGridView.Rows.Count; i++)
                    {
                        FarmGridView.Rows[i].Cells[0].FindControl("EditHyperLink").Visible = false;
                    }

                    ArchivedFarmHyperLink.Visible = false;
                }
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR:", exception);
            ErrorLiteral.Text = "UNKNOWN ERROR. Contact Administrator";
        }
    }
Beispiel #30
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"));
            int farmId  = Convert.ToInt32(coll.Get("fId"));
            int plotId  = Convert.ToInt32(coll.Get("pId"));

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

            // Get the report data.
            try
            {
                FarmService.FarmService farmService = serviceLoader.GetFarm();
                IList <FarmService.MailingLabelInfo> mailingLabels =
                    farmService.GetMailingLabels(agentId, farmId, plotId);

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

                log.Error("Unknown Error", ex);
            }
        }
    }