示例#1
0
 public ReportViewer(reportHoaDon reportHoaDon) : this()
 {
     this.reportHoaDon = reportHoaDon;
     //reportHoaDon.CreateDocument();
     documentViewer1.DocumentSource = reportHoaDon;
     documentViewer1.Zoom           = 0.83f;
 }
示例#2
0
        private void showpreviewHoaDon(object editValue)
        {
            int  temp;
            bool kq = int.TryParse(editValue.ToString(), out temp);

            if (!kq)
            {
                btnPDF.Enabled = false;
                return;
            }
            var          temp2 = db.CTHoaDons.Where(x => x.HoaDonBanId == temp).ToList();
            reportHoaDon rp    = new reportHoaDon(temp2);

            documentViewer1.DocumentSource = rp;
            rp.Nap = false;
            rpF    = rp;
            rp.CreateDocument(false);
        }
        private void toolStripTrangIn_Click(object sender, EventArgs e)
        {
            //Microsoft.Office.Interop.Excel._Application app = new Microsoft.Office.Interop.Excel.Application();
            //Microsoft.Office.Interop.Excel._Workbook workbook = app.Workbooks.Add(Type.Missing);
            //Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
            //worksheet = workbook.Sheets["Sheet1"];
            //worksheet = workbook.ActiveSheet;
            //app.Visible = true;
            //// Dua du lieu vao excel
            //worksheet.Cells[1, 4] = "Bảng Thống Kê Hóa Đơn";
            //worksheet.Cells[2, 3] = "";
            //worksheet.Cells[3, 1] = "STT";
            //worksheet.Cells[3, 2] = "Mã Hóa Đơn";
            //worksheet.Cells[3, 3] = "Mã Nhân Viên";
            //worksheet.Cells[3, 4] = "Khách Hàng";
            //worksheet.Cells[3, 5] = "Mã Phiếu Thuê";
            //worksheet.Cells[3, 6] = "Tiền Phòng";
            //worksheet.Cells[3, 7] = "Số Ngày Thuê";
            //worksheet.Cells[3, 8] = "Tổng Tiền";
            //worksheet.Cells[3, 9] = "Ngày Lập Hóa Đơn";

            //for (int i = 0; i < dataGridViewX1.RowCount; i++)
            //{
            //    for (int j = 0; j < 8; j++)
            //    {
            //        worksheet.Cells[i + 4, 1] = i + 1;
            //        worksheet.Cells[i + 4, j + 2] = dataGridViewX1.Rows[i].Cells[j].Value;
            //    }
            //}
            //int dem = dataGridViewX1.RowCount;



            //// Định dạng trang
            //worksheet.PageSetup.Orientation = Microsoft.Office.Interop.Excel.XlPageOrientation.xlPortrait;
            //worksheet.PageSetup.PaperSize = Microsoft.Office.Interop.Excel.XlPaperSize.xlPaperA4;
            //worksheet.PageSetup.LeftMargin = 0;
            //worksheet.PageSetup.RightMargin = 0;
            //worksheet.PageSetup.TopMargin = 0;
            //worksheet.PageSetup.BottomMargin = 0;

            //// Đinh dạng cột
            //worksheet.Range["A1"].ColumnWidth = 20;
            //worksheet.Range["B1"].ColumnWidth = 45;
            //worksheet.Range["C1"].ColumnWidth = 49;
            //worksheet.Range["D1"].ColumnWidth = 33;
            //worksheet.Range["E1"].ColumnWidth = 31;
            //worksheet.Range["F1"].ColumnWidth = 52;
            //worksheet.Range["G1"].ColumnWidth = 23;
            //worksheet.Range["H1"].ColumnWidth = 22;
            //worksheet.Range["I1"].ColumnWidth = 45;

            //// Định dạng font chữ
            //worksheet.Range["A1", "J100"].Font.Name = "Times New Roman";
            //worksheet.Range["A1", "A100"].Font.Size = 24;
            //worksheet.Range["A3", "J100"].Font.Size = 16;
            //worksheet.Range["A1", "J1"].MergeCells = true;
            //worksheet.Range["A1", "J1"].Font.Bold = true;

            ////worksheet.Range["A3", "J3"].MergeCells = true;
            //worksheet.Range["A3", "J3"].Font.Bold = true;

            //// kẻ bảng
            //worksheet.Range["A3", "J" + (dem + 3)].Borders.LineStyle = 1;


            ////Định dạng dòng text
            //worksheet.Range["A1", "J1"].HorizontalAlignment = 3;
            //worksheet.Range["A3", "J3"].HorizontalAlignment = 3;
            //worksheet.Range["A4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["B4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["C4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["D4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["E4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["F4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["G4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["H4", "J" + (dem + 4)].HorizontalAlignment = 3;
            //worksheet.Range["I4", "J" + (dem + 4)].HorizontalAlignment = 3;
            reportHoaDon f = new reportHoaDon();

            f.ShowDialog();
        }