Exemplo n.º 1
0
        /*Funcion: Crea una RecipeEquipment a partir de los datos de la base
          Param: DataTable
          Return: Lista RecipeEquipmentView
          */
        public List<RecipeEquipmentView> buildEquipment(DataTable DaoResult)
        {
            List<RecipeEquipmentView> ViewList = new List<RecipeEquipmentView>();
            foreach (DataRow row in DaoResult.Rows)
            {
                RecipeEquipmentView x = new RecipeEquipmentView();
                if (DaoResult.Columns.Contains("EquipmentName") && row["EquipmentName"] != DBNull.Value) { x.EquipmentName = row["EquipmentName"].ToString(); }
                if (DaoResult.Columns.Contains("ID") && row["ID"] != DBNull.Value) { x.ID = row["ID"].ToString(); }
                if (DaoResult.Columns.Contains("Link") && row["Link"] != DBNull.Value) { x.Link = (bool)row["Link"]; }
                if (DaoResult.Columns.Contains("GroupId") && row["GroupId"] != DBNull.Value) { x.GroupId = Convert.ToInt32(row["GroupId"]); }
                if (DaoResult.Columns.Contains("RecipeEquipmentId") && row["RecipeEquipmentId"] != DBNull.Value) { x.RecipeEquipmentId = Convert.ToInt32(row["RecipeEquipmentId"]); }

                ViewList.Add(x);
            }
            return ViewList;
        }
        /*
        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);
                }

            }
        }
Exemplo n.º 3
0
        /*Funcion: actualizar equipos de la receta
          Param: RecipeEquipmentView,AuditDataFromWeb
          Return: status
          */
        public CUDView updateRecipeEquipment(RecipeEquipmentView recipe, AuditDataFromWeb audit)
        {
            AuditDao auditDao = new AuditDao();
            DataTable auditDaoResult = auditDao.getRecipeEquipmentByRecipeEquipMentIdAndRecipeId(recipe.RecipeId, recipe.RecipeEquipmentId);
            String OldValues = "RecipeId: " + recipe.RecipeId;
            foreach (DataRow row in auditDaoResult.Rows)
            {
                if (auditDaoResult.Columns.Contains("RecipeEquipmentId") && row["RecipeEquipmentId"] != DBNull.Value) { OldValues = OldValues + ", RecipeEquipmentId: " + Convert.ToInt32(row["RecipeEquipmentId"]); }

                if (auditDaoResult.Columns.Contains("Link") && row["Link"] != DBNull.Value) { OldValues = OldValues + ", Link: " + (bool)row["Link"]; }

            }

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

            if (logic.update == true)
            {
                AuditService auditservice = new AuditService();
                String Action = "Update recipe equipment";
                String NewValues = "RecipeId: " + recipe.RecipeId
                    + ", RecipeEquipmentId: " + recipe.RecipeEquipmentId
                    + ", Link: " + recipe.Link;
                auditservice.formUpdate(Action, NewValues, OldValues, audit);
            }
            return logic;
        }
Exemplo n.º 4
0
 /*
   Funcion: Actualiza el equipo de una receta
   Param: RecipeId, RecipeEquipmentId,RecipeEquipmentLink
   Return: Status
   */
 public String updateRecipeEquipment(RecipeEquipmentView recipeEquipment)
 {
     return context.InsertUpdateDeleteMSQL("EXEC updateRecipeEquipmentLink @RecipeId=" + recipeEquipment.RecipeId + " ,@RecipeEquipmentId=" + recipeEquipment.RecipeEquipmentId + " ,@link=" + recipeEquipment.Link + "");
 }
        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);
                }

            }
        }