Example #1
0
        //重打账单
        private void CtxReprint_Click(object sender, EventArgs e)
        {
            BathDBDataContext db_new = new BathDBDataContext(LogIn.connectionString);
            var seat = getContextSenderSeat(db_new, sender);

            if (seat.systemId == null || seat.status != 3)
            {
                BathClass.printErrorMsg("已经重新开牌,不能重打账单!");
                return;
            }

            var account = db_new.Account.FirstOrDefault(x => x.systemId.Contains(seat.systemId) && x.abandon == null);

            DataGridView dgv = new DataGridView();

            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();

            col.HeaderText = "手牌号";
            dgv.Columns.Add(col);

            DataGridViewTextBoxColumn col1 = new DataGridViewTextBoxColumn();

            col1.HeaderText = "项目名称";
            dgv.Columns.Add(col1);

            DataGridViewTextBoxColumn col2 = new DataGridViewTextBoxColumn();

            col2.HeaderText = "技师";
            dgv.Columns.Add(col2);

            DataGridViewTextBoxColumn col3 = new DataGridViewTextBoxColumn();

            col3.HeaderText = "单价";
            dgv.Columns.Add(col3);

            DataGridViewTextBoxColumn col4 = new DataGridViewTextBoxColumn();

            col4.HeaderText = "数量";
            dgv.Columns.Add(col4);

            DataGridViewTextBoxColumn col5 = new DataGridViewTextBoxColumn();

            col5.HeaderText = "金额";
            dgv.Columns.Add(col5);

            List <string> printCols = new List <string>();

            printCols.Add("手牌");
            printCols.Add("项目名称");
            printCols.Add("技师");
            printCols.Add("单价");
            printCols.Add("数量");
            printCols.Add("金额");

            var co_name = db_new.Options.FirstOrDefault().companyName;

            if (account != null)
            {
                var ids    = account.systemId.Split('|');
                var orders = db_new.HisOrders.Where(x => ids.Contains(x.systemId) && x.paid && x.deleteEmployee == null);
                foreach (var order in orders)
                {
                    string[] row = new string[6];
                    row[0] = order.text;
                    row[1] = order.menu;
                    row[2] = order.technician;

                    var menu = db_new.Menu.FirstOrDefault(x => x.name == order.menu);
                    if (menu != null)
                    {
                        row[3] = menu.price.ToString();
                    }

                    row[4] = order.number.ToString();
                    row[5] = order.money.ToString();
                    dgv.Rows.Add(row);
                }
                PrintBill.Print_DataGridView(account, "存根单", dgv, printCols, co_name);
            }
            else
            {
                var orders = db_new.Orders.Where(x => x.text == seat.text && !x.paid && x.deleteEmployee == null);
                foreach (var order in orders)
                {
                    string[] row = new string[6];
                    row[0] = order.text;
                    row[1] = order.menu;
                    row[2] = order.technician;

                    var menu = db_new.Menu.FirstOrDefault(x => x.name == order.menu);
                    if (menu != null)
                    {
                        row[3] = menu.price.ToString();
                    }

                    row[4] = order.number.ToString();
                    row[5] = order.money.ToString();
                    dgv.Rows.Add(row);
                }

                var money = BathClass.get_cur_orders_money(orders, LogIn.connectionString, BathClass.Now(LogIn.connectionString));
                List <HotelRoom> seats = new List <HotelRoom>();
                seats.Add(seat);
                PrintSeatBill.Print_DataGridView(seats, "转账确认单", dgv, printCols, money.ToString(), co_name);
            }
        }