コード例 #1
0
        protected void enableSecondUser_Click(object sender, ImageClickEventArgs e)
        {
            if (HttpContext.Current.Session["IdRecipe"] != null)
            {
                RecipeService recipeService = new RecipeService();
                RecipeUpdateSecondLoginView update = new RecipeUpdateSecondLoginView();

                string DOMAINUSER = User.Identity.Name;
                string[] paramsLogin = DOMAINUSER.Split('\\');

                update.RecipeId = Int32.Parse(HttpContext.Current.Session["IdRecipe"].ToString());
                update.SecondUserLoginPermision = paramsLogin[1].ToString();// login with actice directory
                update.FirstLogin = (GridView3.SelectedRow.FindControl("FirstUserLoginPermision") as Label).Text;

                bool enable1 = (GridView3.SelectedRow.FindControl("FirstRecipeEnable") as CheckBox).Checked;
                bool enable2 = (GridView3.SelectedRow.FindControl("SecondRecipeEnable") as CheckBox).Checked;

                update.enableFirstUser = enable1;
                update.enableSecondUser = enable2;

                CUDView crud = recipeService.updateSecondEnable(update);

                if (crud.update == false)
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + crud.errorMessage + "')", true);
                }
                else
                {
                    this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('The recipe was activated')", true);
                    fillRecipeTable();
                }
            }
        }
コード例 #2
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);
                }

            }
        }
コード例 #3
0
        /*
        Metodo utilizado para insertar recipes
        */
        private void saveAuxiliar()
        {
            if (Product2.SelectedItem != null & Process2.SelectedItem != null & Operation2.SelectedItem != null)
            {
                if (Process2.SelectedItem.Value != "" & Operation2.SelectedItem.Value != "")
                {
                    if (validateParameterOnRecipeInsert())
                    {
                        if (validatetableParameterOneForInt())
                        {
                            //Crea el servicio
                            RecipeService recipeService = new RecipeService();
                            RecipeInsertView recipe = new RecipeInsertView();
                            recipe.ProcessId = Int32.Parse(Process2.SelectedItem.Value);
                            recipe.OperationId = Int32.Parse(Operation2.SelectedItem.Value);
                            recipe.RecipeEnable = recipeEnable2.Items[0].Selected;
                            String user = Context.User.Identity.Name;
                            String reason = "N/A";
                            //Añade los datos para la auditoria
                            AuditDataFromWeb audit = new AuditDataFromWeb();
                            audit.Reason = reason;
                            audit.StationIP = General.getIp(this.Page);
                            audit.UserName = user;
                            //Realiza la insercion
                            CUDView crud = recipeService.insertRecipe(recipe, audit);
                            string idRecipNew = crud.insertPK;

                            if (crud.insert == false)
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the recipe')", true);
                            }
                            else
                            {

                                //Insert Parameters
                                foreach (GridViewRow gvrow in GridView4.Rows)
                                {
                                    Label lblParameterId = (Label)gvrow.FindControl("ParameterId");
                                    TextBox lblValue = (TextBox)gvrow.FindControl("Value");

                                    if (lblValue.Text != "")
                                    {
                                        RecipeParameterInsertView newParameter = new RecipeParameterInsertView();
                                        newParameter.ParameterId = Int32.Parse(lblParameterId.Text);
                                        newParameter.ParameterValue = Int32.Parse(lblValue.Text);
                                        newParameter.RecipeId = Int32.Parse(idRecipNew);

                                        crud = recipeService.InsertRecipeParameter(newParameter, audit);
                                    }
                                }

                                //Insert Equipments
                                foreach (GridViewRow gvrow in GridView5.Rows)
                                {
                                    CheckBox chk = (CheckBox)gvrow.FindControl("Link");
                                    Label lblID = (Label)gvrow.FindControl("ID");
                                    Label lblEquipment = (Label)gvrow.FindControl("EquipmentName");

                                    RecipeEquipmentInsertView newEquipment = new RecipeEquipmentInsertView();
                                    newEquipment.EquipmentId = lblID.Text;
                                    newEquipment.Link = chk.Checked;
                                    newEquipment.RecipeId = Int32.Parse(idRecipNew);
                                    newEquipment.OperationId = recipe.OperationId;
                                    crud = recipeService.insertRecipeEquipment(newEquipment, audit);
                                }

                                clearFields();
                            }

                        }
                        else
                        {
                            this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('All parameter values must be numbers')", true);
                        }
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please add parameters for this process.')", 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);
            }
        }
コード例 #4
0
 /*
 Metodo que llena la tabla de recetas
 */
 private void fillRecipeTable()
 {
     RecipeService recipeService = new RecipeService();
     List<RecipeView> x = recipeService.getRecipeData();
     GridView3.DataSource = x;
     GridView3.PageIndex = 0;
     GridView3.DataBind();
 }
コード例 #5
0
        /*
        Metodo que llena el dropdown list de productos
        */
        private void fillProducts()
        {
            RecipeService recipeService = new RecipeService();
            List<ProductsView> recipeProduct = recipeService.getProducts();
            Product2.DataSource = recipeProduct;
            Product2.DataBind();

            ListItem l = new ListItem("", "", true);
            l.Selected = true;
            Product2.Items.Insert(0, l);
        }
コード例 #6
0
        /*
        Metodo que llena el drodownlist de procesos cuando se selecciona un producto
        */
        private void fillProcess(int ProductSelected)
        {
            RecipeService recipeService = new RecipeService();
            List<RecipeProcessView> recipeProcess = recipeService.getRecipeProcessForProduct(ProductSelected);
            Process2.DataSource = recipeProcess;
            Process2.DataBind();

            ListItem l = new ListItem("", "", true);
            l.Selected = true;
            Process2.Items.Insert(0, l);
        }
コード例 #7
0
 /*
 Metodo que llena la tabla de equipos cuando una operacion es seleccionada
 */
 private void fillEquipmentTable(int OperationSelected)
 {
     RecipeService recipeService = new RecipeService();
     List<RecipeEquipmentView> equipmentData = recipeService.getEquipmentByOperation(OperationSelected);
     GridView5.DataSource = equipmentData;
     GridView5.DataBind();
 }
コード例 #8
0
 /*Funcion: Obtiene todas los productos
   Param:
   Return: Lista ProductsView
   */
 public List<ProductsView> getProducts()
 {
     RecipeService recipe = new RecipeService();
     return recipe.getProducts();
 }
コード例 #9
0
        /*
        Metodo que actualiza los datos, segun se va cambiando la seleccion de la fila de la tabla de recipes
        */
        protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string value = GridView2.SelectedPersistedDataKey.Value.ToString();
            foreach (GridViewRow row in GridView2.Rows)
            {
                if (row.RowIndex == GridView2.SelectedIndex)
                {
                    row.BackColor = ColorTranslator.FromHtml("#A1DCF2");
                    row.ToolTip = string.Empty;
                }
                else
                {
                    row.BackColor = ColorTranslator.FromHtml("#FFFFFF");
                    row.ToolTip = "Click to select this Operation";
                }
            }

            RecipeService a = new RecipeService();
            List<RecipeView> x = a.searchRecipeByOperation(Int32.Parse(value));

            RecipeUpn.DataSource = x;
            RecipeUpn.DataBind();

            ListItem l = new ListItem("", "", true);
            l.Selected = true;
            RecipeUpn.Items.Insert(0, l);
        }
コード例 #10
0
 /*
 Metodo utilizado para llenar la tabla de recipes con los datos filtrados en la busqueda
 */
 protected void searchButton_Click(object sender, ImageClickEventArgs e)
 {
     RecipeService a = new RecipeService();
     List<RecipeView> x = a.searchRecipe(searchText.Text);
     GridView3.DataSource = x;
     GridView3.DataBind();
 }
コード例 #11
0
 private void fillOperationTable(int ProcessSelected)
 {
     RecipeService recipeService = new RecipeService();
     List<RecipeOperationView> recipeOperation = recipeService.getRecipeOperationForProcess(ProcessSelected);
     GridView2.DataSource = recipeOperation;
     GridView2.DataBind();
 }
コード例 #12
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);
                }

            }
        }
コード例 #13
0
        private void saveAuxiliar()
        {
            if (Product2.SelectedItem != null & Process2.SelectedItem != null & Operation2.SelectedItem != null)
            {
                if (Process2.SelectedItem.Value != "" & Operation2.SelectedItem.Value != "")
                {

                    if (validatetableParameterOneForInt())
                    {
                        string confirmValue = Request.Form["confirm_value"];
                        if (confirmValue == "Yes")
                        {
                            RecipeService recipeService = new RecipeService();
                            RecipeInsertView recipe = new RecipeInsertView();

                            recipe.ProcessId = Int32.Parse(Process2.SelectedItem.Value);
                            recipe.OperationId = Int32.Parse(Operation2.SelectedItem.Value);

                            string DOMAINUSER = User.Identity.Name;
                            string[] paramsLogin = DOMAINUSER.Split('\\');
                            recipe.FirstUserLoginPermision = paramsLogin[1].ToString();// login with actice directory

                            CUDView crud = recipeService.insertRecipe(recipe);
                            string idRecipNew = crud.insertPK;

                            if (crud.insert == false)
                            {
                                this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Could not insert the recipe')", true);
                            }
                            else
                            {

                                //Insert Parameters
                                foreach (GridViewRow gvrow in GridView4.Rows)
                                {
                                    Label lblParameterId = (Label)gvrow.FindControl("ParameterId");
                                    TextBox lblValue = (TextBox)gvrow.FindControl("Value");

                                    if (lblValue.Text != "")
                                    {
                                        RecipeParameterInsertView newParameter = new RecipeParameterInsertView();
                                        newParameter.ParameterId = Int32.Parse(lblParameterId.Text);
                                        newParameter.ParameterValue = Int32.Parse(lblValue.Text);
                                        newParameter.RecipeId = Int32.Parse(idRecipNew);
                                        crud = recipeService.InsertRecipeParameter(newParameter);
                                    }
                                }

                                //Insert Equipments
                                foreach (GridViewRow gvrow in GridView5.Rows)
                                {
                                    CheckBox chk = (CheckBox)gvrow.FindControl("Link");
                                    Label lblID = (Label)gvrow.FindControl("ID");
                                    Label lblEquipment = (Label)gvrow.FindControl("EquipmentName");

                                    RecipeEquipmentInsertView newEquipment = new RecipeEquipmentInsertView();
                                    newEquipment.EquipmentId = lblID.Text;
                                    newEquipment.Link = chk.Checked;
                                    newEquipment.RecipeId = Int32.Parse(idRecipNew);
                                    newEquipment.OperationId = recipe.OperationId;
                                    crud = recipeService.insertRecipeEquipment(newEquipment);
                                }

                                clearFields();
                            }
                        }
                    }
                    else
                    {
                        this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('All parameter values must be numbers')", 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);
            }
        }
コード例 #14
0
        /*
        Metodo que actualiza los datos, segun se va cambiando la seleccion de la fila de la tabla de recipes
        */
        protected void GridView3_SelectedIndexChanged(object sender, EventArgs e)
        {
            recipeEnable.Items[0].Enabled = false;
            //Complete the textbox with the information of the selected row
            Recipe.Text = (GridView3.SelectedRow.FindControl("Recipe") as Label).Text;
            Product.Text = (GridView3.SelectedRow.FindControl("Product") as Label).Text;
            Process.Text = (GridView3.SelectedRow.FindControl("Process") as Label).Text;
            Operation.Text = (GridView3.SelectedRow.FindControl("Operation") as Label).Text;
            recipeEnable.Items[0].Selected = (GridView3.SelectedRow.FindControl("Enabled") as CheckBox).Checked;
            int value = Int32.Parse(GridView3.SelectedPersistedDataKey.Value.ToString());
            //Guarda en un cookie el id del recipe
            HttpContext.Current.Session["IdRecipe"] = value;

            foreach (GridViewRow row in GridView3.Rows)
            {
                if (row.RowIndex == GridView3.SelectedIndex)
                {
                    row.BackColor = ColorTranslator.FromHtml("#A1DCF2");
                    row.ToolTip = string.Empty;
                }
                else
                {
                    row.BackColor = ColorTranslator.FromHtml("#FFFFFF");
                    row.ToolTip = "Click to select this Recipe";
                }
            }

            RecipeService recipeService = new RecipeService();

            List<RecipeParameterView> parameterData = recipeService.getRecipeParameterData(value);
            GridView1.DataSource = parameterData;
            GridView1.DataBind();

            List<RecipeEquipmentView> equipmentData = recipeService.getRecipeEquipmentData(value);
            GridView2.DataSource = equipmentData;
            GridView2.DataBind();

            FirstDIV.Visible = true;
            SecondDIV.Visible = false;

            GridView1.Enabled = false;
            GridView2.Enabled = false;
        }
コード例 #15
0
        /*
        Metodo que llena el drodownlist de operation cuando se selecciona un proceso
        */
        private void fillOperation(int ProcessSelected)
        {
            RecipeService recipeService = new RecipeService();
            List<RecipeOperationView> recipeOperation = recipeService.getRecipeOperationForProcess(ProcessSelected);
            Operation2.DataSource = recipeOperation;
            Operation2.DataBind();

            ListItem l = new ListItem("", "", true);
            l.Selected = true;
            Operation2.Items.Insert(0, l);
        }
コード例 #16
0
 /*Funcion: Obtiene todas los productos
   Param:
   Return: Lista ProductsView
   */
 public List<RecipeProcessView> getProcessForProduct(int idProducts)
 {
     RecipeService recipe = new RecipeService();
     return recipe.getRecipeProcessForProduct(idProducts);
 }
コード例 #17
0
 /*
 Metodo que llena la tabla de parametros a partir de un proceso
 */
 private void fillParameterTable(int ProcessSelected)
 {
     RecipeService recipeService = new RecipeService();
     List<RecipeParameterView> parameterData = recipeService.getParameterByProcess(ProcessSelected);
     GridView4.DataSource = parameterData;
     GridView4.DataBind();
 }
コード例 #18
0
 /*Funcion: Obtiene una lista de parametros de una seccion
   Param:  idSeccion
   Return: Lista RecipeParameterView
   */
 public List<RecipeParameterView> getParameterBySession(String session)
 {
     SessionDao Dao = new SessionDao();
     DataTable DaoResult = Dao.getParameterBySession(session);
     RecipeService Recipe = new RecipeService();
     return Recipe.buildParameter(DaoResult);
 }
コード例 #19
0
 public RecipeController(RecipeService recipeService)
 {
     _recipeService = recipeService;
 }