/*
        Metodo que utiliza para realizar actualizaciones
        */
        private void updateAuxiliar()
        {
            //Se verifica que se haya seleccionado alguna fila de la tabla
            if (HttpContext.Current.Session["ProcessId"] != null)
            {
                int ProcessIdNew = Int32.Parse(HttpContext.Current.Session["ProcessId"].ToString());
                //Se verifica que se hayan aƱadido parametros
                if (verifyParameterTable())
                {
                    //Se crea el servicio
                    ParameterService parameterService = new ParameterService();
                    String reason = Session["reason"].ToString();
                    String user = Context.User.Identity.Name;
                    //Se llenan los datos de la auditoria
                    AuditDataFromWeb audit = new AuditDataFromWeb();
                    audit.Reason = reason;
                    audit.StationIP = General.getIp(this.Page);
                    audit.UserName = user;

                    //Insert Parameters
                    foreach (GridViewRow gvrow in GridView1.Rows)
                    {
                        ParameterUpdateView parameter = new ParameterUpdateView();
                        TextBox lblParameter = (TextBox)gvrow.FindControl("Parameter");
                        TextBox lblMinValue = (TextBox)gvrow.FindControl("MinValue");
                        DropDownList lblUnit = (DropDownList)gvrow.FindControl("Unit");
                        CheckBox lblxPlot = (CheckBox)gvrow.FindControl("xPlot");
                        CheckBox lblyPlot = (CheckBox)gvrow.FindControl("yPlot");
                        TextBox lblIncer = (TextBox)gvrow.FindControl("Incer");

                        Label lblParameterId = (Label)gvrow.FindControl("ParameterId");

                        if (lblParameter.Text != "")
                        {
                            parameter.ParameterMinValue = Double.Parse(lblMinValue.Text);
                            parameter.ParameterName = lblParameter.Text;
                            parameter.ParameterXPlot = lblxPlot.Checked;
                            parameter.ParameterYPlot = lblyPlot.Checked;
                            parameter.ParameterYPlotRange = Int32.Parse(lblIncer.Text);

                            parameter.ProcessId = ProcessIdNew;
                            parameter.UnitId = Int32.Parse(lblUnit.SelectedItem.Value); //aqui se cae
                            parameter.ParameterId = Int32.Parse(lblParameterId.Text);
                            //Se realiza la actualizacion
                            CUDView crud = parameterService.updateParameter(parameter, audit);

                            if (crud.update == false)
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Parameters')", true);
                            }
                            else
                            {
                                clearFields();
                                fillTable();
                            }
                        }
                    }
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Some parameters in Parameter Table has some incorrrect data format.')", true);
                }

            }
        }
        private void updateAuxiliar()
        {
            if (HttpContext.Current.Session["ProcessId"] != null)
            {
                int ProcessIdNew = Int32.Parse(HttpContext.Current.Session["ProcessId"].ToString());

                if (verifyParameterTable())
                {
                    ParameterService parameterService = new ParameterService();

                    //Insert Parameters
                    foreach (GridViewRow gvrow in GridView1.Rows)
                    {
                        ParameterUpdateView parameter = new ParameterUpdateView();
                        TextBox lblParameter = (TextBox)gvrow.FindControl("Parameter");
                        TextBox lblMinValue = (TextBox)gvrow.FindControl("MinValue");
                        DropDownList lblUnit = (DropDownList)gvrow.FindControl("Unit");
                        CheckBox lblxPlot = (CheckBox)gvrow.FindControl("xPlot");
                        CheckBox lblyPlot = (CheckBox)gvrow.FindControl("yPlot");
                        TextBox lblIncer = (TextBox)gvrow.FindControl("Incer");

                        Label lblParameterId = (Label)gvrow.FindControl("ParameterId");

                        if (lblParameter.Text != "")
                        {
                            parameter.ParameterMinValue = Double.Parse(lblMinValue.Text);
                            parameter.ParameterName = lblParameter.Text;
                            parameter.ParameterXPlot = lblxPlot.Checked;
                            parameter.ParameterYPlot = lblyPlot.Checked;
                            parameter.ParameterYPlotRange = Int32.Parse(lblIncer.Text);

                            parameter.ProcessId = ProcessIdNew;
                            parameter.UnitId = Int32.Parse(lblUnit.SelectedItem.Value); //aqui se cae
                            parameter.ParameterId = Int32.Parse(lblParameterId.Text);

                            CUDView crud = parameterService.updateParameter(parameter);

                            if (crud.update == false)
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not update the Parameters')", true);
                            }
                            else
                            {
                                clearFields();
                                fillTable();
                            }
                        }
                    }
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Some parameters in Parameter Table has some incorrrect data format.')", true);
                }

            }
        }