Example #1
0
    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);
            }
        }
    }
Example #2
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";
            }
        }
    }
    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/FarmManagement.aspx");
            }

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

                int userId = farmService.GetUserIdForPlot(plotId);
                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.PlotInfo plot = farmService.GetPlotDetail(plotId);
                PlotNameLabel.Text     = plot.PlotName;
                ContactCountLabel.Text = plot.ContactCount.ToString();
                CreateDateLabel.Text   = plot.CreateDate.ToShortDateString();

                PlotIdHiddenField.Value = plotId.ToString();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }
Example #4
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.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"]);
        }
    }
Example #5
0
    protected void RestoreContactButton_Click(object sender, EventArgs e)
    {
        bool jumpError = false;

        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();
            int plotId = int.Parse(PlotIdHiddenField.Value.ToString());

            for (int i = 0; i < ContactListGridView.Rows.Count; i++)
            {
                GridViewRow row       = ContactListGridView.Rows[i];
                bool        isChecked = ((CheckBox)row.FindControl("ContactIdCheckBox")).Checked;
                if (isChecked)
                {
                    Int64 contactId = Int64.Parse(((CheckBox)row.FindControl("ContactIdCheckBox")).ToolTip);
                    farmService.RestoreContact(contactId, LoginUserId);
                }
            }

            FarmService.ContactInfo[] contacts = farmService.GetArchivedContactListForPlot(plotId);

            if (contacts.Length == 0)
            {
                Response.Redirect("~/Members/ArchivedPlotList.aspx");
            }
            else
            {
                //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();

                ContactListGridView.DataSource = contacts;
                ContactListGridView.DataBind();
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE RESTORING CONTACT:", exception);
            if (exception.Message.Contains("Parent Plot / Farm is not active. Contact cannot be restored."))
            {
                MessageLiteral.Text = "Parent Plot / Farm is not active. Contact cannot be restored.";
            }
            else
            {
                MessageLiteral.Text = "UNKNOWN ERROR: Please Contact Administrator";
                jumpError           = true;
            }
        }
        if (jumpError)
        {
            Response.Redirect("~/Members/ArchivedPlotList.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (IsPrinterRole)
            {
                DeleteContactButton.Enabled = false;
                EditContactButton.Enabled   = false;
            }

            Int64 contactId = 0;
            if ((Request.QueryString["contactId"] != "") && (Request.QueryString["contactId"] != null))
            {
                Int64.TryParse(Request.QueryString["contactId"], out contactId);
            }

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

            if ((Request.QueryString["parentPage"] != "") && (Request.QueryString["parentPage"] != null))
            {
                ParentPageHiddenField.Value = Request.QueryString["parentPage"];
            }
            else
            {
                ParentPageHiddenField.Value = "";
            }

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

                //Getting Required Data
                FarmService.ContactInfo contact = farmService.GetContactDetails(contactId);
                FarmService.PlotInfo    plot    = farmService.GetPlotDetail(contact.PlotId);
                FarmService.FarmInfo    farm    = farmService.GetFarmDetail(plot.FarmId);
                int contactCount = farmService.GetContactCountForPlot(contact.PlotId);

                int userId = farmService.GetUserIdForFarm(plot.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;
                }

                //Header Details
                FarmNameLabel.Text            = farm.FarmName;
                PlotNameLabel.Text            = plot.PlotName;
                ContactCountLabel.Text        = contactCount.ToString();
                ContactCountHiddenField.Value = contactCount.ToString();

                if (farmService.IsDefaultPlot(plot.PlotId))
                {
                    DefaultPlotFlagHiddenField.Value = "true";
                }
                else
                {
                    DefaultPlotFlagHiddenField.Value = "false";
                }

                CreatedOnLabel.Text  = contact.CreateDate.ToShortDateString();
                ModifiedOnLable.Text = contact.LastModifyDate.ToShortDateString();

                //Hidden Fields
                FarmIdHiddenField.Value    = farm.FarmId.ToString();
                PlotIdHiddenField.Value    = plot.PlotId.ToString();
                ContactIdHiddenField.Value = contact.ContactId.ToString();

                //Contact Details
                ContactIdLabel.Text        = contact.ContactId.ToString();
                ScheduleNumberLabel.Text   = contact.ScheduleNumber.ToString();
                OwnerFullNameLabel.Text    = contact.OwnerFullName;
                LotNumberLabel.Text        = contact.Lot.ToString();
                BlockLabel.Text            = contact.Block;
                SubdivisionLabel.Text      = contact.Subdivision;
                FilingLabel.Text           = contact.Filing;
                SiteAddressLabel.Text      = contact.SiteAddress;
                BedroomsLabel.Text         = contact.Bedrooms.ToString();
                FullBathLabel.Text         = contact.FullBath.ToString();
                ThreeQuarterBathLabel.Text = contact.ThreeQuarterBath.ToString();
                HalfBathLabel.Text         = contact.HalfBath.ToString();
                AcresLabel.Text            = contact.Acres.ToString();
                ActMktComboLabel.Text      = contact.ActMktComb;
                OwnerFirstNameLabel.Text   = contact.OwnerFirstName;
                OwnerLastNameLabel.Text    = contact.OwnerLastName;
                OwnerAddress1Label.Text    = contact.OwnerAddress1;
                OwnerArrdess2Label.Text    = contact.OwnerAddress2;
                OwnerCityLabel.Text        = contact.OwnerCity;
                OwnerStateLabel.Text       = contact.OwnerState;
                OwnerZipLabel.Text         = contact.OwnerZip;
                OwnerCountryLabel.Text     = contact.OwnerCountry;
                SaleDateLabel.Text         = contact.SaleDate.ToShortDateString();
                TransAmountLabel.Text      = contact.TransAmount.ToString();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
                ErrorLiteral.Text = "UNKNOWN ERROR: Contact Administrator";
            }
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (IsPrinterRole)
            {
                MoveToButton.Enabled        = false;
                DeleteContactButton.Enabled = false;
                DeletePlotButton.Enabled    = false;
                AddContactButton.Enabled    = false;
                EditPlotButton.Enabled      = false;
            }
            int plotId = 0;

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

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

            ExportToExcelButton.CausesValidation = false;
            ExportToExcelButton.OnClientClick    = "javascript: window.open('./ExcelOrCsvFileDownload.aspx?plotId=" + plotId.ToString() + "');";
            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)
                {
                    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.PlotInfo plot = farmService.GetPlotDetail(plotId);
                PlotNameLabel.Text             = plot.PlotName;
                ContactCountLabel.Text         = plot.ContactCount.ToString();
                CreateDateLabel.Text           = plot.CreateDate.ToShortDateString();
                FarmIdHiddenField.Value        = plot.FarmId.ToString();
                ContactListGridView.DataSource = plot.Contacts;
                ContactListGridView.DataBind();

                //Default Plot flag for validation in Javascript
                if (farmService.IsDefaultPlot(plotId))
                {
                    DefaultPlotFlagHiddenField.Value = "true";
                }
                else
                {
                    DefaultPlotFlagHiddenField.Value = "false";
                }

                //Validation related Data stored in Hidden Field
                if (farmService.IsDefaultPlot(plot.PlotId))
                {
                    DefaultContactHiddenField.Value = "true";
                    MoveToButton.Enabled            = true;

                    //Move to for single contact in a default plot disabled

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

                ContactCountHiddenField.Value = plot.Contacts.Length.ToString();

                //For Single Contact in Default Plot
                if (IsPrinterRole)
                {
                    for (int i = 0; i < plot.Contacts.Length; i++)
                    {
                        ContactListGridView.Rows[i].Cells[0].FindControl("EditContactHyperLink").Visible = false;
                        ContactListGridView.Rows[i].Cells[0].FindControl("ContactIdCheckBox").Visible    = false;
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }
Example #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Panel1.Visible = true;
            Panel2.Visible = false;

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

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

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

            if (plotId == 0)
            {
                Response.Redirect("~/Members/viewFarm.aspx?farmId=" + farmId);
            }

            FarmIdHiddenField.Value = farmId.ToString();
            PlotIdHiddenField.Value = plotId.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();

                FarmIdHiddenField.Value = farmId.ToString();
                PlotIdHiddenField.Value = plotId.ToString();

                FarmService.PlotInfo plot = farmService.GetPlotDetail(plotId);
                PlotNameTextBox.Text = plot.PlotName;

                if (plot.ContactCount > 0)
                {
                    ContactListFileRequiredFieldValidator.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                log.Error("UNKNOWN ERROR:", ex);
            }
        }
    }
Example #9
0
    protected void ModifyPlotButton_Click(object sender, EventArgs e)
    {
        //Store Plot Details and Plot Contact details into the Session
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            IList <FarmService.ContactInfo> contacts = null;

            //Checking For Duplicate Plot Name
            if (farmService.IsPlotNameDuplicateWhileEditingPlot(
                    Convert.ToInt32(FarmIdHiddenField.Value.ToString()),
                    Convert.ToInt32(PlotIdHiddenField.Value.ToString()),
                    PlotNameTextBox.Text))
            {
                ErrorLiteral.Text = "Plot name already exists, Please enter a different Plot name";
                return;
            }

            //Checking File Type
            if (ContactListFileUpload.HasFile)
            {
                if (ContactListFileUpload.FileName.EndsWith(".csv"))
                {
                    contacts = farmService.GetFarmListFromFile(ContactListFileUpload.FileName, Irmac.MailingCycle.BLLServiceLoader.Farm.ContactFileType.Csv, ContactListFileUpload.FileBytes, LoginUserId);
                }
                else
                {
                    if (ContactListFileUpload.FileName.EndsWith(".xls"))
                    {
                        contacts = farmService.GetFarmListFromFile(ContactListFileUpload.FileName, Irmac.MailingCycle.BLLServiceLoader.Farm.ContactFileType.Excel, ContactListFileUpload.FileBytes, LoginUserId);
                    }
                    else
                    {
                        ErrorLiteral.Text = "Invalid File Uploaded. Please Check your file Extention (Must be either .csv or .xls)";
                        return;
                    }
                }
            }

            if (contacts != null)
            {
                ContactListGridView.DataSource = contacts;
                ContactListGridView.DataBind();
                Panel1.Visible      = false;
                Panel2.Visible      = true;
                Session["Contacts"] = contacts;
                ErrorLiteral.Text   = "";
            }
            else
            {
                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.Contacts     = null;
                plot.LastModifyBy = LoginUserId;
                farmService.UpdatePlot(plot);
                Response.Redirect(GetRedirectURL());
            }
        }
        catch (Exception ex)
        {
            log.Error("UNKNOWN ERROR:", ex);
            if (ex.Message.Contains("Irmac.MailingCycle.BLL.NoDataException"))
            {
                ErrorLiteral.Text = "The file does not have any data.";
            }
            else if (ex.Message.Contains("Irmac.MailingCycle.BLL.InvalidFormatException"))
            {
                ErrorLiteral.Text = "The file is in invalid format.";
            }
            else if (ex.Message.Contains("Irmac.MailingCycle.BLL.InvalidDataException"))
            {
                ErrorLiteral.Text = "Incomplete data in the uploaded file.";
            }
            else if (ex.Message.Contains("Irmac.MailingCycle.BLL.InvalidFieldDataException"))
            {
                ErrorLiteral.Text = "Incomplete data in the uploaded file.";
            }
            else if (ex.Message.Contains("You are changing Primary Plot Name which will change the Farm name. A Farm by this name already exisist. 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 exisist. Please provide a differnt Plot name.";
            }
            else if (ex.Message.Contains("No valid Contact records in the uploaded File."))
            {
                ErrorLiteral.Text = "No valid Contact records in the uploaded File.";
            }
            else
            {
                ErrorLiteral.Text = "Unknown Error. Please Contact Administrator.";
            }
        }
    }
Example #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int plotId = 100107;

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

            //if (plotId == 0)
            //    Response.Redirect("~/Members/FarmManagement.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)
                {
                    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.PlotInfo plot = farmService.GetPlotDetail(plotId);
                FarmIdHiddenField.Value        = plot.FarmId.ToString();
                ContactListGridView.DataSource = plot.Contacts;
                ContactListGridView.DataBind();

                //Block Edit Course for the Printer

                /*
                 * if (IsPrinterRole)
                 * {
                 *  ContactListGridView.Columns.RemoveAt(0);
                 *  ContactListGridView.Columns.RemoveAt(1);
                 *
                 *  for (int i = 0; i < plot.Contacts.Length; i++)
                 *  {
                 *      ContactListGridView.Rows[i].Cells[0].FindControl("EditContactHyperLink").Visible = false;
                 *      ContactListGridView.Rows[i].Cells[0].FindControl("ContactIdCheckBox").Visible = false;
                 *  }
                 * }
                 */
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Int64 contactId = 0;
            if ((Request.QueryString["contactId"] != "") && (Request.QueryString["contactId"] != null))
            {
                Int64.TryParse(Request.QueryString["contactId"], out contactId);
            }

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

            if ((Request.QueryString["parentPage"] != "") && (Request.QueryString["parentPage"] != null))
            {
                ParentPageHiddenField.Value = Request.QueryString["parentPage"];
            }
            else
            {
                ParentPageHiddenField.Value = "";
            }

            try
            {
                // Get the common web service instance.

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

                FarmService.ContactInfo contact = farmService.GetContactDetails(contactId);

                int userId = farmService.GetUserIdForPlot(contact.PlotId);
                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;
                }
                ContactIdLabel.Text          = contact.ContactId.ToString();
                ScheduleNumberTextBox.Text   = contact.ScheduleNumber.ToString();
                OwnerFullNameTextBox.Text    = contact.OwnerFullName;
                LotTextBox.Text              = contact.Lot.ToString();
                BlockTextBox.Text            = contact.Block;
                SubDivisionTextBox.Text      = contact.Subdivision;
                FilingTextBox.Text           = contact.Filing;
                SiteAddressTextBox.Text      = contact.SiteAddress;
                BedroomsTextBox.Text         = contact.Bedrooms.ToString();
                FullBathTextBox.Text         = contact.FullBath.ToString();
                ThreeQuarterBathTextBox.Text = contact.ThreeQuarterBath.ToString();
                HalfBathTextBox.Text         = contact.HalfBath.ToString();
                AcresTextBox.Text            = contact.Acres.ToString();
                ActMktCombTextBox.Text       = contact.ActMktComb;
                OwnerFirstNameTextBox.Text   = contact.OwnerFirstName;
                OwnerLastNameTextBox.Text    = contact.OwnerLastName;
                OwnerAddress1TextBox.Text    = contact.OwnerAddress1;
                OwnerAddress2TextBox.Text    = contact.OwnerAddress2;
                OwnerCityTextBox.Text        = contact.OwnerCity;
                OwnerStateTextBox.Text       = contact.OwnerState;
                OwnerZipTextBox.Text         = contact.OwnerZip;
                OwnerCountryTextBox.Text     = contact.OwnerCountry;
                SaleDateTextBox.Text         = contact.SaleDate.ToShortDateString();
                TransAmountTextBox.Text      = contact.TransAmount.ToString();
                PlotIdHiddenField.Value      = contact.PlotId.ToString();

                FarmService.PlotInfo plot = farmService.GetPlotDetail(Convert.ToInt32(PlotIdHiddenField.Value));
                PlotNameLabel.Text     = plot.PlotName;
                ContactCountLabel.Text = plot.ContactCount.ToString();
                CreateDateLabel.Text   = plot.CreateDate.ToShortDateString();
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR:", exception);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int    farmId            = 0;
            int    plotId            = 0;
            string contactIdsFromGET = "";

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

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

            contactIdsFromGET = Request.QueryString["contactIds"];

            FarmIdHiddenField.Value     = farmId.ToString();
            PlotIdHiddenField.Value     = plotId.ToString();
            ContactIdsHiddenField.Value = contactIdsFromGET;

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

                //Getting Farm Name
                FarmService.FarmInfo farm = farmService.GetFarmDetail(farmId);
                FarmNameLabel.Text = farm.FarmName;

                //Getting From Plot Name
                FarmService.PlotInfo plot = farmService.GetPlotDetail(plotId);
                PlotNameLabel.Text = plot.PlotName;

                //Get Plot List for the Farm
                IList <FarmService.PlotInfo> plots = farmService.GetPlotListSummaryForFarm(farmId);
                PlotListDropDownList.DataSource     = plots;
                PlotListDropDownList.DataValueField = "PlotId";
                PlotListDropDownList.DataTextField  = "PlotName";
                PlotListDropDownList.DataBind();
                PlotListDropDownList.Items.Insert(0, new ListItem("<Select a Plot>", "-1"));
                PlotListDropDownList.Items.Remove(PlotListDropDownList.Items.FindByValue(plotId.ToString()));
                PlotListDropDownList.Items.Add(new ListItem("New Plot ...", "-2"));
                PlotListDropDownList.Attributes.Add("onChange", "javascript: newPlot(this);");
                NewPlotHiddenField.Value = "";
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR WHILE LOADING MOVECONTACT:", exception);
                ErrorLiteral.Text  = "Unable to Load the Farm";
                SaveButton.Visible = false;
            }
        }
        else
        {
            if ((NewPlotHiddenField.Value.ToString() != "") && (PlotListDropDownList.SelectedValue.ToString() == "-2"))
            {
                PlotListDropDownList.Items.FindByValue("-2").Text = NewPlotHiddenField.Value.ToString();
            }
            else
            {
                PlotListDropDownList.Items.FindByValue("-2").Text = "New Plot ...";
                NewPlotHiddenField.Value = "";
            }
        }
    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();
            string contactIds = ContactIdsHiddenField.Value.ToString();

            string[] arrContactId = contactIds.Split(new char[] { ';' });

            RegistrationService.LoginInfo loginInfo = (RegistrationService.LoginInfo)Session["loginInfo"];
            int userId = loginInfo.UserId;

            if (PlotListDropDownList.SelectedValue.ToString() == "-2")
            {
                //Check the New Plot Name for Duplicate
                if (farmService.IsPlotNameDuplicateWhileAddingNewPlot(Convert.ToInt32(FarmIdHiddenField.Value.ToString()), NewPlotHiddenField.Value.ToString()))
                {
                    ErrorLiteral.Text = "Duplicate Plot Name provided. Please provide a different Plot Name";
                    PlotListDropDownList.Items.FindByValue("-2").Text = "New Plot ...";
                    PlotListDropDownList.SelectedIndex = 0;
                    NewPlotHiddenField.Value           = "";
                    return;
                }

                //Default Plot Check
                if (farmService.IsDefaultPlot(Convert.ToInt32(PlotIdHiddenField.Value.ToString())))
                {
                    if (arrContactId.Length >= farmService.GetContactCountForPlot(Convert.ToInt32(PlotIdHiddenField.Value.ToString())))
                    {
                        ErrorLiteral.Text = "Error: Default Plot Cannot be empty.";
                        PlotListDropDownList.Items.FindByValue("-2").Text = "New Plot ...";
                        NewPlotHiddenField.Value = "";
                        return;
                    }
                }

                //Building Model Object
                FarmService.PlotInfo plot = new FarmService.PlotInfo();
                plot.PlotId       = 0;
                plot.PlotName     = NewPlotHiddenField.Value.ToString();
                plot.FarmId       = Convert.ToInt32(FarmIdHiddenField.Value.ToString());
                plot.LastModifyBy = userId;
                int plotId = farmService.CreatePlotForMoveContacts(plot);
                for (int i = 0; i < arrContactId.Length; i++)
                {
                    farmService.MoveContactToPlot(Convert.ToInt64(arrContactId[i]), plotId, "", userId);
                }
            }
            else
            {
                int plotId = int.Parse(PlotListDropDownList.SelectedValue.ToString());
                for (int i = 0; i < arrContactId.Length; i++)
                {
                    farmService.MoveContactToPlot(Convert.ToInt64(arrContactId[i]), plotId, "", userId);
                }
            }

            ErrorLiteral.Text          = "Contacts have been moved successfully.";
            SaveButton.Visible         = false;
            CancelButton.OnClientClick = "javascript: opener.location.href('ViewFarm.aspx?farmId=" + FarmIdHiddenField.Value.ToString() + "'); window.close();";
            CancelButton.Text          = "Close";
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE MOVING A CONTACT:", exception);
            if (exception.Message.Contains("Cannot Empty Default Plot"))
            {
                ErrorLiteral.Text = "Cannot Empty Default Plot";
            }
            else if (exception.Message.Contains("Plot Name already Exist. Please Provide a different Plot Name"))
            {
                ErrorLiteral.Text = "Plot Name already Exist. Please Provide a different Plot Name";
            }
            else
            {
                ErrorLiteral.Text = "Unable to Move a Contact";
            }
        }
    }