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