Exemple #1
0
        //退单
        private void btnReturn_Click(object sender, EventArgs e)
        {
            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("需要输入订单!");
                return;
            }

            string orderId = dgvExpense.CurrentRow.Cells[0].Value.ToString();

            //var order = db.Orders.FirstOrDefault(x => x.id == orderId);
            if (dgvExpense.CurrentRow.Cells[3].Value.ToString().Contains("套餐优惠"))
            {
                BathClass.printErrorMsg("输入订单编号错误!");
                return;
            }
            if (!m_Orders.Contains(orderId))
            {
                if (BathClass.printAskMsg("没入数据库,直接删除?") == DialogResult.Yes)
                {
                    string cmd_str = "delete from [Orders] where id=" + orderId;
                    if (!dao.execute_command(cmd_str))
                    {
                        BathClass.printErrorMsg("退单失败,请重试!");
                        return;
                    }
                    //db.Orders.DeleteOnSubmit(order);
                    //db.SubmitChanges();

                    BathClass.find_combo(m_con_str, m_Seat.systemId, m_Seat.text);
                    //BathClass.find_combo(db, m_Seat, m_Orders);
                    //m_Orders.Remove(order);
                    dgvExpense_show();
                }
                return;
            }

            if (dao.get_authority(m_user, "退单"))
            {
                return_order(orderId, m_user);
                return;
            }

            InputEmployeeByPwd inputServerForm = new InputEmployeeByPwd(m_con_str);

            if (inputServerForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (!dao.get_authority(inputServerForm.employee, "退单"))
            {
                BathClass.printErrorMsg("权限不够");
                return;
            }

            return_order(orderId, inputServerForm.employee);
        }
        //扫微信赠送商品
        private void ToolWX_Click(object sender, EventArgs e)
        {
            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("需要选择行!");
                return;
            }

            Employee donor_user = null;

            var db = new BathDBDataContext(LogIn.connectionString);
            if (BathClass.getAuthority(db, LogIn.m_User, "微信赠送"))
            {
                donor_user = LogIn.m_User;
            }
            else
            {
                var form = new InputEmployeeByPwd();
                if (form.ShowDialog() != DialogResult.OK) return;
                if (!BathClass.getAuthority(db, form.employee, "微信赠送"))
                {
                    BathClass.printErrorMsg("用户不具有微信赠送权限!");
                    return;
                }

                donor_user = form.employee;
            }

            var sql = new StringBuilder();
            int orderId = MConvert<int>.ToTypeOrDefault(dgvExpense.CurrentRow.Cells[0].Value, 0);
            var order = dao.get_order("id", orderId);
            if (order.money == 0 && !StringUtil.isEmpty(order.donorExplain) && order.donorExplain==Constants.WX_DONOR)
            {
                sql.Append("update [Orders] set donorEmployee=null, donorExplain=null,donorTime=null,");
                sql.Append("money=orders.number*(select price from menu where menu.name=orders.menu) where ");
                sql.Append(" id=").Append(orderId);
            }
            else
            {
                sql.Append("update [Orders] set donorEmployee='").Append(donor_user.name).Append("', ");
                sql.Append(" donorExplain='").Append(Constants.WX_DONOR).Append("',donorTime=getdate(),money=0 where ");
                sql.Append(" id=").Append(orderId);
            }

            if (!dao.execute_command(sql.ToString()))
            {
                BathClass.printErrorMsg("微信赠送失败,请重试!");
                return;
            }
            dgvExpense_show();
        }
        //团购优惠
        private void ToolGroupBuy_Click(object sender, EventArgs e)
        {
            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("未选择行!");
                return;
            }

            Employee donor_user = null;
            var db = new BathDBDataContext(LogIn.connectionString);
            if (BathClass.getAuthority(db, LogIn.m_User, Constants.GROUPBUY_DONOR))
            {
                donor_user = LogIn.m_User;
            }
            else
            {
                var form = new InputEmployeeByPwd();
                if (form.ShowDialog() != DialogResult.OK) return;
                if (!BathClass.getAuthority(db, form.employee, Constants.GROUPBUY_DONOR))
                {
                    BathClass.printErrorMsg("用户不具有团购打折权限!");
                    return;
                }

                donor_user = form.employee;
            }

            var promotion = dao.get_GroupBuyPromotion();
            if (promotion == null)
                return;

            Dictionary<string, string> offers = promotion.disAssemble();
            var order = dao.get_order("id", dgvExpense.CurrentRow.Cells[0].Value);
            var menu = dao.get_Menu("name", dgvExpense.CurrentRow.Cells[4].Value);
            if (!offers.Keys.Contains(menu.id.ToString()))
                return;

            var discount_info = offers[menu.id.ToString()].Split('#');
            string discount_type = discount_info[0];
            double discount_val = MConvert<double>.ToTypeOrDefault(discount_info[1], 0);
            StringBuilder sb = new StringBuilder();

            if (discount_type == "折扣")
            {
                order.money = Math.Round(order.money * discount_val, 0);
            }
            else if (discount_type == "折后价" && order.money != 0)
            {
                order.money = discount_val * order.number;
            }

            sb.Append(" update [Orders] set money=").Append(order.money).Append(", donorExplain='").Append(Constants.GROUPBUY_DONOR);
            sb.Append("',donorTime=getdate(),donorEmployee='").Append(donor_user.name);
            sb.Append("' where id=").Append(order.id);
            if (!dao.execute_command(sb.ToString()))
            {
                BathClass.printErrorMsg("团购打折失败!");
            }
            dgvExpense_show();
        }
Exemple #4
0
        //重新结账
        private void CtxRepay_Click(object sender, EventArgs e)
        {
            //TableCashierCheckForm tableCashierSummaryForm = new TableCashierCheckForm();
            //tableCashierSummaryForm.ShowDialog();

            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "重新结账"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }

            //if (seat.status != SeatStatus.PAIED && seat.status != SeatStatus.AVILABLE)
            //{
            //    BathClass.printErrorMsg("手牌正在使用,不能重新结账");
            //    return;
            //}

            RepayActListForm form = new RepayActListForm(seat, inputEmployee.employee);
            form.ShowDialog();

            /*var act = db_new.Account.FirstOrDefault(x => x.systemId.Contains(seat.systemId) && x.abandon == null);
            if (act == null)
            {
                if (BathClass.printAskMsg("手牌未结账,是否直接恢复手牌?") != DialogResult.Yes)
                    return;

                seat.status = 2;
                db_new.SubmitChanges();
                return;
            }
            var ids = act.systemId.Split('|');
            var seats = db_new.Seat.Where(x => ids.Contains(x.systemId));
            foreach (var s in seats)
            {
                if (s.status == 2 || s.status == 6 || s.status == 7)
                {
                    BathClass.printErrorMsg("已经重新开牌,请先更换手牌");
                    return;
                }
                s.status = 2;
                var orders = db_new.HisOrders.Where(x => x.systemId == s.systemId);
                foreach (var order in orders)
                {
                    var ho = new Orders();
                    ho.menu = order.menu;
                    ho.text = order.text;
                    ho.systemId = order.systemId;
                    ho.number = order.number;
                    ho.priceType = order.priceType;
                    ho.money = order.money;
                    ho.technician = order.technician;
                    ho.techType = order.techType;
                    ho.inputTime = order.inputTime;
                    ho.inputEmployee = order.inputEmployee;
                    ho.deleteEmployee = order.deleteEmployee;
                    ho.donorEmployee = order.donorEmployee;
                    ho.comboId = order.comboId;
                    ho.paid = false;
                    ho.accountId = order.accountId;
                    ho.billId = order.billId;
                    db_new.HisOrders.DeleteOnSubmit(order);
                    db_new.Orders.InsertOnSubmit(ho);
                }
            }
            act.abandon = inputEmployee.employee.id;
            var cc = db_new.CardCharge.Where(x => act.id.ToString() == x.CC_AccountNo);
            if (cc.Any())
                db_new.CardCharge.DeleteAllOnSubmit(cc);
            db_new.SubmitChanges();*/
        }
Exemple #5
0
        //更换手牌
        private void CtxChangeSeat_Click(object sender, EventArgs e)
        {
            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "更换手牌"))
            {
                BathClass.printErrorMsg(inputEmployee.employee.id + "不具有更换手牌操作权限!");
                return;
            }

            if (seat.status != SeatStatus.USING)
            {
                BathClass.printErrorMsg("该手牌目前不在使用中,不能换台!");
                return;
            }

            List<int> sLst = new List<int>();
            sLst.Add(1);
            sLst.Add(3);
            InputSeatForm inputSeatForm = new InputSeatForm(sLst);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;

            StringBuilder sb = new StringBuilder();
            sb.Append(@"update [Orders] set text='" + inputSeatForm.m_Seat.text + "' where systemId='" + seat.systemId + "' ");
            //Seat newSeat = db_new.Seat.FirstOrDefault(x => x == inputSeatForm.m_Seat);
            //var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
            //foreach (Orders order in orders)
                //order.text = newSeat.text;

            sb.Append(@"update [Seat] set systemId='" + seat.systemId + "',name='" + seat.name + "',population=" + seat.population);
            sb.Append(",openTime=getdate(),openEmployee='" + LogIn.m_User.id + "',chainId='" + seat.chainId + "',status=" + seat.status);
            sb.Append(",note='" + seat.note + "',ordering='False'");
            //newSeat.systemId = seat.systemId;
            //newSeat.name = seat.name;
            //newSeat.population = seat.population;
            //newSeat.openTime = BathClass.Now(LogIn.connectionString);
            //newSeat.openEmployee = LogIn.m_User.name;
            //newSeat.phone = seat.phone;
            //newSeat.chainId = seat.chainId;
            //newSeat.status = seat.status;
            //newSeat.note = seat.note;
            //newSeat.ordering = seat.ordering;

            sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')");
            if (!dao.execute_command(sb.ToString()))
            {
                BathClass.printErrorMsg("更换手牌失败,请重试!");
                return;
            }

            //BathClass.reset_seat(seat);
            //db_new.SubmitChanges();
        }
Exemple #6
0
        //右键解除警告
        private void unWarnTool_Click(object sender, EventArgs e)
        {
            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(sender);
            if (seat.status != SeatStatus.WARNING)
                return;

            Employee op_user;
            if (dao.get_authority(LogIn.m_User, "解除警告"))
                op_user = LogIn.m_User;
            else
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;
                if (dao.get_authority(inputEmployee.employee, "解除警告"))
                    op_user = inputEmployee.employee;
                else
                {
                    BathClass.printErrorMsg("不具有权限!");
                    return;
                }
            }

            string cmd_str = @"update [Seat] set status=2, unWarn='" + op_user.id + "' where text='" + seat.text + "'";
            if (!dao.execute_command(cmd_str))
            {
                BathClass.printErrorMsg("解除警告失败,请重试!");
                return;
            }
            //seat.status = 2;
            //seat.unwarn = op_user.id;
            //db_new.SubmitChanges();
        }
        //手工打折
        private void discountTool_Click(object sender, EventArgs e)
        {
            var dc = new BathDBDataContext(LogIn.connectionString);
            Employee oper = null;
            if (BathClass.getAuthority(dc, LogIn.m_User, "手工打折"))
                oper = LogIn.m_User;

            if (oper == null)
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;

                if (BathClass.getAuthority(dc, inputEmployee.employee, "手工打折"))
                    oper = inputEmployee.employee;
                else
                {
                    BathClass.printErrorMsg("没有手工打折权限");
                    return;
                }
            }
            if (oper == null)
                return;

            InputNumber inputNumberForm = new InputNumber("输入折扣率(<10)");
            if (inputNumberForm.ShowDialog() != DialogResult.OK)
                return;

            double number = inputNumberForm.number;
            double discountRate = 0;
            if (number < 1)
                discountRate = number;
            else
                discountRate = number / 10.0;
            var os = dc.Orders.Where(x => m_Seats.Select(y => y.systemId).Contains(x.systemId) && x.deleteEmployee == null);
            foreach (Orders o in os)
                o.money = Math.Round(o.money * discountRate);

            foreach (HotelRoom seat in m_Seats)
            {
                seat.discount = inputNumberForm.number;
                seat.discountEmployee = oper.id;
            }

            Operation op = new Operation();
            op.employee = oper.name;
            op.seat = string.Join("|", m_Seats.Select(y => y.text).ToArray());
            op.openEmployee = string.Join("|", m_Seats.Select(y => y.openEmployee).ToArray());
            //op.openTime = seat.openTime;
            op.explain = "手工打折";
            op.note1 = number.ToString();
            op.note2 = string.Join("|", m_Seats.Select(y => y.systemId).ToArray());
            op.opTime = BathClass.Now(LogIn.connectionString);
            dc.Operation.InsertOnSubmit(op);

            dc.SubmitChanges();
            dgvExpense_show(dc);
            setStatus(dc);
        }
        //扣卡
        private void toolDeduct_Click(object sender, EventArgs e)
        {
            //if (m_thread != null && m_thread.IsAlive)
            //    m_thread.Abort();

            var dc = new BathDBDataContext(LogIn.connectionString);
            DeductedCardForm form = new DeductedCardForm();
            if (BathClass.getAuthority(dc, LogIn.m_User, "扣卡"))
                form.ShowDialog();
            else
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;

                if (!BathClass.getAuthority(dc, inputEmployee.employee, "扣卡"))
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有扣卡权限!");
                    return;
                }
                form.ShowDialog();
            }
        }
Exemple #9
0
        //取消开牌
        private void CtxCancelOpen_Click(object sender, EventArgs e)
        {
            var seat = getContextSenderSeat(sender);
            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

            if (dao.get_authority(LogIn.m_User, "取消开牌") ||
                (inputEmployee.ShowDialog() == DialogResult.OK &&
                dao.get_authority(inputEmployee.employee, "取消开牌")))
            {
                if (seat.status != SeatStatus.USING)
                {
                    BathClass.printErrorMsg("该台位不在使用中,不能取消开台!");
                    return;
                }

                var cancel_open_delay = LogIn.options.取消开牌时限;
                if (cancel_open_delay != null && (dao.Now() - seat.openTime.Value).TotalMinutes >= Convert.ToDouble(cancel_open_delay))
                {
                    BathClass.printErrorMsg("已超过取消开牌时限!");
                    return;
                }

                var orders = dao.get_orders("systemId='" + seat.systemId + "'");
                if (orders.Count > 2)
                {
                    BathClass.printErrorMsg("已经点单,不能取消开台");
                    return;
                }

                if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                    return;

                string user_id;
                if (inputEmployee.employee != null)
                    user_id = inputEmployee.employee.id;
                else
                    user_id = LogIn.m_User.id;

                string cmd_str = @"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('"
                    + user_id + "','" + seat.text + "','" + seat.openEmployee + "','" + seat.openTime.ToString()
                    + "','取消开牌',getdate())";

                cmd_str += @" delete from [Orders] where systemId='" + seat.systemId + "'";
                cmd_str += dao.reset_seat_string() + "text='" + seat.text + "')";
                if (!dao.execute_command(cmd_str))
                {
                    BathClass.printErrorMsg("取消开牌失败!");
                    return;
                }
            }
            else
            {
                BathClass.printErrorMsg("不具有取消开牌权限!");
            }
        }
Exemple #10
0
        //换房
        private void ToolChangeRoom_Click(object sender, EventArgs e)
        {
            var seat = read_seat_by_card();
            if (seat == null)
            {
                BathClass.printErrorMsg("房间未定义或者读取卡片数据失败!");
                return;
            }

            Employee oper = null;
            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

            if (dao.get_authority(LogIn.m_User, "更换手牌"))
            {
                oper = LogIn.m_User;
            }
            else if (inputEmployee.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            else
            {
                if (dao.get_authority(inputEmployee.employee, "更换手牌"))
                {
                    oper = inputEmployee.employee;
                }
                else
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有更换手牌操作权限!");
                    return;
                }
            }

            if (seat.status != SeatStatus.USING)
            {
                BathClass.printErrorMsg("该房间目前不在使用中,不能换房!");
                return;
            }

            var form = new ChangeRoomForm(seat, oper.id);
            form.ShowDialog();
        }
        //扣卡
        private void btnDeduct_Click(object sender, EventArgs e)
        {
            if (BathClass.getAuthority(db, LogIn.m_User, "扣卡"))
                id.ReadOnly = false;
            else
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;

                if (!BathClass.getAuthority(db, inputEmployee.employee, "扣卡"))
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有扣卡权限!");
                    return;
                }
                id.ReadOnly = false;
            }
        }
Exemple #12
0
        //非自动感应手牌开牌
        private void open_seat_by_card()
        {
            try
            {
                if (!seatLock)
                {
                    BathClass.printErrorMsg("未启用手牌锁");
                    return;
                }

                if (lock_type == "欧亿达")
                {
                    Thread.Sleep(500);
                    if (OYD.FKOPEN() != 1)
                        return;

                    OYD.CH375SetTimeout(0, 5000, 5000);
                }

                byte[] buff = new byte[200];
                string seat_text = "";
                CSeat seat = null;

                int rt = -1;
                if (lock_type == "欧亿达")
                {
                    Thread.Sleep(500);
                    rt = OYD.OYEDA_id(buff);
                }
                else if (lock_type == "锦衣卫")
                    rt = JYW.ReadID(buff);
                else if (lock_type == "RF")
                    rt = RF.RF_RFID(ref seat_text);

                if (rt != 0)
                    return;

                if (lock_type == "欧亿达")
                {
                    seat_text = Encoding.Default.GetString(buff, 0, 20).Trim();
                    seat_text = seat_text.Substring(0, 16);
                }
                else if (lock_type == "锦衣卫")
                {
                    seat_text = BathClass.byteToHexStr(buff);
                    seat_text = seat_text.Substring(0, 16);
                }

                seat = dao.get_seat("text", seat_text);
                if (seat == null)
                {
                    BathClass.printErrorMsg("手牌" + seat_text + "不存在");
                    return;
                }

                if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED)
                {
                    if (lock_type == "欧亿达")
                        Thread.Sleep(500);

                    if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) ||
                        (lock_type == "锦衣卫" && JYW.FK(buff) != 0) ||
                        (lock_type == "RF" && RF.RF_FK(seat_text) != 0))
                        return;

                    open_one_seat(seat);
                    open_seat(seat);
                }
                else if (seat.status == SeatStatus.USING)
                {
                    InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

                    if (dao.get_authority(LogIn.m_User, "取消开牌") ||
                        (inputEmployee.ShowDialog() != DialogResult.OK &&
                        dao.get_authority(inputEmployee.employee, "取消开牌")))
                    {

                        var q = LogIn.options.取消开牌时限;
                        if (q != null && (DateTime.Now - seat.openTime.Value).TotalMinutes >= Convert.ToDouble(q))
                        {
                            BathClass.printErrorMsg("已超过取消开牌时限");
                            return;
                        }
                        var orders = dao.get_orders("systemId='" + seat.systemId + "'");
                        if (orders.Count() >= 2)
                        {
                            BathClass.printErrorMsg("已经点单,不能取消开台");
                            return;
                        }

                        if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                            return;

                        if (lock_type == "欧亿达")
                            Thread.Sleep(500);

                        if ((lock_type == "欧亿达" && OYD.OYEDA_md(buff) != 0) ||
                        (lock_type == "锦衣卫" && JYW.MD(buff) != 0) ||
                            (lock_type == "RF" && RF.RF_MD() != 0))
                            return;

                        string cmd_str = @"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('"
                            + inputEmployee.employee.id + "','" + seat.text + "','"
                            + seat.openEmployee + "','" + seat.openTime.ToString()
                            + "','取消开牌',getdate()";

                        cmd_str += @" delete from [Orders] where systemId='" + seat.systemId + "'";
                        cmd_str += dao.reset_seat_string() + "text='" + seat.text + "')";
                        if (!dao.execute_command(cmd_str))
                        {
                            BathClass.printErrorMsg("取消开牌失败!");
                            return;
                        }
                    }
                    else
                    {
                        BathClass.printErrorMsg("不具有取消开牌权限");
                    }
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemple #13
0
        //更换手牌
        private void CtxChangeSeat_Click(object sender, EventArgs e)
        {
            var seat = getContextSenderSeat(sender);

            Employee oper = null;
            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

            if (dao.get_authority(LogIn.m_User, "更换手牌"))
            {
                oper = LogIn.m_User;
            }
            else if (inputEmployee.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            else
            {
                if (dao.get_authority(inputEmployee.employee, "更换手牌"))
                {
                    oper = inputEmployee.employee;
                }
                else
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有更换手牌操作权限!");
                    return;
                }
            }

            if (seat.status != SeatStatus.USING)
            {
                BathClass.printErrorMsg("该手牌目前不在使用中,不能换台!");
                return;
            }

            List<int> sLst = new List<int>();
            sLst.Add(1);
            sLst.Add(3);
            InputSeatForm inputSeatForm = new InputSeatForm(sLst);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;

            StringBuilder sb = new StringBuilder();
            sb.Append(@"update [Orders] set text='" + inputSeatForm.m_Seat.text + "' where systemId='" + seat.systemId + "' ");
            sb.Append(@"update [Seat] set systemId='" + seat.systemId + "'");
            sb.Append(",openTime=getdate(),openEmployee='" + oper.id + "',chainId='" + seat.chainId);
            sb.Append("',status=" + (int)seat.status + ",ordering='False'");
            if (seat.name != null && seat.name != "")
                sb.Append(",name='" + seat.name + "'");

            if (seat.population != null)
                sb.Append(",population=" + seat.population);

            if (seat.note != null && seat.name != "")
                sb.Append(",note='" + seat.note + "'");

            sb.Append(" where id=" + inputSeatForm.m_Seat.id);
            sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')");
            if (!dao.execute_command(sb.ToString()))
            {
                BathClass.printErrorMsg("更换手牌失败,请重试!");
                return;
            }
        }
Exemple #14
0
        //手牌线程
        private void seat_card_thread()
        {
            while (true)
            {
                try
                {
                    if (lock_type == "欧亿达")
                    {
                        Thread.Sleep(500);
                        if (OYD.FKOPEN() != 1)
                            continue;

                        OYD.CH375SetTimeout(0, 5000, 5000);
                    }

                    byte[] buff = new byte[200];
                    string seat_text = "";
                    CSeat seat = null;

                    int rt = -1;
                    if (lock_type == "欧亿达")
                    {
                        Thread.Sleep(500);
                        rt = OYD.OYEDA_id(buff);
                    }
                    else if (lock_type == "锦衣卫")
                        rt = JYW.ReadID(buff);
                    else if (lock_type == "RF")
                        rt = RF.RF_RFID(ref seat_text);

                    if (rt != 0)
                        continue;

                    if (lock_type == "欧亿达")
                    {
                        seat_text = Encoding.Default.GetString(buff, 0, 20).Trim();
                        seat_text = seat_text.Substring(0, 16);
                    }
                    else if (lock_type == "锦衣卫")
                    {
                        seat_text = BathClass.byteToHexStr(buff);
                        seat_text = seat_text.Substring(0, 16);
                    }

                    seat = dao.get_seat("oId", seat_text);
                    if (seat == null)
                    {
                        if (this.InvokeRequired)
                            this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                new object[] { "手牌" + seat_text + "不存在" });
                        else
                            BathClass.printErrorMsg("手牌" + seat_text + "不存在");
                        continue;
                    }

                    if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED)
                    {
                        if (lock_type == "欧亿达")
                            Thread.Sleep(500);

                        if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) ||
                            (lock_type == "锦衣卫" && JYW.FK(buff) != 0) ||
                            (lock_type == "RF" && RF.RF_FK(seat_text) != 0))
                            continue;

                        open_one_seat(seat);

                        if (this.InvokeRequired)
                            this.Invoke(new delegate_open_seat(open_seat), new object[] { seat });
                        else
                            open_seat(seat);
                        //Thread.Sleep(500);
                    }
                    else if (seat.status == SeatStatus.USING)
                    {
                        InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

                        if (dao.get_authority(LogIn.m_User, "取消开牌") ||
                            (inputEmployee.ShowDialog() != DialogResult.OK &&
                            dao.get_authority(inputEmployee.employee, "取消开牌")))
                        {

                            if (cancel_open_delay != null &&
                                (DateTime.Now - seat.openTime.Value).TotalMinutes >= MConvert<double>.ToTypeOrDefault(cancel_open_delay, 0))
                            {
                                if (this.InvokeRequired)
                                    this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                        new object[] { "已超过取消开牌时限" });
                                else
                                    BathClass.printErrorMsg("已超过取消开牌时限");
                                continue;
                            }

                            var order_count = dao.get_orders_count("systemId='" + seat.systemId + "'");
                            //var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
                            if (order_count >= 2)
                            {
                                if (this.InvokeRequired)
                                    this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                        new object[] { "已经点单,不能取消开台" });
                                else
                                    BathClass.printErrorMsg("已经点单,不能取消开台");
                                continue;
                            }

                            if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                                continue;

                            if (lock_type == "欧亿达")
                                Thread.Sleep(500);

                            if ((lock_type == "欧亿达" && OYD.OYEDA_md(buff) != 0) ||
                            (lock_type == "锦衣卫" && JYW.MD(buff) != 0) ||
                                (lock_type == "RF" && RF.RF_MD() != 0))
                                continue;

                            string cancel_open_id;
                            if (inputEmployee.employee != null)
                                cancel_open_id = inputEmployee.employee.id;
                            else
                                cancel_open_id = LogIn.m_User.id;

                            StringBuilder sb = new StringBuilder();
                            sb.Append(@"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('");
                            sb.Append(cancel_open_id + "','" + seat.text + "','");
                            sb.Append(seat.openEmployee + "','" + seat.openTime.ToString());
                            sb.Append("','取消开牌',getdate())");

                            sb.Append(@" delete from [Orders] where text='" + seat.text + "'");
                            sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')");
                            if (!dao.execute_command(sb.ToString()))
                            {
                                if (this.InvokeRequired)
                                    this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                        new object[] { "取消开牌失败" });
                                else
                                    BathClass.printErrorMsg("取消开牌失败");
                                continue;
                            }
                        }
                        else
                        {
                            if (this.InvokeRequired)
                                this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                    new object[] { "不具有取消开牌权限" });
                            else
                                BathClass.printErrorMsg("不具有取消开牌权限");
                        }
                    }
                    else
                    {
                        if (this.InvokeRequired)
                            this.Invoke(new delegate_print_msg(BathClass.printErrorMsg),
                                    new object[] { "手牌不可用" });
                        else
                            BathClass.printErrorMsg("手牌不可用");
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemple #15
0
        //更换手牌
        private void CtxChangeSeat_Click(object sender, EventArgs e)
        {
            var seat = getContextSenderSeat(sender);

            Employee oper = null;
            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

            if (dao.get_authority(LogIn.m_User, "更换手牌"))
            {
                oper = LogIn.m_User;
            }
            else if (inputEmployee.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            else
            {
                if (dao.get_authority(inputEmployee.employee, "更换手牌"))
                {
                    oper = inputEmployee.employee;
                }
                else
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有更换手牌操作权限!");
                    return;
                }
            }

            if (seat.status != SeatStatus.USING)
            {
                BathClass.printErrorMsg("该手牌目前不在使用中,不能换台!");
                return;
            }

            List<int> sLst = new List<int>();
            sLst.Add(1);
            sLst.Add(3);
            InputSeatForm inputSeatForm = new InputSeatForm(sLst);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;
        }
        private void unWarnTool_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            Seat seat = getContextSenderSeat(db_new, sender);
            if (seat.status != 6)
                return;

            Employee op_user;
            if (BathClass.getAuthority(db_new, LogIn.m_User, "解除警告"))
                op_user = LogIn.m_User;
            else
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;
                if (BathClass.getAuthority(db_new, inputEmployee.employee, "解除警告"))
                    op_user = inputEmployee.employee;
                else
                {
                    BathClass.printErrorMsg("不具有权限!");
                    return;
                }
            }

            seat.status = 2;
            seat.unwarn = op_user.id;
            db_new.SubmitChanges();
        }
Exemple #17
0
        //重新结账
        private void CtxRepay_Click(object sender, EventArgs e)
        {
            var seat = getContextSenderSeat(sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "重新结账"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }

            //if (seat.status != SeatStatus.PAIED && seat.status != SeatStatus.AVILABLE)
            //{
            //    BathClass.printErrorMsg("手牌正在使用,不能重新结账");
            //    return;
            //}

            RepayActListForm form = new RepayActListForm(seat, inputEmployee.employee);
            form.ShowDialog();
        }
Exemple #18
0
        //查询服务
        private void btnCheck_Click(object sender, EventArgs e)
        {
            Employee user;
            if (user_card)
            {
                var form = new InputEmployeeByCard(connectionString);
                if (form.ShowDialog() != DialogResult.OK)
                    return;
                user = form.employee;
            }
            else
            {
                var form = new InputEmployeeByPwd(connectionString);
                if (form.ShowDialog() != DialogResult.OK)
                    return;

                user = form.employee;
            }

            CheckForm checkForm = new CheckForm(user);
            checkForm.ShowDialog();
            techId.Focus();
        }
Exemple #19
0
        //取消开房
        private void ToolCancelOpen_Click(object sender, EventArgs e)
        {
            var seat = read_seat_by_card();
            if (seat == null)
            {
                BathClass.printErrorMsg("房间未定义或者读取卡片数据失败!");
                return;
            }

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

            if (dao.get_authority(LogIn.m_User, "取消开牌") ||
                (inputEmployee.ShowDialog() == DialogResult.OK &&
                dao.get_authority(inputEmployee.employee, "取消开牌")))
            {
                if (seat.status != SeatStatus.USING)
                {
                    BathClass.printErrorMsg("该台位不在使用中,不能取消开台!");
                    return;
                }

                var cancel_open_delay = LogIn.options.取消开牌时限;
                if (cancel_open_delay != null && (dao.Now() - seat.openTime.Value).TotalMinutes >= Convert.ToDouble(cancel_open_delay))
                {
                    BathClass.printErrorMsg("已超过取消开牌时限!");
                    return;
                }

                var orders = dao.get_orders("systemId='" + seat.systemId + "'");
                if (orders.Count > 2)
                {
                    BathClass.printErrorMsg("已经点单,不能取消开台");
                    return;
                }

                if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                    return;

                string user_id;
                if (inputEmployee.employee != null)
                    user_id = inputEmployee.employee.id;
                else
                    user_id = LogIn.m_User.id;

                string cmd_str = @"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('"
                    + user_id + "','" + seat.text + "','" + seat.openEmployee + "','" + seat.openTime.ToString()
                    + "','取消开牌',getdate())";

                cmd_str += @" delete from [Orders] where systemId='" + seat.systemId + "'";
                cmd_str += dao.reset_seat_string() + "text='" + seat.text + "')";
                if (!dao.execute_command(cmd_str))
                {
                    BathClass.printErrorMsg("取消开房失败!");
                    return;
                }

                byte[] buff = new byte[200];
                //int rt = RoomProRFL.initializeUSB(1);

                int hotelId = MConvert<int>.ToTypeOrDefault(IOUtil.get_config_by_key(ConfigKeys.KEY_HOTELID), -1);
                if (hotelId == -1)
                {
                    BathClass.printErrorMsg("未定义酒店标志!");
                    return;
                }

                int rt = RoomProRFL.CardErase(1, hotelId, buff);
                if (rt != 0)
                {
                    BathClass.printErrorMsg("退房失败!");
                    return;
                }
                RoomProRFL.Buzzer(1, 40);
            }
            else
            {
                BathClass.printErrorMsg("不具有取消开牌权限!");
            }
        }
        //留牌操作 F9
        //private void toolKeep_Click(object sender, EventArgs e)
        //{
        //    List<int> sLst = new List<int>();
        //    sLst.Add(2);
        //    sLst.Add(6);
        //    sLst.Add(7);
        //    InputSeatForm inputseatForm = new InputSeatForm(sLst);
        //    if (inputseatForm.ShowDialog() != DialogResult.OK)
        //        return;
        //    var seat = inputseatForm.m_Seat;
        //    if (m_Seats.FirstOrDefault(x=>x.text==seat.text) == null)
        //    {
        //        m_Seats.Add(seat);
        //        var dc_new = new BathDBDataContext(LogIn.connectionString);
        //        dc_new.HotelRoom.FirstOrDefault(x => x.text == inputseatForm.m_Seat.text).paying = false;
        //        dc_new.SubmitChanges();
        //    }
        //    dgvChain_show();
        //    dgvChain.CurrentCell = null;
        //    //chain = true;
        //    //dgvExpense_show();
        //    //setStatus();
        //}
        //联牌账务
        //private void btnChain_Click(object sender, EventArgs e)
        //{
        //    //chain = true;
        //    dgvChain.CurrentCell = null;
        //    dgvExpense_show();
        //    setStatus();
        //}
        //退单 F10
        private void toolReturn_Click(object sender, EventArgs e)
        {
            BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString);

            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("需要输入订单!");
                return;
            }

            int orderId = Convert.ToInt32(dgvExpense.CurrentRow.Cells[0].Value);
            var order = dc.Orders.FirstOrDefault(x => x.id == orderId);
            if (order == null || order.menu.Contains("套餐"))
            {
                BathClass.printErrorMsg("不能删除套餐优惠!");
                return;
            }

            InputEmployeeByPwd inputServerForm = new InputEmployeeByPwd();

            Employee del_employee;
            if (BathClass.getAuthority(dc, LogIn.m_User, "退单"))
                del_employee = LogIn.m_User;
            else if (inputServerForm.ShowDialog() != DialogResult.OK)
                return;
            else if (!BathClass.getAuthority(dc, inputServerForm.employee, "退单"))
            {
                BathClass.printErrorMsg("没有退单权限");
                return;
            }
            else
                del_employee = inputServerForm.employee;

            order.deleteEmployee = del_employee.id.ToString();

            Employee employee = dc.Employee.FirstOrDefault(x => x.id.ToString() == order.technician);
            if (employee != null)
                employee.status = "空闲";

            dc.SubmitChanges();

            find_combo(dc, order);
            dgvExpense_show(dc);
            setStatus(dc);
        }
        //退单 F10
        private void toolReturn_Click(object sender, EventArgs e)
        {
            BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString);

            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("需要输入订单!");
                return;
            }

            int orderId = Convert.ToInt32(dgvExpense.CurrentRow.Cells[0].Value);
            var order = dc.Orders.FirstOrDefault(x => x.id == orderId);
            if (order == null || order.menu.Contains("套餐"))
            {
                BathClass.printErrorMsg("不能删除套餐优惠!");
                return;
            }

            InputEmployeeByPwd inputServerForm = new InputEmployeeByPwd();
            if (inputServerForm.ShowDialog() != DialogResult.OK)
                return;
            order.deleteEmployee = inputServerForm.employee.id.ToString();

            Employee employee = dc.Employee.FirstOrDefault(x => x.id.ToString() == order.technician);
            if (employee != null)
                employee.status = "空闲";

            var menu = dc.Menu.FirstOrDefault(x => x.name == order.menu);
            if (dc.Catgory.FirstOrDefault(x=>x.id == menu.catgoryId).name == "会员卡")
            {
                var cardno = dc.CardCharge.FirstOrDefault(x => x.systemId == order.systemId).CC_CardNo;
                dc.CardCharge.DeleteAllOnSubmit(dc.CardCharge.Where(x => x.systemId == order.systemId));

                if (!order.menu.Contains("充值") && BathClass.printAskMsg("是否删除售卡记录?") == DialogResult.Yes)
                {
                    dc.CardInfo.DeleteOnSubmit(dc.CardInfo.FirstOrDefault(x => x.CI_CardNo == cardno));
                }
            }
            dc.SubmitChanges();

            Seat seat = dc.Seat.FirstOrDefault(x => x.systemId == order.systemId);
            //BathClass.find_combo(dc, seat, null);
            dgvExpense_show();
            setStatus();
        }
Exemple #22
0
        //取消开牌
        private void CtxCancelOpen_Click(object sender, EventArgs e)
        {
            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "取消开牌"))
            {
                BathClass.printErrorMsg(inputEmployee.employee.id + "不具有取消开台权限!");
                return;
            }

            if (seat.status != SeatStatus.USING)
            {
                BathClass.printErrorMsg("该台位不在使用中,不能取消开台!");
                return;
            }

            //var options = db_new.Options.FirstOrDefault();
            var q = LogIn.options.取消开牌时限;
            if (q != null && (dao.Now() - seat.openTime.Value).TotalMinutes >= Convert.ToInt32(q))
            {
                BathClass.printErrorMsg("已超过取消开牌时限!");
                return;
            }

            var orders = dao.get_orders("systemId='" + seat.systemId + "'");
            //var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
            if (orders.Count > 2)
            {
                BathClass.printErrorMsg("已经点单,不能取消开台");
                return;
            }

            if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                return;

            StringBuilder sb = new StringBuilder();
            sb.Append(@"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('");
            sb.Append(inputEmployee.employee.id + "','" + seat.text + "','" + seat.openEmployee + "','" + seat.openTime.ToString());
            sb.Append("','取消开牌',getdate()");
            //Operation op = new Operation();
            //op.employee = inputEmployee.employee.id;
            //op.seat = seat.text;
            //op.openEmployee = seat.openEmployee;
            //op.openTime = seat.openTime;
            //op.explain = "取消开牌";
            //op.opTime = BathClass.Now(LogIn.connectionString);
            //db_new.Operation.InsertOnSubmit(op);

            sb.Append(@" delete from [Orders] where systemId='" + seat.systemId + "'");
            sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')");
            //db_new.Orders.DeleteAllOnSubmit(db_new.Orders.Where(x => x.systemId == seat.systemId));
            //BathClass.reset_seat(seat);
            //db_new.SubmitChanges();
            if (!dao.execute_command(sb.ToString()))
            {
                BathClass.printErrorMsg("取消开牌失败!");
                return;
            }
        }
        //扣卡
        private void btnDeduct_Click(object sender, EventArgs e)
        {
            if (dao.get_authority(LogIn.m_User, "扣卡"))
            {
                id.Enabled = true;
                id.Focus();
            }
            else
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;

                if (!dao.get_authority(inputEmployee.employee, "扣卡"))
                {
                    BathClass.printErrorMsg(inputEmployee.employee.id + "不具有扣卡权限!");
                    return;
                }
                id.Enabled = true;
                id.Focus();
            }
        }
Exemple #24
0
        //锁定解锁
        private void CtxLock_Click(object sender, EventArgs e)
        {
            //BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(sender);

            if (dao.get_authority(LogIn.m_User, "锁定解锁"))
            {
                lock_unlock(seat, LogIn.m_User);
                return;
            }

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "锁定解锁"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }
            lock_unlock(seat, inputEmployee.employee);
        }
Exemple #25
0
        //取消开牌
        private void CtxCancelOpen_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(db_new, sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!BathClass.getAuthority(db_new, inputEmployee.employee, "取消开牌"))
            {
                BathClass.printErrorMsg(inputEmployee.employee.id + "不具有取消开台权限!");
                return;
            }

            if (seat.status != 2)
            {
                BathClass.printErrorMsg("该台位不在使用中,不能取消开台!");
                return;
            }

            var options = db_new.Options.FirstOrDefault();
            if (options != null)
            {
                var q = options.取消开牌时限;
                if (q != null && GeneralClass.Now-seat.openTime>=TimeSpan.Parse("00:"+q.ToString()+":00"))
                {
                    BathClass.printErrorMsg("已超过取消开牌时限!");
                    return;
                }
            }
            var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
            if (orders.Count() > 2)
            {
                BathClass.printErrorMsg("已经点单,不能取消开台");
                return;
            }

            if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                return;

            Operation op = new Operation();
            op.employee = inputEmployee.employee.id;
            op.seat = seat.text;
            op.openEmployee = seat.openEmployee;
            op.openTime = seat.openTime;
            op.explain = "取消开牌";
            op.opTime = BathClass.Now(LogIn.connectionString);
            db_new.Operation.InsertOnSubmit(op);

            db_new.Orders.DeleteAllOnSubmit(db_new.Orders.Where(x => x.systemId == seat.systemId));
            BathClass.reset_seat(seat);
            db_new.SubmitChanges();
        }
Exemple #26
0
        //停用启用
        private void CtxSop_Click(object sender, EventArgs e)
        {
            var seat = getContextSenderSeat(sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!dao.get_authority(inputEmployee.employee, "停用启用"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }

            if (seat.status == SeatStatus.USING || seat.status == SeatStatus.WARNING ||
                seat.status == SeatStatus.DEPOSITLEFT || seat.status == SeatStatus.RESERVE)
            {
                BathClass.printErrorMsg("手牌正在使用不能停用");
                return;
            }
            else if (seat.status == SeatStatus.LOCKING)
            {
                BathClass.printErrorMsg("手牌已经锁定,不能停用");
                return;
            }
            else if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED)
            {
                string cmd_str = @"update [Seat] set status=" + (int)SeatStatus.STOPPED + " where text='" + seat.text + "'";
                if (!dao.execute_command(cmd_str))
                {
                    BathClass.printErrorMsg("手牌停用失败!");
                    return;
                }
            }
            else if (seat.status == SeatStatus.STOPPED)
            {
                string cmd_str = @"update [Seat] set status=" + (int)SeatStatus.AVILABLE + " where text='" + seat.text + "'";
                if (!dao.execute_command(cmd_str))
                {
                    BathClass.printErrorMsg("手牌启用失败!");
                    return;
                }
            }

            //db_new.SubmitChanges();
        }
Exemple #27
0
        //更换手牌
        private void CtxChangeSeat_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(db_new, sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!BathClass.getAuthority(db_new, inputEmployee.employee, "更换手牌"))
            {
                BathClass.printErrorMsg(inputEmployee.employee.id + "不具有更换手牌操作权限!");
                return;
            }

            if (seat.status != 2)
            {
                BathClass.printErrorMsg("该手牌目前不在使用中,不能换台!");
                return;
            }

            List<int> sLst = new List<int>();
            sLst.Add(1);
            sLst.Add(3);
            var inputSeatForm = new InputRoomForm(sLst);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;

            HotelRoom newSeat = db_new.HotelRoom.FirstOrDefault(x => x == inputSeatForm.m_Seat);
            var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
            foreach (Orders order in orders)
                order.text = newSeat.text;

            newSeat.systemId = seat.systemId;
            newSeat.name = seat.name;
            newSeat.population = seat.population;
            newSeat.openTime = GeneralClass.Now;
            newSeat.openEmployee = LogIn.m_User.name;
            newSeat.phone = seat.phone;
            newSeat.chainId = seat.chainId;
            newSeat.status = seat.status;
            newSeat.note = seat.note;
            newSeat.ordering = seat.ordering;

            BathClass.reset_seat(seat);
            db_new.SubmitChanges();
        }
        //退单 F10
        private void toolReturn_Click(object sender, EventArgs e)
        {
            if (dgvExpense.CurrentCell == null)
            {
                BathClass.printErrorMsg("需要输入订单!");
                return;
            }

            int orderId = MConvert<int>.ToTypeOrDefault(dgvExpense.CurrentRow.Cells[0].Value, 0);
            var order = dao.get_order("id", orderId);
            m_Seat = m_Seats.FirstOrDefault(x => x.systemId == order.systemId);
            if (order == null || order.menu.Contains("套餐优惠"))
            {
                BathClass.printErrorMsg("不能删除套餐优惠!");
                return;
            }

            InputEmployeeByPwd inputServerForm = new InputEmployeeByPwd();
            Employee del_employee;

            if (dao.get_authority(LogIn.m_User, "退单"))
                del_employee = LogIn.m_User;
            else if (inputServerForm.ShowDialog() != DialogResult.OK)
                return;
            else if (!dao.get_authority(inputServerForm.employee, "退单"))
            {
                BathClass.printErrorMsg("没有退单权限");
                return;
            }
            else
                del_employee = inputServerForm.employee;

            var form = new DeleteExplainForm();
            if (form.ShowDialog() != DialogResult.OK)
                return;

            string deleteExpalin = form.txt;
            string cmd_str = @"update [Orders] set deleteEmployee='" + del_employee.id + "', deleteExplain='"
             + deleteExpalin + "', deleteTime=getdate() where id=" + order.id;

            if (!dao.execute_command(cmd_str))
            {
                BathClass.printErrorMsg("退单失败,请重试!");
                return;
            }

            BathClass.find_combo(LogIn.connectionString, m_Seat.systemId, m_Seat.text);
            dgvExpense_show();

            if (!dao.execute_command("update [OrderStockOut] set deleteEmployee='" + del_employee.id + "' where orderId=" + order.id.ToString()))
            {
                BathClass.printErrorMsg("退换消耗品失败!");
            }
        }
Exemple #29
0
        //停用启用
        private void CtxSop_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(db_new, sender);

            InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
            if (inputEmployee.ShowDialog() != DialogResult.OK)
                return;

            if (!BathClass.getAuthority(db_new, inputEmployee.employee, "停用启用"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }

            if (seat.status == 2 || seat.status == 6 || seat.status == 7 || seat.status == 8)
            {
                BathClass.printErrorMsg("手牌正在使用不能停用");
                return;
            }
            else if (seat.status == 4)
            {
                BathClass.printErrorMsg("手牌已经锁定,不能停用");
                return;
            }
            else if (seat.status == 1 || seat.status == 3)
            {
                seat.status = 5;
            }
            else if (seat.status == 5)
            {
                seat.status = 1;
            }

            db_new.SubmitChanges();
        }
        //手工打折
        private void discountTool_Click(object sender, EventArgs e)
        {
            //var dc = new BathDBDataContext(LogIn.connectionString);
            Employee oper = null;
            //if (BathClass.getAuthority(dc, LogIn.m_User, "手工打折"))
                //oper = LogIn.m_User;

            if ((dao.get_authority(LogIn.m_User, "手工打折")))
                oper = LogIn.m_User;

            if (oper == null)
            {
                InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();
                if (inputEmployee.ShowDialog() != DialogResult.OK)
                    return;

                //if (BathClass.getAuthority(dc, inputEmployee.employee, "手工打折"))
                //    oper = inputEmployee.employee;

                if ((dao.get_authority(inputEmployee.employee, "手工打折")))
                    oper = LogIn.m_User;
                else
                {
                    BathClass.printErrorMsg("没有手工打折权限");
                    return;
                }
            }
            if (oper == null)
                return;

            InputNumber inputNumberForm = new InputNumber("输入折扣率(<10)", false);
            if (inputNumberForm.ShowDialog() != DialogResult.OK)
                return;

            double number = inputNumberForm.number;
            double discountRate = 0;
            if (number < 1)
                discountRate = number;
            else
                discountRate = number / 10.0;

            //var os = dc.Orders.Where(x => m_Seats.Select(y => y.systemId).Contains(x.systemId) && x.deleteEmployee == null);
            //foreach (Orders o in os)
                //o.money = Math.Round(o.money * discountRate);

            //string cmd_str = @"if exists(select 1 from sysobjects where id=object_id('discount_money') and objectproperty(id,'IsInlineFunction')=0)"
            //                + @" drop function [dbo].[discount_money]"
            //                + @" go"
            //                + @" create function discount_money(@systemId nvarchar(MAX), @discount float)"
            //                + @" returns real"
            //                + @" as"
            //                + @" begin"
            //                + " declare @discount_money real"
            //                + @" declare @money real"
            //                + " select @money=money from [orders] where systemId=@systemId and deleteEmployee is null"
            //                + @" set @discount_money=@discount*@money"
            //                + @" Return (@discount_money)"
            //                + @" end"
            //                + @" go";

            string cmd_str = @"update [Orders] set money=round(money*" + discountRate.ToString() + ",0) " + " where ";
            string seat_cmd_str = " update table [Seat] set discount='" +
                inputNumberForm.number.ToString() +
                ", discountEmployee='" + oper.id + "' where ";
            int count = m_Seats.Count;
            string id_str = "";
            for (int i = 0; i < count; i++ )
            {
                id_str += @"systemId='" + m_Seats[i].systemId + "'";
                //seat_cmd_str += "text='" + m_Seats[i].text + "'";
                if (i != count - 1)
                    id_str += " or ";
            }
            cmd_str += id_str;
            cmd_str += @" update [Seat] set discount='" + inputNumberForm.number.ToString()
                      +@"', discountEmployee='" + oper.id + "' where ";
            cmd_str += id_str;

            cmd_str += " insert into [Operation](employee, seat, openEmployee, explain, note1, note2, opTime) values('" +
                oper.name + "','" + string.Join("|", m_Seats.Select(y => y.text).ToArray()) + "','" +
                string.Join("|", m_Seats.Select(y => y.openEmployee).ToArray()) + "','手工打折','" + number.ToString() + "','" +
                string.Join("|", m_Seats.Select(y => y.systemId).ToArray()) + "',getdate())";

            if (!dao.execute_command(cmd_str))
            {
                BathClass.printErrorMsg("手工打折失败,请重试!");
                //return;
            }
            dgvExpense_show();
            //Operation op = new Operation();
            //op.employee = oper.name;
            //op.seat = string.Join("|", m_Seats.Select(y => y.text).ToArray());
            //op.openEmployee = string.Join("|", m_Seats.Select(y => y.openEmployee).ToArray());
            ////op.openTime = seat.openTime;
            //op.explain = "手工打折";
            //op.note1 = number.ToString();
            //op.note2 = string.Join("|", m_Seats.Select(y => y.systemId).ToArray());
            //op.opTime = now;
            //dc.Operation.InsertOnSubmit(op);

            //dc.SubmitChanges();
        }
Exemple #31
0
        //非自动感应手牌
        private void open_seat_noauto()
        {
            try
            {
                if (!seatLock)
                {
                    BathClass.printErrorMsg("未启用手牌锁");
                    return;
                }

                if (lock_type == "欧亿达")
                {
                    Thread.Sleep(500);
                    if (OYD.FKOPEN() != 1)
                        return;

                    OYD.CH375SetTimeout(0, 5000, 5000);
                }

                byte[] buff = new byte[200];
                string seat_text = "";

                int rt = -1;
                if (lock_type == "欧亿达")
                {
                    Thread.Sleep(500);
                    rt = OYD.OYEDA_id(buff);
                }
                else if (lock_type == "锦衣卫")
                    rt = JYW.ReadID(buff);
                else if (lock_type == "RF")
                    rt = RF.RF_RFID(ref seat_text);

                if (rt != 0)
                    return;

                CSeat seat = null;
                if (lock_type == "欧亿达")
                {
                    seat_text = Encoding.Default.GetString(buff, 0, 20).Trim();
                    seat_text = seat_text.Substring(0, 16);
                }
                else if (lock_type == "锦衣卫")
                {
                    seat_text = BathClass.byteToHexStr(buff);
                    seat_text = seat_text.Substring(0, 16);

                }
                seat = dao.get_seat("oId", seat_text);

                //var db_new = new BathDBDataContext(LogIn.connectionString);
                //var seat = db_new.Seat.FirstOrDefault(x => x.text == seat_text);
                //seat = dao.get_seat("text", seat_text);
                if (seat == null)
                {
                    BathClass.printErrorMsg("手牌" + seat_text + "不存在");
                    return;
                }

                if (seat.status == SeatStatus.AVILABLE || seat.status == SeatStatus.PAIED)
                {
                    if (lock_type == "欧亿达")
                        Thread.Sleep(500);

                    if ((lock_type == "欧亿达" && OYD.OYEDA_fk(buff) != 0) ||
                        (lock_type == "锦衣卫" && JYW.FK(buff) != 0) ||
                        (lock_type == "RF" && RF.RF_FK(seat_text) != 0))
                        return;

                    open_one_seat(seat);
                    open_seat(seat);
                }
                else if (seat.status == SeatStatus.USING)
                {
                    InputEmployeeByPwd inputEmployee = new InputEmployeeByPwd();

                    if (dao.get_authority(LogIn.m_User, "取消开牌") ||
                        (inputEmployee.ShowDialog() != DialogResult.OK &&
                        dao.get_authority(inputEmployee.employee, "取消开牌")))
                    {

                        var q = LogIn.options.取消开牌时限;
                        if (q != null && (DateTime.Now - seat.openTime.Value).TotalMinutes >= Convert.ToDouble(q))
                        {
                            BathClass.printErrorMsg("已超过取消开牌时限");
                            return;
                        }
                        var orders = dao.get_orders("systemId='" + seat.systemId + "'");
                        //var orders = db_new.Orders.Where(x => x.systemId == seat.systemId);
                        if (orders.Count() >= 2)
                        {
                            BathClass.printErrorMsg("已经点单,不能取消开台");
                            return;
                        }

                        if (BathClass.printAskMsg("确认取消开台?") != DialogResult.Yes)
                            return;

                        if (lock_type == "欧亿达")
                            Thread.Sleep(500);

                        if ((lock_type == "欧亿达" && OYD.OYEDA_md(buff) != 0) ||
                        (lock_type == "锦衣卫" && JYW.MD(buff) != 0) ||
                            (lock_type == "RF" && RF.RF_MD() != 0))
                            return;

                        StringBuilder sb = new StringBuilder();
                        sb.Append(@"insert into [Operation](employee,seat,openEmployee,openTime,explain,opTime) values('");
                        sb.Append(inputEmployee.employee.id + "','" + seat.text + "','");
                        sb.Append(seat.openEmployee + "','" + seat.openTime.ToString());
                        sb.Append("','取消开牌',getdate()");

                        sb.Append(" delete from [Orders] where systemId='" + seat.systemId + "'");
                        sb.Append(dao.reset_seat_string() + "text='" + seat.text + "')");
                        if (!dao.execute_command(sb.ToString()))
                        {
                            BathClass.printErrorMsg("取消开牌失败!");
                            return;
                        }
                        //Operation op = new Operation();

                        //if (inputEmployee.employee != null)
                        //    op.employee = inputEmployee.employee.id;
                        //else
                        //    op.employee = LogIn.m_User.id;
                        //op.seat = seat.text;
                        //op.openEmployee = seat.openEmployee;
                        //op.openTime = seat.openTime;
                        //op.explain = "取消开牌";
                        //op.opTime = BathClass.Now(LogIn.connectionString);
                        //db_new.Operation.InsertOnSubmit(op);

                        //db_new.SystemIds.DeleteAllOnSubmit(db_new.SystemIds.Where(x => x.systemId == seat.systemId));
                        //db_new.Orders.DeleteAllOnSubmit(db_new.Orders.Where(x => x.systemId == seat.systemId));
                        //BathClass.reset_seat(seat);
                        //db_new.SubmitChanges();
                    }
                    else
                    {
                        BathClass.printErrorMsg("不具有取消开牌权限");
                    }
                }
            }
            catch (System.Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }