Beispiel #1
0
        private void ucSign1_OnSign(bool login)
        {
            if (login)
            {
                if (nodeSolutionInProcess != null)
                {
                    ///si el nuevo nodo seleccionado es un estandar de verificación
                    ///reasignar el tipo de solucion intermedia de su solución padre
                    int type_sol = Convert.ToInt32(nodeSolutionInProcess["Type_sol"]);

                    if (type_sol == 3 || type_sol == 4)
                    {
                        if (nodeSolutionInProcess.Level == 1)
                        {
                            type_sol = 1;
                        }
                        if (nodeSolutionInProcess.Level == 2)
                        {
                            type_sol = 2;
                        }
                    }

                    FormSelMethods fmSelMethods = new FormSelMethods(group_solution, type_sol);

                    if (fmSelMethods.ShowDialog() == DialogResult.OK)
                    {
                        // --- guardar grupo de solución
                        CGroup_solutionFactory fagroup_solution = new CGroup_solutionFactory();
                        bool result = false;

                        if (!(result = fagroup_solution.Update(group_solution)))
                        {
                            result = fagroup_solution.Insert(group_solution);
                        }

                        // --- guardando soluciones
                        if (result)
                        {
                            // --- guardar los cambios en las soluciones
                            CSolutionFactory faSolution      = new CSolutionFactory();
                            bool             result_solution = false;
                            for (int i = 0; i < lstSolution.Count; i++)
                            {
                                result_solution = false;

                                if (lstSolution[i].Idsolution == 0)
                                {
                                    #region Grabar metodos a nueva solución ingresada

                                    lstSolution[i].Idgroup_solution = group_solution.Idgroup_solution;
                                    lstSolution[i].Cod_solution     = null;

                                    if (!(result_solution = faSolution.Update(lstSolution[i])))
                                    {
                                        result_solution = faSolution.Insert(lstSolution[i]);
                                    }

                                    // --- asignar un correlativo dependiendo del tipo de solución
                                    // 1:solución intermedia1, 2:solución intermedia 2, 3:estandar de verificación
                                    if (result_solution)
                                    {
                                        ModCorrelatives oModCorrelatives = new ModCorrelatives();
                                        if (lstSolution[i].Type_sol == 1 || lstSolution[i].Type_sol == 2)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(ModCorrelatives.Correlative.SolucionIntermedia);
                                        }
                                        else if (lstSolution[i].Type_sol == 3 || lstSolution[i].Type_sol == 4)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(ModCorrelatives.Correlative.EstandarVerificacion);
                                        }

                                        faSolution.Update(lstSolution[i]);
                                    }

                                    if (result_solution)
                                    {
                                        // --- grabar métodos de la solución
                                        CSolution_methodsFactory faSolution_methods = new CSolution_methodsFactory();
                                        CSolution_methods        oSolution_methods  = new CSolution_methods();
                                        string concatMethods          = "";
                                        bool   result_solution_method = false;

                                        // --- grabar linkeo de solución y métodos
                                        foreach (CMethodMini item in fmSelMethods.LstMethodMini)
                                        {
                                            if (item.Sel)
                                            {
                                                // indexar método a la solución
                                                oSolution_methods                   = new CSolution_methods();
                                                oSolution_methods.Idsolution        = lstSolution[i].Idsolution;
                                                oSolution_methods.Idtemplate_method = item.Idtemplate_method;
                                                oSolution_methods.Status            = true;

                                                if (!(result_solution_method = faSolution_methods.Update(oSolution_methods)))
                                                {
                                                    result_solution_method = faSolution_methods.Insert(oSolution_methods);
                                                }

                                                // concatenar método
                                                concatMethods += concatMethods.Trim().Length == 0 ? item.Cod_template_method : ", " + item.Cod_template_method;
                                            }
                                        }

                                        // asignar concatenado de métodos seleccionados al campo de la solucion[i]
                                        lstSolution[i].Concat_cod_methods = concatMethods;
                                        faSolution.Update(lstSolution[i]);
                                    }
                                    #endregion
                                }
                            }

                            treeSolInterm.DataSource = lstSolution;
                            FlagSolutionInProcess    = false;

                            ShowStatusButtons();

                            new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();

                            ucSign1.Clear();
                            treeSolInterm.ExpandAll();
                        }

                        onSignSolInterm(group_solution);
                    }
                }
                else
                {
                    ///No existe ningún nodo en proceso, entonces los cambios
                    ///fueron sobre el estado de las soluciones
                    ///
                    CSolutionFactory faSolution = new CSolutionFactory();
                    for (int i = 0; i < lstSolution.Count; i++)
                    {
                        faSolution.Update(lstSolution[i]);
                    }

                    treeSolInterm.DataSource = lstSolution;

                    ShowStatusButtons();
                    new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();
                    ucSign1.Clear();
                    treeSolInterm.ExpandAll();

                    onSignSolInterm(group_solution);
                }
            }
            else
            {
                new FormMessage("Error", "Contraseña incorrecta.", true, false).ShowDialog();
            }
        }
Beispiel #2
0
        private void ucSign1_OnSign(bool login)
        {
            if (login)
            {
                if (ckDisabledSolution.Checked)
                {
                    //desactiva toda solución y sus métodos
                    if (MessageBox.Show("Esta seguro que desea desactivar la solución.", "Desactivando solución", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        //desactivar solucion
                        TreeListNode     node = treeSolInterm.FocusedNode;
                        int              idsolution_interm = Convert.ToInt32(node["Idsolution_interm"]);
                        CSolution_interm sol = new CSolution_intermFactory().GetAll().Where(x => x.Idsolution_interm == idsolution_interm).FirstOrDefault();
                        sol.Solution_obs    = cbMotivo.Text;
                        sol.Solution_status = false;
                        if (sol != null)
                        {
                            new CSolution_intermFactory().Update(sol);
                        }
                    }
                }
                else
                {
                    if (Son_Datos_Correctos())
                    {
                        //según la ubicación de la pagina graba
                        //guardando soluciones
                        int idsolution_interm = 0;
                        CSolution_intermFactory faSolution_interm = new CSolution_intermFactory();
                        bool result_solution = false;

                        TreeListNode node = treeSolInterm.FocusedNode;
                        idsolution_interm = Convert.ToInt32(node["Idsolution_interm"]);
                        int typeSol = Convert.ToInt32(node["Type_sol"]);

                        for (int i = 0; i < lstSolution.Count; i++)
                        {
                            result_solution = false;

                            if (lstSolution[i].Idsolution_interm == idsolution_interm)
                            {
                                if (idsolution_interm == 0)
                                {
                                    // 1:{solución intermedia1}, 2:{solución intermedia 2}, 3:{estandar de verificación}
                                    lstSolution[i].Cod_solution = null;

                                    if (!(result_solution = faSolution_interm.Update(lstSolution[i])))
                                    {
                                        result_solution = faSolution_interm.Insert(lstSolution[i]);
                                    }

                                    // --- asignar un correlativo dependiendo del tipo de solución
                                    if (result_solution)
                                    {
                                        idsolution_interm = lstSolution[i].Idsolution_interm;

                                        ModCorrelatives oModCorrelatives = new ModCorrelatives();
                                        if (lstSolution[i].Type_sol == 1)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.SolucionInterm1);
                                        }
                                        else if (lstSolution[i].Type_sol == 2)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.SolucionInterm2);
                                        }
                                        else if (lstSolution[i].Type_sol == 3)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.EstandarVerificacion);
                                        }
                                        else if (lstSolution[i].Type_sol == 4)
                                        {
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.EstandarCalibracion);
                                        }

                                        faSolution_interm.Update(lstSolution[i]);

                                        // guardar método actual a la solución
                                        CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                        oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                        oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                        oSolution_interm_methods.Status            = true;

                                        if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                        {
                                            new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);
                                        }

                                        if (typeSol == 4)
                                        {
                                            // guardar estandares de calibración
                                            ucCalibStd1.SaveCalibs(lstSolution[i]);
                                        }
                                    }
                                }
                                else // solucion existente
                                {
                                    if (typeSol == 1 || typeSol == 2 || typeSol == 3)
                                    {
                                        if (ckAssignMethod.Checked)
                                        {
                                            // guardar método actual a la solución
                                            CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                            oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                            oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                            oSolution_interm_methods.Status            = true;

                                            if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                            {
                                                new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);
                                            }
                                        }
                                    }
                                    else if (typeSol == 4)
                                    {
                                        // asignar método, solo si no lo está
                                        CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                        oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                        oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                        oSolution_interm_methods.Status            = true;

                                        if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                        {
                                            new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);
                                        }

                                        // guardar estandares de calibración
                                        ucCalibStd1.SaveCalibs(lstSolution[i]);
                                    }
                                }
                            }
                        }


                        treeSolInterm.DataSource = lstSolution;
                        gcMethods.DataSource     = new ModSolInterm().GetMethodsBySol(idsolution_interm);

                        // Seleccionar solucion
                        if (idsolution_interm != 0)
                        {
                            TreeListNode nodo = treeSolInterm.FindNodeByFieldValue("Idsolution_interm", idsolution_interm);
                            treeSolInterm.FocusedNode = nodo;
                        }

                        new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();

                        ucSign1.Clear();
                        treeSolInterm.ExpandAll();
                    }
                    else
                    {
                        ucSign1.Clear();
                    }
                }
            }
            else
            {
                new FormMessage("Error", "Contraseña incorrecta.", true, false).ShowDialog();
            }
        }
Beispiel #3
0
        private void ucSign1_OnSign(bool login)
        {
            if (login)
            {
                if (nodeSolutionInProcess != null)
                {
                    ///si el nuevo nodo seleccionado es un estandar de verificación
                    ///reasignar el tipo de solucion intermedia de su solución padre
                    int type_sol = Convert.ToInt32(nodeSolutionInProcess["Type_sol"]);

                    if (type_sol == 3 || type_sol == 4)
                    {
                        if (nodeSolutionInProcess.Level == 1)
                            type_sol = 1;
                        if (nodeSolutionInProcess.Level == 2)
                            type_sol = 2;
                    }

                    FormSelMethods fmSelMethods = new FormSelMethods(group_solution, type_sol);

                    if (fmSelMethods.ShowDialog() == DialogResult.OK)
                    {
                        // --- guardar grupo de solución
                        CGroup_solutionFactory fagroup_solution = new CGroup_solutionFactory();
                        bool result = false;

                        if (!(result = fagroup_solution.Update(group_solution)))
                            result = fagroup_solution.Insert(group_solution);

                        // --- guardando soluciones
                        if (result)
                        {
                            // --- guardar los cambios en las soluciones
                            CSolutionFactory faSolution = new CSolutionFactory();
                            bool result_solution = false;
                            for (int i = 0; i < lstSolution.Count; i++)
                            {
                                result_solution = false;

                                if (lstSolution[i].Idsolution == 0)
                                {
                                    #region Grabar metodos a nueva solución ingresada

                                    lstSolution[i].Idgroup_solution = group_solution.Idgroup_solution;
                                    lstSolution[i].Cod_solution = null;

                                    if (!(result_solution = faSolution.Update(lstSolution[i])))
                                        result_solution = faSolution.Insert(lstSolution[i]);

                                    // --- asignar un correlativo dependiendo del tipo de solución
                                    // 1:solución intermedia1, 2:solución intermedia 2, 3:estandar de verificación
                                    if (result_solution)
                                    {
                                        ModCorrelatives oModCorrelatives = new ModCorrelatives();
                                        if (lstSolution[i].Type_sol == 1 || lstSolution[i].Type_sol == 2)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(ModCorrelatives.Correlative.SolucionIntermedia);
                                        else if (lstSolution[i].Type_sol == 3 || lstSolution[i].Type_sol == 4)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(ModCorrelatives.Correlative.EstandarVerificacion);

                                        faSolution.Update(lstSolution[i]);
                                    }

                                    if (result_solution)
                                    {
                                        // --- grabar métodos de la solución
                                        CSolution_methodsFactory faSolution_methods = new CSolution_methodsFactory();
                                        CSolution_methods oSolution_methods = new CSolution_methods();
                                        string concatMethods = "";
                                        bool result_solution_method = false;

                                        // --- grabar linkeo de solución y métodos
                                        foreach (CMethodMini item in fmSelMethods.LstMethodMini)
                                        {
                                            if (item.Sel)
                                            {
                                                // indexar método a la solución
                                                oSolution_methods = new CSolution_methods();
                                                oSolution_methods.Idsolution = lstSolution[i].Idsolution;
                                                oSolution_methods.Idtemplate_method = item.Idtemplate_method;
                                                oSolution_methods.Status = true;

                                                if (!(result_solution_method = faSolution_methods.Update(oSolution_methods)))
                                                    result_solution_method = faSolution_methods.Insert(oSolution_methods);

                                                // concatenar método
                                                concatMethods += concatMethods.Trim().Length == 0 ? item.Cod_template_method : ", " + item.Cod_template_method;
                                            }
                                        }

                                        // asignar concatenado de métodos seleccionados al campo de la solucion[i]
                                        lstSolution[i].Concat_cod_methods = concatMethods;
                                        faSolution.Update(lstSolution[i]);
                                    }
                                    #endregion
                                }
                            }

                            treeSolInterm.DataSource = lstSolution;
                            FlagSolutionInProcess = false;

                            ShowStatusButtons();

                            new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();

                            ucSign1.Clear();
                            treeSolInterm.ExpandAll();
                        }

                        onSignSolInterm(group_solution);
                    }
                }
                else
                {
                    ///No existe ningún nodo en proceso, entonces los cambios
                    ///fueron sobre el estado de las soluciones
                    ///
                    CSolutionFactory faSolution = new CSolutionFactory();
                    for (int i = 0; i < lstSolution.Count; i++)
                        faSolution.Update(lstSolution[i]);

                    treeSolInterm.DataSource = lstSolution;

                    ShowStatusButtons();
                    new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();
                    ucSign1.Clear();
                    treeSolInterm.ExpandAll();

                    onSignSolInterm(group_solution);
                }
            }
            else
                new FormMessage("Error", "Contraseña incorrecta.", true, false).ShowDialog();
        }
Beispiel #4
0
        private void ucSign1_OnSign(bool login)
        {
            if (login)
            {
                if (ckDisabledSolution.Checked)
                {
                    //desactiva toda solución y sus métodos
                    if (MessageBox.Show("Esta seguro que desea desactivar la solución.", "Desactivando solución", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                    {
                        //desactivar solucion
                        TreeListNode node = treeSolInterm.FocusedNode;
                        int idsolution_interm = Convert.ToInt32(node["Idsolution_interm"]);
                        CSolution_interm sol = new CSolution_intermFactory().GetAll().Where(x => x.Idsolution_interm == idsolution_interm).FirstOrDefault();
                        sol.Solution_obs = cbMotivo.Text;
                        sol.Solution_status = false;
                        if (sol != null)
                            new CSolution_intermFactory().Update(sol);
                    }
                }
                else
                {
                    if (Son_Datos_Correctos())
                    {
                        //según la ubicación de la pagina graba
                        //guardando soluciones
                        int idsolution_interm = 0;
                        CSolution_intermFactory faSolution_interm = new CSolution_intermFactory();
                        bool result_solution = false;

                        TreeListNode node = treeSolInterm.FocusedNode;
                        idsolution_interm = Convert.ToInt32(node["Idsolution_interm"]);
                        int typeSol = Convert.ToInt32(node["Type_sol"]);

                        for (int i = 0; i < lstSolution.Count; i++)
                        {
                            result_solution = false;

                            if (lstSolution[i].Idsolution_interm == idsolution_interm)
                            {
                                if (idsolution_interm == 0)
                                {
                                    // 1:{solución intermedia1}, 2:{solución intermedia 2}, 3:{estandar de verificación}
                                    lstSolution[i].Cod_solution = null;

                                    if (!(result_solution = faSolution_interm.Update(lstSolution[i])))
                                        result_solution = faSolution_interm.Insert(lstSolution[i]);

                                    // --- asignar un correlativo dependiendo del tipo de solución
                                    if (result_solution)
                                    {
                                        idsolution_interm = lstSolution[i].Idsolution_interm;

                                        ModCorrelatives oModCorrelatives = new ModCorrelatives();
                                        if (lstSolution[i].Type_sol == 1)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.SolucionInterm1);
                                        else if (lstSolution[i].Type_sol == 2)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.SolucionInterm2);
                                        else if (lstSolution[i].Type_sol == 3)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.EstandarVerificacion);
                                        else if (lstSolution[i].Type_sol == 4)
                                            lstSolution[i].Cod_solution = oModCorrelatives.GetCorrelative(Comun.Correlative.EstandarCalibracion);

                                        faSolution_interm.Update(lstSolution[i]);

                                        // guardar método actual a la solución
                                        CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                        oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                        oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                        oSolution_interm_methods.Status = true;

                                        if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                            new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);

                                        if (typeSol == 4)
                                        {
                                            // guardar estandares de calibración
                                            ucCalibStd1.SaveCalibs(lstSolution[i]);
                                        }
                                    }
                                }
                                else // solucion existente
                                {
                                    if (typeSol == 1 || typeSol == 2 || typeSol == 3)
                                    {
                                        if (ckAssignMethod.Checked)
                                        {
                                            // guardar método actual a la solución
                                            CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                            oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                            oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                            oSolution_interm_methods.Status = true;

                                            if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                                new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);
                                        }
                                    }
                                    else if (typeSol == 4)
                                    {
                                        // asignar método, solo si no lo está
                                        CSolution_interm_methods oSolution_interm_methods = new CSolution_interm_methods();
                                        oSolution_interm_methods.Idsolution_interm = lstSolution[i].Idsolution_interm;
                                        oSolution_interm_methods.Idtemplate_method = Convert.ToInt32(cbMethod1.EditValue);
                                        oSolution_interm_methods.Status = true;

                                        if (!new CSolution_interm_methodsFactory().Update(oSolution_interm_methods))
                                            new CSolution_interm_methodsFactory().Insert(oSolution_interm_methods);

                                        // guardar estandares de calibración
                                        ucCalibStd1.SaveCalibs(lstSolution[i]);
                                    }
                                }
                            }
                        }

                        treeSolInterm.DataSource = lstSolution;
                        gcMethods.DataSource = new ModSolInterm().GetMethodsBySol(idsolution_interm);

                        // Seleccionar solucion
                        if (idsolution_interm != 0)
                        {
                            TreeListNode nodo = treeSolInterm.FindNodeByFieldValue("Idsolution_interm", idsolution_interm);
                            treeSolInterm.FocusedNode = nodo;
                        }

                        new FormMessage("Guardado", "Guardado correctamente.", true, false).ShowDialog();

                        ucSign1.Clear();
                        treeSolInterm.ExpandAll();
                    }
                    else
                    {
                        ucSign1.Clear();
                    }

                }
            }
            else
                new FormMessage("Error", "Contraseña incorrecta.", true, false).ShowDialog();
        }