Exemplo n.º 1
0
        private void BTRegister_Click(object sender, EventArgs e)
        {
            string code = TextCode.Text.Trim();
            if (code == "")
            {
                BathClass.printErrorMsg("公司代码为空!");
                return;
            }

            string name = TextName.Text.Trim();
            if (name == "")
            {
                BathClass.printErrorMsg("公司名称为空!");
                return;
            }

            string errorDesc = "";
            var success = ShopManagement.registerCompany(LogIn.connectionIP, code, name, TextTel.Text.Trim(), TextTel.Text.Trim(), out errorDesc);

            if (success)
            {
                var db = new BathDBDataContext(LogIn.connectionString);
                db.Options.FirstOrDefault().company_Code = code;
                db.SubmitChanges();

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                BathClass.printErrorMsg(errorDesc);
            }
        }
Exemplo n.º 2
0
        //对话框载入
        private void BonusTableForm_Load(object sender, EventArgs e)
        {
            db = new BathDBDataContext(LogIn.connectionString);
            var format = db.Options.FirstOrDefault().提成报表格式;
            if (format == null)
            {
                format = FORMAT_ALL_DIANLUN;
                db.SubmitChanges();
            }

            if (format == FORMAT_ALL_DIANLUN)
            {
                CheckerLunDian.Checked = true;
                CheckerPaid.Checked = true;
            }
            else if (format == FORMAT_ALL_NODIANLUN)
            {
                CheckerLunDian.Checked = false;
                CheckerPaid.Checked = true;
            }
            else if (format == FORMAT_INPUTTIME_DIANLUN)
            {
                CheckerLunDian.Checked = true;
                CheckerPaid.Checked = false;
            }
            else if (format == FORMAT_INPUTTIME_NODIANLUN)
            {
                CheckerLunDian.Checked = false;
                CheckerPaid.Checked = false;
            }
        }
Exemplo n.º 3
0
        //构造函数
        public SeatExpenseForm(HotelRoom seat)
        {
            var db = new BathDBDataContext(LogIn.connectionString);

            if (MainWindow.seatLock)
            {
                m_Seats.Add(db.HotelRoom.FirstOrDefault(x => x.text == seat.text));
            }
            else
            {
                var seats = db.HotelRoom.Where(x => (seat.chainId == null && x.text == seat.text) || (seat.chainId != null && x.chainId == seat.chainId));
                seats = seats.Where(x => x.status == 2 || x.status == 6 || x.status == 7 || x.status == 8);
                m_Seats.AddRange(seats);
            }
            foreach (var s in m_Seats)
            {
                s.paying = true;
            }
            db.SubmitChanges();
            //m_Seats.AddRange(db.HotelRoom.Where(x => x.chainId == seat.chainId && (x.status == 2 || x.status == 6 || x.status == 7)));

            InitializeComponent();
        }
Exemplo n.º 4
0
        //全部重排
        private void toolReArrange_Click(object sender, EventArgs e)
        {
            var dc = new BathDBDataContext(m_con_str);
            dc.ExecuteCommand("truncate table techindex");
            dc.SubmitChanges();

            var job_ids = dc.Job.Where(x => x.name.Contains("技师")).Select(x => x.id);
            foreach (var job_id in job_ids)
            {
                var techs = dc.Employee.Where(x => x.jobId == job_id);

                techs = techs.Where(x => x.techStatus == null || x.techStatus == "空闲" || x.techStatus == "待钟");

                var techs_male = techs.Where(x=>x.gender=="男");
                var techIndex = new TechIndex();
                techIndex.dutyid = job_id;
                techIndex.gender = "男";
                techIndex.ids = string.Join("%", techs_male.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray());
                dc.TechIndex.InsertOnSubmit(techIndex);

                var techs_female = techs.Where(x => x.gender == "女");
                techIndex = new TechIndex();
                techIndex.dutyid = job_id;
                techIndex.gender = "女";
                techIndex.ids = string.Join("%", techs_female.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray());
                dc.TechIndex.InsertOnSubmit(techIndex);
            }
            dc.SubmitChanges();
            dgv_show(dc);
        }
Exemplo n.º 5
0
        //留牌操作 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);
        }
Exemplo n.º 6
0
        private void SeatExpenseForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            var dc = new BathDBDataContext(LogIn.connectionString);
            var lockSeat = BathClass.ToBool(dc.Options.FirstOrDefault().结账未打单锁定手牌);

            for (int i = 0; i < m_Seats.Count; i++ )
            {
                var s_new = dc.HotelRoom.FirstOrDefault(x => x.text == m_Seats[i].text);
                s_new.paying = false;
                if (lockSeat && s_new.status != 3 && s_new.status != 8 && dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
                {
                    s_new.status = 4;
                }
            }
            dc.SubmitChanges();
        }
Exemplo n.º 7
0
        //加收过夜费
        private void order_guoye(HotelRoom seat, BathDBDataContext dc)
        {
            if (!BathClass.ToBool(m_Options.自动加收过夜费))
                return;

            if (dc.Orders.FirstOrDefault(x=>x.systemId==seat.systemId && x.menu=="过夜费") != null ||
                dc.HisOrders.FirstOrDefault(x => x.systemId == seat.systemId && x.menu == "过夜费") != null)
                return;

            var m_OverMenu = dc.Menu.FirstOrDefault(x => x.name == "过夜费");
            if (m_OverMenu == null)
                return;

            DateTime now = DateTime.Now;
            string year = now.Year.ToString();
            string month = now.Month.ToString();
            string day = now.Day.ToString();
            string date = year+"-"+month+"-"+day+" ";
            string time = ":00:00";

            DateTime st = DateTime.Parse(date + m_Options.过夜费起点 + time);
            DateTime et = DateTime.Parse(date + m_Options.过夜费终点 + time);

            DateTime open_time = seat.openTime.Value;
            if ((now >= et && open_time >= et) || (open_time <= st && now <= st))
                return;

            Orders order = new Orders();
            order.menu = m_OverMenu.name;
            order.text = seat.text;
            order.systemId = seat.systemId;
            order.number = 1;
            order.money = m_OverMenu.price;
            order.inputTime = now;
            order.inputEmployee = "过夜费";
            order.departmentId = 1;
            order.paid = false;
            dc.Orders.InsertOnSubmit(order);
            dc.SubmitChanges();
            find_combo(dc, order);
        }
Exemplo n.º 8
0
        private void find_combo(BathDBDataContext dc, Orders theOrder)
        {
            dc.Orders.DeleteAllOnSubmit(dc.Orders.Where(x => x.systemId == theOrder.systemId && x.menu.Contains("套餐")));
            var orders = dc.Orders.Where(x => x.systemId == theOrder.systemId && x.deleteEmployee == null);
            orders = orders.Where(x => !x.inputEmployee.Contains("电脑"));
            foreach (Orders tmp_order in orders)
            {
                tmp_order.comboId = null;
            }
            dc.SubmitChanges();

            var order_menus = orders.Where(x => x.comboId == null).Select(x => x.menu);
            var menus = dc.Menu;
            var comboList = dc.Combo.OrderByDescending(x => x.originPrice - x.price);
            foreach (Combo combo in comboList)
            {
                List<int> menuIds = BathClass.disAssemble(combo.menuIds);
                var combo_menus = menus.Where(x => menuIds.Contains(x.id)).Select(x => x.name);
                if (combo_menus.All(x => order_menus.Any(y => y == x)))
                {
                    foreach (var combo_menu in combo_menus)
                    {
                        var tmp_order = orders.FirstOrDefault(x => x.menu == combo_menu);
                        tmp_order.comboId = combo.id;
                        if (combo.priceType == "免项目")
                        {
                            var freeIds = BathClass.disAssemble(combo.freeMenuIds);
                            var freeMenus = dc.Menu.Where(x => freeIds.Contains(x.id)).Select(x => x.name);
                            if (freeMenus.Contains(tmp_order.menu))
                                tmp_order.money = 0;
                        }
                    }
                    if (combo.priceType == "减金额")
                    {
                        Orders comboOrder = new Orders();
                        comboOrder.menu = "套餐" + combo.id.ToString() + "优惠";
                        comboOrder.text = theOrder.text;
                        comboOrder.systemId = theOrder.systemId;
                        comboOrder.number = 1;
                        comboOrder.inputTime = GeneralClass.Now;
                        comboOrder.inputEmployee = "套餐";
                        comboOrder.paid = false;
                        comboOrder.comboId = combo.id;
                        comboOrder.departmentId = 1;
                        comboOrder.money = Convert.ToDouble(combo.price) - combo.originPrice;

                        dc.Orders.InsertOnSubmit(comboOrder);
                    }
                    dc.SubmitChanges();
                }
            }
        }
Exemplo n.º 9
0
        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();
        }
Exemplo n.º 10
0
        //添加备注
        private void CtxAddNote_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            Seat seat = getContextSenderSeat(db_new, sender);
            if (seat.status != 2 && seat.status != 6)
            {
                GeneralClass.printErrorMsg("手牌未使用,不能添加备注");
                return;
            }

            NoteForm noteForm = new NoteForm();
            if (noteForm.ShowDialog() != DialogResult.OK)
                return;

            seat.note = noteForm.note;
            db_new.SubmitChanges();
        }
Exemplo n.º 11
0
        //消费录入
        private void orderTool_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            if (!BathClass.getAuthority(db_new, LogIn.m_User, "完整点单") &&
                !BathClass.getAuthority(db_new, LogIn.m_User, "可见本人点单"))
            {
                BathClass.printErrorMsg("权限不够!");
                return;
            }
            List<int> sLst = new List<int>();
            sLst.Add(2);
            sLst.Add(6);

            var inputSeatForm = new InputRoomForm(sLst);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;

            var seat = db_new.HotelRoom.FirstOrDefault(x => x.text == inputSeatForm.m_Seat.text);
            seat.ordering = true;
            db_new.SubmitChanges();

            var orderForm = new HotelRoomOrderForm(inputSeatForm.m_Seat);
            orderForm.ShowDialog();

            seat.ordering = false;
            db_new.SubmitChanges();
        }
Exemplo n.º 12
0
        private void lock_unlock(HotelRoom seat, BathDBDataContext db_new, Employee employee)
        {
            if (seat.status == 1 || seat.status == 2)
                seat.status = 4;
            else if (seat.status == 4)
            {
                Operation op = new Operation();
                op.employee = employee.name;
                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);

                if (seat.systemId == null)
                    seat.status = 1;
                else
                    seat.status = 2;
            }

            db_new.SubmitChanges();
        }
Exemplo n.º 13
0
        //押金离场
        private void btnDeposit_Click(object sender, EventArgs e)
        {
            List<int> s = new List<int>();
            s.Add(2);
            s.Add(7);
            var inputSeatForm = new InputRoomForm(s);
            if (inputSeatForm.ShowDialog() != DialogResult.OK)
                return;

            var seat = inputSeatForm.m_Seat;
            if (seat.status == 2)
            {
                DepositForm depositForm = new DepositForm(inputSeatForm.m_Seat);
                depositForm.ShowDialog();
            }
            else if (seat.status == 7 && BathClass.printAskMsg("是否取消押金离场状态")==DialogResult.Yes)
            {
                var db_new = new BathDBDataContext(LogIn.connectionString);
                var seat_new = db_new.HotelRoom.FirstOrDefault(x => x.text == seat.text);
                seat_new.status = 2;
                seat_new.note = null;
                db_new.SubmitChanges();
            }
        }
Exemplo n.º 14
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();
        }
Exemplo n.º 15
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();
        }
Exemplo n.º 16
0
        //载入消费
        private void btnReload_Click(object sender, EventArgs e)
        {
            var dc_new = new BathDBDataContext(LogIn.connectionString);
            if (seatText.Text != "")
            {
                m_Seat = dc_new.HotelRoom.FirstOrDefault(x => x.text == seatText.Text || x.oId == seatText.Text);
                seatText.Text = "";

                if (m_Seat == null || m_Seat.status != 2 && m_Seat.status != 6 && m_Seat.status != 7 && m_Seat.status != 8)
                {
                    BathClass.printErrorMsg("该手牌不在使用中,不能结账!");
                    return;
                }
                if (m_Seats.FirstOrDefault(x=>x.text==m_Seat.text) == null)
                {
                    if (m_Seat.note != null)
                        BathClass.printInformation(m_Seat.note);
                    string t = Convert.ToDateTime(m_Seat.openTime).ToShortTimeString();
                    dgvChain.Rows.Add();
                    dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[0].Value = m_Seat.text;
                    dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[1].Value = use_oyd;
                    dgvChain.Rows[dgvChain.Rows.Count - 1].Cells[2].Value = t;

                    order_guoye(m_Seat, dc_new);
                    m_Seats.Add(m_Seat);
                    m_Seat.paying = true;
                    dc_new.SubmitChanges();

                    //dgvChain_show();
                    dgvChain.CurrentCell = null;
                    //chain = true;
                    dgvExpense_show(dc_new);
                    setStatus(dc_new);
                }
            }
        }
Exemplo n.º 17
0
        //手工打折
        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);
        }
Exemplo n.º 18
0
        //确定重新结账
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (dgv.CurrentCell == null)
            {
                BathClass.printErrorMsg("未选中账单号");
                return;
            }

            var db_new = new BathDBDataContext(LogIn.connectionString);
            var act = db_new.Account.FirstOrDefault(x => x.id.ToString() == dgv.CurrentRow.Cells[0].Value.ToString());
            if (act == null)
            {
                if (BathClass.printAskMsg("手牌未结账,是否直接恢复手牌?") != DialogResult.Yes)
                    return;
            }

            var texts = act.text.Split('|');
            var ids = act.systemId.Split('|');
            //var seats = db_new.HotelRoom.Where(x => texts.Contains(x.text));
            for (int i = 0; i < texts.Count(); i++)
            {
                var s = db_new.HotelRoom.FirstOrDefault(x => x.text == texts[i]);
                if (s == null) continue;

                if (s.status == 2 || s.status == 6 || s.status == 7)
                {
                    BathClass.printErrorMsg("手牌: " + s.text + "已经重新开牌,请先更换手牌");
                    return;
                }
                s.status = 8;
                s.systemId = ids[i];
                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;
                    ho.stopTiming = true;
                    ho.departmentId = 1;
                    db_new.HisOrders.DeleteOnSubmit(order);
                    db_new.Orders.InsertOnSubmit(ho);
                }
            }
            act.abandon = m_user.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();

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 19
0
        //签字免单
        private void freeTool_Click(object sender, EventArgs e)
        {
            SignForFreeForm inputSerForm = new SignForFreeForm();
            if (inputSerForm.ShowDialog() != DialogResult.OK)
                return;

            var dc_new = new BathDBDataContext(LogIn.connectionString);
            Account account = new Account();
            insert_account(dc_new, ref account, inputSerForm.signature);

            set_order_paid(dc_new, account);
            update_seat_room(dc_new);
            dc_new.SubmitChanges();
            setStatus(dc_new);

            if (printBill)
                printTool_Click(dc_new, "结账单");
            if (printStubBill)
                printTool_Click(dc_new, "存根单");
            if (printShoe)
            {
                List<string> seat_texts = new List<string>();
                var ts = account.text.Split('|').ToList();
                foreach (var tx in ts)
                {
                    var s = m_Seats.FirstOrDefault(x => x.text == tx);
                    if (s == null) continue;
                    int i = m_Seats.IndexOf(s);
                    if (dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
                        seat_texts.Add(tx);
                }
                PrintShoeMsg.Print_DataGridView(seat_texts, account.payEmployee, account.payTime.ToString(), companyName);
            }

            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 20
0
        private void handle_exception(System.Exception ex)
        {
            //send_email(ex.Message);
            BathClass.printErrorMsg("系统出错:" + ex.Message + ",请重试!");

            if (account.id != 0)
            {
                var dc = new BathDBDataContext(LogIn.connectionString);
                var act = dc.Account.FirstOrDefault(x => x.id == account.id);
                dc.Account.DeleteOnSubmit(act);
                dc.SubmitChanges();
            }
            this.DialogResult = DialogResult.Cancel;
        }
Exemplo n.º 21
0
        //插入账单数据库
        private void insert_account(BathDBDataContext dc, ref Account account, string name)
        {
            account.text = string.Join(";", m_Seats.OrderBy(x => x.text).Select(x => x.text).ToArray());
            account.systemId = string.Join(";", m_Seats.OrderBy(x => x.text).Select(x => x.systemId).ToArray());
            account.openTime = string.Join(";", m_Seats.OrderBy(x => x.text).Select(x => x.openTime.ToString()).ToArray());
            account.openEmployee = string.Join(";", m_Seats.OrderBy(x => x.text).Select(x => x.openEmployee).ToArray());
            account.payTime = GeneralClass.Now;
            account.payEmployee = LogIn.m_User.id;
            account.server = BathClass.get_rooms_expenses(dc, m_Seats, LogIn.connectionString);
            account.serverEmployee = name;
            account.macAddress = BathClass.getMacAddr_Local();

            dc.Account.InsertOnSubmit(account);
            dc.SubmitChanges();
        }
        //对话框载入
        private void PromotionForm_Load(object sender, EventArgs e)
        {
            db = new BathDBDataContext(LogIn.connectionString);
            m_Promotion = db.GroupBuyPromotion.FirstOrDefault();
            if (m_Promotion == null)
            {
                m_Promotion = new GroupBuyPromotion();
                db.GroupBuyPromotion.InsertOnSubmit(m_Promotion);
                db.SubmitChanges();
            }

            m_Offer = BathClass.disAssemble(db, m_Promotion);
            dgvDetails_show();
        }
Exemplo n.º 23
0
        //宾客付款
        private void payTool_Click(object sender, EventArgs e)
        {
            BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString);

            var seats = new List<HotelRoom>();
            seats = m_Seats;
            List<bool> keeps = new List<bool>();
            foreach (DataGridViewRow r in dgvChain.Rows)
            {
                keeps.Add(r.Cells[1].EditedFormattedValue.ToString() == "True");
            }

            PayForm payForm = new PayForm(seats, keeps, m_Member, discount_money);
            if (payForm.ShowDialog() != DialogResult.OK)
                return;

            var ids = string.Join("|", m_Seats.OrderBy(x=>x.text).Select(x => x.systemId).ToArray());
            var act_old = dc.Account.FirstOrDefault(x => x.systemId == ids && x.abandon != null);
            var act = dc.Account.FirstOrDefault(x => x.systemId == ids && x.abandon == null);
            if (act_old == null)
            {
                if (printBill)
                    printTool_Click(dc, "结账单");
                if (printStubBill)
                    printTool_Click(dc, "存根单");
                if (printShoe)
                {
                    List<string> seat_texts = new List<string>();
                    var ts = act.text.Split('|').ToList();
                    foreach (var tx in ts )
                    {
                        var s = m_Seats.FirstOrDefault(x => x.text == tx);
                        if (s == null) continue;
                        int i = m_Seats.IndexOf(s);
                        if (dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
                            seat_texts.Add(tx);
                    }
                    PrintShoeMsg.Print_DataGridView(seat_texts, act.payEmployee, act.payTime.ToString(), companyName);
                }
            }
            else
            {
                printTool_Click(dc, "补救单");
            }

            sendMessageToShoes(act);

            //处理留牌
            bool kept = false;
            for (int i = 0; i < m_Seats.Count; i++ )
            {
                if (dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
                    continue;

                kept = true;
                var s = m_Seats[i];
                var seat = dc.HotelRoom.FirstOrDefault(x => x.systemId == s.systemId);
                var orders = dc.Orders.Where(x => x.systemId == seat.systemId && x.priceType == "每小时");
                foreach (var order in orders)
                {
                    order.inputTime = GeneralClass.Now;
                    order.paid = false;
                    order.accountId = null;
                }
                seat.status = 2;
            }
            if (kept)
                dc.SubmitChanges();

            //if (seats == m_Seats)
            this.DialogResult = DialogResult.OK;
            //else
            //{
            //    m_Seats.Remove(m_Seat);
            //    dgvChain_show();
            //    dgvChain.CurrentCell = null;
            //    chain = true;
            //    dgvExpense_show();
            //    setStatus();
            //}
        }
Exemplo n.º 24
0
        //定时轮询
        private void detect_msg()
        {
            while(true)
            {
                try
                {
                    var dc = new BathDBDataContext(connectionString);
                    var job = dc.Job.FirstOrDefault(x => x.ip == m_ip);
                    if (job == null)
                        m_msg = dc.TechMsg.FirstOrDefault(x => !x.read);
                    else
                    {
                        m_msg = dc.TechMsg.FirstOrDefault(x => !x.read &&
                            (x.techType == job.name || (x.techId!=null && x.techId!="" &&
                            dc.Employee.FirstOrDefault(y=>y.id==x.techId).jobId==job.id)));
                    }

                    if (m_msg == null)
                    {
                        this.Invoke(new delegate_no_param(unable_msg_btn), null);
                        continue;
                    }

                    var tech = dc.Employee.FirstOrDefault(x => x.msgId == m_msg.id);
                    if (tech == null && job != null)
                    {
                        tech = dc.Employee.FirstOrDefault(x => x.id == m_msg.techId);
                        if (tech == null)
                        {
                            if (m_msg.gender == null || m_msg.gender.Trim() == "" || m_msg.gender == "无"|| m_msg.gender == "女")
                            {
                                var tLst = dc.TechIndex.FirstOrDefault(x => x.dutyid == job.id && x.gender == "女").ids.Split('%').ToList();

                                foreach (var techIds in tLst)
                                {
                                    var tech_id = techIds.Split('=');
                                    if (tech_id[1] == "F") continue;

                                    var tmp_tech = dc.Employee.FirstOrDefault(x => x.id == tech_id[0]);
                                    if (tmp_tech.techStatus == "空闲" || tmp_tech.techStatus == null)
                                    {
                                        tech = tmp_tech;
                                        tech.techStatus = "待钟";
                                        tech.techMenu = m_msg.menu;
                                        tech.room = m_msg.room;
                                        tech.seat = m_msg.seat;
                                        tech.msgId = m_msg.id;

                                        m_msg.techId = tech.id;
                                        dc.SubmitChanges();

                                        this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[]{dc, "女", SplitGender.Panel1});
                                        //this.Invoke(new delegate_no_param(create_tech_panel));
                                        break;
                                    }
                                }
                            }
                            else if (m_msg.gender == "男")
                            {
                                var tLst = dc.TechIndex.FirstOrDefault(x => x.dutyid == job.id && x.gender == "男").ids.Split('%').ToList();

                                foreach (var techIds in tLst)
                                {
                                    var tech_id = techIds.Split('=');
                                    if (tech_id[1] == "F") continue;
                                    var tmp_tech = dc.Employee.FirstOrDefault(x => x.id == tech_id[0]);
                                    if (tmp_tech.techStatus == "空闲" || tmp_tech.techStatus == null)
                                    {
                                        tech = tmp_tech;
                                        tech.techStatus = "待钟";
                                        tech.techMenu = m_msg.menu;
                                        tech.room = m_msg.room;
                                        tech.seat = m_msg.seat;
                                        tech.msgId = m_msg.id;

                                        m_msg.techId = tech.id;
                                        dc.SubmitChanges();

                                        this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[]{dc, "男", SplitGender.Panel2});
                                        //this.Invoke(new delegate_no_param(create_tech_panel));
                                        break;
                                    }
                                }
                            }

                        }
                        else
                        {
                            tech.techStatus = "待钟";
                            tech.techMenu = m_msg.menu;
                            tech.room = m_msg.room;
                            tech.seat = m_msg.seat;
                            tech.msgId = m_msg.id;

                            m_msg.techId = tech.id;
                            dc.SubmitChanges();

                            Control sp = SplitGender.Panel1;
                            if (tech.gender == "男")
                                sp = SplitGender.Panel2;

                            this.Invoke(new delegate_create_tech_panel_gender(create_tech_panel_gender),
                                            new object[] { dc, tech.gender, sp });
                            //this.Invoke(new delegate_no_param(create_tech_panel));

                        }

                    }
                    this.Invoke(new delegate_no_param(showMessage));
                    play();
                    if (print_tech_msg)
                        print_msg(dc);
                }
                catch
                {
                }
            }
        }
Exemplo n.º 25
0
        //发送消息给鞋部
        private void sendMessageToShoes(Account account)
        {
            var dc_new = new BathDBDataContext(LogIn.connectionString);
            var op = dc_new.Options.FirstOrDefault();
            if (op == null)
                return;

            var q = op.启用鞋部;
            if (!Convert.ToBoolean(q))
                return;

            ShoeMsg msg = new ShoeMsg();
            msg.text = account.text;
            msg.payEmployee = account.payEmployee;
            msg.payTime = account.payTime;
            msg.processed = false;
            dc_new.ShoeMsg.InsertOnSubmit(msg);
            dc_new.SubmitChanges();
        }
Exemplo n.º 26
0
        private void 退钟回原排ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;
            ContextMenuStrip cmenu = item.GetCurrentParent() as ContextMenuStrip;
            Button bt = cmenu.SourceControl as Button;
            if (bt.BackColor == avi_color)
                return;

            var dc = new BathDBDataContext(connectionString);
            var tech = dc.Employee.FirstOrDefault(x => x.id == bt.Name);
            tech.techStatus = "空闲";
            tech.techMenu = null;
            tech.room = null;
            tech.seat = null;
            tech.msgId = null;
            dc.SubmitChanges();

            bt.BackColor = avi_color;
            bt.Text = "技师:" + tech.id;
        }
Exemplo n.º 27
0
        //男技师重排
        private void BtnRearrangeMale_Click(object sender, EventArgs e)
        {
            var dc = new BathDBDataContext(m_con_str);

            string typeSelName = seatTypeTree.SelectedNode.Text;

            if (typeSelName == "所有技师")
                return;

            var job_id = dc.Job.FirstOrDefault(x => x.name == typeSelName).id;
            var techs = dc.Employee.Where(x => x.jobId == job_id);

            techs = techs.Where(x => x.techStatus == null || x.techStatus == "空闲" || x.techStatus == "待钟");

            var techs_male = techs.Where(x => x.gender == "男");

            var techIndex = dc.TechIndex.FirstOrDefault(x => x.dutyid == job_id && x.gender == "男");
            bool new_techIndex = false;
            if (techIndex == null)
            {
                new_techIndex = true;
                techIndex = new TechIndex();
            }
            techIndex.dutyid = job_id;
            techIndex.gender = "男";
            techIndex.ids = string.Join("%", techs_male.OrderBy(x => x.id).Select(x => x.id + "=T").ToArray());

            if (new_techIndex)
                dc.TechIndex.InsertOnSubmit(techIndex);

            dc.SubmitChanges();
            dgv_show(dc);
        }
Exemplo n.º 28
0
        //宾客转账
        private void transferTool_Click(object sender, EventArgs e)
        {
            InputSeatForm seatForm = new InputSeatForm(2);
            if (seatForm.ShowDialog() != DialogResult.OK)
                return;

            if (m_Seats.FirstOrDefault(x => x.text == seatForm.m_Seat.text) != null)
            {
                BathClass.printErrorMsg("转账手牌中已经包含该手牌,请重新输入");
                return;
            }

            var dc = new BathDBDataContext(LogIn.connectionString);
            string systemId = seatForm.m_Seat.systemId;
            foreach (HotelRoom s in m_Seats)
            {

                var orderList = dc.Orders.Where(x => x.systemId == s.systemId && x.deleteEmployee == null && !x.paid);
                foreach (Orders order in orderList)
                {
                    order.systemId = systemId;
                    if (order.priceType == "每小时")
                    {
                        order.priceType = "停止消费";
                        order.money = order.money * Math.Ceiling((GeneralClass.Now - order.inputTime).TotalHours);
                    }
                    order.stopTiming = true;
                }
                dc.HotelRoom.FirstOrDefault(x=>x.text==s.text).status = 3;
            }
            dc.SubmitChanges();

            List<string> printCols = new List<string>();
            printCols.Add("手牌");
            printCols.Add("项目名称");
            printCols.Add("技师");
            printCols.Add("单价");
            printCols.Add("数量");
            printCols.Add("金额");
            PrintSeatBill.Print_DataGridView(m_Seats, "转账确认单", dgvExpense, printCols, moneyPayable.Text, companyName);
            this.DialogResult = DialogResult.OK;
        }
Exemplo n.º 29
0
        //女技师向下
        private void BtnDownFemale_Click(object sender, EventArgs e)
        {
            if (DgvFemale.CurrentCell == null)
            {
                BathClass.printErrorMsg("没有选择行!");
                return;
            }

            if (DgvFemale.CurrentCell.RowIndex == DgvFemale.Rows.Count - 1)
            {
                BathClass.printErrorMsg("已经排末排,不能退后");
                return;
            }

            var db = new BathDBDataContext(m_con_str);
            var tech_id = DgvFemale.CurrentRow.Cells[0].Value.ToString();
            var job_id = db.Employee.FirstOrDefault(x => x.id == tech_id).jobId;
            var tech_index = db.TechIndex.FirstOrDefault(x => x.dutyid == job_id && x.gender == "女");
            var old_index = tech_index.ids.Split('%');

            int col_index = DgvFemale.CurrentCell.ColumnIndex;
            int row_index = DgvFemale.CurrentCell.RowIndex;
            int count = DgvFemale.Rows.Count;
            var new_index = new List<string>();
            for (int i = 0; i < count; i++)
            {
                if (i == row_index)
                {
                    new_index.Add(old_index[i + 1]);
                    new_index.Add(old_index[i]);
                    i++;
                }
                else
                {
                    new_index.Add(old_index[i]);
                }
            }

            tech_index.ids = string.Join("%", new_index.ToArray());
            db.SubmitChanges();
            dgv_show(db);
            DgvFemale.CurrentCell = DgvFemale[col_index, row_index + 1];
        }
Exemplo n.º 30
0
        //删除手牌
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (dgvChain.CurrentCell == null)
            {
                BathClass.printErrorMsg("未选择手牌!");
                return;
            }

            string text = dgvChain.CurrentRow.Cells[0].Value.ToString();

            int i = m_Seats.IndexOf(m_Seats.FirstOrDefault(x => x.text == text));
            if (use_oyd && dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
            {
                BathClass.printErrorMsg("已经刷手牌,不能删除!");
                return;
            }
            dgvChain.Rows.RemoveAt(i);
            m_Seats.Remove(m_Seats.FirstOrDefault(x => x.text == text));

            var dc_new = new BathDBDataContext(LogIn.connectionString);
            dc_new.HotelRoom.FirstOrDefault(x => x.text == text).paying = false;
            dc_new.SubmitChanges();

            //dgvChain_show();
            dgvChain.CurrentCell = null;
            //chain = true;
            dgvExpense_show(dc_new);
            setStatus(dc_new);
        }