Ejemplo n.º 1
0
 private void SelectDeskDoneShowBtn(object sender, EventArgs e)
 {
     deskNum  = comboBox2.SelectedItem.ToString();
     orderNum = ControlOrderClass.GetNowOrderNum();
     btnSubmitOrder.Enabled = true;
     foodGroupBox.Enabled   = true;
 }
Ejemplo n.º 2
0
        private void btn预约_Click(object sender, EventArgs e)
        {
            if (panel1.Enabled == false || roomComboBox.SelectedItem.ToString() == "")
            {
                MessageBox.Show("请选择房间和餐桌!", "操作提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SqlConnection conn = new SqlConnection(Properties.Settings.Default.connDateString);

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = conn;

            for (int j = 0; j < deskDataView.Rows.Count; j++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)deskDataView.Rows[j].Cells[2];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag == true)
                {
                    List <Dish> dish     = new List <Dish>();
                    string      deskNum  = deskDataView.Rows[j].Cells[0].Value.ToString();
                    string      orderNum = ControlOrderClass.GetNowOrderNum(bookDatePicker.Value.Date);

                    string sqlDate = bookDatePicker.Value.Date.ToString("yyyy-MM-dd");//当天的

                    StringBuilder strSQLinsert = new StringBuilder();
                    strSQLinsert.Append("insert ");
                    strSQLinsert.Append("into CustomerDesk(Ctellphone, Did, Ordernum, Orderdate, Ifcheckout, Ordermoney) ");
                    strSQLinsert.Append(
                        string.Format
                            ("values('{0}','{1}','{2}','{3}','否', 0);", nowOrderDishCustomerID, deskNum, orderNum, sqlDate));
                    cmd.CommandText = strSQLinsert.ToString();
                    cmd.ExecuteNonQuery();
                } //END if 桌子为勾选状态
            }     //END for 每张桌子

            MessageBox.Show("预定成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            cmd.Dispose();
            conn.Dispose();
            conn.Close();

            this.Close();
        }
Ejemplo n.º 3
0
        private void btnSubmitOrder_Click(object sender, EventArgs e)
        {
            if (ReasonableCheck() == false)
            {
                return;
            }

            SqlConnection conn = new SqlConnection(Properties.Settings.Default.connDateString);

            conn.Open();
            SqlCommand cmd = new SqlCommand();

            cmd.Connection = conn;

            DialogResult result            = DialogResult.Cancel;
            int          successOrderCount = 0;

            for (int j = 0; j < deskDataView.Rows.Count; j++)
            {
                DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)deskDataView.Rows[j].Cells[2];
                Boolean flag = Convert.ToBoolean(checkCell.Value);
                if (flag == true)
                {
                    List <Dish> dish = new List <Dish>();
                    deskNum  = deskDataView.Rows[j].Cells[0].Value.ToString();
                    orderNum = ControlOrderClass.GetNowOrderNum();
                    for (int k = 0; k < tempDish.Count; k++)
                    {
                        Dish temp = tempDish[k];
                        temp.deskID   = deskNum;
                        temp.orderNum = orderNum;
                        dish.Add(temp);
                    }

                    //orderMsg是订单信息,构造这个订单信息的字符串并打印,用于确认订单信息。
                    StringBuilder orderMsg = new StringBuilder();
                    orderMsg.Append("\t\t请确认订单信息\n\n");
                    orderMsg.Append("订单号:" + orderNum + "\t" + "单位:人民币(元)\n");
                    orderMsg.Append("---------------------------------------------------------------\n");
                    orderMsg.Append("顾客:" + nowOrderDishCustomerName + "\t\t" + "联系方式:" + nowOrderDishCustomerID + "\n");
                    orderMsg.Append("---------------------------------------------------------------\n");
                    cmd.CommandText = string.Format("select Rname from Room where Rid in (select Droomid from Desk where Did = '{0}');", deskNum);
                    string roomName = cmd.ExecuteScalar().ToString();
                    orderMsg.Append("房间:" + roomName + "\t\t" + "餐桌:" + deskNum + "\n");
                    orderMsg.Append("===================================\n");
                    orderMsg.Append("菜的编号\t菜的种类 \t    菜名\t\t菜价\n");

                    //以下是菜的具体信息
                    for (int i = 0; i < tempDish.Count; i++)
                    {
                        cmd.CommandText = string.Format("select Fname, Fprice from Menu where Fid = '{0}';", tempDish[i].foodID);
                        SqlDataReader sdr           = cmd.ExecuteReader();
                        string        tempFoodNname = "";
                        float         tempFoodPrice = 0;
                        if (sdr.Read())
                        {
                            tempFoodNname = sdr["Fname"].ToString();
                            tempFoodPrice = float.Parse(sdr["Fprice"].ToString());
                        }
                        orderMsg.Append("---------------------------------------------------------------\n");
                        orderMsg.Append(string.Format("{0}\t  {1}\t{2,-10}\t{3:f2}\n", tempDish[i].foodID, tempDish[i].foodType, tempFoodNname, tempFoodPrice));
                        sdr.Dispose();
                        sdr.Close();
                    }

                    orderMsg.Append("===================================\n");
                    orderMsg.Append(string.Format("\t\t\t已选{0}道菜,总计{1:f2}元\n", count, orderMoney));

                    DateTime now = DateTime.Now;
                    sqlDate = now.ToString("yyyy-MM-dd");//当天的
                    result  =
                        MessageBox.Show(orderMsg.ToString(), "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    if (result == DialogResult.OK)
                    {
                        StringBuilder strSQLinsert = new StringBuilder();
                        strSQLinsert.Append("insert ");
                        strSQLinsert.Append("into CustomerDesk(Ctellphone, Did, Ordernum, Orderdate, Ifcheckout, Ordermoney) ");
                        strSQLinsert.Append(
                            string.Format
                                ("values('{0}','{1}','{2}','{3}','否',{4});", nowOrderDishCustomerID, deskNum, orderNum, sqlDate, orderMoney));
                        cmd.CommandText = strSQLinsert.ToString();
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = string.Format("update Desk set Difuse = '是' where Did = '{0}';", deskNum);
                        cmd.ExecuteNonQuery();

                        StringBuilder strUpdateRoom = new StringBuilder();
                        strUpdateRoom.Append("update Room ");
                        strUpdateRoom.Append("set Rusedesks = Rusedesks + 1 ");
                        strUpdateRoom.Append("where Rid in ");
                        strUpdateRoom.Append(" (select Droomid ");
                        strUpdateRoom.Append("  from Desk ");
                        strUpdateRoom.Append(string.Format("  where Did = '{0}');", deskNum));
                        cmd.CommandText = strUpdateRoom.ToString();
                        cmd.ExecuteNonQuery();

                        for (int i = 0; i < dish.Count; i++)
                        {
                            ControlOrderClass.GetDish(dish[i]);
                            StringBuilder strSQLinsertDeskMenu = new StringBuilder();
                            strSQLinsertDeskMenu.Append("insert ");
                            strSQLinsertDeskMenu.Append("into DeskMenu(Did, Fid, Ordernum, Ifservedish) ");
                            strSQLinsertDeskMenu.Append(
                                string.Format("values('{0}', '{1}', '{2}', '否')"
                                              , dish[i].deskID, dish[i].foodID, dish[i].orderNum));
                            cmd.CommandText = strSQLinsertDeskMenu.ToString();
                            cmd.ExecuteNonQuery();
                        }
                        successOrderCount++;
                    } //END if 点击确认正式下单并更新后台数据库
                }     //END if 桌子为勾选状态
            }         //END for 每张桌子


            MessageBox.Show("成功提交" + successOrderCount + "个订单,请耐心等候!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            orderDishListBox.Items.Clear();
            orderDishListBox.Items.Add("菜编号    菜名        菜价");
            count             = 0;
            orderMoney        = 0;
            summaryLabel.Text = string.Format("已选{0}道菜,共计:{1}元", count, orderMoney);
            cmd.Dispose();
            conn.Dispose();
            conn.Close();
            tempDish.Clear();
            this.Close();
        }