예제 #1
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";
            }
        }
    }
예제 #2
0
 protected void ContactListGridView_PageIndexChanging(object sender,
                                                      GridViewPageEventArgs e)
 {
     ContactListGridView.DataSource = (IList <FarmService.ContactInfo>)Session["Contacts"];
     ContactListGridView.PageIndex  = e.NewPageIndex;
     ContactListGridView.DataBind();
 }
예제 #3
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);
        }
    }
예제 #4
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";
        }
    }
예제 #5
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);
        }
    }
예제 #6
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());
        }
    }
예제 #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);
            }
        }
    }
예제 #8
0
    protected void DeleteContactButton_Click(object sender, EventArgs e)
    {
        // List of Contacts to be deleted
        List <Int64> contactIdList = new List <Int64>();

        for (int i = 0; i < ContactListGridView.Rows.Count; i++)
        {
            GridViewRow row       = ContactListGridView.Rows[i];
            bool        isChecked = ((CheckBox)row.FindControl("ContactIdCheckBox")).Checked;

            if (isChecked)
            {
                Int64 temp = Int64.Parse(((CheckBox)row.FindControl("ContactIdCheckBox")).ToolTip);
                contactIdList.Add(temp);
            }
        }

        if (contactIdList.Count < 1) // Atleast One Contact to be selected
        {
            MessageLiteral.Text = "Select Atleast One Contact to Delete";
        }
        else
        {
            // Delete the List of Selected Contacts
            try
            {
                // Get the common web service instance.

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

                for (int i = 0; i < contactIdList.Count; i++)
                {
                    farmService.DeleteContact(contactIdList[i], LoginUserId);
                }
                MessageLiteral.Text = "Selected Contact List deleted";

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

                int plotContactCount = farmService.GetContactCountForPlot(plotId);

                // Check If Plot is Empty
                if (plotContactCount > 0)
                {
                    ContactCountLabel.Text = plotContactCount.ToString();
                    FarmService.ContactInfo[] contacts = farmService.GetContactListForPlot(plotId);
                    ContactListGridView.DataSource = contacts;
                    ContactListGridView.DataBind();
                    if (farmService.IsDefaultPlot(plotId))
                    {
                        DefaultContactHiddenField.Value = "true";
                    }
                    else
                    {
                        DefaultContactHiddenField.Value = "false";
                    }

                    ContactCountHiddenField.Value = contacts.Length.ToString();
                }
                else // Action for Empty Plot is to remove the Plot
                {
                    farmService.DeletePlot(plotId, LoginUserId);
                    //Check for Empty Farm
                    if (farmService.GetPlotCountForFarm(Convert.ToInt32(FarmIdHiddenField.Value)) > 0)
                    {
                        Response.Redirect("~/Members/ViewFarm.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
                    }
                    else // Action for Empty Farm is to remove Farm
                    {
                        farmService.DeleteFarm(Convert.ToInt32(FarmIdHiddenField.Value), LoginUserId);
                        Response.Redirect("~/Members/FarmManagement.aspx");
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error("UNKNOWN ERROR WHILE DELETE CONTACT:", exception);
                if (exception.Message.Contains("This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Contact Cannot be deleted"))
                {
                    MessageLiteral.Text = "This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Contact Cannot be deleted";
                }

                else
                {
                    MessageLiteral.Text = "Error: Unable to Delete Contact";
                }
            }
        }
    }
예제 #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.";
            }
        }
    }
예제 #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);
            }
        }
    }
예제 #11
0
    protected void CreateFarmButton_Click(object sender, EventArgs e)
    {
        //Store Farm Details and Farm Contact details into the Session
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();
            //Checking File Type
            if (!ContactListFileUpload.HasFile)
            {
                ErrorLiteral.Text = "Please Select The File";
                return;
            }

            //Check for Duplicate Farm Name
            if (farmService.IsFarmNameDuplicateWhileAddingNewFarm(GetAgentId(), FarmNameTextBox.Text))
            {
                ErrorLiteral.Text = "Farm name already exists, Please enter a different farm name";
                return;
            }

            //Load the Contact File List
            IList <FarmService.ContactInfo> contacts;

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

            ContactListGridView.DataSource = contacts;
            ContactListGridView.DataBind();
            Panel1.Visible      = false;
            Panel2.Visible      = true;
            Session["Contacts"] = contacts;
            ErrorLiteral.Text   = "";
        }
        catch (Exception ex)
        {
            log.Error("UNKNOWN ERROR WHILE CONTACT FILE UPLOAD:", 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("Farm Name already Exist. Please give another name"))
            {
                ErrorLiteral.Text = "Farm Name already Exist. Please give another 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.";
            }
        }
    }
예제 #12
0
    protected void ModifyFarmButton_Click(object sender, EventArgs e)
    {
        //Store Farm Details and Farm Contact details into the Session
        try
        {
            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            //Checking For Duplicate Farm Name
            if (farmService.IsFarmNameDuplicateWhileEditingFarm(
                    GetAgentId(),
                    Convert.ToInt32(FarmIdHiddenField.Value),
                    FarmNameTextBox.Text))
            {
                ErrorLiteral.Text = "Farm name already exists, Please enter a different farm name";
                return;
            }

            IList <FarmService.ContactInfo> contacts = null;
            //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;
                if (!IsAgentRole)
                {
                    ForAgentLiteral1.Visible = true;
                    ForAgentLiteral1.Text    = ForAgentLiteral.Text;
                }
                else
                {
                    ForAgentLiteral1.Visible = false;
                }

                ErrorLiteral.Text = "";
            }
            else
            {
                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     = null;
                farm.UserId                = GetAgentId();
                farmService.UpdateFarmPlot(farm);
                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("Farm Name already Exist"))
            {
                ErrorLiteral.Text = "Farm Name already exists";
            }
            else if (ex.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."))
            {
                ErrorLiteral.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 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.";
            }
        }
    }