Esempio n. 1
0
        protected bool ProjectCenterSet()
        {
            string projectID = (Page.RouteData.Values["project_id"] as string);
            List <ProjectInfoTreeLocation> projectInfoTreeLocation = new ProjectInfoTreeLocationBLL().GetProjectInfoTreeLocationsByProjectID(Convert.ToInt32(projectID));

            return(projectInfoTreeLocation.Count > 0 && projectInfoTreeLocation.First().X != 0);
        }
Esempio n. 2
0
        protected void ButtonAddNewTreeDetails_Click(object sender, System.EventArgs e)
        {
            ProjectInfoTreeLocation ProjectInfoTreeLocation = new ProjectInfoTreeLocationBLL().GetProjectInfoTreeLocationsByProjectID(Convert.ToInt32(RouteData.Values["Project_id"]))[0];
            int count = new Project_OrganismsBLL().GetTotalCountForAllProject_OrganismsByProjectID(Convert.ToInt32(RouteData.Values["Project_id"]));

            Response.RedirectToRoute("tl-tree-details", new
            {
                edit_mode           = "new",
                Project_id          = RouteData.Values["Project_id"],
                project_organism_id = 0,
                number = count + 1,
                x      = ProjectInfoTreeLocation.X,
                y      = ProjectInfoTreeLocation.Y,
                lat    = ProjectInfoTreeLocation.Lat,
                lon    = ProjectInfoTreeLocation.Lon
            });
        }
Esempio n. 3
0
    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 });
        }
    }