⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formprint.cs

📁 水晶报表使用例子
💻 CS
字号:
using System;
using System.IO;
using System.Text;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

namespace PrintApp
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		public CrystalDecisions.Windows.Forms.CrystalReportViewer ChangAnRPTtViewer;
		private System.Windows.Forms.Button btnFile;
		private System.Windows.Forms.Button btnPrintOutStorage;
		private System.Windows.Forms.Button btnPrintProduct;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private PrintApp.ChangAnRPT ddd;

		public Form1()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}
		
		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.ChangAnRPTtViewer = new CrystalDecisions.Windows.Forms.CrystalReportViewer();
			this.btnPrintOutStorage = new System.Windows.Forms.Button();
			this.btnFile = new System.Windows.Forms.Button();
			this.btnPrintProduct = new System.Windows.Forms.Button();
			this.SuspendLayout();
			// 
			// ChangAnRPTtViewer
			// 
			this.ChangAnRPTtViewer.ActiveViewIndex = -1;
			this.ChangAnRPTtViewer.DisplayGroupTree = false;
			this.ChangAnRPTtViewer.Location = new System.Drawing.Point(0, 3);
			this.ChangAnRPTtViewer.Name = "ChangAnRPTtViewer";
			this.ChangAnRPTtViewer.ReportSource = null;
			this.ChangAnRPTtViewer.ShowExportButton = false;
			this.ChangAnRPTtViewer.ShowTextSearchButton = false;
			this.ChangAnRPTtViewer.Size = new System.Drawing.Size(478, 357);
			this.ChangAnRPTtViewer.TabIndex = 0;
			// 
			// btnPrintOutStorage
			// 
			this.btnPrintOutStorage.Location = new System.Drawing.Point(6, 363);
			this.btnPrintOutStorage.Name = "btnPrintOutStorage";
			this.btnPrintOutStorage.Size = new System.Drawing.Size(150, 30);
			this.btnPrintOutStorage.TabIndex = 2;
			this.btnPrintOutStorage.Text = "打印出库";
			this.btnPrintOutStorage.Click += new System.EventHandler(this.btnPrint_Click);
			// 
			// btnFile
			// 
			this.btnFile.Location = new System.Drawing.Point(333, 363);
			this.btnFile.Name = "btnFile";
			this.btnFile.Size = new System.Drawing.Size(138, 30);
			this.btnFile.TabIndex = 3;
			this.btnFile.Text = "文件操作";
			this.btnFile.Click += new System.EventHandler(this.btnFile_Click);
			// 
			// btnPrintProduct
			// 
			this.btnPrintProduct.Location = new System.Drawing.Point(189, 363);
			this.btnPrintProduct.Name = "btnPrintProduct";
			this.btnPrintProduct.Size = new System.Drawing.Size(120, 30);
			this.btnPrintProduct.TabIndex = 4;
			this.btnPrintProduct.Text = "打印商品";
			this.btnPrintProduct.Click += new System.EventHandler(this.btnPrintProduct_Click);
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(481, 395);
			this.Controls.Add(this.btnPrintProduct);
			this.Controls.Add(this.btnFile);
			this.Controls.Add(this.btnPrintOutStorage);
			this.Controls.Add(this.ChangAnRPTtViewer);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void Form1_Load(object sender, System.EventArgs e)
		{
			ddd = new PrintApp.ChangAnRPT();
			ddd.SetConnectionInfo("IntelP4", "WMS", "sa", "");
		}

		private void btnPrint_Click(object sender, System.EventArgs e)
		{			
			ddd.PrintOutStoreLabel(ChangAnRPTtViewer);
		}

		private void btnPrintProduct_Click(object sender, System.EventArgs e)
		{
			ddd.PrintProductLabel(ChangAnRPTtViewer);
		}

		private void ReadIniData()
		{
			string sPath = "c:\\wms\\wms.ini"; 
			IniFile iniFile = new IniFile(sPath);
			StringBuilder temp = new StringBuilder(255); 
			int i = iniFile.GetPrivateProfileStringA("Section", "Key","", temp, 255, sPath);

			temp.ToString();
		}

		private void btnFile_Click(object sender, System.EventArgs e)
		{
			FileFun testFile = new FileFun();
			testFile.SetFilePath("C:\\Program Files\\Multdrop\\TEMP", "test.dat", "test.bak");            
			testFile.HandleFile();
			Path.ChangeExtension("C:\\Program Files\\Multdrop\\TEMP\\test.dat", ".bak");
		}
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -