private void bbiInMaVach_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (dsDanhSachHangHoa.InMaVach.Rows.Count <= 0) { XtraMessageBox.Show("Không có dữ liệu để in.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DataTable dtInMaVach = new DataTable(); dtInMaVach = dsDanhSachHangHoa.InMaVach.Copy(); dtInMaVach.Rows.Clear(); foreach (DataRow drDong in dsDanhSachHangHoa.InMaVach) { for(int i = 0; i < Convert.ToInt32(drDong[colSoLuongTem.FieldName]); i++) { DataRow drDongIn = dtInMaVach.NewRow(); drDongIn[colMaVach.FieldName] = drDong[colMaVach.FieldName]; drDongIn[colTenHang.FieldName] = drDong[colTenHang.FieldName]; drDongIn[colTongTrongLuong.FieldName] = drDong[colTongTrongLuong.FieldName]; drDongIn[colTrongLuong.FieldName] = drDong[colTrongLuong.FieldName]; drDongIn[colTienCong.FieldName] = drDong[colTienCong.FieldName]; drDongIn[colHot.FieldName] = drDong[colHot.FieldName]; drDongIn[colLoaiVang.FieldName] = drDong[colLoaiVang.FieldName]; drDongIn[colNhaCungCap.FieldName] = drDong[colNhaCungCap.FieldName]; drDongIn[colHamLuongPho.FieldName] = drDong[colHamLuongPho.FieldName]; drDongIn[colSoLuongTem.FieldName] = drDong[colSoLuongTem.FieldName]; dtInMaVach.Rows.Add(drDongIn); dtInMaVach.AcceptChanges(); } } var rpt = new rptInMaVach(dtInMaVach, txtTenDoanhNghiep.Text, txtDiaChi.Text); if (XtraMessageBox.Show("Bạn có muốn nạp lại vị trí từ file vị trí không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "(*.repx)|*.pepx;|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.Multiselect = false; // Call the ShowDialog method to show the dialog box. if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) return; string path = openFileDialog1.FileName; //PrintingSystem ps = new PrintingSystem(); //// Load the document from a file. //ps.LoadDocument(path); //// Create an instance of the preview dialog. //PrintPreviewFormEx preview = new PrintPreviewFormEx(); //// Load the report document into it. //preview.PrintingSystem = ps; //// Show the preview dialog. //preview.Show(); rpt.LoadLayout(path); } rpt.AssignPrintTool(new ReportPrintTool(rpt)); rpt.CreateDocument(); rpt.ShowPreview(); }
private void btnIn_Click(object sender, EventArgs e) { //DataTable dtInMaVach = new DataTable(); //for (int i = 0; i < Convert.ToInt32(txtSoLuongTem.Value); i++) //{ // DataRow drDongIn = dtInMaVach.NewRow(); // drDongIn["MaVach"] = txtMaVach.Text; // drDongIn["TenHang"] = txtTenHang.Text; // drDongIn["TongTrongLuong"] = txtTongTrongLuong.Value; // drDongIn["TrongLuong"] = txtTrongLuong.Value; ; // drDongIn["TienCong"] = txtTienCong.Value; // drDongIn["Hot"] = txtHot.Value; // drDongIn["LoaiVang"] = ""; // drDongIn["NhaCungCap"] = txtNhaCungCap.Text; // drDongIn["HamLuongPho"] = txtHamLuongPho.Text; // drDongIn["SoLuongTem"] = txtSoLuongTem.Value; // dtInMaVach.Rows.Add(drDongIn); // dtInMaVach.AcceptChanges(); //} //var rptMaVach = new rptInMaVach(dtInMaVach, tenTiem); var rptMaVach = new rptInMaVach(tenTiem, diaChi, txtMaVach.Text, txtTenHang.Text, txtTongTrongLuong.Value, txtTongTrongLuong.Value, txtTienCong.Value, txtHot.Value, "", txtNhaCungCap.Text, txtHamLuongPho.Text, Convert.ToInt32(txtSoLuongTem.Value)); rptMaVach.AssignPrintTool(new ReportPrintTool(rptMaVach)); rptMaVach.CreateDocument(); rptMaVach.ShowPreview(); }