Ejemplo n.º 1
0
 //数据行转化为seat实例
 public Seats DataRowToSeat(DataRow dr)
 {
     Seats se = new Seats();
     se.restaurant_ID = (int)dr["restaurant_ID"];
     se.seat_style = (int)dr["seat_style"];
     se.seat_use = (int)dr["seat_use"];
     se.seat_left = (int)dr["seat_left"];
     se.seat_all = (int)dr["seat_all"];
     return se;
 }
Ejemplo n.º 2
0
 //根据餐厅ID查询座位
 public Seats select_seat(int restaurant_ID)
 {
     String sql = "select * from seat_information where restaurant_ID=@restaurant_ID";
     SqlParameter[] param =
     {
         new SqlParameter("@restaurant_ID",SqlDbType.Int)
     };
     param[0].Value = restaurant_ID;
     Seats se = new Seats();
     DataTable dt = SqlHelper.ExecuteSelect(sql, param);
     foreach (DataRow dr in dt.Rows)
     {
         se = DataRowToSeat(dr);
     }
     return se;
 }
Ejemplo n.º 3
0
 //根据餐厅ID修改座位
 public int update_seat(int restaurant_ID, Seats se)
 {
     String sql = "update seat_information set seat_style=@seat_style,seat_use=@seat_use,seat_left=@seat_left where restaurant_ID=@restaurant_ID";
     SqlParameter[] param =
     {
         new SqlParameter("@restaurant_ID",SqlDbType.Int),
         new SqlParameter("@seat_style",SqlDbType.Int),
         new SqlParameter("@seat_use",SqlDbType.Int),
         new SqlParameter("@seat_left",SqlDbType.Int),
         new SqlParameter("@seat_all",SqlDbType.Int)
     };
     param[0].Value = restaurant_ID;
     param[1].Value = se.seat_style;
     param[2].Value = se.seat_use;
     param[3].Value = se.seat_all - se.seat_use;
     param[4].Value = se.seat_all;
     return SqlHelper.ExecuteQuery(sql, param);
 }
Ejemplo n.º 4
0
 //加入座位函数
 public int Add_seat(Seats se)
 {
     String sql = "insert into seat_information values(@restaurant_ID,@seat_style,@seat_use,@seat_left,@seat_all)";
     SqlParameter[] param =
     {
         new SqlParameter("@restaurant_ID",SqlDbType.Int),
         new SqlParameter("@seat_style",SqlDbType.Int),
         new SqlParameter("@seat_use",SqlDbType.Int),
         new SqlParameter("@seat_left",SqlDbType.Int),
         new SqlParameter("@seat_all",SqlDbType.Int),
     };
     param[0].Value = se.restaurant_ID;
     param[1].Value = se.seat_style;
     param[2].Value = se.seat_use;
     param[3].Value = se.seat_all - se.seat_use;
     param[4].Value = se.seat_all;
     return SqlHelper.ExecuteQuery(sql, param);
 }
Ejemplo n.º 5
0
        private void button2_Click_1(object sender, RoutedEventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("请输入小店名称。");
            }
            else if (textBox2.Text == "")
            {
                MessageBox.Show("请输入密码。");
            }
            else if (textBox3.Text == "")
            {
                MessageBox.Show("请确认密码。");
            }
            else if (textBox4.Text == "")
            {
                MessageBox.Show("请输入验证问题。");
            }
            else if (textBox5.Text == "")
            {
                MessageBox.Show("请输入答案。");
            }
            else if (textBox6.Text == "")
            {
                MessageBox.Show("请输入小店描述。");
            }
            else if (textBox8.Text == "")
            {
                MessageBox.Show("请输入2人桌总数。");
            }
            else if (textBox9.Text == "")
            {
                MessageBox.Show("请输入4人桌总数。");
            }
            else if (textBox10.Text == "")
            {
                MessageBox.Show("请输入8人桌总数。");
            }
            else if (textBox11.Text == "")
            {
                MessageBox.Show("请输入12人桌总数。");
            }
            else if (textBox12.Text == "")
            {
                MessageBox.Show("请输入手机号。");
            }
            else if (textBox13.Text == "")
            {
                MessageBox.Show("请输入对外联系方式。");
            }
            else if (textBox14.Text == "")
            {
                MessageBox.Show("请输入详细地址。");
            }
            else if (serve == 1000)
            {
                MessageBox.Show("请选择是否配送外卖。");
            }
            else if (textBox2.Text != textBox3.Text)
            {
                MessageBox.Show("密码输入错误,请重新输入密码");
            }
            else if (textBox7.Text == "")
            {
                MessageBox.Show("请输入图片");
            }
            else if (textBox12.Text.Length != 11)
            {
                MessageBox.Show("手机号码位数不正确,轻松重新输入");
                textBox12.Clear();
            }
            else
            {
                rests = r_dal.GetAllRestaurant();
                int amount = rests.Count;
                int j = 0;
                while (j < amount)
                {
                    if (textBox12.Text == rests[j].rest_telephone)
                    {
                        MessageBox.Show("该手机号已被注册,请重新输入");
                        break;
                    }
                    j++;
                }
                if (j == amount)
                {
                    rest.rest_name = textBox1.Text;
                    rest.rest_password = textBox2.Text;
                    rest.rest_question = textBox4.Text;
                    rest.rest_answer = textBox5.Text;
                    rest.rest_description = textBox6.Text;
                    rest.rest_telephone = textBox12.Text;
                    rest.rest_homephone = textBox13.Text;
                    rest.rest_location = textBox14.Text;
                    rest.rest_service = serve;
                    rest.rest_privilege = WuYouHui;
                    rest.begin_date = DateTime.Now;
                    rest.end_date = DateTime.Now;
                    rest.rest_state = WeiShenHe;
                    rest.rest_district = comboBox2.Text;
                    if (bll.Add_restaurant(rest))
                    {
                        int count = bll.GetAllRestaurant().Count;
                        List<Restaurant> restaurants = new List<Restaurant>();
                        restaurants = bll.GetAllRestaurant();
                        int i = 0;
                        while (i < count)
                        {
                            if (textBox12.Text == restaurants[i].rest_telephone)
                            {
                                if (textBox2.Text == restaurants[i].rest_password)
                                {
                                    common.rest = restaurants[i];
                                    break;
                                }

                            }
                            i++;
                        }
                        pic.pic_style = 2;                  //2
                        pic.pic_owner = common.rest.ID;
                        dal.Add_picture(pic);               //加入pic数据库
                        MessageBox.Show("添加成功");
                        restaurants = bll.GetAllRestaurant();
                        count = bll.GetAllRestaurant().Count;
                        for (i = 1; i < count; i++)
                        {
                            if (common.rest.rest_telephone == restaurants[i].rest_telephone)
                            {
                                common.rest = restaurants[i];
                                break;
                            }
                        }
                        Seats se = new Seats();
                        if (textBox8.Text != "")
                        {
                            se.restaurant_ID = common.rest.ID;
                            se.seat_style = seat2;
                            se.seat_all = Convert.ToInt16(textBox8.Text);
                            se.seat_use = 0;
                            s_bll.Add_Seat(se);
                        }
                        if (textBox9.Text != "")
                        {
                            se.restaurant_ID = common.rest.ID;
                            se.seat_style = seat4;
                            se.seat_all = Convert.ToInt32(textBox9.Text);
                            se.seat_use = 0;
                            s_bll.Add_Seat(se);
                        }
                        if (textBox10.Text != "")
                        {
                            se.restaurant_ID = common.rest.ID;
                            se.seat_style = seat8;
                            se.seat_all = Convert.ToInt16(textBox10.Text);
                            se.seat_use = 0;
                            s_bll.Add_Seat(se);
                        }
                        if (textBox11.Text != "")
                        {
                            se.restaurant_ID = common.rest.ID;
                            se.seat_style = seat12;
                            se.seat_all = Convert.ToInt16(textBox11.Text);
                            se.seat_use = 0;
                            s_bll.Add_Seat(se);
                        }
                        Win_Owner1 win_owner = new Win_Owner1();
                        win_owner.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("添加失败");
                    }
                }
            }
        }
Ejemplo n.º 6
0
 public bool Add_Seat(Seats dat)
 {
     return dal.Add_seat(dat) > 0;
 }