string GetFormatCorrelative(string type_correlative, long?code_value)
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModule       = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys(type_correlative));

            return(oModule.Prefix + oModule.Cod_serie + "-" + CompleteZeros(Convert.ToInt64(code_value), Convert.ToInt16(oModule.Num_digits)));
        }
Exemple #2
0
        public string GetFormatProgramCode(long?Cod_recep_sample_report)
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModule       = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("PP"));

            return(oModule.Prefix + oModule.Cod_serie + "-" + CompleteZeros(Convert.ToInt64(Cod_recep_sample_report), Convert.ToInt16(oModule.Num_digits)));
        }
Exemple #3
0
        public long GetNewCodProgram()
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModule       = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("PP"));

            oModule.Correlative = oModule.Correlative + 1;
            faCorr_module.Update(oModule);
            return(Convert.ToInt16(oModule.Correlative));
        }
        long GetNewCorrelative(string type_correlative)
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModule       = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys(type_correlative));

            oModule.Correlative = oModule.Correlative + 1;
            faCorr_module.Update(oModule);
            return(Convert.ToInt16(oModule.Correlative));
        }
Exemple #5
0
        /// <summary>
        /// update row in the table
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <returns>true for successfully updated</returns>
        public bool Update(CCorr_modules businessObject)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

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

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

            try
            {
                sqlCommand.Parameters.AddWithValue("p_cod_module", businessObject.Cod_module);
                sqlCommand.Parameters["p_cod_module"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_name_module", businessObject.Name_module);
                sqlCommand.Parameters["p_name_module"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_prefix", businessObject.Prefix);
                sqlCommand.Parameters["p_prefix"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_correlative", businessObject.Correlative);
                sqlCommand.Parameters["p_correlative"].NpgsqlDbType = NpgsqlDbType.Integer;
                sqlCommand.Parameters.AddWithValue("p_num_digits", businessObject.Num_digits);
                sqlCommand.Parameters["p_num_digits"].NpgsqlDbType = NpgsqlDbType.Smallint;
                sqlCommand.Parameters.AddWithValue("p_usernew", businessObject.Usernew);
                sqlCommand.Parameters["p_usernew"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_datenew", businessObject.Datenew);
                sqlCommand.Parameters["p_datenew"].NpgsqlDbType = NpgsqlDbType.Date;
                sqlCommand.Parameters.AddWithValue("p_useredit", businessObject.Useredit);
                sqlCommand.Parameters["p_useredit"].NpgsqlDbType = NpgsqlDbType.Varchar;
                sqlCommand.Parameters.AddWithValue("p_dateedit", businessObject.Dateedit);
                sqlCommand.Parameters["p_dateedit"].NpgsqlDbType = NpgsqlDbType.Date;
                sqlCommand.Parameters.AddWithValue("p_status", businessObject.Status);
                sqlCommand.Parameters["p_status"].NpgsqlDbType = NpgsqlDbType.Boolean;
                sqlCommand.Parameters.AddWithValue("p_cod_serie", businessObject.Cod_serie);
                sqlCommand.Parameters["p_cod_serie"].NpgsqlDbType = NpgsqlDbType.Varchar;


                MainConnection.Open();

                if (Convert.ToInt32(sqlCommand.ExecuteScalar()) > 0)
                {
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                throw new Exception("CCorr_modules::Update::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Exemple #6
0
        /// <summary>
        /// Populate business object from data reader
        /// </summary>
        /// <param name="businessObject">business object</param>
        /// <param name="dataReader">data reader</param>
        internal void PopulateBusinessObjectFromReader(CCorr_modules businessObject, IDataReader dataReader)
        {
            businessObject.Cod_module = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Cod_module.ToString()));

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Name_module.ToString())))
            {
                businessObject.Name_module = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Name_module.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Prefix.ToString())))
            {
                businessObject.Prefix = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Prefix.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Correlative.ToString())))
            {
                businessObject.Correlative = dataReader.GetInt32(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Correlative.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Num_digits.ToString())))
            {
                businessObject.Num_digits = (short?)dataReader.GetInt16(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Num_digits.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Usernew.ToString())))
            {
                businessObject.Usernew = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Usernew.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Datenew.ToString())))
            {
                businessObject.Datenew = dataReader.GetDateTime(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Datenew.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Useredit.ToString())))
            {
                businessObject.Useredit = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Useredit.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Dateedit.ToString())))
            {
                businessObject.Dateedit = dataReader.GetDateTime(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Dateedit.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Status.ToString())))
            {
                businessObject.Status = dataReader.GetBoolean(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Status.ToString()));
            }

            if (!dataReader.IsDBNull(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Cod_serie.ToString())))
            {
                businessObject.Cod_serie = dataReader.GetString(dataReader.GetOrdinal(CCorr_modules.CCorr_modulesFields.Cod_serie.ToString()));
            }
        }
Exemple #7
0
        /// <summary>
        /// Populate business objects from the data reader
        /// </summary>
        /// <param name="dataReader">data reader</param>
        /// <returns>list of CCorr_modules</returns>
        internal List <CCorr_modules> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <CCorr_modules> list = new List <CCorr_modules>();

            while (dataReader.Read())
            {
                CCorr_modules businessObject = new CCorr_modules();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
Exemple #8
0
        protected override bool Grabar_Registro()
        {
            CCorrelativeFactory faCorrelative = new CCorrelativeFactory();
            CCorrelative        oCorrelative  = new CCorrelative();

            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oCorr_module  = new CCorr_modules();

            bool result = false;

            try
            {
                for (int i = 0; i < gvCorrelativos.RowCount; i++)
                {
                    //oCorrelative = new CCorrelative();
                    //oCorrelative.Cod_type_sample = gvCorrelativos.GetRowCellValue(i, gcCorr_cod_type_sample).ToString();
                    //oCorrelative.Cod_serie = gvCorrelativos.GetRowCellValue(i, gcCorr_cod_serie).ToString();
                    //oCorrelative.Correlative = Convert.ToInt32(gvCorrelativos.GetRowCellValue(i, gcCorr_correlative));
                    //oCorrelative.Mreach15 = Convert.ToBoolean(gvCorrelativos.GetRowCellValue(i, gcCorr_mreach15));
                    //oCorrelative.Num_digits = Convert.ToInt16(gvCorrelativos.GetRowCellValue(i, gcCorr_num_digits));
                    //oCorrelative.Prefix = gvCorrelativos.GetRowCellValue(i, gcCorr_prefix).ToString();

                    //if (!(result = faCorrelative.Update(oCorrelative)))
                    //    result = faCorrelative.Insert(oCorrelative);

                    //if (!result)
                    //    break;

                    oCorrelative = (CCorrelative)gvCorrelativos.GetRow(i);
                    if (!new CCorrelativeFactory().Update(oCorrelative))
                    {
                        new CCorrelativeFactory().Insert(oCorrelative);
                    }
                }

                for (int i = 0; i < gvVarios.RowCount; i++)
                {
                    oCorr_module = (CCorr_modules)gvVarios.GetRow(i);
                    new CCorr_modulesFactory().Update(oCorr_module);
                }
            }
            catch (Exception ex)
            {
                ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message);
                result = false;
            }

            return(result);
        }
        protected override bool Grabar_Registro()
        {
            CCorrelativeFactory faCorrelative = new CCorrelativeFactory();
            CCorrelative oCorrelative = new CCorrelative();

            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules oCorr_module = new CCorr_modules();

            bool result = false;

            try
            {
                for (int i = 0; i < gvCorrelativos.RowCount; i++)
                {
                    //oCorrelative = new CCorrelative();
                    //oCorrelative.Cod_type_sample = gvCorrelativos.GetRowCellValue(i, gcCorr_cod_type_sample).ToString();
                    //oCorrelative.Cod_serie = gvCorrelativos.GetRowCellValue(i, gcCorr_cod_serie).ToString();
                    //oCorrelative.Correlative = Convert.ToInt32(gvCorrelativos.GetRowCellValue(i, gcCorr_correlative));
                    //oCorrelative.Mreach15 = Convert.ToBoolean(gvCorrelativos.GetRowCellValue(i, gcCorr_mreach15));
                    //oCorrelative.Num_digits = Convert.ToInt16(gvCorrelativos.GetRowCellValue(i, gcCorr_num_digits));
                    //oCorrelative.Prefix = gvCorrelativos.GetRowCellValue(i, gcCorr_prefix).ToString();

                    //if (!(result = faCorrelative.Update(oCorrelative)))
                    //    result = faCorrelative.Insert(oCorrelative);

                    //if (!result)
                    //    break;

                    oCorrelative = (CCorrelative)gvCorrelativos.GetRow(i);
                    if (!new CCorrelativeFactory().Update(oCorrelative))
                        new CCorrelativeFactory().Insert(oCorrelative);
                }

                for (int i = 0; i < gvVarios.RowCount; i++)
                {
                    oCorr_module = (CCorr_modules)gvVarios.GetRow(i);
                    new CCorr_modulesFactory().Update(oCorr_module);
                }
            }
            catch (Exception ex)
            {
                ComunForm.Send_message(this.Text, TypeMsg.error, ex.Message);
                result = false;
            }

            return result;
        }
Exemple #10
0
        public string GetFormatReportCode(short?type_report, long?Cod_recep_sample_report)
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModuleRP     = new CCorr_modules();
            CCorr_modules        oModuleRF     = new CCorr_modules();

            oModuleRP = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("RP"));
            oModuleRF = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("RF"));

            if (type_report == 1)
            {
                return(oModuleRP.Prefix + oModuleRP.Cod_serie + "-" + CompleteZeros(Convert.ToInt64(Cod_recep_sample_report), Convert.ToInt16(oModuleRP.Num_digits)));
            }
            else
            {
                return(oModuleRF.Prefix + oModuleRF.Cod_serie + "-" + CompleteZeros(Convert.ToInt64(Cod_recep_sample_report), Convert.ToInt16(oModuleRF.Num_digits)));
            }
        }
Exemple #11
0
        /// <summary>
        /// Select by primary key
        /// </summary>
        /// <param name="keys">primary keys</param>
        /// <returns>CCorr_modules business object</returns>
        public CCorr_modules SelectByPrimaryKey(CCorr_modulesKeys keys)
        {
            NpgsqlCommand sqlCommand = new NpgsqlCommand();

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

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

            try
            {
                sqlCommand.Parameters.Add(new NpgsqlParameter("p_cod_module", NpgsqlDbType.Varchar, 20, "", ParameterDirection.Input, false, 0, 0, DataRowVersion.Proposed, keys.Cod_module));


                MainConnection.Open();

                NpgsqlDataReader dataReader = sqlCommand.ExecuteReader();

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

                    PopulateBusinessObjectFromReader(businessObject, dataReader);

                    return(businessObject);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("CCorr_modules::SelectByPrimaryKey::Error occured.", ex);
            }
            finally
            {
                MainConnection.Close();
                sqlCommand.Dispose();
            }
        }
Exemple #12
0
        public long GetNewCodReport(short type_report)
        {
            CCorr_modulesFactory faCorr_module = new CCorr_modulesFactory();
            CCorr_modules        oModule       = new CCorr_modules();

            if (type_report == 1)
            {
                oModule             = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("RP"));
                oModule.Correlative = oModule.Correlative + 1;
                faCorr_module.Update(oModule);
            }
            else
            {
                oModule             = faCorr_module.GetByPrimaryKey(new CCorr_modulesKeys("RF"));
                oModule.Correlative = oModule.Correlative + 1;
                faCorr_module.Update(oModule);
            }

            return(Convert.ToInt16(oModule.Correlative));
        }