protected void OdsProject_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e) { int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat); if (result != 0) { Project project = new ProjectBLL().GetProjectByProjectID(result); UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); if (user != null) { // ProjectInfo TextBox txtProjectName = (TextBox)formViewProject.FindControl("txtProjectName"); TextBox txtClient = (TextBox)formViewProject.FindControl("txtClient"); TextBox txtAddress1 = (TextBox)formViewProject.FindControl("txtAddress1"); TextBox txtAddress2 = (TextBox)formViewProject.FindControl("txtAddress2"); DropDownList ddlCity = (DropDownList)formViewProject.FindControl("ddlCity"); TextBox txtState = (TextBox)formViewProject.FindControl("txtState"); TextBox txtZipCode = (TextBox)formViewProject.FindControl("txtZipCode"); TextBox txtDescription = (TextBox)formViewProject.FindControl("txtDescription"); TextBox txtComments = (TextBox)formViewProject.FindControl("txtComments"); ProjectInfo projectInfo = new ProjectInfo(); projectInfo.ProjectName = txtProjectName.Text; projectInfo.Client = txtClient.Text; projectInfo.Address1 = txtAddress1.Text; projectInfo.Address2 = txtAddress2.Text; projectInfo.CityID = Convert.ToInt32(ddlCity.SelectedValue); projectInfo.State = txtState.Text; projectInfo.ZipCode = txtZipCode.Text.Replace("-", ""); projectInfo.Description = txtDescription.Text.Substring(0, Math.Min(txtDescription.Text.Length, 5000)); projectInfo.Comments = txtComments.Text.Substring(0, Math.Min(txtComments.Text.Length, 5000)); projectInfo.ProjectID = project.ProjectID; projectInfo.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoBLL().CreateNewProjectInfo(projectInfo); // // Group_Projects List <Group> groupList = user.Group_Users.Select(instance => instance.Group).ToList(); Group group = groupList[0]; Group_Projects group_Projects = new Eisk.BusinessEntities.Group_Projects(); group_Projects.GroupID = group.GroupID; group_Projects.GroupReference.EntityKey = group.EntityKey; group_Projects.ProjectID = project.ProjectID; group_Projects.ProjectReference.EntityKey = project.EntityKey; new Group_ProjectsBLL().CreateNewGroup_Projects(group_Projects); // } Response.RedirectToRoute("project-details", new { edit_mode = "edit", Project_id = result.ToString() }); } }
protected void odsProjectListing_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); if (user != null) { var group = user.Group_Users.Select(instance => instance.Group).ToList(); e.InputParameters["groupID"] = group[0].GroupID; } }
private static ProjectActionStatus Validate(string Project, actionType act) { ProjectBLL ProjectBLL = new ProjectBLL(); List <Project> Projects = ProjectBLL.GetProjectByFilter(Project.Trim()); if (Projects.Count > 0 && act == actionType.insert) { UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); foreach (var item in Projects) { if (item.Group_Projects.First().GroupID == user.Group_Users.First().GroupID) { return(ProjectActionStatus.Duplicate); } } return(ProjectActionStatus.Success); } else { return(ProjectActionStatus.Success); } }
protected void OdsProject_Organism_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e) { int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat); //string lat = ""; //string lon = ""; if (result != 0) { Project_Organisms project_Organisms = new Project_OrganismsBLL().GetProject_OrganismsByProjectOrganismID(result); ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocationBLL().GetProjectInfoTreeLocationsByProjectID(project_Organisms.ProjectID)[0]; bool fromInventory = false; UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); if (user != null) { // TreeDetail TextBox txtVaras = (TextBox)formViewTlProject_Organism.FindControl("txtVaras"); HiddenField hfDap = (HiddenField)formViewTlProject_Organism.FindControl("hfDap"); TextBox txtDap = (TextBox)formViewTlProject_Organism.FindControl("txtDap"); TextBox txtDapCounter = (TextBox)formViewTlProject_Organism.FindControl("txtDapCounter"); TextBox txtHeight = (TextBox)formViewTlProject_Organism.FindControl("txtHeight"); TextBox txtCommentary = (TextBox)formViewTlProject_Organism.FindControl("txtCommentary"); Label lblNumber = (Label)formViewTlProject_Organism.FindControl("lblNumber"); TextBox txtX = (TextBox)formViewTlProject_Organism.FindControl("txtX"); TextBox txtY = (TextBox)formViewTlProject_Organism.FindControl("txtY"); TextBox txtLat = (TextBox)formViewTlProject_Organism.FindControl("txtLat"); TextBox txtLon = (TextBox)formViewTlProject_Organism.FindControl("txtLon"); RadioButtonList rblActionProposed = (RadioButtonList)formViewTlProject_Organism.FindControl("rblActionProposed"); RadioButtonList rblCondition = (RadioButtonList)formViewTlProject_Organism.FindControl("rblCondition"); // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Edgardo Ramos - 20130928 CheckBox chkLittoral = (CheckBox)formViewTlProject_Organism.FindControl("chkLittoral"); CheckBox chkMaritimeZone = (CheckBox)formViewTlProject_Organism.FindControl("chkMaritimeZone"); // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- TreeDetail treeDetail = new TreeDetail(); if (!string.IsNullOrEmpty(txtVaras.Text) && txtVaras.Text != "0") // Is Cepa { treeDetail.Dap = 0; treeDetail.Dap_Counter = 0; } else if (txtDapCounter.Text == "1") // Solo un Dap { //treeDetail.Dap = Convert.ToDecimal(txtDap.Text);// new DapBLL().GetDap(0); //treeDetail.Dap_Counter = Convert.ToInt32(txtDapCounter.Text); //new DapBLL().GetDapCount(0); treeDetail.Dap = Convert.ToDecimal(hfDap.Value); // new DapBLL().GetDap(0); treeDetail.Dap_Counter = Convert.ToInt32(1); //new DapBLL().GetDapCount(0); } else // Mas de un Dap { string[] daps = hfDap.Value.Split(','); double dapTotal = 0; foreach (string dap in daps) { dapTotal += Convert.ToDouble(dap); }//dapTotal;// new DapBLL().GetDap(0); treeDetail.Dap = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Count())) * 100) / 100); treeDetail.Dap_Counter = Convert.ToInt32(txtDapCounter.Text); //new DapBLL().GetDapCount(0); } treeDetail.Varas = Convert.ToInt32(string.IsNullOrEmpty(txtVaras.Text) ? "0" : txtVaras.Text); treeDetail.Height = Convert.ToDecimal(txtHeight.Text); treeDetail.Commentary = (txtCommentary.Text.Length > txtCommentary.MaxLength) ? txtCommentary.Text.Substring(0, txtCommentary.MaxLength) : txtCommentary.Text; treeDetail.Number = Convert.ToInt32(lblNumber.Text); // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Edgardo Ramos - 20130928 decimal dec; RadioButtonList rblPosition = (RadioButtonList)formViewTlProject_Organism.FindControl("rblPosition"); if (rblPosition.SelectedValue == "0") // Nad83 { treeDetail.X = decimal.TryParse(txtX.Text, out dec) ? Convert.ToDecimal(txtX.Text) : 0; treeDetail.Y = decimal.TryParse(txtY.Text, out dec) ? Convert.ToDecimal(txtY.Text) : 0; if (treeDetail.X != 0 && treeDetail.Y != 0) { Dictionary <string, object> anewpointObj = Utility.ConvertToLatLng(treeDetail.X.ToString(), treeDetail.Y.ToString(), @"~/App_Resources/client-scripts/tl/"); treeDetail.Lat = Convert.ToDecimal(anewpointObj["y"]); txtLat.Text = treeDetail.Lat.ToString(); treeDetail.Lon = Convert.ToDecimal(anewpointObj["x"]); txtLon.Text = treeDetail.Lon.ToString(); } else { treeDetail.Lat = 0; treeDetail.Lon = 0; } } else // StatePlanes { treeDetail.Lat = decimal.TryParse(txtLat.Text, out dec) ? Convert.ToDecimal(txtLat.Text) : 0; treeDetail.Lon = decimal.TryParse(txtLon.Text, out dec) ? Convert.ToDecimal(txtLon.Text) : 0; if (treeDetail.Lat != 0 && treeDetail.Lon != 0) { Dictionary <string, object> anewpointObj = Utility.ConvertToStatePlane(treeDetail.Lon.ToString(), treeDetail.Lat.ToString(), @"~/App_Resources/client-scripts/tl/"); treeDetail.X = Convert.ToDecimal(anewpointObj["x"]); txtX.Text = treeDetail.X.ToString(); treeDetail.Y = Convert.ToDecimal(anewpointObj["y"]); txtY.Text = treeDetail.Y.ToString(); } else { treeDetail.X = 0; treeDetail.Y = 0; } } //treeDetail.X = Convert.ToDecimal(txtX.Text); //treeDetail.Y = Convert.ToDecimal(txtY.Text); //treeDetail.Lat = Convert.ToDecimal(txtLat.Text); //treeDetail.Lon = Convert.ToDecimal(txtLon.Text); treeDetail.Littoral = chkLittoral.Checked; treeDetail.MaritimeZone = chkMaritimeZone.Checked; // --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- treeDetail.CreatedDate = DateTime.Now; treeDetail.CreatorUserID = user.UserID; treeDetail.EditedDate = DateTime.Now; treeDetail.EditorUserID = user.UserID; ActionProposed actionProposed = new ActionProposedBLL().GetActionProposedByActionProposedID(Convert.ToInt32(rblActionProposed.SelectedValue)); treeDetail.ActionProposedID = actionProposed.ActionProposedID; treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey; Condition condition = new ConditionBLL().GetConditionByConditionID(Convert.ToInt32(rblCondition.SelectedValue)); treeDetail.ConditionID = condition.ConditionID; treeDetail.ConditionReference.EntityKey = condition.EntityKey; treeDetail.ProjectOrganismID = project_Organisms.ProjectOrganismID; treeDetail.Project_OrganismsReference.EntityKey = project_Organisms.EntityKey; int treeDetailID = new TreeDetailBLL().CreateNewTreeDetail(treeDetail); if (treeDetail.Varas != null && treeDetail.Varas > 0) // Is Cepa { // } else if (txtDapCounter.Text == "1") // Solo un Dap { Dap dap = new Dap(); dap.DapValue = Convert.ToDecimal(hfDap.Value); dap.TreeDetailsID = treeDetailID; dap.TreeDetailReference.EntityKey = treeDetail.EntityKey; new DapBLL().CreateNewDap(dap); } else // Mas de un Dap { string[] daps = hfDap.Value.Split(','); foreach (string dapString in daps) { Dap dap = new Dap(); dap.DapValue = Convert.ToDecimal(dapString); dap.TreeDetailsID = treeDetailID; dap.TreeDetailReference.EntityKey = treeDetail.EntityKey; new DapBLL().CreateNewDap(dap); } } fromInventory = Convert.ToDecimal(projectInfoTreeLocation.X) == Convert.ToDecimal(treeDetail.X) && Convert.ToDecimal(projectInfoTreeLocation.Y) == Convert.ToDecimal(treeDetail.Y); // } if (fromInventory) { Response.RedirectToRoute("tl-treeinventory", new { project_id = RouteData.Values["project_id"] }); } else { Response.RedirectToRoute("tl", new { Project_id = RouteData.Values["Project_id"] }); Response.RedirectLocation += "?poid=" + project_Organisms.ProjectOrganismID + "&lat=0&lon=0"; } //Response.RedirectToRoute("tl-tree-details_edit", new { edit_mode = "edit", project_id = Page.RouteData.Values["project_id"] as string, project_organism_id = result }); } }
protected void OdsProject_Details_Inserted(object sender, System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs e) { int integer; int result = Convert.ToInt32(e.ReturnValue, System.Globalization.CultureInfo.CurrentCulture.NumberFormat); if (result != 0) { Project project = new ProjectBLL().GetProjectByProjectID(result); UserBLL userBLL = new UserBLL(); Eisk.BusinessEntities.User user = userBLL.GetUserByUserName((HttpContext.Current.User.Identity).Name); if (user != null) { // ProjectInfoTreeLocation TextBox txtX = (TextBox)formViewTlProject.FindControl("txtX"); TextBox txtY = (TextBox)formViewTlProject.FindControl("txtY"); TextBox txtLat = (TextBox)formViewTlProject.FindControl("txtLat"); TextBox txtLon = (TextBox)formViewTlProject.FindControl("txtLon"); TextBox txtParking = (TextBox)formViewTlProject.FindControl("txtParking"); RadioButtonList rblCalc = (RadioButtonList)formViewTlProject.FindControl("rblCalc"); TextBox txtAcres = (TextBox)formViewTlProject.FindControl("txtAcres"); DropDownList ddlDistanceBetweenTrees = (DropDownList)formViewTlProject.FindControl("ddlDistanceBetweenTrees"); TextBox txtLots0 = (TextBox)formViewTlProject.FindControl("txtLots0"); TextBox txtLots1 = (TextBox)formViewTlProject.FindControl("txtLots1"); TextBox txtLots2 = (TextBox)formViewTlProject.FindControl("txtLots2"); TextBox txtLots3 = (TextBox)formViewTlProject.FindControl("txtLots3"); RadioButtonList rblSocialInterest = (RadioButtonList)formViewTlProject.FindControl("rblSocialInterest"); RadioButtonList rblPreviouslyImpacted = (RadioButtonList)formViewTlProject.FindControl("rblPreviouslyImpacted"); ProjectInfoTreeLocation projectInfoTreeLocation = new ProjectInfoTreeLocation(); projectInfoTreeLocation.X = Convert.ToDecimal(txtX.Text); projectInfoTreeLocation.Y = Convert.ToDecimal(txtY.Text); projectInfoTreeLocation.Lat = Convert.ToDecimal(txtLat.Text); projectInfoTreeLocation.Lon = Convert.ToDecimal(txtLon.Text); projectInfoTreeLocation.Parkings = Convert.ToInt32(txtParking.Text); projectInfoTreeLocation.Acres = Convert.ToDecimal(txtAcres.Text); projectInfoTreeLocation.SocialInterest = rblSocialInterest.SelectedValue == "1"; projectInfoTreeLocation.PreviouslyImpacted = rblPreviouslyImpacted.SelectedValue == "1"; projectInfoTreeLocation.Mitigation = Convert.ToInt32(rblCalc.SelectedValue); if (rblCalc.SelectedValue == "0") { projectInfoTreeLocation.Lots0 = projectInfoTreeLocation.Lots1 = projectInfoTreeLocation.Lots2 = projectInfoTreeLocation.Lots3 = 0; } else { projectInfoTreeLocation.Lots0 = Int32.TryParse(txtLots0.Text, out integer) ? integer : 0; projectInfoTreeLocation.Lots1 = Int32.TryParse(txtLots1.Text, out integer) ? integer : 0; projectInfoTreeLocation.Lots2 = Int32.TryParse(txtLots2.Text, out integer) ? integer : 0; projectInfoTreeLocation.Lots3 = Int32.TryParse(txtLots3.Text, out integer) ? integer : 0; projectInfoTreeLocation.DistanceBetweenTrees = null; } projectInfoTreeLocation.ProjectID = project.ProjectID; projectInfoTreeLocation.ProjectReference.EntityKey = project.EntityKey; new ProjectInfoTreeLocationBLL().CreateNewProjectInfoTreeLocation(projectInfoTreeLocation); // } Response.RedirectToRoute(new { edit_mode = "edit", Project_id = result.ToString() }); } }
//------------------------------------------------------------------------------------------------------------------------------------------------------------- public TreeDetail CreateProject_Organism(int varas, decimal height, decimal lat, decimal lon, int[] daps, ActionProposed actionProposed, Condition condition, string commentary, Organism organism, Project project, Eisk.BusinessEntities.User user) { Project_Organisms project_Organism = new Project_Organisms(); project_Organism.CreatorUserID = user.UserID; project_Organism.CreatedDate = DateTime.Now; project_Organism.EditorUserID = user.UserID; project_Organism.EditedDate = DateTime.Now; project_Organism.OrganismID = organism.OrganismID; project_Organism.OrganismReference.EntityKey = organism.EntityKey; project_Organism.ProjectID = project.ProjectID; project_Organism.ProjectReference.EntityKey = project.EntityKey; int project_OrganismID = new Project_OrganismsBLL().CreateNewProject_Organisms(project_Organism); TreeDetail treeDetail = new TreeDetail(); if (varas != 0) // Is Cepa { treeDetail.Dap = 0; treeDetail.Dap_Counter = 0; } else if (daps.Length == 1) // Solo un Dap { treeDetail.Dap = daps[0]; treeDetail.Dap_Counter = 1; } else // Mas de un Dap { double dapTotal = 0; foreach (int dap in daps) { dapTotal += dap; } treeDetail.Dap = Convert.ToDecimal(Math.Round(Math.Sqrt(Math.Pow(dapTotal, 2D) / Convert.ToDouble(daps.Length)) * 100) / 100); treeDetail.Dap_Counter = daps.Length; } treeDetail.Varas = varas; treeDetail.Height = height; treeDetail.Commentary = commentary; List <Project_Organisms> project_Organisms = new Project_OrganismsBLL().GetProject_OrganismsByProjectID(project.ProjectID); Dictionary <string, object> anewpointObj = JavaScriptHelper.ConvertToStatePlane(lon.ToString(), lat.ToString()); treeDetail.Number = project_Organisms.Count; treeDetail.Y = Convert.ToDecimal(anewpointObj["y"]); treeDetail.X = Convert.ToDecimal(anewpointObj["x"]); treeDetail.Lat = Convert.ToDecimal(lat); treeDetail.Lon = Convert.ToDecimal(lon); treeDetail.CreatedDate = DateTime.Now; treeDetail.CreatorUserID = user.UserID; treeDetail.EditedDate = DateTime.Now; treeDetail.EditorUserID = user.UserID; treeDetail.ActionProposedID = actionProposed.ActionProposedID; treeDetail.ActionProposedReference.EntityKey = actionProposed.EntityKey; treeDetail.ConditionID = condition.ConditionID; treeDetail.ConditionReference.EntityKey = condition.EntityKey; treeDetail.ProjectOrganismID = project_Organism.ProjectOrganismID; treeDetail.Project_OrganismsReference.EntityKey = project_Organism.EntityKey; int treeDetailID = new TreeDetailBLL().CreateNewTreeDetail(treeDetail); foreach (decimal dapDecimal in daps) { Dap dap = new Dap(); dap.DapValue = dapDecimal; dap.TreeDetailsID = treeDetailID; dap.TreeDetailReference.EntityKey = treeDetail.EntityKey; new DapBLL().CreateNewDap(dap); } return(treeDetail); }