コード例 #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 los parametros de una receta
   Param: ParameterValue,ParameterId,RecipeId
   Return: Status
   */
 public String updateRecipeValue(RecipeUpdateValueView parameter)
 {
     return context.InsertUpdateDeleteMSQL("EXEC updateRecipeParameterValue @ParameterValue=" + parameter.ParameterValue + ", @ParameterId=" + parameter.ParameterId + ", @RecipeId=" + parameter.RecipeId + "");
 }
コード例 #3
0
        /*Funcion: actualizar datos receta
          Param: RecipeUpdateValueView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeValue(RecipeUpdateValueView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeParameterByRecipeIdAndParameterId(recipe.RecipeId, recipe.ParameterId);
            String OldValues = "RecipeId: " + recipe.RecipeId;

            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("ParameterId") && row["ParameterId"] != DBNull.Value) { OldValues = OldValues + ", ParameterId: " + Convert.ToInt32(row["ParameterId"]); }
                if (auditDaoResult.Columns.Contains("ParameterValue") && row["ParameterValue"] != DBNull.Value) { OldValues = OldValues + ", ParameterValue: " + Convert.ToInt32(row["ParameterValue"]); }

            }

            //Update
            RecipeDao Dao = new RecipeDao();
            String state = Dao.updateRecipeValue(recipe);
            CUDView logic = CUDVerifyLogic.verifierInsertDeleteUpdate("update", state);
            //Fin update

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe parameter value";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", ParameterId: " + recipe.ParameterId
                    + ", ParameterValue: " + recipe.ParameterValue;

                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);
                }

            }
        }