Пример #1
0
        private void btnPrintbill_Click(object sender, EventArgs e)
        {
            // update bill vao csdl sau khi thanh toan
            string table = txtSeat.Text;

            etBill.Id = getIDbillfromTable(table);
            DateTime datevalue = DateTime.Now;

            etBill.DateBill = datevalue.ToString("MM-dd-yyyy HH:mm:ss");
            etBill.IdTable  = txtSeat.Text;
            if (cbMember.Checked == true)
            {
                if ((txtmember.Tag + "") == "1")
                {
                    etBill.IdMember = busCus.GetValue("where PhoneNumber=N'" + txtmember.Text + "'", 0);
                }
                else
                {
                    MessageBox.Show("Bạn đã nhập sai thông tin thành viên!");
                    return;
                }
            }
            else
            {
                etBill.IdMember = "";
            }
            etBill.Status     = 1 + "";
            etBill.TotalPrice = outprice;
            busBill.UpdateBill(etBill);
            //update thong tin thanh vien vao csdl sau khi thanh toan
            if (cbDiscount.SelectedIndex != 0 && cbMember.Checked && (txtmember.Tag + "") == "1")
            {
                DataTable dt = busCus.CreateData("where PhoneNumber =N'" + txtmember.Text + "'");
                etCus.Id    = dt.Rows[0][0] + "";
                etCus.Name  = dt.Rows[0][1] + "";
                etCus.Phone = dt.Rows[0][4] + "";
                DateTime d  = Convert.ToDateTime(dt.Rows[0][2] + "");
                string   s1 = d.ToString("yyy-MM-dd");
                etCus.DOB   = s1;
                etCus.Sex   = dt.Rows[0][3] + "";
                etCus.Point = int.Parse(dt.Rows[0][5] + "") + Convert.ToInt32(outprice / 1000);
                MessageBox.Show(etCus.Phone + "  " + etCus.Point);
                busCus.UpdateCustomer(etCus);
            }
            {
            }
            try
            {
                PrintDialog   _PrintDialog   = new PrintDialog();
                PrintDocument _PrintDocument = new PrintDocument();
                _PrintDialog.Document     = _PrintDocument;                                                   //add the document to the dialog box
                _PrintDocument.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(CreateReceipt); //add an event handler that will do the printing
                //on a till you will not want to ask the user where to print but this is fine for the test envoironment.
                //DialogResult result = _PrintDialog.ShowDialog();

                //if (result == DialogResult.OK)
                {
                    _PrintDocument.Print();
                }
            }
            catch (Exception)
            {
            }
            RefreshForm();
        }