//宾客付款
        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();
            //}
        }
        //宾客付款
        private void payTool_Click(object sender, EventArgs e)
        {
            int j = 0;
            Dictionary<Int64, bool> orders = new Dictionary<Int64, bool>();
            foreach (DataGridViewRow r in dgvExpense.Rows)
            {
                bool pay = r.Cells[1].EditedFormattedValue.ToString() == "True";
                orders.Add(Convert.ToInt64(r.Cells[0].Value), pay);
                j++;
            }

            double money = Convert.ToDouble(moneyPayable.Text);

            PayForm payForm = new PayForm(m_Seats, orders, m_Member, discount_money, money);
            if (payForm.ShowDialog() != DialogResult.OK)
                return;

            var dgv = new_datagridView();
            foreach (DataGridViewRow r in dgvExpense.Rows)
            {
                if (r.Cells[1].EditedFormattedValue.ToString() != "True") continue;

                dgv.Rows.Add(r.Cells[3].Value, r.Cells[11].Value, r.Cells[4].Value, r.Cells[5].Value,
                        r.Cells[6].Value, r.Cells[7].Value, r.Cells[8].Value);

            }

            int newAccountId = payForm.newAccountId;
            var act = dao.get_account("id=" + newAccountId);
            var has_repaid = dao.exist_instance("Account", "systemId='" + act.systemId + "' and abandon is not null");
            if (!has_repaid)
            {
                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);
                }

                //启动打印线程
                Thread td = new Thread(delegate() { print_Bill(dgv, printBill, printStubBill, printShoe, seat_texts, false, act); });
                td.Start();
            }
            else
            {
                Thread td = new Thread(delegate() { print_Bill(dgv, false, false, false, null, true, act); });
                td.Start();
            }

            if (auto_shoe)
                sendMessageToShoes(act);

            //处理留牌
            string update_str = @"update [Seat] set note='已留牌', status=2 where ";
            string txt_str = "";
            for (int i = 0; i < m_Seats.Count; i++ )
            {
                if (dgvChain.Rows[i].Cells[1].EditedFormattedValue.ToString() == "False")
                    continue;

                if (txt_str != "")
                    txt_str += " or ";
                txt_str += "text='" + m_Seats[i].text + "'";
            }

            if (txt_str != "")
            {
                update_str += txt_str;
                if (!dao.execute_command(update_str))
                {
                    BathClass.printErrorMsg("手牌状态更新失败!");
                }
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Beispiel #3
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();
            //}
        }