Exemplo n.º 1
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of CSolution_methods</returns>
        internal List <CSolution_methods> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <CSolution_methods> list = new List <CSolution_methods>();

            while (dataReader.Read())
            {
                CSolution_methods businessObject = new CSolution_methods();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(CSolution_methods businessObject, IDataReader dataReader)
        {
            businessObject.Idsolution_methods = dataReader.GetInt32(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Idsolution_methods.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Idsolution.ToString())))
            {
                businessObject.Idsolution = dataReader.GetInt32(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Idsolution.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Idtemplate_method.ToString())))
            {
                businessObject.Idtemplate_method = dataReader.GetInt32(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Idtemplate_method.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Status.ToString())))
            {
                businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CSolution_methods.CSolution_methodsFields.Status.ToString()));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>CSolution_methods business object</returns>
        public CSolution_methods SelectByPrimaryKey(CSolution_methodsKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_solution_methods_SelectByPrimaryKey";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_idsolution_methods", NpgsqlDbType.Integer, 4, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Idsolution_methods));


                MainConnection.Open();

                NpgsqlDataReader dataReader = sqlCommand.ExecuteReader();

                if (dataReader.Read())
                {
                    CSolution_methods businessObject = new CSolution_methods();

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("CSolution_methods::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// insert new row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true of successfully insert</returns>
        public bool Insert(CSolution_methods businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_solution_methods_Insert";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.AddWithValue("p_idsolution_methods", businessObject.Idsolution_methods);
                sqlCommand.Parameters["p_idsolution_methods"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters["p_idsolution_methods"].Direction    = ParameterDirection.InputOutput;

                sqlCommand.Parameters.AddWithValue("p_idsolution", businessObject.Idsolution);
                sqlCommand.Parameters["p_idsolution"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_idtemplate_method", businessObject.Idtemplate_method);
                sqlCommand.Parameters["p_idtemplate_method"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;


                MainConnection.Open();

                sqlCommand.ExecuteNonQuery();
                businessObject.Idsolution_methods = Convert.ToInt32(sqlCommand.Parameters["p_idsolution_methods"].Value);

                return(true);
            }
            catch (Exception ex)
            {
                throw new Exception("CSolution_methods::Insert::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(CSolution_methods businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

            sqlCommand.CommandText = "public.sp_solution_methods_Update";
            sqlCommand.CommandType = CommandType.StoredProcedure;

            // Use connection object of base class
            sqlCommand.Connection = MainConnection;

            try
            {
                sqlCommand.Parameters.AddWithValue("p_idsolution_methods", businessObject.Idsolution_methods);
                sqlCommand.Parameters["p_idsolution_methods"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_idsolution", businessObject.Idsolution);
                sqlCommand.Parameters["p_idsolution"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_idtemplate_method", businessObject.Idtemplate_method);
                sqlCommand.Parameters["p_idtemplate_method"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;


                MainConnection.Open();

                if (Convert.ToInt32(sqlCommand.ExecuteScalar()) > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception("CSolution_methods::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Exemplo n.º 6
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();
            }
        }
Exemplo n.º 7
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();
        }