/* Metodo para realizar una insersion */ private void saveAuxiliar() { if (Upn2.Text != "" & ProcessSelector.SelectedItem != null & Product2.SelectedItem != null) { if (ProcessSelector.SelectedItem.Value != "" & Product2.SelectedItem.Value != "") { if (validateRecipeonOperation() & checkEnableRecipeInsert()) { UpnService upnService = new UpnService(); UpnInsertView upn = new UpnInsertView(); upn.ProductLineId = Int32.Parse(Product2.SelectedItem.Value); upn.UpnId = Upn2.Text; upn.UPNStatus = upnEnable2.Items[0].Selected; upn.Multisession = multisessionCheck.Items[0].Selected; upn.UpnTypeId = 0; // cambiar, esta alambrado String user = Context.User.Identity.Name; AuditDataFromWeb audit = new AuditDataFromWeb(); audit.Reason = "N/A"; audit.StationIP = General.getIp(this.Page); audit.UserName = user; CUDView crud = upnService.insertUpn(upn, audit); if (crud.insert == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the UPN')", true); } else { foreach (GridViewRow gvrow in GridView2.Rows) { CheckBox operationEnable = (CheckBox)gvrow.FindControl("EnableOperation"); Label lblOperationId = (Label)gvrow.FindControl("OperationId"); Label lblRecipeId = (Label)gvrow.FindControl("recipeOperationId"); Label lblRecipe = (Label)gvrow.FindControl("recipeOperation"); if (lblRecipe.Text != "") { UpnInsertOperationView newOperationUpn = new UpnInsertOperationView(); newOperationUpn.OperationEnable = operationEnable.Checked; newOperationUpn.OperationId = Int32.Parse(lblOperationId.Text); newOperationUpn.ProcessId = Int32.Parse(ProcessSelector.SelectedItem.Value); newOperationUpn.RecipeId = Int32.Parse(lblRecipeId.Text); newOperationUpn.UpnId = upn.UpnId; crud = upnService.insertUpnOperation(newOperationUpn, audit); } } if (crud.insert == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the operation')", true); } fillUpnTable(); Upn.Text = ""; Product.Text = ""; clearOperationTable(); clearProcesses(); fillProducts(); clearRecipeUpn(); FirstDIV.Visible = true; SecondDIV.Visible = false; } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Add at least one enabled recipe to operation table.')", true); } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true); } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true); } }
private void saveAuxiliar() { if (Upn2.Text != "" & ProcessSelector.SelectedItem != null & Product2.SelectedItem != null) { if (ProcessSelector.SelectedItem.Value != "" & Product2.SelectedItem.Value != "") { if (validateRecipeonOperation()) { string confirmValue = Request.Form["confirm_value"]; if (confirmValue == "Yes") { UpnService upnService = new UpnService(); UpnInsertView upn = new UpnInsertView(); upn.ProductLineId = Int32.Parse(Product2.SelectedItem.Value); upn.UpnId = Upn2.Text; upn.UPNStatus = upnEnable2.Items[0].Selected; upn.UpnTypeId = 0; // cambiar, esta alambrado CUDView crud = upnService.insertUpn(upn); if (crud.insert == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the UPN')", true); } else { foreach (GridViewRow gvrow in GridView2.Rows) { CheckBox operationEnable = (CheckBox)gvrow.FindControl("EnableOperation"); Label lblOperationId = (Label)gvrow.FindControl("OperationId"); Label lblRecipeId = (Label)gvrow.FindControl("recipeOperationId"); Label lblRecipe = (Label)gvrow.FindControl("recipeOperation"); if (lblRecipe.Text != "") { UpnInsertOperationView newOperationUpn = new UpnInsertOperationView(); newOperationUpn.OperationEnable = operationEnable.Checked; newOperationUpn.OperationId = Int32.Parse(lblOperationId.Text); newOperationUpn.ProcessId = Int32.Parse(ProcessSelector.SelectedItem.Value); newOperationUpn.RecipeId = Int32.Parse(lblRecipeId.Text); newOperationUpn.UpnId = upn.UpnId; crud = upnService.insertUpnOperation(newOperationUpn); } } if (crud.insert == false) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the operation')", true); } fillUpnTable(); Upn.Text = ""; Product.Text = ""; clearOperationTable(); clearProcesses(); fillProducts(); clearRecipeUpn(); FirstDIV.Visible = true; SecondDIV.Visible = false; } } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Add at least one recipe to operation table.')", true); } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true); } } else { this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please complete all fields.')", true); } }
/* Funcion: Insertar Operaciones de los Upn Param: upnId, OperationID,RecipeID,OperationEnable Return: Status */ public String insertUpnOperation(UpnInsertOperationView upnOperationView) { return context.InsertUpdateDeleteMSQL("EXEC createUpnOperation @UpnId='"+upnOperationView.UpnId+"', @ProcessId="+ upnOperationView.ProcessId + ", @OperationId=" + upnOperationView.OperationId + ",@RecipeId=" + upnOperationView.RecipeId + ", @OperationEnable=" + upnOperationView .OperationEnable+ ""); }
/*Funcion: Inserta una operacion Upn Param: UpnInsertOperationView, AuditDataFromWeb Return: Lista UpnOperationView */ public CUDView insertUpnOperation(UpnInsertOperationView upnOperationView, AuditDataFromWeb audit) { UpnDao Dao = new UpnDao(); String state = Dao.insertUpnOperation(upnOperationView); CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("insert", state); if (logic.insert == true) { AuditService auditservice = new AuditService(); String Action = "Insert new upn operation"; String NewValues = "UpnId: " + upnOperationView.UpnId + ", RecipeId: " + upnOperationView.RecipeId + ", ProcessId: " + upnOperationView.ProcessId + ", OperationId: " + upnOperationView.OperationId + ", OperationEnable: " + upnOperationView.OperationEnable; auditservice.formInsert(Action, NewValues, audit); } return logic; }