示例#1
0
        //开台
        private bool OpenTableAndAddBill(string tableno)
        {
            //打开开台、单据录入窗口
            AddForm addfrm = new AddForm();
            addfrm.Text = "开台/新建单据";
            addfrm.frmmode = 1;
            addfrm.GetConsumeBillTypeList(); //开台新建单据只允许添加消费单据
            addfrm.ComboBox1.Text = addfrm.ComboBox1.Items[0].ToString();
            addfrm.Label5.Text = "请为 " + tableno + " 号桌台开台并添加消费单据";

            addfrm.ShowDialog();
            if (addfrm.DialogResult == DialogResult.OK)
            {
                rms_var.ExeOpenTable(tableno, System.Convert.ToInt32(addfrm.NumericUpDown1.Value), addfrm.TextBox2.Text);
                string serialno;
                serialno = rms_var.GenUniqueCode();
                rms_var.AddBalanceTable(serialno, tableno, addfrm.NumericUpDown1.Value.ToString(), addfrm.TextBox2.Text);
                GetTableList(cbTableType.Text);
                //准备添加第一张单据
                if (! rms_var.SameBillinSale(addfrm.TextBox1.Text, addfrm.ComboBox1.Text))
                {
                    if (rms_var.AddSaleBill(serialno, tableno, addfrm.TextBox1.Text, rms_var.GetBillTypeCode(addfrm.ComboBox1.Text), addfrm.TextBox2.Text))
                    {
                        CurrentTableNo = tableno;
                        CurrentBillNo = addfrm.TextBox1.Text;
                        CurrentBillTypename = addfrm.ComboBox1.Text;
                    }
                    else
                    {
                        MessageBox.Show("加单操作失败!已分配的单据号可能已被其他客户端抢先使用,请重新执行加单操作。");
                    }
                }
                else
                {
                    MessageBox.Show("开台已成功但加单失败(存在同号单据),请手动执行加单操作。");
                }
                //这里添加桌台的其他信息

                //End
                return true;
            }
            else
            {
                return false;
            }
        }
示例#2
0
        //加单
        private void AddBill(string tableno)
        {
            //打开单据录入窗口
            AddForm addfrm = new AddForm();
            addfrm.Text = "添加单据";
            addfrm.frmmode = 0;
            //Dim tableno As String
            //tableno = dgTableStatus.Item(dgTableStatus.CurrentRowIndex, 0)
            CurrentTableNo = tableno;
            //检测当前桌台是否有消费单据
            if (rms_var.TableConsumeBillExists(tableno))
            {
                addfrm.GetBillTypeList();
            }
            else
            {
                addfrm.GetConsumeBillTypeList();
            }

            addfrm.NumericUpDown1.Visible = false;
            addfrm.Label3.Visible = false;
            addfrm.Label5.Text = "请为 " + tableno + " 号桌台加单";

            addfrm.ComboBox1.Text = addfrm.ComboBox1.Items[0].ToString();
            addfrm.ShowDialog();
            if (addfrm.DialogResult == DialogResult.OK)
            {
                //准备添加单据
                if (! rms_var.SameBillinSale(addfrm.TextBox1.Text, addfrm.ComboBox1.Text))
                {
                    if (rms_var.AddSaleBill(rms_var.GetCurrentTableSerialNo(tableno), tableno, addfrm.TextBox1.Text, rms_var.GetBillTypeCode(addfrm.ComboBox1.Text), addfrm.TextBox2.Text))
                    {
                        CurrentBillNo = addfrm.TextBox1.Text;
                        MessageBox.Show("加单操作顺利完成");
                        //刷新桌台的单据列表
                        ShowBill(CurrentTableNo, "last");
                    }
                    else
                    {
                        MessageBox.Show("加单操作失败!已分配的单据号可能已被其他客户端抢先使用,请重新执行加单操作。");
                    }
                }
                else
                {
                    MessageBox.Show("加单操作失败!已经存在同号单据,请重新执行加单操作。");
                }
            }
        }
示例#3
0
        //完成预定将预订桌台转为开台
        public static bool CompleteAppoint(string appointno)
        {
            if (MessageBox.Show("确定要完成选中的预定订单,并将预订的桌台状态设为使用吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();
                conn.ConnectionString = ConnStr;
                try
                {
                    SqlCommand selectCMD = new SqlCommand();
                    selectCMD.Connection = conn;
                    conn.Open();

                    string tableno;

                    selectCMD.CommandText = "update appointbill set status='1' where appointno='" + appointno + "'";
                    selectCMD.ExecuteNonQuery();

                    selectCMD.CommandText = "select tableno from view_appointtable where appointno='" + appointno + "'";

                    SqlDataAdapter dbDA = new SqlDataAdapter();
                    dbDA.SelectCommand = selectCMD;
                    DataSet dbDS = new DataSet();
                    dbDA.Fill(dbDS, "t1");

                    //遍历所有当前预订到期的桌台
                    //同一桌台使用相同的 serialno 等同于 并台
                    string serialno;
                    serialno = GenUniqueCode();

                    for (int i = 0; i <= dbDS.Tables[0].Rows.Count - 1; i++)
                    {
                        if (GetTableStatus(dbDS.Tables[0].Rows[i][0].ToString()) ==1) //正在使用中
                        {
                            MessageBox.Show("在当前 " + DateTime.Now.ToShortDateString() + " " + TimeBlock + " 预订到期的 " + dbDS.Tables[0].Rows[i][0] + " 号桌台正在使用,更新预订操作不能完成!");
                            return false;
                        }
                    }

                    for (int i = 0; i <= dbDS.Tables[0].Rows.Count - 1; i++)
                    {
                        tableno = dbDS.Tables[0].Rows[i][0].ToString();
                        //打开开台、单据录入窗口
                        AddForm addfrm = new AddForm();
                        addfrm.Text = "开台/新建单据";
                        addfrm.frmmode = 1;
                        addfrm.GetConsumeBillTypeList(); //开台新建单据只允许添加消费单据
                        addfrm.NumericUpDown1.Value = decimal.Parse(GetTableMaxPeopleNumber(tableno)); //返回桌台最大载客数
                        addfrm.ComboBox1.Text = addfrm.ComboBox1.Items[0].ToString();
                        addfrm.Label5.Text = "请为 " + tableno + " 号桌台开台并添加消费单据";

                        addfrm.ShowDialog();
                        if (addfrm.DialogResult == DialogResult.OK)
                        {
                            ExeOpenTable(tableno, System.Convert.ToInt32(addfrm.NumericUpDown1.Value), addfrm.TextBox2.Text);
                            //准备添加第一张单据
                            if (! SameBillinSale(addfrm.TextBox1.Text, addfrm.ComboBox1.Text))
                            {

                                AddSaleBill(serialno, tableno, addfrm.TextBox1.Text, GetBillTypeCode(addfrm.ComboBox1.Text), addfrm.TextBox2.Text);
                                AddBalanceTable(serialno, tableno, addfrm.NumericUpDown1.Value.ToString(), addfrm.TextBox2.Text);

                                //遍历所有当前预订到期的订单菜品,添加到当前单据及桌台中
                                selectCMD.CommandText = "select foodcode,price,quantity,oprandi,taste from view_appointfood where appointno='" + appointno + "'";
                                SqlDataAdapter dbDA1 = new SqlDataAdapter();
                                dbDA1.SelectCommand = selectCMD;
                                DataSet dbDS1 = new DataSet();
                                dbDA1.Fill(dbDS1, "t");

                                for (int j = 0; j <= dbDS1.Tables[0].Rows.Count - 1; j++)
                                {
                                    AddFoodtoBill(serialno, GenUniqueCode(), addfrm.TextBox1.Text, GetBillTypeCode(addfrm.ComboBox1.Text), dbDS1.Tables[0].Rows[j][0].ToString(), dbDS1.Tables[0].Rows[j][1].ToString(), System.Convert.ToDouble(dbDS1.Tables[0].Rows[j][2]), 0, dbDS1.Tables[0].Rows[j][3].ToString(), dbDS1.Tables[0].Rows[j][4].ToString(), opinfo.OpID, "", 0);
                                }

                            }
                            else
                            {
                                MessageBox.Show("已经存在同类型的单据了");
                            }
                        }
                        else
                        {
                            return false;
                        }
                        addfrm.Dispose();
                    }

                    selectCMD.CommandText = "update appointbill set status='1' where appointno='" + appointno + "'";
                    selectCMD.ExecuteNonQuery();

                    MessageBox.Show("预订转开台操作顺利完成!");
                    return true;

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    return false;
                }
                finally
                {
                    conn.Close();
                }
            }
            return false;
        }