Exemple #1
0
 //添加菜单函数
 public int Add_order(Order ord)
 {
     String sql = "insert into order_information values(@customer_ID,@restaurant_ID,@schould_pay,@actually_pay,@score_use,@order_privilege,@order_description,@order_date,@order_state,@meal_style,@order_location)";
     SqlParameter[] param =
     {
         new SqlParameter("@customer_ID",SqlDbType.Int),
         new SqlParameter("@restaurant_ID",SqlDbType.Int),
         new SqlParameter("@schould_pay",SqlDbType.Float),
         new SqlParameter("@actually_pay",SqlDbType.Float),
         new SqlParameter("@score_use",SqlDbType.Int),
         new SqlParameter("@order_privilege",SqlDbType.Int),
         new SqlParameter("@order_description",SqlDbType.VarChar),
         new SqlParameter("@order_date",SqlDbType.DateTime),
         new SqlParameter("@order_state",SqlDbType.Int),
         new SqlParameter("@meal_style",SqlDbType.Int),
         new SqlParameter("@order_location",SqlDbType.VarChar)
         //new SqlParameter("@ID",SqlDbType.Int)
     };
     param[0].Value = ord.customer_ID;
     param[1].Value = ord.restaurant_ID;
     param[2].Value = ord.should_pay;
     param[3].Value = ord.actually_pay;
     param[4].Value = ord.score_use;
     param[5].Value = ord.order_privilege;
     param[6].Value = ord.order_description;
     param[7].Value = ord.order_date;
     param[8].Value = ord.order_state;
     param[9].Value = ord.meal_state;
     param[10].Value = ord.order_location;
     return SqlHelper.ExecuteQuery(sql, param);
 }
Exemple #2
0
 //根据菜单ID修改菜单信息
 public int Update_order(Order ord, int ID)
 {
     String sql = "update order_information set customer_ID=@customer_ID,restaurant_ID=@restaurant_ID,should_pay=@should_pay,actually_pay=@actually_pay,score_use=@score_use,order_privilege=@order_privilege,order_description=@order_description,order_state=@order_state,meal_state=@meal_state,order_location=@order_location where ID=@ID";
     SqlParameter[] param =
     {
         new SqlParameter("@customer_ID",SqlDbType.Int),
         new SqlParameter("@restaurant_ID",SqlDbType.Int),
         new SqlParameter("@should_pay",SqlDbType.Float),
         new SqlParameter("@actually_pay",SqlDbType.Float),
         new SqlParameter("@score_use",SqlDbType.Int),
         new SqlParameter("@order_privilege",SqlDbType.Int),
         new SqlParameter("@order_description",SqlDbType.VarChar),
         new SqlParameter("@order_state",SqlDbType.Int),
         new SqlParameter("@meal_state",SqlDbType.Int),
         new SqlParameter("@ID",SqlDbType.Int),
         new SqlParameter("@order_location",SqlDbType.VarChar)
     };
     param[0].Value = ord.customer_ID;
     param[1].Value = ord.restaurant_ID;
     param[2].Value = ord.should_pay;
     param[3].Value = ord.actually_pay;
     param[4].Value = ord.score_use;
     param[5].Value = ord.order_privilege;
     param[6].Value = ord.order_description;
     param[7].Value = ord.order_state;
     param[8].Value = ord.meal_state;
     param[9].Value = ID;
     param[10].Value = ord.order_location;
     return SqlHelper.ExecuteQuery(sql, param);
 }
        public Win_MyMenu()
        {
            InitializeComponent();
            this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            OrderDAL o_dal = new OrderDAL();
            RestaurantDAL r_dal = new RestaurantDAL();
            DataTable dt = new DataTable();
            List<Order> orders = o_dal.select_order_by_cus_id(common.cus.ID);

            Order ord = new Order();
            int count = orders.Count;
            dt = o_dal.select_order_by_cus_id_dt(common.cus.ID);
            dt.Columns.Add("order_restaurant", typeof(String));
            dt.Columns.Add("order_state_str", typeof(String));
            string order_state;
            for (int i = 0; i < count; i++)
            {
                dt.Rows[i]["order_restaurant"] = r_dal.select_restaurant(orders[i].restaurant_ID).rest_name;
                if (orders[i].order_state == 1)
                    order_state = "已接单";
                else
                    order_state = "未接单";
                dt.Rows[i]["order_state_str"] = order_state;
            }
            dataGrid1.ItemsSource = dt.DefaultView;
        }
Exemple #4
0
 //根据餐厅ID查询菜单
 public List<Order> select_order_by_rest_id(int restaurant_ID)
 {
     String sql = "select * from order_information where restaurant_ID=@restaurant_ID and order_state=1";
     SqlParameter param = new SqlParameter("@restaurant_ID", SqlDbType.Int);
     param.Value = restaurant_ID;
     DataTable dt = SqlHelper.ExecuteSelect(sql, param);
     List<Order> orders = new List<Order>();
     Order ord = new Order();
     foreach (DataRow dr in dt.Rows)
     {
         ord = DataRowToOrder(dr);
         orders.Add(ord);
     }
     return orders;
 }
Exemple #5
0
 public Order select_customer_phone(int rest_ID, int state)
 {
     String sql = "select customer_ID from order_information where restaurant_ID=@rest_ID and order_state=@state";
     SqlParameter[] param =
     {
         new SqlParameter("@rest_ID",SqlDbType.Int),
         new SqlParameter("@state",SqlDbType.Int)
     };
     param[0].Value = rest_ID;
     param[1].Value = state;
     Order order = new Order();
     DataTable dt = SqlHelper.ExecuteSelect(sql, param);
     foreach (DataRow dr in dt.Rows)
     {
         order = DataRowToOrder(dr);
     }
     return order;
 }
Exemple #6
0
 //返回list
 public List<Order> select_order_list(int rest_ID, int state)
 {
     Order order = new Order();
     List<Order> orders=new List<Order>();
     String sql = "select * from order_information where restaurant_ID=@rest_ID and order_state=@state";
     SqlParameter[] param =
     {
         new SqlParameter("@rest_ID",SqlDbType.Int),
         new SqlParameter("@state",SqlDbType.Int)
     };
     param[0].Value = rest_ID;
     param[1].Value = state;
     DataTable dt = SqlHelper.ExecuteSelect(sql, param);
     foreach (DataRow dr in dt.Rows)
     {
         order = DataRowToOrder(dr);
         orders.Add(order);
     }
     return orders;
 }
Exemple #7
0
 //数据行转化为Order实例
 public Order DataRowToOrder(DataRow dr)
 {
     Order ord = new Order();
     ord.ID = (int)dr["ID"];
     ord.customer_ID = (int)dr["customer_ID"];
     ord.restaurant_ID = (int)dr["restaurant_ID"];
     ord.should_pay = (float)Convert.ToDouble(dr["should_pay"]);
     ord.actually_pay = (float)Convert.ToDouble(dr["actually_pay"]);
     ord.score_use = (int)dr["score_use"];
     ord.order_privilege = (int)dr["order_privilege"];
     ord.order_description = dr["order_description"].ToString();
     ord.order_date = (DateTime)dr["order_date"];
     ord.order_state = (int)dr["order_state"];
     ord.meal_state = (int)dr["meal_state"];
     ord.order_location =Convert.ToString( dr["order_location"]);
     return ord;
 }
Exemple #8
0
 public bool Update_order(Order ord, int ID)
 {
     return dal.Update_order(ord, ID) > 0;
 }
Exemple #9
0
 public bool Add_order(Order ord)
 {
     return dal.Add_order(ord) > 0;
 }