/*Funcion: actualizar parametros Param: ParameterUpdateView,AuditDataFromWeb Return: status */ public CUDView updateParameter(ParameterUpdateView parameter, AuditDataFromWeb audit) { AuditDao auditDao = new AuditDao(); DataTable auditDaoResult = auditDao.getParameterByParameterID(parameter.ParameterId); String OldValues = "ParameterId: " + parameter.ParameterId; foreach (DataRow row in auditDaoResult.Rows) { if (auditDaoResult.Columns.Contains("ParameterMinValue") && row["ParameterMinValue"] != DBNull.Value) { OldValues = OldValues + ", ParameterMinValue: " + Convert.ToDouble(row["ParameterMinValue"]); } if (auditDaoResult.Columns.Contains("ParameterName") && row["ParameterName"] != DBNull.Value) { OldValues = OldValues + ", ParameterName: " + row["ParameterName"].ToString(); } if (auditDaoResult.Columns.Contains("ParameterXPlot") && row["ParameterXPlot"] != DBNull.Value) { OldValues = OldValues + ", ParameterXPlot: " + (bool)row["ParameterXPlot"]; } if (auditDaoResult.Columns.Contains("ParameterYPlot") && row["ParameterYPlot"] != DBNull.Value) { OldValues = OldValues + ", ParameterYPlot: " + (bool)row["ParameterYPlot"]; } if (auditDaoResult.Columns.Contains("ParameterYPlotRange") && row["ParameterYPlotRange"] != DBNull.Value) { OldValues = OldValues + ", ParameterYPlotRange: " + Convert.ToInt32(row["ParameterYPlotRange"]); } if (auditDaoResult.Columns.Contains("ProcessId") && row["ProcessId"] != DBNull.Value) { OldValues = OldValues + ", ProcessId: " + Convert.ToInt32(row["ProcessId"]); } if (auditDaoResult.Columns.Contains("UnitId") && row["UnitId"] != DBNull.Value) { OldValues = OldValues + ", UnitId: " + row["UnitId"].ToString(); } } ParameterDao Dao = new ParameterDao(); String state = Dao.updateParameter(parameter); CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state); if (logic.update == true) { AuditService auditservice = new AuditService(); String Action = "Update parameter"; String NewValues = "ParameterId: " + parameter.ParameterId + ", ParameterMinValue: " + parameter.ParameterMinValue + ", ParameterName: " + parameter.ParameterName + ", ParameterXPlot: " + parameter.ParameterXPlot + ", ParameterYPlot: " + parameter.ParameterYPlot + ", ParameterYPlotRange: " + parameter.ParameterYPlotRange + ", ProcessId: " + parameter.ProcessId + ", UnitId: " + parameter.UnitId; auditservice.formUpdate(Action, NewValues, OldValues, audit); } return logic; }
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); } } }
/* 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); } } }
/* Funcion: Actualiza parametros Param: ParameterId, ProcessId,ParameterName,UnitId,ParameterMinValue,ParameterXPlot,ParameterYPlot,ParameterYPlotRange Return: Status */ public String updateParameter(ParameterUpdateView parameter) { return context.InsertUpdateDeleteMSQL("EXEC updateParameter @ParameterId= "+parameter.ParameterId+", @ProcessId= "+parameter.ProcessId +", @ParameterName= '"+parameter.ParameterName+"', @UnitId= "+parameter.UnitId+", @ParameterMinValue= "+parameter.ParameterMinValue +", @ParameterXPlot= "+parameter.ParameterXPlot+", @ParameterYPlot= "+parameter.ParameterYPlot+", @ParameterYPlotRange= "+parameter.ParameterYPlotRange+";"); }