Пример #1
0
        private DateTime?GetLastExecuteService(OdbcConnection cnn)
        {
            DateTime?      result = (DateTime?)null;
            OdbcCommand    DbCommand;
            OdbcDataReader DbReader;

            try
            {
                DbCommand             = cnn.CreateCommand();
                DbCommand.CommandText = "SELECT UltimoMarca FROM ULTIMO WHERE UltimoEmpleado = ?";
                DbCommand.Parameters.Add("@param1", OdbcType.Int).Value = "999999999";
                DbReader = DbCommand.ExecuteReader();
                int fCount = DbReader.FieldCount;
                while (DbReader.Read())
                {
                    for (int i = 0; i < fCount; i++)
                    {
                        result = (DbReader.GetDateTime(0));
                    }
                }
                DbReader.Close();
                DbCommand.Dispose();
            }
            catch (OdbcException ex)
            {
                WriteToFile("ERROR: Error al obtener la ultima ejecución de la base. " + " - " + ex.Message);
            }

            return(result);
        }
Пример #2
0
        private IEnumerable <long> GetSelectedEmployee(OdbcConnection cnn, DateTime dateExecute)
        {
            List <long>    result = new List <long>();
            OdbcCommand    DbCommand;
            OdbcDataReader DbReader;

            try
            {
                DbCommand             = cnn.CreateCommand();
                DbCommand.CommandText = "SELECT EmpleadoID FROM LIQHORAS1  WHERE LiqHoraFecha = ? AND LiqSeccionTrabaja = ?";
                DbCommand.Parameters.Add("@param1", OdbcType.DateTime).Value = dateExecute;
                DbCommand.Parameters.Add("@param2", OdbcType.Int).Value      = "999999999";
                DbReader = DbCommand.ExecuteReader();
                int fCount = DbReader.FieldCount;
                while (DbReader.Read())
                {
                    for (int i = 0; i < fCount; i++)
                    {
                        result.Add(DbReader.GetInt64(0));
                    }
                }
                DbReader.Close();
                DbCommand.Dispose();
            }
            catch (OdbcException ex)
            {
                WriteToFile("ERROR: Error al obtener la ultima ejecución de la base. " + " - " + ex.Message);
            }

            return(result);
        }
Пример #3
0
        private List <long> GetActiveEmployees(OdbcConnection cnn)
        {
            List <long>    employees = new List <long>();
            OdbcCommand    DbCommand;
            OdbcDataReader DbReader;

            try
            {
                DbCommand             = cnn.CreateCommand();
                DbCommand.CommandText = "SELECT EmpleadoID FROM EMPLEADO WHERE EmpleadoInactivo = 0";
                DbReader = DbCommand.ExecuteReader();
                int fCount = DbReader.FieldCount;
                while (DbReader.Read())
                {
                    for (int i = 0; i < fCount; i++)
                    {
                        employees.Add(DbReader.GetInt32(i));
                    }
                }
                DbReader.Close();
                DbCommand.Dispose();
            }
            catch (OdbcException ex)
            {
                WriteToFile("ERROR: Error al obtener empleados de la base. " + " - " + ex.Message);
            }
            return(employees);
        }
Пример #4
0
Файл: iFix.cs Проект: plats98/TI
        public static void Test2()
        {
            String connStr = "DSN=FIX Dynamics Real Time Data;Uid=sa";

            OdbcConnection DbConnection = new OdbcConnection(connStr);

            try
            {
                DbConnection.Open();
            }
            catch (OdbcException ex)
            {
                Console.WriteLine("connection to the DSN '" + connStr + "' failed.");
                Console.WriteLine("The OdbcConnection returned the following message");
                Console.WriteLine(ex.Message);
                return;
            }

            String      query     = "SELECT * FROM SCADA01";
            OdbcCommand DbCommand = DbConnection.CreateCommand();

            DbCommand.CommandText = query;

            OdbcDataReader DbReader;

            try
            {
                DbReader = DbCommand.ExecuteReader();
                // rest of the code to process the result set
            }
            catch (OdbcException ex)
            {
                Console.WriteLine("Executing the query '" + query + "' failed.");
                Console.WriteLine("The OdbcCommand returned the following message");
                Console.WriteLine(ex.Message);
                return;
            }

            int fCount = DbReader.FieldCount;

            Debug.Print("");
            for (int i = 0; i < fCount; i++)
            {
                String fName = DbReader.GetName(i);
                Debug.Print(fName + ":");
            }
            Debug.Print("");



            while (DbReader.Read())
            {
                String col = "";
                for (int i = 0; i < fCount; i++)
                {
                    col = col + SafeGetString(DbReader, i) + " : ";
                }
                Debug.Print(col + "");
                Debug.Print("");
            }


            DbReader.Close();
            DbCommand.Dispose();
            DbConnection.Close();
        }
Пример #5
0
        //Ayala 13.04.2015
        public SupplierShipmentDoc GetShippmentNo(OdbcConnection DbConnection, SupplierShipmentDoc ship, FlexSupplier supp, EventLog lg)
        {
            supp.SupplierNo       = "";
            supp.CompanyNo        = "";
            supp.SupplierName     = "";
            supp.SupplierAddress  = "";
            supp.PurchasingPerson = "";
            supp.SupplierPhone    = "";
            supp.SearchKey        = "";
            supp.SupplierEmail    = "";
            ship.shippmentNo      = "";
            ship.supplierID       = "";
            string OrderNo   = String.Empty;
            string OrderLine = String.Empty;
            string DateIn    = String.Empty;

            int         ShipNo    = 0;
            OdbcCommand DbCommand = DbConnection.CreateCommand();

            DbCommand.CommandTimeout = 3600;
            OdbcDataReader DbReader;

            DbCommand.CommandText = String.Format("select  b405.t_dino,b405.t_suno,b020.t_nama,b020.t_namc, b020.t_refs, b020.t_telp, b020.t_seak,b040.t_email  from baandb.ttdltc102{0} as b102, baandb.ttdpur045{0} as b405, "
                                                  + " baandb.ttccom020{0} as b020 , baandb.ttccom040{0} as b040 " +
                                                  " where b102.t_tord=1  and  b102.t_clot like '%{1}%'  and  b102.t_item like '%{2}%' and b405.t_suno=b020.t_suno  " +
                                                  " and b040.t_suno=b405.t_suno and  b040.t_actv=1 "
                                                  + " and b405.t_orno= b102.t_orno and b405.t_pono= b102.t_pono and b405.t_date= b102.t_trdt", "400", ship.lotNo.Replace(" ", ""), ship.makat.Replace(" ", ""));

            bool b = false;

            try
            {
                DbReader = DbCommand.ExecuteReader();
            }
            catch (Exception ex)
            {
                return(ship);
            }

            if (DbReader.Read())
            {
                ship.shippmentNo      = DbReader.GetString(0).Replace(" ", "").Trim();
                ship.supplierID       = DbReader.GetString(1).Replace(" ", "").Trim();
                supp.SupplierNo       = ship.SupplierID;
                supp.CompanyNo        = ship.Company;
                supp.SupplierName     = DbReader.GetString(2).Trim();
                supp.SupplierAddress  = DbReader.GetString(3).Trim();
                supp.PurchasingPerson = DbReader.GetString(4).Trim();
                supp.SupplierPhone    = DbReader.GetString(5).Trim();
                supp.SearchKey        = DbReader.GetString(6).Trim();
                supp.SupplierEmail    = DbReader.GetString(7).Trim();

                b = true;
            }
            DbReader.Close();
            if (b)
            {
                DbCommand.CommandText = String.Format("select b102.t_clot  , b102.t_item   from baandb.ttdltc102{0} as b102, baandb.ttdpur045{0} as b405, "
                                                      + " baandb.ttccom020{0} as b020  " +
                                                      " where b102.t_tord=1  and b405.t_orno= b102.t_orno and b405.t_pono= b102.t_pono and b405.t_date= b102.t_trdt and b405.t_suno=b020.t_suno and "
                                                      + " b405.t_dino like '%{1}%'", "400", ship.shippmentNo);


                try
                {
                    DbReader = DbCommand.ExecuteReader();
                }
                catch (Exception ex)
                {
                    return(ship);
                }
                string first = ship.lotNo.Replace(" ", "");
                Dictionary <string, string> lotsAndMakat = new Dictionary <string, string>();
                List <string> Lots   = new List <string>();
                List <string> Makats = new List <string>();
                Lots.Add(first);

                string firstMakat = ship.makat.Replace(" ", "");
                Makats.Add(firstMakat);
                ship.lotNo = ship.lotNo.Replace(" ", "");
                ship.makat = ship.makat.Replace(" ", "");
                bool c = false;

                lotsAndMakat.Add(first, firstMakat);
                while (DbReader.Read())
                {
                    if (first == DbReader.GetString(0).Replace(" ", "").Trim() && DbReader.GetString(1).Replace(" ", "").Trim() == firstMakat)
                    {
                        c = true;
                    }

                    else
                    {
                        if (ship.lotNo.Length < 255 && ship.makat.Length < 255)
                        {
                            if (!Lots.Contains(DbReader.GetString(0).Replace(" ", "").Trim()))
                            {
                                ship.lotNo = ship.lotNo + ("," + DbReader.GetString(0).Replace(" ", "").Trim());
                                Lots.Add(DbReader.GetString(0).Replace(" ", "").Trim());
                            }
                            if (!Makats.Contains(DbReader.GetString(1).Replace(" ", "").Trim()))
                            {
                                ship.makat = ship.makat + ("," + DbReader.GetString(1).Replace(" ", "").Trim());
                                Makats.Add(DbReader.GetString(1).Replace(" ", "").Trim());
                            }
                        }
                    }
                }

                DbReader.Close();
            }



            if (!b)
            {
                DbCommand.CommandText = String.Format("select  b405.t_dino,b405.t_suno,b020.t_nama,b020.t_namc, b020.t_refs, b020.t_telp, b020.t_seak  from baandb.ttdltc102{0} as b102, baandb.ttdpur045{0} as b405, "
                                                      + " baandb.ttccom020{0} as b020  " +
                                                      " where b102.t_tord=1  and  b102.t_clot like '%{1}%'  and  b102.t_item like '%{2}%' and b405.t_suno=b020.t_suno  " +
                                                      " "
                                                      + " and b405.t_orno= b102.t_orno and b405.t_pono= b102.t_pono and b405.t_date= b102.t_trdt", "400", ship.lotNo.Replace(" ", ""), ship.makat.Replace(" ", ""));


                try
                {
                    DbReader = DbCommand.ExecuteReader();
                }
                catch (Exception ex)
                {
                    return(ship);
                }

                if (DbReader.Read())
                {
                    ship.shippmentNo      = DbReader.GetString(0).Replace(" ", "").Trim();
                    ship.supplierID       = DbReader.GetString(1).Replace(" ", "").Trim();
                    supp.SupplierNo       = ship.SupplierID;
                    supp.CompanyNo        = ship.Company;
                    supp.SupplierName     = DbReader.GetString(2).Trim();
                    supp.SupplierAddress  = DbReader.GetString(3).Trim();
                    supp.PurchasingPerson = DbReader.GetString(4).Trim();
                    supp.SupplierPhone    = DbReader.GetString(5).Trim();
                    supp.SearchKey        = DbReader.GetString(6).Trim();
                }


                DbReader.Close();
            }

            return(ship);
        }