示例#1
0
        // Get Menuorder by Order Status
        public static List <MenuOrder> MenuOrderGet(OrderStatus orderstatus)
        {
            List <MenuOrder> retObject  = new List <MenuOrder>();
            SqlConnection    connection = null;

            try
            {
                connection = new SqlConnection();
                connection.ConnectionString = connectionString;

                SqlCommand comm = new SqlCommand();
                comm.Connection  = connection;
                comm.CommandText = "sprocMenuOrderGetForOrderStatus";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                comm.Parameters.AddWithValue("@OrderStatusID", orderstatus.ID);

                connection.Open();
                SqlDataReader dr = comm.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        MenuOrder menuOrder = new MenuOrder();
                        menuOrder.ID            = (int)dr["MenuID"];
                        menuOrder.Quantity      = (int)dr["Quantity"];
                        menuOrder.ItemPrice     = (decimal)dr["ItemPrice"];
                        menuOrder.OrderStatusID = (int)dr["OrderStatusID"];
                        menuOrder.Comment       = (string)dr["Comment"];
                        menuOrder.TotalPrice    = (decimal)dr["TotalPrice"];
                        menuOrder.Menu          = DAL.MenuGet((int)dr["MenuID"]);
                        retObject.Add(menuOrder);
                        //retObject.ID = (int)dr["MenuID"];
                    }
                }
            }

            catch (Exception ex)
            {
                retObject = null;
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(retObject);
        }
示例#2
0
        // Get Everything from the Database.
        public static List <MenuOrder> MenuOrderGet()
        {
            List <MenuOrder> retList    = new List <MenuOrder>();
            SqlConnection    connection = null;

            try
            {
                connection = new SqlConnection();
                connection.ConnectionString = connectionString;

                SqlCommand comm = new SqlCommand();
                comm.Connection  = connection;
                comm.CommandText = "sprocMenuOrderGetAll";
                comm.CommandType = System.Data.CommandType.StoredProcedure;

                connection.Open();
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    MenuOrder menuOrder = new MenuOrder();
                    menuOrder.ID            = (int)dr["MenuOrderID"];
                    menuOrder.ItemPrice     = (decimal)dr["ItemPrice"];
                    menuOrder.Quantity      = (int)dr["Quantity"];
                    menuOrder.TotalPrice    = (decimal)dr["TotalPrice"];
                    menuOrder.OrderStatusID = (int)dr["OrderStatusID"];
                    menuOrder.MenuID        = (int)dr["MenuID"];
                    menuOrder.Comment       = (string)dr["Comment"];

                    retList.Add(menuOrder);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(retList);
        }
示例#3
0
        // MenuOrder Add
        public static int MenuOrderAdd(MenuOrder menuOrder)
        {
            SqlConnection connection = null;
            int           retInt     = 0;

            try
            {
                connection = new SqlConnection();
                connection.ConnectionString = connectionString;

                SqlCommand comm = new SqlCommand();
                comm.Connection  = connection;
                comm.CommandText = "sproc_MenuOrderAdd";
                comm.CommandType = System.Data.CommandType.StoredProcedure;
                SqlParameter retParameter = new SqlParameter();
                retParameter           = comm.Parameters.AddWithValue("@MenuOrderID", System.Data.SqlDbType.Int);
                retParameter.Direction = System.Data.ParameterDirection.Output;
                retInt = (int)retParameter.Value;
                comm.Parameters.AddWithValue("@Quantity", menuOrder.Quantity);
                comm.Parameters.AddWithValue("@ItemPrice", menuOrder.ItemPrice);
                comm.Parameters.AddWithValue("@TotalPrice", menuOrder.TotalPrice);
                comm.Parameters.AddWithValue("@Comment", menuOrder.Comment);
                comm.Parameters.AddWithValue("@MenuID", menuOrder.MenuID);
                comm.Parameters.AddWithValue("@OrderStatusID", menuOrder.OrderStatusID);

                connection.Open();
                comm.ExecuteNonQuery();
            }


            catch (Exception ex)
            {
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }
            return(retInt);
        }