Example #1
0
        public void insert_into_common_table(Connection connection, int id_store, int id_client, int dist)
        {
            try
            {
                if (connection._connection.State == System.Data.ConnectionState.Closed)
                {
                    connection.Open();
                }
                var command = new Oracle.ManagedDataAccess.Client.OracleCommand("insert_into_distance_table", connection._connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add("store_id", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value  = id_store;
                command.Parameters.Add("client_id", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value = id_client;
                command.Parameters.Add("distance", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value  = dist;

                command.ExecuteNonQuery();

                Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader();
                connection.Close();
            }
            catch (Exception e)
            {
                connection.Close();
                throw;
            }
        }
Example #2
0
        public List <Address> getCityStore(Connection connection)
        {
            try
            {
                if (connection._connection.State == System.Data.ConnectionState.Closed)
                {
                    connection.Open();
                }

                var command = new OracleCommand("getCities", connection._connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                List <Address>  addressList = new List <Address>();
                OracleParameter output      = command.Parameters.Add("l_cursor", OracleDbType.RefCursor);
                output.Direction = System.Data.ParameterDirection.ReturnValue;
                command.ExecuteNonQuery();

                Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Address address = new Address(
                        reader.GetInt32(0),
                        reader.GetString(1));
                    addressList.Add(address);
                }
                connection.Close();
                return(addressList);
                //  return null;
            }
            catch (Exception e)
            {
                connection.Close();
                throw;
            }
        }
Example #3
0
        public void InsertProductInList(int list_id, int product_id, int quantity, Connection connection)
        {
            try
            {
                if (connection._connection.State == System.Data.ConnectionState.Closed)
                {
                    connection.Open();
                }
                var command = new Oracle.ManagedDataAccess.Client.OracleCommand("insert_product_info", connection._connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add("list_id", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value    = list_id;
                command.Parameters.Add("product_id", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value = product_id;
                command.Parameters.Add("quantity_2", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value = quantity;

                command.ExecuteNonQuery();

                Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader();
                connection.Close();
            }
            catch (Exception e)
            {
                connection.Close();
                throw;
            }
        }
Example #4
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                dgvPreview.Columns.Clear();

                oraClient.OracleCommand cmd = oracleConnection.CreateCommand();
                cmd.CommandText = txtWGStatement.Text;
                using (oraClient.OracleDataReader reader = cmd.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        DataTable dataTable = new DataTable();
                        dataTable.Load(reader);
                        dgvPreview.DataSource = dataTable;
                    }
                    reader.Close();
                    reader.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error in btnLoad_Click()", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #5
0
        public int viewTroops()
        {
            Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection(DbConnect.oradb);

            String strSQL = "SELECT * FROM V_PlayerTroops";

            conn.Open();

            Oracle.ManagedDataAccess.Client.OracleCommand    cmd = new Oracle.ManagedDataAccess.Client.OracleCommand(strSQL, conn);
            Oracle.ManagedDataAccess.Client.OracleDataReader dr  = cmd.ExecuteReader();

            //read the record in dr
            dr.Read();

            if (dr.IsDBNull(0))
            {
                playerTroops = 1;
            }
            else
            {
                playerTroops = Convert.ToInt16(dr.GetValue(0)) + 1;
            }

            conn.Close();


            return(playerTroops);
        }
Example #6
0
        public List <Products_Info> GetDbProductsList(Connection connection, int id)
        {
            try
            {
                if (connection._connection.State == System.Data.ConnectionState.Closed)
                {
                    connection.Open();
                }
                var command = new Oracle.ManagedDataAccess.Client.OracleCommand("returnCartPro", connection._connection);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                List <Products_Info> products_Info_list = new List <Products_Info>();

                command.Parameters.Add("ID_INPUT", OracleDbType.Int32, System.Data.ParameterDirection.Input).Value = id;
                Oracle.ManagedDataAccess.Client.OracleParameter p_rc = command.Parameters.Add("rc", OracleDbType.RefCursor,
                                                                                              DBNull.Value,
                                                                                              System.Data.ParameterDirection.Output);
                // Oracle.ManagedDataAccess.Client.OracleParameter output = command.Parameters.Add("rc", OracleDbType.RefCursor);
                // output.Direction = System.Data.ParameterDirection.ReturnValue;
                command.ExecuteNonQuery();

                Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    Products_Info products_Info = new Products_Info(
                        reader.GetInt32(0),
                        reader.GetString(1),
                        reader.GetInt32(2),
                        reader.GetInt32(3),
                        reader.GetString(4),
                        reader.GetString(5));
                    products_Info_list.Add(products_Info);
                }
                connection.Close();
                return(products_Info_list);
                //  return null;
            }
            catch (Exception e)
            {
                connection.Close();
                throw;
            }
        }
Example #7
0
        private void previousOrdersBtn_Click(object sender, EventArgs e)
        {
            string[] words = greetingLabel.Text.Split(' ');

            string name    = words[1];
            string surname = words[2];

            Connection connection = new Connection();

            if (connection._connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }
            var command = new Oracle.ManagedDataAccess.Client.OracleCommand("GETUSERORDERS1", connection._connection);

            command.CommandType = System.Data.CommandType.StoredProcedure;
            command.Parameters.Add("nume", OracleDbType.Varchar2, System.Data.ParameterDirection.Input).Value    = name;
            command.Parameters.Add("prenume", OracleDbType.Varchar2, System.Data.ParameterDirection.Input).Value = surname;
            List <Order> orders_list = new List <Order>();

            Oracle.ManagedDataAccess.Client.OracleParameter output = command.Parameters.Add("l_cursor", OracleDbType.RefCursor);
            output.Direction = System.Data.ParameterDirection.ReturnValue;
            command.ExecuteNonQuery();

            Oracle.ManagedDataAccess.Client.OracleDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                Order order = new Order(reader.GetInt32(0));
                orders_list.Add(order);
            }

            connection.Close();

            seeOrdersForm seeOrdersForm = new seeOrdersForm(connection, orders_list);
        }
        public ActionResult Lister()
        {
            User user = (User)Session["User"];

            Oracle.ManagedDataAccess.Client.OracleCommand    ObjSelct = new Oracle.ManagedDataAccess.Client.OracleCommand("select * from QUESTIONS", user.connexion);
            Oracle.ManagedDataAccess.Client.OracleDataReader ObjeRead = ObjSelct.ExecuteReader();
            List <Question> q = new List <Question>();

            while (ObjeRead.Read())
            {
                Question QQ = new Question();
                QQ.Id         = ObjeRead.GetString(0);
                QQ.Enoncer    = ObjeRead.GetString(1);
                QQ.flag       = ObjeRead.GetString(2);
                QQ.Dificulter = ObjeRead.GetString(3);

                q.Add(QQ);
            }
            ObjeRead.Close();



            return(View(q));
        }
Example #9
0
 /// <summary>
 /// SQLSelect: Fait un select sur la connection courante
 /// et met le resultat dans monReader. La commande
 /// est passé en paramètre.
 /// </summary>
 public void SQLSelect(String maCommandeSQLString)
 {
     if ((maCommandeSQLString == null) ||
         (maCommandeSQLString == ""))
         {
             throw new JCASQLODPException(
                 "Aucune commande SQL n'a été fournie.");
         }
     maCommandeSQL.Connection = maConnection;
     maCommandeSQL.CommandText = maCommandeSQLString;
     maCommandeSQL.CommandType = CommandType.Text;
     try {
       monReader = maCommandeSQL.ExecuteReader();
       monReader.Read();
     }
     catch (OracleException excep)
     {
         if (ExceptionDetaillee)
             throw new JCASQLODPException("Commande SQL:" + Environment.NewLine +
             maCommandeSQLString + Environment.NewLine +
             excep.Message, excep);
         else throw excep;
     }
     if (ActiverResume) Resumer();
 }