Exemple #1
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            IngresConnection con = new IngresConnection(Login.myConnectionString);

            con.Open();
            IngresCommand cmd = new IngresCommand();

            cmd.Connection  = con;
            cmd.CommandText = "rol_create";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new IngresParameter("t_id_rol", IngresType.Decimal));
            cmd.Parameters.Add(new IngresParameter("t_nombre", IngresType.VarChar));
            cmd.Parameters["t_id_rol"].Value = 0;
            cmd.Parameters["t_nombre"].Value = this.nombre.Text;
            try
            {
                cmd.ExecuteNonQuery();
                MetroMessageBox.Show(this, "Elemento creado correctamente.", "Nota", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            catch (IngresException c)
            {
                MetroMessageBox.Show(this, c.ErrorCode + c.Message, "Error");
            }
            con.Close();
            this.read();
        }
Exemple #2
0
        private void Delete_Click(object sender, EventArgs e)
        {
            IngresConnection con = new IngresConnection(Login.myConnectionString);

            con.Open();
            IngresCommand cmd = new IngresCommand();

            cmd.Connection  = con;
            cmd.CommandText = "rol_delete";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new IngresParameter("t_id_rol", IngresType.Decimal));
            cmd.Parameters["t_id_rol"].Value = int.Parse(this.metroTextBox1.Text);
            IngresTransaction trans = con.BeginTransaction();

            cmd.Transaction = trans;
            try
            {
                cmd.ExecuteNonQuery();
                trans.Commit();
                MetroMessageBox.Show(this, "Elemento eliminado correctamente.", "Nota", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            catch (IngresException c)
            {
                MetroMessageBox.Show(this, c.ErrorCode + c.Message, "Error");
            }
            con.Close();
            this.read();
        }
Exemple #3
0
 public static List <Members> ReportHQPSLF132(string batchno)
 {
     using (IngresConnection db = new IngresConnection(ConfigurationManager.ConnectionStrings["pfmdb"].ConnectionString))
     {
         List <Members> data = new List <Members>();
         db.Open();
         try
         {
             db.Query("set lockmode session where readlock=nolock");
             if (batchno.Contains("ER"))
             {
                 data = db.Query <Members>("select a.status_code,a.batchno,a.eyername as fname," +
                                           "b.branch_name, int2(0) as indiv_payor,a.eyeraddr as home_address,a.zipcode from lo_stl_billing_employer a " +
                                           "inner join hdmf_branches b on b.branch_code=a.branch_code " +
                                           "where batchno=@batchno and a.status_code=10", new { batchno = batchno }).ToList();
             }
             else
             {
                 data = db.Query <Members>("select a.lname,a.fname,a.mid,a.name_ext,e.branch_name," +
                                           " home_address,int2(1) as indiv_payor,a.zipcode from lo_stl_billing_members a inner join hdmf_branches e on " +
                                           "e.branch_code=a.branch_code where   a.status_code=10 and a.indiv_payor=1 and batchno=@batchno",
                                           new { batchno = batchno }).ToList();
             }
             db.Close();
             db.Dispose();
         }
         catch (Exception ex)
         {
         }
         return(data);
     }
 }
Exemple #4
0
        private string GetForeignKeyReferenceTableName(string owner, string tableName, string columnName)
        {
            var conn = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    using (var tableCommand = conn.CreateCommand())
                    {
                        tableCommand.CommandText = "SELECT p.table_name " + "FROM iiref_constraints rc " +
                                                   "INNER JOIN iikeys p " +
                                                   "ON p.schema_name = rc.unique_schema_name " +
                                                   "AND p.constraint_name = rc.unique_constraint_name " +
                                                   "INNER JOIN iiconstraints c " +
                                                   "ON c.schema_name = rc.ref_schema_name " +
                                                   "AND c.constraint_name = rc.ref_constraint_name " +
                                                   "INNER JOIN iikeys f " + "ON f.schema_name = rc.ref_schema_name " +
                                                   "AND f.constraint_name = rc.ref_constraint_name " +
                                                   "AND p.key_position = f.key_position " +
                                                   $"WHERE f.schema_name = '{owner}' " +
                                                   $"AND f.table_name = '{tableName}' " +
                                                   $"AND f.column_name = '{columnName}'";
                        return(tableCommand.ExecuteScalar().ToString());
                    }
                }
            }
            finally
            {
                conn.Close();
            }
        }
        private string GetConstraintName(string owner, string tableName, string columnName)
        {
            var conn = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    using (var tableDetailsCommand = conn.CreateCommand())
                    {
                        tableDetailsCommand.CommandText = string.Format("SELECT k.constraint_name " +
                                                                        "FROM iikeys k " +
                                                                        "INNER JOIN iiconstraints c " +
                                                                        "ON k.constraint_name = c.constraint_name " +
                                                                        "WHERE c.constraint_type = 'R' " +
                                                                        "AND k.schema_name = '{0}' " +
                                                                        "AND k.table_name = '{1}' " +
                                                                        "AND k.column_name = '{2}'",
                                                                        owner, tableName, columnName);
                        var result = tableDetailsCommand.ExecuteScalar();
                        return(result == null ? String.Empty : result.ToString());
                    }
                }
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #6
0
        private bool IsForeignKey(string owner, string tableName, string columnName)
        {
            var conn = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    using (var tableDetailsCommand = conn.CreateCommand())
                    {
                        tableDetailsCommand.CommandText = "SELECT COUNT(0) " + "FROM iikeys k " +
                                                          "INNER JOIN iiconstraints c " +
                                                          "ON k.constraint_name = c.constraint_name " +
                                                          "WHERE c.constraint_type = 'R' " +
                                                          $"AND k.schema_name = '{owner}' " +
                                                          $"AND k.table_name = '{tableName}' " +
                                                          $"AND k.column_name = '{columnName}'";
                        var obj = tableDetailsCommand.ExecuteScalar();

                        int result;
                        if (obj != null &&
                            Int32.TryParse(obj.ToString(), out result))
                        {
                            return(result > 0);
                        }
                    }
                }
            }
            finally
            {
                conn.Close();
            }
            return(false);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            string SQLStatement = "select * from revenue";
            // SQLStatement = "delete from revenue";
            // SQLStatement = "insert into revenue(myid, material, revenue) values(1, 'Flower', 12.34)";
            // SQLStatement = "insert into revenue(myid, material, revenue) values(2, 'car', 1.34)";
            // SQLStatement = "insert into revenue(myid, material, revenue) values(3, '花', 26.989)";
            // SQLStatement = "insert into revenue(myid, material, revenue) values(3, '汽车',26.989)";

            IngresConnection  con       = new IngresConnection(string.Format("Host={0};Database={1};Uid={2};Pwd={3}", "XXX", "demodb", "Administrator", "HX"));
            IngresDataAdapter da        = new IngresDataAdapter(new IngresCommand(SQLStatement, con));
            DataTable         sqlresult = new DataTable();

            da.Fill(sqlresult);
            con.Close();
            da.Dispose();

            foreach (DataColumn sqlcol in sqlresult.Columns)
            {
                Console.WriteLine(sqlcol.DataType);
            }

            Console.WriteLine(sqlresult.Rows.Count);
            Console.Read();
        }
        public Task <List <Table> > GetTables(string owner)
        {
            var tables = new List <Table>();
            var conn   = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    var tableCommand = conn.CreateCommand();
                    tableCommand.CommandText = String.Format("SELECT table_name " +
                                                             "FROM iitables " +
                                                             "WHERE table_owner = '{0}' " +
                                                             "AND table_type in ('T', 'V') " +
                                                             "AND table_name NOT LIKE 'ii%'",
                                                             owner);

                    var sqlDataReader = tableCommand.ExecuteReader(CommandBehavior.CloseConnection);
                    while (sqlDataReader.Read())
                    {
                        var tableName = sqlDataReader.GetString(0).TrimEnd();
                        tables.Add(new Table {
                            Name = tableName
                        });
                    }
                }
                tables.Sort((x, y) => String.CompareOrdinal(x.Name, y.Name));
            }
            finally
            {
                conn.Close();
            }
            return(Task.FromResult(tables));
        }
Exemple #9
0
        public static List <Employer> GetDeliveryReport(string hub_code)
        {
            using (IngresConnection db = new IngresConnection(ConfigurationManager.ConnectionStrings["pfmdb"].ConnectionString))
            {
                List <Employer> data = new List <Employer>();
                db.Open();
                try
                {
                    var key = "batchno" + hub_code;

                    // Try to get the object from the cache
                    //data = _cache[key] as List<Employer>;
                    //if (data == null)
                    //{
                    db.Query("set lockmode session where readlock=nolock");
                    data = db.Query <Employer>("select batchno,cutdate " +
                                               "from lo_stl_billing_employer " +
                                               "where  ifnull(batchno,'')<>'' " +
                                               "group by batchno,cutdate").ToList();
                    // _cache.Set(key, data, DateTimeOffset.Now.AddMinutes(1));
                    // }
                }
                catch (Exception ex)
                {
                }
                db.Close();
                db.Dispose();
                return(data);
            }
        }
Exemple #10
0
        public Task <IList <string> > GetOwners()
        {
            IList <string> owners = new List <string>();
            var            conn   = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    var tableCommand = conn.CreateCommand();
                    tableCommand.CommandText = "SELECT DISTINCT table_owner FROM iitables WHERE table_owner <> '$ingres'";
                    var sqlDataReader = tableCommand.ExecuteReader(CommandBehavior.CloseConnection);
                    while (sqlDataReader.Read())
                    {
                        var ownerName = sqlDataReader.GetString(0).TrimEnd();
                        owners.Add(ownerName);
                    }
                }
            }
            finally
            {
                conn.Close();
            }

            return(Task.FromResult(owners));
        }
        /// <summary>
        /// Gets the Id for the current application.
        /// </summary>
        /// <param name="conn">The Ingres connection to use.</param>
        /// <param name="tran">The Ingres transaction to use.</param>
        /// <returns>The Id for the current application.</returns>
        private string GetApplicationId(IngresConnection conn, IngresTransaction tran)
        {
            string id = null;

            string sql = @"
                          SELECT  
                              ApplicationId 
                          FROM 
                              aspnet_Applications 
                          WHERE LoweredApplicationName = ?
                         ";

            // Create the new command and enrol in the current transaction
            IngresCommand cmd = new IngresCommand(sql, this.conn);

            cmd.Transaction = this.tran;

            cmd.Parameters.Add("LoweredApplicationName", DbType.String).Value = this.config.ApplicationName.ToLower();

            conn.Open();

            IngresDataReader reader = cmd.ExecuteReader();

            if (reader != null)
            {
                if (reader.HasRows)
                {
                    reader.Read();

                    // Retrieve the Id
                    id = DBUtil.ColValAsString(reader, "ApplicationId");

                    reader.Close();
                }
                else
                {
                    // Close the reader.
                    reader.Close();

                    // We don't have an application so create one.
                    this.CreateApplication(this.config.ApplicationName, out id);
                }
            }

            // Mark the application Id as current so that we don't have to fetch it from the database
            // again unless it changes.
            this.config.IsApplicationIdCurrent = true;

            // Close the connection
            conn.Close();

            return(id);
        }
Exemple #12
0
        private void Update_Click(object sender, EventArgs e)
        {
            IngresConnection con = new IngresConnection(Login.myConnectionString);

            con.Open();
            IngresCommand cmd = new IngresCommand();

            cmd.Connection  = con;
            cmd.CommandText = "empleado_update";
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.Add(new IngresParameter("t_id_empleado", IngresType.Decimal));
            cmd.Parameters.Add(new IngresParameter("t_primer_nombre", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_segundo_nombre", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_primer_apellido", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_segundo_apellido", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_calle", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_avenida", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_num_casa", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_ciudad", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_departamento", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_referencia", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_correo_primario", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_correo_secundario", IngresType.VarChar));
            cmd.Parameters.Add(new IngresParameter("t_fecha_nacimiento", IngresType.Date));
            cmd.Parameters.Add(new IngresParameter("t_fecha_inicio", IngresType.Date));
            cmd.Parameters["t_id_empleado"].Value       = int.Parse(this.id.Text);
            cmd.Parameters["t_primer_nombre"].Value     = this.prinom.Text;
            cmd.Parameters["t_segundo_nombre"].Value    = this.senom.Text;
            cmd.Parameters["t_primer_apellido"].Value   = this.priape.Text;
            cmd.Parameters["t_segundo_apellido"].Value  = this.seape.Text;
            cmd.Parameters["t_calle"].Value             = this.ca.Text;
            cmd.Parameters["t_avenida"].Value           = this.avenida.Text;
            cmd.Parameters["t_num_casa"].Value          = this.numcasa.Text;
            cmd.Parameters["t_ciudad"].Value            = this.ciudad.Text;
            cmd.Parameters["t_departamento"].Value      = this.departamento.Text;
            cmd.Parameters["t_referencia"].Value        = this.referencia.Text;
            cmd.Parameters["t_correo_primario"].Value   = this.pricorreo.Text;
            cmd.Parameters["t_correo_secundario"].Value = this.secorreo.Text;
            cmd.Parameters["t_fecha_nacimiento"].Value  = this.metroDateTime1.Value.ToString("yyyy-MM-dd");
            cmd.Parameters["t_fecha_inicio"].Value      = this.metroDateTime2.Value.ToString("yyyy-MM-dd");
            try
            {
                cmd.ExecuteNonQuery();
                MetroMessageBox.Show(this, "Elemento actualizado correctamente.", "Nota", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
            catch (IngresException c)
            {
                MetroMessageBox.Show(this, c.ErrorCode + c.Message, "Error");
            }
            con.Close();
            this.read();
        }
Exemple #13
0
        /// <summary>
        /// Handles the press of the test connection string button.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event arguments.</param>
        private void TestConnectionString(object sender, EventArgs e)
        {
            this.btnTest.Enabled = false;

            IngresConnection conn = new IngresConnection();

            if (this.tbConnectionString.Text.Trim() == string.Empty)
            {
                MessageBox.Show("A connection string must be entered.");

                this.btnTest.Enabled = true;

                return;
            }

            try
            {
                conn.ConnectionString = this.tbConnectionString.Text;
            }
            catch (Exception)
            {
                this.tbConnectionResult.Text = "Invalid connection string.";

                this.btnTest.Enabled = true;

                return;
            }

            try
            {
                conn.Open();

                this.tbConnectionResult.Text = "Successfully opened a connection!";

                MessageBox.Show("A connection to the database was successfully opened!\n\nCopy the generated connection string for use in the web config file.", "Successful Connection");
            }
            catch (Exception ex)
            {
                this.tbConnectionResult.Text = ex.Message;
            }
            finally
            {
                if (conn.State != ConnectionState.Closed)
                {
                    conn.Close();
                }

                conn = null;

                this.btnTest.Enabled = true;
            }
        }
Exemple #14
0
        private DataTable GetSQLTable(CustomListData data)
        {
            IngresConnection con = GetConnection(data);

            data.Properties.TryGetValue("SQLStatement", StringComparison.OrdinalIgnoreCase, out var SQLStatement);

            IngresDataAdapter da        = new IngresDataAdapter(new IngresCommand(SQLStatement, con));
            DataTable         sqlresult = new DataTable();

            da.Fill(sqlresult);
            con.Close();
            da.Dispose();
            return(sqlresult);
        }
Exemple #15
0
        private void read()
        {
            this.dt = new System.Data.DataTable();
            IngresConnection con   = new IngresConnection(Login.myConnectionString);
            string           query = "select * from read_rol";
            IngresCommand    comm  = new IngresCommand(query, con);

            con.Open();
            IngresDataAdapter adapt = new IngresDataAdapter(comm);

            adapt.Fill(this.dt);
            con.Close();
            this.metroGrid1.DataSource = this.dt;
            adapt.Dispose();
        }
Exemple #16
0
        private void metroButton1_Click_1(object sender, EventArgs e)
        {
            Login.username = this.name.Text;
            string password = this.pass.Text;

            Login.myConnectionString = "host=(local);port=II7;database=proyecto;dbms_user="******";dbms_password="******"Error al conectarse");
            }
        }
Exemple #17
0
        /// Return True if the provider can deduce that the
        /// database exists only based on the connection.
        protected override bool DbDatabaseExists(
            DbConnection connection,
            int?commandTimeout,
            StoreItemCollection storeItemCollection)
        {
            CheckNotNull(connection, "connection");
            CheckNotNull(storeItemCollection, "storeItemCollection");

            // if database existence state is known then return it
            if (DbDatabaseExistsState != null)
            {
                return((bool)DbDatabaseExistsState);
            }

            // let's find the real database existence state
            if (connection.State == ConnectionState.Open)
            {
                DbDatabaseExistsState = true;
                return(true);  // database is open so it exists
            }

            try
            {
                using (IngresConnection conn = new IngresConnection())
                {
                    conn.ConnectionString = connection.ConnectionString;
                    conn.Open();
                    conn.Close();
                    DbDatabaseExistsState = true;
                    return(true);  // database opens OK so it exists
                }
            }
            catch
            {
                return(false);     // database does not open
                                   // leave DbDatabaseExistsState as unknown
            }
        }  // DbDatabaseExists
Exemple #18
0
 public static List <Members> ReportHQPSLF131(string batchno)
 {
     using (IngresConnection db = new IngresConnection(ConfigurationManager.ConnectionStrings["pfmdb"].ConnectionString))
     {
         List <Members> data = new List <Members>();
         db.Open();
         try
         {
             //if (data == null && search_status == true)
             //{
             db.Query("set lockmode session where readlock=nolock");
             if (batchno.Contains("ER"))
             {
                 data = db.Query <Members>("select a.status_code,a.area_code," +
                                           "a.pagibig_erid,a.batchno,a.pick_date," +
                                           "a.cutdate,a.pod_date,a.days_delay," +
                                           "a.unit_price,a.penalty,a.eyername as fname," +
                                           "b.branch_name, int2(0) as indiv_payor from lo_stl_billing_employer a " +
                                           "inner join hdmf_branches b on b.branch_code=a.branch_code " +
                                           "where batchno=@batchno", new { batchno = batchno }).ToList();
             }
             else
             {
                 data = db.Query <Members>("select a.lname,a.fname,a.mid,a.name_ext, a.pagibigid,a.batchno,a.pick_date,a.cutdate,a.pod_date, " +
                                           "a.days_delay,a.unit_price,a.penalty,e.branch_name,a.indiv_payor " +
                                           "from lo_stl_billing_members a inner join hdmf_branches e on " +
                                           "e.branch_code=a.branch_code where a.indiv_payor=1 and batchno=@batchno",
                                           new { batchno = batchno }).ToList();
             }
             db.Close();
             db.Dispose();
         }
         catch (Exception ex)
         {
         }
         return(data);
     }
 }
Exemple #19
0
    static void TestDbProc(string connstring, Type type)
    {
        int    recsaffected;
        string strSeq;
        string strName;

        IngresConnection conn = new IngresConnection(connstring);
        IngresCommand    cmd;

        Console.WriteLine("\nTestDbProc (using " + type.ToString()
                          + ") to database: " + conn.Database);

        conn.Open();

        cmd = new IngresCommand(
            "declare global temporary table session.tab (seq integer," +
            "tabname varchar(32), tabowner varchar(32), numpages integer)" +
            " on commit preserve rows with norecovery", conn);
        recsaffected = cmd.ExecuteNonQuery();
        Console.WriteLine("ExecuteNonQuery(\"declare gtt\") returned " +
                          recsaffected.ToString());

        cmd = new IngresCommand(
            "insert into session.tab (tabname,tabowner,numpages)" +
            " select table_name,table_owner,number_pages from iitables", conn);
        recsaffected = cmd.ExecuteNonQuery();
        Console.WriteLine("ExecuteNonQuery(\"insert into gtt\") returned " +
                          recsaffected.ToString());


        cmd = new IngresCommand(
            "{ call gttproc(gtt1 = session.tab)}", conn);
//        "{ call gttproc(session.tab)}", conn);
        cmd.CommandType = CommandType.Text;
        recsaffected    = cmd.ExecuteNonQuery();
        Console.WriteLine("ExecuteNonQuery(\"execute proc\") returned " +
                          recsaffected.ToString());

        cmd = new IngresCommand(
            "select seq,tabname from session.tab", conn);

        IngresDataReader reader = cmd.ExecuteReader();

        Console.Write(reader.GetName(0) + "\t");
        Console.Write(reader.GetName(1));
        Console.WriteLine();

        while (reader.Read())
        {
            strSeq = reader.IsDBNull(0)?
                     "<none>":reader.GetInt32(0).ToString();
            strName = reader.IsDBNull(1)?
                      "<none>":reader.GetString(1);

            Console.WriteLine(strSeq + "\t" + strName);
        }  // end while loop through result set

        reader.Close();



        conn.Close();
    }
Exemple #20
0
        public Task <IList <Column> > GetTableDetails(Table table, string owner)
        {
            table.Owner = owner;
            IList <Column> columns = new List <Column>();
            var            conn    = new IngresConnection(_connectionString);

            conn.Open();
            try
            {
                using (conn)
                {
                    using (var tableDetailsCommand = conn.CreateCommand())
                    {
                        tableDetailsCommand.CommandText = string.Format("SELECT" +
                                                                        " column_name," +
                                                                        " column_datatype," +
                                                                        " column_nulls," +
                                                                        " column_length," +
                                                                        " column_scale " +
                                                                        "FROM iicolumns " +
                                                                        "WHERE table_owner = '{0}' " +
                                                                        "AND table_name = '{1}' " +
                                                                        "ORDER BY column_sequence",
                                                                        owner, table.Name);

                        using (var sqlDataReader = tableDetailsCommand.ExecuteReader(CommandBehavior.Default))
                        {
                            while (sqlDataReader.Read())
                            {
                                string columnName        = sqlDataReader.GetString(0).TrimEnd();
                                string dataType          = sqlDataReader.GetString(1).TrimEnd();
                                bool   isNullable        = sqlDataReader.GetString(2).Equals("Y", StringComparison.CurrentCultureIgnoreCase);
                                int    characterMaxLenth = sqlDataReader.GetInt32(3);
                                int    numericPrecision  = sqlDataReader.GetInt32(3);
                                int    numericScale      = sqlDataReader.GetInt32(4);

                                var m = new DataTypeMapper();

                                columns.Add(new Column
                                {
                                    Name           = columnName,
                                    DataType       = dataType,
                                    IsNullable     = isNullable,
                                    IsPrimaryKey   = IsPrimaryKey(owner, table.Name, columnName),
                                    IsForeignKey   = IsForeignKey(owner, table.Name, columnName),
                                    MappedDataType = m.MapFromDBType(ServerType.Ingres, dataType, characterMaxLenth, numericPrecision, numericScale),
                                    DataLength     = characterMaxLenth,
                                    ConstraintName = GetConstraintName(owner, table.Name, columnName),
                                    DataPrecision  = numericPrecision,
                                    DataScale      = numericScale
                                });

                                table.Columns = columns;
                            }
                            table.PrimaryKey           = DeterminePrimaryKeys(table);
                            table.ForeignKeys          = DetermineForeignKeyReferences(table);
                            table.HasManyRelationships = DetermineHasManyRelationships(table);
                        }
                    }
                }
            }
            finally
            {
                conn.Close();
            }

            return(Task.FromResult(columns));
        }
Exemple #21
0
        public static List <Employer> ReportHQPSLF134(string batchno)
        {
            using (IngresConnection db = new IngresConnection(ConfigurationManager.ConnectionStrings["pfmdb"].ConnectionString))
            {
                List <Employer> data = new List <Employer>();
                db.Open();
                try
                {
                    //if (data == null && search_status == true)
                    //{
                    db.Query("set lockmode session where readlock=nolock");

                    if (batchno.Contains("ER"))
                    {
                        var output = db.Query <Employer>("select e.branch_name,f.hub_name,a.trackno, " +
                                                         "a.cutdate,a.num_envelope as num,a.batchno, " +
                                                         "a.unit_price,a.penalty,a.status_code,a.area_code," +
                                                         "a.days_delay " +
                                                         "from lo_stl_billing_employer a " +
                                                         "inner join hdmf_branches e on e.branch_code=a.branch_code " +
                                                         "inner join hdmf_hub_master f on f.hub_code=a.hub_code " +
                                                         "where batchno=@batchno",
                                                         new { batchno = batchno }).ToList();

                        foreach (var item in output.OrderBy(a => a.status_code).ToList())
                        {
                            var abc = data.ToList();
                            var c   = data.Where(b => b.branch_name == item.branch_name && b.area_code == item.area_code).SingleOrDefault();
                            if (c == null)
                            {
                                data.Add(new Employer()
                                {
                                    hub_name    = item.hub_name,
                                    trackno     = item.trackno,
                                    branch_name = item.branch_name,
                                    area_code   = item.area_code,
                                    cutdate     = item.cutdate,
                                    days_delay  = item.days_delay,
                                    unit_price  = item.unit_price,
                                    penalty     = item.penalty,
                                    num         = (item.status_code == 9) ? item.num : 0,
                                    rts         = (item.status_code == 10) ? item.num : 0
                                });
                            }
                            else
                            {
                                c.num = (item.status_code == 9) ? item.num + c.num : c.num;
                                c.rts = (item.status_code == 10) ? c.rts + item.num : 0;
                            }
                        }
                    }
                    else
                    {
                        var output = db.Query <Employer>("select a.penalty,a.trackno,a.batchno,a.status_code," +
                                                         "a.area_code,e.branch_name,a.cutdate," +
                                                         "a.unit_price,f.hub_name,count(*) as num " +
                                                         "from lo_stl_billing_members a " +
                                                         "inner join hdmf_branches e on e.branch_code=a.branch_code " +
                                                         "inner join hdmf_hub_master f on f.hub_code=a.hub_code " +
                                                         "where indiv_payor=1  and batchno=@batchno " +
                                                         "group by a.penalty,a.trackno,a.status_code," +
                                                         "a.area_code,e.branch_name,a.cutdate," +
                                                         "a.unit_price,f.hub_name,a.batchno order by a.status_code", new { batchno = batchno }).ToList();


                        foreach (var item in output)
                        {
                            var c = data.Where(b => b.branch_name == item.branch_name && b.area_code == item.area_code).SingleOrDefault();
                            if (c == null)
                            {
                                data.Add(new Employer()
                                {
                                    hub_name    = item.hub_name,
                                    trackno     = item.trackno,
                                    branch_name = item.branch_name,
                                    area_code   = item.area_code,
                                    cutdate     = item.cutdate,
                                    days_delay  = item.days_delay,
                                    unit_price  = item.unit_price,
                                    penalty     = item.penalty,
                                    num         = (item.status_code == 9) ? item.num : 0,
                                    rts         = (item.status_code == 10) ? item.num : 0
                                });
                            }
                            else
                            {
                                c.num = (item.status_code == 9) ? item.num : c.num;
                                c.rts = (item.status_code == 10) ? item.num : 0;
                            }
                        }
                    }



                    db.Close();
                    db.Dispose();
                }
                catch (Exception ex)
                {
                }
                return(data);
            }
        }
Exemple #22
0
        private void TestConnection(string connectionString)
        {
            IngresConnection connection =
                new IngresConnection(connectionString);

            Cursor cursor = Cursor.Current;   // save cursor, probably Arrow
            Cursor.Current = Cursors.WaitCursor;  // hourglass cursor
            try // to open the connection
            {
                connection.Open();  // try opening the connection
            }
            finally
            {
                Cursor.Current = cursor;  // restore Arrow cursor
            }
            connection.Close();
        }