/* Metodo para realizar una actualizacion de un recipe */ private void updateAuxiliar() { //Verifica que un recipe haya sido seleccionado if (HttpContext.Current.Session["IdRecipe"] != null) { if (validatetableParameterTwoForInt()) { //Crea el servicio RecipeService recipeService = new RecipeService(); RecipeUpdateView recipe = new RecipeUpdateView(); recipe.RecipeId = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString()); recipe.RecipeEnable = recipeEnable.Items[0].Selected; String reason = Session["reason"].ToString(); String user = Context.User.Identity.Name; //Llena los datos de la auditoria AuditDataFromWeb audit = new AuditDataFromWeb(); audit.Reason = reason; audit.StationIP = General.getIp(this.Page); audit.UserName = user; //Realiza la actualización CUDView crud = recipeService.updateRecipe(recipe, audit); if (crud.update == true) { int idRecipe = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString()); //Update Parameters foreach (GridViewRow gvrow in GridView1.Rows) { Label lblParameterId = (Label)gvrow.FindControl("ParameterId"); TextBox lblValue = (TextBox)gvrow.FindControl("Value"); if (lblValue.Text != "") { RecipeUpdateValueView newParameter = new RecipeUpdateValueView(); newParameter.ParameterValue = Int32.Parse(lblValue.Text); newParameter.RecipeId = idRecipe; newParameter.ParameterId = Int32.Parse(lblParameterId.Text); crud = recipeService.updateRecipeValue(newParameter, audit); } } //Update Equipments foreach (GridViewRow gvrow in GridView2.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("Link"); Label lblID = (Label)gvrow.FindControl("ID"); Label RecipeEquipmentId = (Label)gvrow.FindControl("RecipeEquipmentId"); RecipeEquipmentView newEquipment = new RecipeEquipmentView(); newEquipment.RecipeId = idRecipe; newEquipment.EquipmentId = lblID.Text; newEquipment.Link = chk.Checked; newEquipment.RecipeEquipmentId = Int32.Parse(RecipeEquipmentId.Text); crud = recipeService.updateRecipeEquipment(newEquipment, audit); } clearFields(); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + crud.errorMessage + "')", true); } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('All parameter values must be numbers')", true); } } }
private void updateAuxiliar() { if (HttpContext.Current.Session["IdRecipe"] != null) { if (validatetableParameterTwoForInt()) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { RecipeService recipeService = new RecipeService(); //Update Recipe bool enable1 = (GridView3.SelectedRow.FindControl("FirstRecipeEnable") as CheckBox).Checked; bool enable2 = (GridView3.SelectedRow.FindControl("SecondRecipeEnable") as CheckBox).Checked; RecipeUpdateView recipe = new RecipeUpdateView(); recipe.RecipeId = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString()); recipe.RecipeEnable = recipeEnable.Items[0].Selected; recipe.FirstRecipeEnable = enable1; recipe.SecondRecipeEnable = enable2; //----------------it can crash CUDView crud = recipeService.updateRecipe(recipe); if (crud.update == true) { //Update Parameters foreach (GridViewRow gvrow in GridView1.Rows) { Label lblParameterId = (Label)gvrow.FindControl("ParameterId"); TextBox lblValue = (TextBox)gvrow.FindControl("Value"); if (lblValue.Text != "") { RecipeUpdateValueView newParameter = new RecipeUpdateValueView(); newParameter.ParameterValue = Int32.Parse(lblValue.Text); newParameter.RecipeId = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString()); newParameter.ParameterId = Int32.Parse(lblParameterId.Text); crud = recipeService.updateRecipeValue(newParameter); } } //Update Equipments foreach (GridViewRow gvrow in GridView2.Rows) { CheckBox chk = (CheckBox)gvrow.FindControl("Link"); Label lblID = (Label)gvrow.FindControl("ID"); RecipeEquipmentView newEquipment = new RecipeEquipmentView(); newEquipment.RecipeId = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString()); newEquipment.EquipmentId = lblID.Text; newEquipment.Link = chk.Checked; crud = recipeService.updateRecipeEquipment(newEquipment); } clearFields(); } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + crud.errorMessage + "')", true); } } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('All parameter values must be numbers')", true); } } }