示例#1
0
 private void ExecuteDataReader(U2Connection con)
 {
     try
     {
         if (settings.AccessMode == "Native")
         {
             // Need to confirm how to use UniDataSet
         }
         else
         {
             U2Command cmd = con.CreateCommand();
             cmd.Connection  = con;
             cmd.CommandText = settings.CommandText;
             U2DataReader dr = cmd.ExecuteReader();
             while (dr.Read())
             {
                 // Do something
             }
         }
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
        public ActionResult GetProduct(string term)
        {
            List <Product> ProductsFound = new List <Product>();

            string Upperterm = term.ToUpper();

            try
            {
                string s = ConfigurationManager.AppSettings["TESTString"];

                U2Connection con = new U2Connection();
                U2Command    cmd = con.CreateCommand();
                con.ConnectionString = s;
                con.Open();

                cmd.CommandText = "SELECT PROD,SALE, DESC1 FROM IVMST WHERE UPPER(DESC1) LIKE '%" + Upperterm + "%'";

                U2DataReader dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    Product ProductList = new Product {
                        DESC1 = dr["DESC1"].ToString(),
                        PROD  = dr["PROD"].ToString(),
                        SALE  = dr["SALE"].ToString()
                    };

                    ProductsFound.Add(ProductList);
                }


                con.Close();
            }
            catch (Exception e)
            {
                // Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                }
            }
            finally
            {
                // string line = Console.ReadLine();
            }


            return(Json(ProductsFound, JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public static List <Orders> GetProducts(List <Orders> Cart)
        {
            List <Orders> shoppingCart = Cart;


            U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();

            conn_str.UserID     = "Demo";
            conn_str.Password   = "******";
            conn_str.Server     = "localhost";
            conn_str.Database   = "pwdemo";
            conn_str.ServerType = "UNIVERSE";
            conn_str.Pooling    = false;
            string       s    = conn_str.ToString();
            U2Connection con1 = new U2Connection();

            con1.ConnectionString = s;
            con1.Open();

            U2Command cmd1 = con1.CreateCommand();

            foreach (var Product in shoppingCart)
            {
                try
                {
                    cmd1.CommandText = "SELECT [DESC_POS] FROM IVMST WHERE ID=" + Product.Serial.ToString();
                    U2DataReader dr1 = cmd1.ExecuteReader();

                    while (dr1.Read())
                    {
                        Product.ProdDescription = string.Format(dr1["DESC_POS"].ToString());
                        dr1.Close();
                    }
                }
                catch (Exception ex)
                {
                }
            }



            con1.Close();

            return(shoppingCart);
        }
示例#4
0
        static void Main(string[] args)
        {
            try
            {
                U2ConnectionStringBuilder conn_str = new U2ConnectionStringBuilder();
                conn_str.UserID     = "user";
                conn_str.Password   = "******";
                conn_str.Server     = "localhost";
                conn_str.Database   = "HS.SALES";
                conn_str.ServerType = "UNIVERSE";
                conn_str.Pooling    = false;
                string       s   = conn_str.ToString();
                U2Connection con = new U2Connection();
                con.ConnectionString = s;
                con.Open();
                Console.WriteLine("Connected.........................");
                U2Command cmd = con.CreateCommand();
                cmd.CommandText = "SELECT * FROM CUSTOMER";
                U2DataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    string s1 = string.Format("FNAME={0}     LNAME={1}", dr["FNAME"], dr["LNAME"] + Environment.NewLine);
                    Console.WriteLine(s1);
                }


                con.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                Console.WriteLine("Enter to exit:");
                string line = Console.ReadLine();
            }
        }
        public ActionResult About()
        {
            string NewOrderID = null; //rnd.Next(1, 10000).ToString();   // creates a number between 1 and 6

            string s = ConfigurationManager.AppSettings["TESTString"];

            U2Connection con = new U2Connection();
            U2Command    cmd = con.CreateCommand();

            con.ConnectionString = s;
            con.Open();

            cmd.CommandText = "SELECT MAX(RECID) FROM SHOPPINGCART";
            U2DataReader dr = cmd.ExecuteReader();

            while (dr.Read())
            {
                string MaxID = dr["RECID"].ToString();

                NewOrderID = (Convert.ToInt32(MaxID) + 1).ToString();
            }
            con.Close();



            if (Request.Cookies["ComputymeOrder"] == null)
            {
                //Drop cookie
                HttpCookie myCookie = new HttpCookie("ComputymeOrder");
                myCookie["OrderID"]     = NewOrderID;
                myCookie["OrderStatus"] = "New";
                myCookie.Expires        = DateTime.Now.AddDays(1d);
                Response.Cookies.Add(myCookie);
            }
            else
            {
                string OrderStatus;
                //if (Request.Cookies["ComputymeOrder"]["OrderID"] != null  )
                if (Request.Cookies["ComputymeOrder"]["OrderID"] != null)
                {
                    OrderStatus = Request.Cookies["ComputymeOrder"]["OrderStatus"];

                    if (OrderStatus == "New")
                    {
                        NewOrderID = Request.Cookies["ComputymeOrder"]["OrderID"];
                    }
                }
                else
                {
                    //Drop cookie
                    HttpCookie myCookie = new HttpCookie("ComputymeOrder");
                    myCookie["OrderID"]     = NewOrderID;
                    myCookie["OrderStatus"] = "New";
                    myCookie.Expires        = DateTime.Now.AddDays(1d);
                    Response.Cookies.Add(myCookie);
                }
                // Check if it exists.
            }

            Computyme.Models.NewOrder.UniqueOrder OrderID = new Models.NewOrder.UniqueOrder {
                OrderID = NewOrderID, UserID = "4561"
            };

            ViewData["TransacionID"] = OrderID;
            return(View());
        }
        //file for customers -- IVCUST
        //NAME_1 = NAME of customer
        //ADDR_1 = Street address of customer -
        //ADDR_2 = Second address of customer
        //CSZ = City, St Zip of customer
        //Phone_1 = Primary Phone number of customer
        public ActionResult GetCustomer(string term)
        {
            List <Computyme.Models.Customer.Customer> CustomerFound = new List <Computyme.Models.Customer.Customer>();

            string Upperterm = term.ToUpper();

            try
            {
                string s = ConfigurationManager.AppSettings["TESTString"];

                U2Connection con = new U2Connection();
                U2Command    cmd = con.CreateCommand();
                con.ConnectionString = s;
                con.Open();

                cmd.CommandText = "SELECT NAME_1,ADDR_1, ADDR_2,CSZ, PHONE_1,EMAIL  FROM IVCUST WHERE UPPER(NAME_1) LIKE '%" + Upperterm + "%'";

                U2DataReader dr = cmd.ExecuteReader();

                string cell  = "111-111-1111";
                string email = "None";
                while (dr.Read())
                {
                    try
                    {
                        if (dr["Phone_1"] != null)
                        {
                            cell = (dr["Phone_1"] ?? "").ToString();
                        }
                    }
                    catch { cell = "111-111-1111"; }

                    try
                    {
                        if (dr["EMAIL"] != null)
                        {
                            email = (dr["EMAIL"] ?? "").ToString();
                        }
                    }
                    catch { email = "None"; }



                    string Fullstring = (dr["NAME_1"] ?? "").ToString();
                    string LName      = Fullstring.Substring(0, Fullstring.IndexOf(","));
                    string FName      = Fullstring.Replace(LName, "").Replace(",", "");
                    string address    = (dr["ADDR_1"] ?? "").ToString();

                    Computyme.Models.Customer.Customer CustomerList = new Computyme.Models.Customer.Customer
                    {
                        Fname   = FName,
                        Lname   = LName,
                        Address = (dr["ADDR_1"] ?? "").ToString(),
                        Cell    = cell,
                        Email   = email
                    };

                    CustomerFound.Add(CustomerList);
                }


                con.Close();
            }
            catch (Exception e)
            {
                // Console.WriteLine(e.Message);
                if (e.InnerException != null)
                {
                }
            }
            finally
            {
                // string line = Console.ReadLine();
            }


            return(Json(CustomerFound, JsonRequestBehavior.AllowGet));
        }