//修改订单数据库的paid属性
 private void set_order_paid(BathDBDataContext dc, Account account)
 {
     foreach (HotelRoom seat in m_Seats)
     {
         var orderList = dc.Orders.Where(x => x.systemId == seat.systemId && !x.paid);
         foreach (Orders order in orderList)
         {
             var ho = new HisOrders();
             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 = true;
             ho.accountId = account.id;
             ho.billId = order.billId;
             dc.HisOrders.InsertOnSubmit(ho);
             dc.Orders.DeleteOnSubmit(order);
         }
     }
 }
        //插入账单数据库
        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 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();
        }
 //修改订单数据库的paid属性
 private void set_order_paid(Account account)
 {
     var orderList = db.Orders.Where(x => x.systemId == m_Seat.systemId && !x.paid);
     foreach (Orders order in orderList)
     {
         order.paid = true;
         order.accountId = account.id;
     }
 }
        //签字免单
        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;
        }
        //宾客付款
        private void payTool_Click(object sender, EventArgs e)
        {
            BathDBDataContext dc = new BathDBDataContext(LogIn.connectionString);

            HintForm hintForm = new HintForm("请插入会员卡...");
            if (hintForm.ShowDialog() != DialogResult.OK)
                return;

            MemberCardUsingForm memberCardUsingForm = new MemberCardUsingForm(Convert.ToDouble(moneyPayable.Text));
            if (memberCardUsingForm.ShowDialog() != DialogResult.OK)
                return;

            if (m_Member == null)
                m_Member = memberCardUsingForm.m_member;

            Account account = new Account();
            account.text = m_Seat.text;
            account.systemId = m_Seat.systemId;
            account.openTime = m_Seat.openTime.ToString();
            account.openEmployee = m_Seat.openEmployee;
            account.payTime = DateTime.Now;
            account.payEmployee = LogIn.m_User.id.ToString();
            account.macAddress = PCUtil.getMacAddr_Local();
            if (m_promotion_Member != null)
            {
                account.promotionMemberId = m_promotion_Member.CI_CardNo;
                account.promotionAmount = discount_money;
            }
            if (m_Member != null)
                account.memberId = memberCardUsingForm.m_member.CI_CardNo;

            account.creditCard = Convert.ToInt32(moneyPayable.Text);
            db.Account.InsertOnSubmit(account);

            db.SubmitChanges();

            var orderList = db.Orders.Where(x => x.systemId == m_Seat.systemId && !x.paid);
            foreach (Orders order in orderList)
            {
                order.paid = true;
                order.accountId = account.id;
            }

            m_Seat.status = 3;
            var room = db.Room.FirstOrDefault(x => x.seat == m_Seat.text);
            if (room != null)
                room.status = "等待清洁";

            insert_member_infor(account);
            db.SubmitChanges();

            var act_old = dc.Account.FirstOrDefault(x => x.systemId == m_Seat.systemId && x.abandon != null);
            if (act_old == null)
            {
                printTool_Click("结账单");
                printTool_Click("存根单");
            }
            else
            {
                printTool_Click("补救单");
            }

            var act = dc.Account.FirstOrDefault(x => x.systemId == m_Seat.systemId && x.abandon == null);
        }
        //发送消息给鞋部
        private void sendMessageToShoes(Account account)
        {
            if (db.Options.Count() == 0)
                return;

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

            ShoeMsg msg = new ShoeMsg();
            msg.text = account.text;
            msg.payEmployee = account.payEmployee;
            msg.payTime = account.payTime;
            msg.processed = false;
            db.ShoeMsg.InsertOnSubmit(msg);
            db.SubmitChanges();
        }
        //插入账单数据库
        private void insert_account(ref Account account, string name)
        {
            account.text = m_Seat.text;
            account.systemId = m_Seat.systemId;
            account.openTime = m_Seat.openTime.ToString();
            account.openEmployee = m_Seat.openEmployee;
            account.payTime = DateTime.Now;
            account.payEmployee = LogIn.m_User.id;
            account.server = BathClass.get_seat_expense(m_Seat, LogIn.connectionString);
            account.serverEmployee = name;
            account.macAddress = PCUtil.getMacAddr_Local();

            db.Account.InsertOnSubmit(account);
            db.SubmitChanges();
        }
        //插入会员消费记录
        private void insert_member_infor(Account account)
        {
            double account_money = BathClass.get_account_money(account);
            if (m_promotion_Member != null)
            {
                CardCharge cc = new CardCharge();
                cc.CC_CardNo = m_promotion_Member.CI_CardNo;
                cc.CC_AccountNo = account.id.ToString();
                cc.CC_ItemExplain = "会员打折";
                cc.expense = account_money;
                cc.CC_InputOperator = LogIn.m_User.id.ToString();
                cc.CC_InputDate = DateTime.Now;
                db.CardCharge.InsertOnSubmit(cc);
            }

            if (m_Member != null)
            {
                CardCharge cc = new CardCharge();
                cc.CC_CardNo = m_Member.CI_CardNo;
                cc.CC_AccountNo = account.id.ToString();
                cc.CC_ItemExplain = "会员刷卡";
                cc.CC_LenderSum = account.creditCard;
                cc.expense = account_money;
                cc.CC_InputOperator = LogIn.m_User.id.ToString();
                cc.CC_InputDate = DateTime.Now;
                db.CardCharge.InsertOnSubmit(cc);
                db.SubmitChanges();
            }
            //db.SubmitChanges();
        }
 partial void DeleteAccount(Account instance);
 partial void UpdateAccount(Account instance);
 partial void InsertAccount(Account instance);
Exemple #13
0
        public static void Print_DataGridView(Account acctount, string title,
            DataGridView dgv, List<string> printCols, string coName)
        {
            PrintPreviewDialog ppvw;
            try
            {
                printer = printDoc.PrinterSettings.PrinterName;
                if (printer == "δ����Ĭ�ϴ�ӡ��")
                {
                    BathClass.printErrorMsg("δ����Ĭ�ϴ�ӡ��");
                    return;
                }
                //if (printer == "")
                //{
                //    PrinterChooseForm printerChooseForm = new PrinterChooseForm();
                //    if (printerChooseForm.ShowDialog() != DialogResult.OK)
                //        return;
                //    printer = printerChooseForm.printer;
                //}

                // Getting DataGridView object to print
                //m_Seat = seat;
                m_Act = acctount;
                m_dgv = dgv;
                m_cols = printCols;
                m_Money = BathClass.get_account_money(m_Act).ToString();
                printTile = title;

                DashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                companyName = coName;
                printDoc.PrinterSettings.PrinterName = printer;
                printDoc.DefaultPageSettings.Margins.Left = 10;
                printDoc.DefaultPageSettings.Margins.Right = 10;
                printDoc.DefaultPageSettings.Margins.Top = 0;
                printDoc.DefaultPageSettings.Margins.Bottom = 30;

                PrintController printController = new StandardPrintController();
                printDoc.PrintController = printController;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #14
0
        //获取账单金额
        public static double get_account_money(Account account)
        {
            double money = 0;
            money += MConvert<double>.ToTypeOrDefault(account.cash, 0);
            money += MConvert<double>.ToTypeOrDefault(account.bankUnion ,0);
            money += MConvert<double>.ToTypeOrDefault(account.creditCard, 0);
            money += MConvert<double>.ToTypeOrDefault(account.coupon, 0);
            money += MConvert<double>.ToTypeOrDefault(account.groupBuy, 0);
            money += MConvert<double>.ToTypeOrDefault(account.zero, 0);
            money += MConvert<double>.ToTypeOrDefault(account.server, 0);
            money -= MConvert<double>.ToTypeOrDefault(account.changes, 0);
            money += MConvert<double>.ToTypeOrDefault(account.wipeZero, 0);

            return money;
        }