Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            #region TestMethods

            //SMTPOutgoing smptOutgoing = new SMTPOutgoing();
            //smptOutgoing.SMTP("","","","");
            //Console.WriteLine("Complete");
            //Console.ReadLine();

            //ADO.NET connection
            IDataAccess _da = new DataAccess.DataAccess();

            //var query = from p in dbContext.ProductSet
            //            where p.Categories.CategoryName == "Seafood"
            //            select p;
            //IEnumerable<Product> products = query.ToList();

            _da = new DataAccess.DataAccess();
            _da.Open();
            DataSet ds = _da.Read("Select * from Orders");
            DataTable dt = ds.Tables[0];

            //Refernce another project (MVC)
            //Ask for user input
            //Create Inforce referential integrity with complex object
            //Read
            //Update
            //Delete record
            //Reference JAVA
            //Reference Perl
            //referenca SOAP

            #region Load dictionary values in enum or from web.config file.
                    Dictionary<int, string> type = new Dictionary<int, string>();
                    type.Add(1, "Home");
                    type.Add(2, "Product");
                    type.Add(3, "Parts");
                    type.Add(4, "Service Order");

                    Console.WriteLine("Select type");

                    string selectedValue = Console.Read().ToString();
                    type.ContainsKey(Convert.ToInt32(selectedValue));

                    //foreach (KeyValuePair<int, string> pair in selectedValue) {
                    //    Console.WriteLine(pair.Key.ToString());
                    //}

                    selectedValue.GetType();

                    if (true) {
                        Console.WriteLine("You've selected ", "KeyValue");
                    } else {
                        Console.WriteLine("Invalid selection");
                    }
                    Console.ReadLine();
                #endregion

            #endregion
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Select command
        /// </summary>
        /// <param name="select">Select from database</param>
        public DataSet Read(string cmd)
        {
            IDataAccess _da = new DataAccess();

            SqlConnection connection = new SqlConnection();

            DataTable dt = new DataTable();
            DataSet ds = new DataSet();

            string sc = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
            string us = "Data Source=" + sc.Remove(0, 6) + "\\NORTHWIND.MDF";
            string fs = us.Replace("\\", "\\");

            SqlCommand command = new SqlCommand("Select * from Orders", connection);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            adapter.Fill(ds);

            _da = new DataAccess();
            _da.Open();
            connection.ConnectionString = fs;

            connection.Open();

            ds = _da.Read("Select * from Orders");
            dt = ds.Tables[0];

            return ds;
        }