//将数据行转化为Orderitem实例
 public OrderItem_Information DataRowToOrderitem(DataRow dr)
 {
     OrderItem_Information orderit = new OrderItem_Information();
     orderit.order_ID = (int)dr["order_ID"];
     orderit.dish_ID = (int)dr["dish_ID"];
     orderit.dish_amount = (int)dr["dish_amount"];
     orderit.total_pay = (float)Convert.ToDouble(dr["total_pay"]);
     return orderit;
 }
 //根据菜单ID修改菜单项信息函数
 public int Update_orderitem(OrderItem_Information orderit, int ID)
 {
     String sql = "update orderitem_information set dish_ID=@dish_ID,dish_amount=@dish_amount,total_pay=@total_pay where order_ID=@ID";
     SqlParameter[] param =
      {
          new SqlParameter("@dish_ID",SqlDbType.Int),
          new SqlParameter("@dish_amount",SqlDbType.Int),
          new SqlParameter("@total_pay",SqlDbType.Float),
          new SqlParameter("@ID",SqlDbType.Int),
      };
     param[0].Value = orderit.dish_ID;
     param[1].Value = orderit.dish_amount;
     param[2].Value = orderit.total_pay;
     param[3].Value = ID;
     return SqlHelper.ExecuteQuery(sql, param);
 }
 //加入订单id,菜色id,数量,价格
 public int Add_orderitem(OrderItem_Information orderitem)
 {
     String sql = "insert into orderitem_information values(@order_ID,@dish_ID,@dish_amount,@total_pay)";
     SqlParameter[] param =
     {
         new SqlParameter("@order_ID",SqlDbType.Int),
         new SqlParameter("@dish_ID",SqlDbType.Int),
         new SqlParameter("@dish_amount",SqlDbType.Int),
         new SqlParameter("@total_pay",SqlDbType.Float)
     };
     param[0].Value = orderitem.order_ID;
     param[1].Value = orderitem.dish_ID;
     param[2].Value = orderitem.dish_amount;
     param[3].Value = orderitem.total_pay;
     return SqlHelper.ExecuteQuery(sql, param);
 }
 public bool Update_orderitem(OrderItem_Information orderit, int ID)
 {
     return dal.Update_orderitem(orderit, ID) > 0;
 }
 public bool Add_orderitem(OrderItem_Information orderit)
 {
     return dal.Add_orderitem(orderit) > 0;
 }
 //生成订单
 public void Made_Order()
 {
     DataTable dt;
     dt = bll.Load_Service_dis(common.rest.ID);
     //Order ord = new Order();
     common.ord.customer_ID = common.cus.ID;
     common.ord.restaurant_ID = common.rest.ID;
     common.ord.should_pay = Convert.ToInt32(lab_price.Content);
     common.ord.order_privilege = (int)dt.Rows[0]["rest_privilege"];
     common.ord.actually_pay = common.ord.should_pay;
     common.ord.score_use = 0;
     common.ord.order_description = "";
     common.ord.order_date = DateTime.Now;
     common.ord.order_state = 0;
     common.ord.meal_state = 0;
     common.ord.order_location = "";
     o_dal.Add_order(common.ord);
     common.ord = o_dal.select_order_by_restID_and_date(common.ord.restaurant_ID, common.ord.order_date);
     OrderItem_Information ordit = new OrderItem_Information();
     if (lab_count1.Content.ToString() != ""&&lab_count1.Content.ToString()!="0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes1[0].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count1.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label1.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count2.Content.ToString() != "" && lab_count2.Content.ToString() != "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes1[1].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count2.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label2.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count3.Content.ToString() != "" && lab_count3.Content.ToString() != "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes1[2].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count3.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label13.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count4.Content.ToString() != "" && lab_count4.Content.ToString() != "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[0].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count4.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label20.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count5.Content.ToString() != "" && lab_count5.Content.ToString()!= "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[1].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count5.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label22.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count6.Content.ToString() != "" && lab_count6.Content.ToString()!= "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[2].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count6.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label24.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count7.Content.ToString() != "" && lab_count7.Content.ToString()!= "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[3].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count7.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label24.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count8.Content.ToString() != "" && lab_count8.Content.ToString()!= "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[4].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count8.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label26.Content);
         oit_dal.Add_orderitem(ordit);
     }
     if (lab_count9.Content.ToString() != "" && lab_count9.Content.ToString()!= "0")
     {
         ordit.order_ID = common.ord.ID;
         ordit.dish_ID = dishes0[5].ID;
         ordit.dish_amount = Convert.ToInt32(lab_count9.Content);
         ordit.total_pay = ordit.dish_amount * (float)Convert.ToDouble(label28.Content);
         oit_dal.Add_orderitem(ordit);
     }
 }