コード例 #1
0
        /*
        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);
                }

            }
        }
コード例 #2
0
ファイル: RecipeDao.cs プロジェクト: dcanessa/Proyecto-Boston
 /*
   Funcion: actualiza una receta
   Param: recipeId,recipeEnable
   Return: status
   */
 public String updateRecipe(RecipeUpdateView recipe)
 {
     return context.InsertUpdateDeleteMSQL("EXEC updateRecipe @RecipeId = " + recipe.RecipeId + ", @RecipeStatus = '" + recipe.RecipeEnable+ "';");
 }
コード例 #3
0
        /*Funcion: actualizar una receta
          Param: recipeId,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipe(RecipeUpdateView recipe, AuditDataFromWeb audit)
        {
            CUDView logic = new CUDView();
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeOldValues(recipe.RecipeId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("RecipeStatus") && row["RecipeStatus"] != DBNull.Value) { OldValues = OldValues + ", RecipeEnable: " + (bool)row["RecipeStatus"]; }
            }

            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipe(recipe);
            logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEnable: " + recipe.RecipeEnable
                    ;
                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }

            return logic;
        }
コード例 #4
0
        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);
                }

            }
        }