Пример #1
0
        /// <summary>
        /// 新建打印线程,不会卡主线程
        /// </summary>
        /// <param name="_print_bill">是否打印结账单</param>
        /// <param name="_print_stubBill">是否打印村跟单</param>
        /// <param name="_print_shoe">是否打印取鞋小票</param>
        /// <param name="seat_texts">需要取鞋的手牌号</param>
        /// <param name="_reprint">是否打印补救单</param>
        /// <param name="act">打印的账单</param>
        private void print_Bill(DataGridView dgv, bool _print_bill, bool _print_stubBill, bool _print_shoe, List<string> seat_texts, bool _reprint, CAccount act)
        {
            try
            {
                ////0编号,1结账,2单据号,3 手牌,4项目名称,5技师,6单位,7数量,8金额,9消费时间,10录入员工,11房间

                List<string> printCols = new List<string>();
                printCols.Add("手牌");
                if (use_pad)
                    printCols.Add("房间");
                printCols.Add("项目名称");
                printCols.Add("技师");
                printCols.Add("单价");
                printCols.Add("数量");
                printCols.Add("金额");

                var ids = string.Join("|", m_Seats.OrderBy(x => x.text).Select(x => x.systemId).ToArray());

                foreach (var s in m_Seats)
                {
                    m_rooms.Add(dao.get_seat_room(s.text));
                }

                if (MConvert<bool>.ToTypeOrDefault(LogIn.options.启用大项拆分, false))
                {
                    var dgv1 = new_datagridView();
                    var db = new BathDBDataContext(LogIn.connectionString);
                    foreach (DataGridViewRow r in dgv.Rows)
                    {
                        string menuName = MConvert<string>.ToTypeOrDefault(r.Cells[2].Value, "");
                        var dgv_menu = db.Menu.FirstOrDefault(x => x.name == menuName);
                        if (dgv_menu != null)
                        {
                            if (db.BigCombo.FirstOrDefault(x => x.menuid == dgv_menu.id) != null)
                            {
                                var substIDs = BathClass.disAssemble(db.BigCombo.FirstOrDefault(x => x.menuid == dgv_menu.id).substmenuid, Constants.SplitChar);
                                for (int i = 0; i < substIDs.Count; i++)
                                {
                                    var menu = db.Menu.FirstOrDefault(x => x.id == substIDs[i]);
                                    dgv1.Rows.Add(r.Cells[0].Value, r.Cells[1].Value, menu.name, r.Cells[3].Value,
                                        menu.price, r.Cells[5].Value, menu.price * MConvert<double>.ToTypeOrDefault(r.Cells[5].Value, 0));
                                }
                                continue;
                            }
                        }

                        dgv1.Rows.Add(r.Cells[0].Value, r.Cells[1].Value, r.Cells[2].Value, r.Cells[3].Value,
                                r.Cells[4].Value, r.Cells[5].Value, r.Cells[6].Value);
                    }

                    if (_print_bill)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "结账单", dgv1, printCols, companyName);
                    if (_print_stubBill)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "存根单", dgv1, printCols, companyName);
                    if (_reprint)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "补救单", dgv1, printCols, companyName);
                    dgv = null;
                    dgv1 = null;
                }
                else
                {
                    if (_print_bill)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "结账单", dgv, printCols, companyName);
                    if (_print_stubBill)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "存根单", dgv, printCols, companyName);
                    if (_reprint)
                        PrintBill.Print_DataGridView(m_Seats, m_rooms, act, "补救单", dgv, printCols, companyName);
                    dgv = null;
                }

                if (_print_shoe)
                    PrintShoeMsg.Print_DataGridView(seat_texts, act.payEmployee, act.payTime.ToString(), companyName);
            }
            catch (System.Exception e)
            {
                BathClass.printErrorMsg(e.Message);
            }
        }
Пример #2
0
        //发送消息给鞋部
        private void sendMessageToShoes(CAccount account)
        {
            var pars = new List<string>();
            pars.Add("text");
            pars.Add("payEmployee");
            pars.Add("payTime");
            pars.Add("processed");

            var vals = new List<string>();
            vals.Add(account.text);
            vals.Add(account.payEmployee);
            vals.Add(account.payTime.ToString());
            vals.Add("False");

            dao.insert_table_row("ShoeMsg", pars, vals);
        }
Пример #3
0
        public CAccount get_account(string state_str)
        {
            CAccount account = null;
            SqlConnection sqlCn = null;
            string cmd_str = "";

            try
            {
                sqlCn = new SqlConnection(_con_str);
                sqlCn.Open();

                cmd_str = "Select * from [Account] where (" + state_str + ")";
                SqlCommand cmdSelect = new SqlCommand(cmd_str, sqlCn);
                using (SqlDataReader dr = cmdSelect.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        account = new CAccount();

                        account.id = (int)dr["id"];
                        account.text = dr["text"].ToString();
                        account.systemId = dr["systemId"].ToString();
                        account.openTime = dr["openTime"].ToString();
                        account.openEmployee = dr["openEmployee"].ToString();
                        account.payTime = (DateTime)dr["payTime"];
                        account.payEmployee = dr["payEmployee"].ToString();
                        account.name = dr["name"].ToString();
                        account.promotionMemberId = dr["promotionMemberId"].ToString();
                        account.promotionAmount = ToDouble(dr["promotionAmount"]);
                        account.memberId = dr["memberId"].ToString();
                        account.serverEmployee = dr["serverEmployee"].ToString();
                        account.cash = ToDouble(dr["cash"]);
                        account.bankUnion = ToDouble(dr["bankUnion"]);
                        account.creditCard = ToDouble(dr["creditCard"]);
                        account.coupon = ToDouble(dr["coupon"]);
                        account.groupBuy = ToDouble(dr["groupBuy"]);
                        account.zero = ToDouble(dr["zero"]);
                        account.server = ToDouble(dr["server"]);
                        account.changes = ToDouble(dr["changes"]);
                        account.wipeZero = ToDouble(dr["wipeZero"]);
                        account.macAddress = dr["macAddress"].ToString();
                        account.abandon = dr["abandon"].ToString();
                        account.departmentId = ToInt(dr["departmentId"]);

                        break;
                    }
                }

            }
            catch (System.Exception e)
            {
                IOUtil.insert_file(DateTime.Now.ToString() + "=" + cmd_str);
                BathClass.printErrorMsg(e.Message);
            }
            finally
            {
                close_connection(sqlCn);
            }

            return account;
        }
Пример #4
0
        public static void Print_DataGridView(List<CSeat> seats, List<string> room, CAccount acctount, string title,
            DataGridView dgv, List<string> printCols, string coName)
        {
            PrintPreviewDialog ppvw;
            try
            {
                printer = printDoc.PrinterSettings.PrinterName;
                if (printer == "δ����Ĭ�ϴ�ӡ��")
                {
                    BathClass.printErrorMsg("δ����Ĭ�ϴ�ӡ��");
                    return;
                }
                m_seats = seats;
                m_room = room;
                m_Act = acctount;
                m_dgv = dgv;
                m_cols = printCols;
                tmpTop = 0;
                m_Money = BathClass.get_account_money(m_Act).ToString();
                printTile = title;

                BathDBDataContext dc = null;
                if (m_Act.memberId != null)
                {
                    card_info = new Dictionary<string, string>();
                    dc = new BathDBDataContext(LogIn.connectionString);
                    string[] cardNoList = m_Act.memberId.Split('|');

                    foreach (var cardNo in cardNoList)
                    {
                        card_info[cardNo] = BathClass.get_member_balance(dc, cardNo).ToString();
                    }
                }

                DashPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
                companyName = coName;
                printDoc.PrinterSettings.PrinterName = printer;
                printDoc.OriginAtMargins = true;
                printDoc.DefaultPageSettings.Margins.Left = 3;
                printDoc.DefaultPageSettings.Margins.Right = 3;
                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);
            }
        }
Пример #5
0
        //获取账单金额
        public static double get_account_money(CAccount 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;
        }