Example #1
0
        //点击台位按钮
        private void btn_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;
            btn.Enabled = false;
            btn.Enabled = true;

            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            //m_Seat = db_new.Seat.FirstOrDefault(x => x.text == btn.Text);
            m_Seat = dao.get_seat("text", btn.Text);

            SeatStatus status = m_Seat.status;
            switch (status)
            {
                case SeatStatus.AVILABLE://可用
                case SeatStatus.PAIED://已经结账
                    BathClass.printErrorMsg("手牌未开牌");
                    break;
                case SeatStatus.USING://正在使用
                case SeatStatus.DEPOSITLEFT://押金离场
                    if (!dao.get_authority(LogIn.m_User, "完整点单") &&
                        !dao.get_authority(LogIn.m_User, "可见本人点单"))
                    {
                        BathClass.printErrorMsg("权限不够!");
                        break;
                    }

                    if (MConvert<bool>.ToTypeOrDefault(m_Seat.paying, false))
                    {
                        BathClass.printErrorMsg("正在结账!");
                        break;
                    }
                    //if (BathClass.ToBool(m_Seat.ordering))
                    //{
                    //    BathClass.printErrorMsg("正在录单!");
                    //    break;
                    //}

                    //m_Seat.ordering = true;
                    //db_new.SubmitChanges();

                    OrderForm orderForm = new OrderForm(m_Seat, LogIn.m_User, LogIn.connectionString, false);
                    orderForm.ShowDialog();

                    //m_Seat.ordering = false;
                    //db_new.SubmitChanges();

                    break;
                case SeatStatus.LOCKING://锁定
                    BathClass.printErrorMsg("手牌已经锁定!");
                    break;
                case SeatStatus.STOPPED://停用
                    BathClass.printErrorMsg("台位已经停用!");
                    break;
                case SeatStatus.WARNING://警告
                    OrderCheckForm orderCheckForm = new OrderCheckForm(m_Seat, LogIn.connectionString, LogIn.options);
                    orderCheckForm.ShowDialog();
                    break;
                case SeatStatus.REPAIED:
                    BathClass.printErrorMsg("补救台位不能录单");
                    break;
                default:
                    break;
            }
        }
        //监控台位数据库改变
        /*private void watchSeat()
        {
            if (m_connection == null)
                m_connection = new SqlConnection(LogIn.connectionString);

            if (m_connection.State != ConnectionState.Open)
                m_connection.Open();

            SqlCommand cmd = m_connection.CreateCommand();
            cmd.Notification = null;//清除
            cmd.CommandText = "select id, oId, text, typeId, systemId, openTime, openEmployee, payTime, payEmployee, chainId, status From dbo.Seat";

            //监控台位数据库
            SqlDependency dependency = new SqlDependency(cmd);
            dependency.OnChange += new OnChangeEventHandler(seat_OnChange);

            //SqlDependency绑定的SqlCommand对象必须要执行一下,才能将SqlDependency对象的HasChange属性设为true
            SqlDataAdapter thisAdapter = new SqlDataAdapter(cmd);
            DataSet posDataSet = new DataSet();
            thisAdapter.Fill(posDataSet, "Seat");

            //刷新台位信息
            if (this.WindowState != FormWindowState.Minimized)
                update_seats();
            //刷新状态栏
            setStatus();
        }

        private delegate void watchSeatDelegate();

        //监控台位数据库改变
        private void seat_OnChange(object sender, SqlNotificationEventArgs e)
        {
            //因为是子线程,需要用invoke方法更新ui
            if (this.InvokeRequired)
            {
                this.Invoke(new watchSeatDelegate(watchSeat), null);
            }
            else
            {
                watchSeat();
            }

            SqlDependency dependency = (SqlDependency)sender;
            //通知之后,当前dependency失效,需要重新设置通知
            dependency.OnChange -= seat_OnChange;
        }*/
        //点击台位按钮
        private void btn_Click(object sender, EventArgs e)
        {
            var db_new = new BathDBDataContext(LogIn.connectionString);
            Button btn = sender as Button;
            btn.Enabled = false;
            btn.Enabled = true;

            var seat = db_new.Seat.FirstOrDefault(x => x.text == btn.Text);
            switch (seat.status)
            {
                case 2://正在使用
                case 6://警告
                case 7://押金离场
                case 8://重新结账
                    var dao = new DAO(LogIn.connectionString);
                    var s = dao.get_seat("text='" + seat.text + "'");
                    OrderCheckForm orderForm = new OrderCheckForm(s, LogIn.connectionString, LogIn.options);
                    orderForm.ShowDialog();
                    break;
                default:
                    break;
            }
        }
Example #3
0
        //F6开牌
        private void tool_open_seat()
        {
            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            string text = tSeat.Text;
            m_Seat = dao.get_seat("text='" + text + "' or oId='" + text + "'");
            //m_Seat = db_new.Seat.FirstOrDefault(x => x.text == text || x.oId == text);
            if (m_Seat == null)
            {
                BathClass.printErrorMsg("手牌不可用!");
                return;
            }

            switch (m_Seat.status)
            {
                case SeatStatus.AVILABLE://可用
                case SeatStatus.PAIED://已经结账
                    BathClass.printErrorMsg("手牌未开牌");
                    break;
                case SeatStatus.USING://正在使用
                case SeatStatus.DEPOSITLEFT://押金离场
                    if (!dao.get_authority(LogIn.m_User, "完整点单") &&
                        !dao.get_authority(LogIn.m_User, "可见本人点单"))
                    {
                        BathClass.printErrorMsg("权限不够!");
                        break;
                    }
                    if (MConvert<bool>.ToTypeOrDefault(m_Seat.paying, false))
                    {
                        BathClass.printErrorMsg("正在结账!");
                        break;
                    }
                    //if (BathClass.ToBool(m_Seat.ordering))
                    //{
                    //    BathClass.printErrorMsg("正在录单!");
                    //    break;
                    //}

                    //m_Seat.ordering = true;
                    //db_new.SubmitChanges();

                    OrderForm orderForm = new OrderForm(m_Seat, LogIn.m_User, LogIn.connectionString, false);
                    orderForm.ShowDialog();

                    //m_Seat.ordering = false;
                    //db_new.SubmitChanges();
                    break;
                case SeatStatus.LOCKING://锁定
                    BathClass.printErrorMsg("手牌已经锁定!");
                    break;
                case SeatStatus.STOPPED://停用
                    BathClass.printErrorMsg("手牌已经停用!");
                    break;
                case SeatStatus.WARNING://警告
                    OrderCheckForm orderCheckForm = new OrderCheckForm(m_Seat, LogIn.connectionString,LogIn.options);
                    orderCheckForm.ShowDialog();
                    break;
                case SeatStatus.REPAIED:
                    BathClass.printErrorMsg("补救台位不能录单");
                    break;
                default:
                    break;
            }

            tSeat.Text = "";
        }
        private void tool_open_seat()
        {
            var db_new = new BathDBDataContext(LogIn.connectionString);
            string text = tSeat.Text;
            m_Seat = db_new.Seat.FirstOrDefault(x => x.text == text);
            if (m_Seat == null || (m_Seat.status != 2 && m_Seat.status != 6 && m_Seat.status != 7 && m_Seat.status != 8))
            {
                GeneralClass.printErrorMsg("手牌不存在或者不在使用中,不可查看消费!");
                return;
            }

            var dao = new DAO(LogIn.connectionString);
            var s = dao.get_seat("text", m_Seat.text);
            OrderCheckForm orderCheckForm = new OrderCheckForm(s, LogIn.connectionString, LogIn.options);
            orderCheckForm.ShowDialog();
            tSeat.Text = "";
        }