using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using RMReportEngine;
using RM.Interop.ReportMachine;

namespace RMDemo_CSharpe
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class FormUserPreview : System.Windows.Forms.Form
    {
		private System.Data.OleDb.OleDbConnection oleDbConnection1;
		private System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
		private System.Data.OleDb.OleDbCommand oleDbInsertCommand1;
		private System.Data.OleDb.OleDbCommand oleDbUpdateCommand1;
		private System.Data.OleDb.OleDbCommand oleDbDeleteCommand1;
		private System.Data.OleDb.OleDbDataAdapter oleDbDataAdapter1;
		private RMReportEngine.RMReport rmReport1;
        private System.Data.DataSet dataSet11;
        private AxRM.Interop.ReportMachine.AxRMReportPreviewX axRMReportPreviewX1;
        private Panel panel1;
        private Button button1;
		private System.ComponentModel.IContainer components;

		public FormUserPreview()
		{
			//
			// 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.components = new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormUserPreview));
            this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();
            this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
            this.oleDbInsertCommand1 = new System.Data.OleDb.OleDbCommand();
            this.oleDbUpdateCommand1 = new System.Data.OleDb.OleDbCommand();
            this.oleDbDeleteCommand1 = new System.Data.OleDb.OleDbCommand();
            this.oleDbDataAdapter1 = new System.Data.OleDb.OleDbDataAdapter();
            this.dataSet11 = new System.Data.DataSet();
            this.axRMReportPreviewX1 = new AxRM.Interop.ReportMachine.AxRMReportPreviewX();
            this.rmReport1 = new RMReportEngine.RMReport();
            this.panel1 = new System.Windows.Forms.Panel();
            this.button1 = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.axRMReportPreviewX1)).BeginInit();
            this.panel1.SuspendLayout();
            this.SuspendLayout();
            // 
            // oleDbConnection1
            // 
            this.oleDbConnection1.ConnectionString = resources.GetString("oleDbConnection1.ConnectionString");
            // 
            // oleDbSelectCommand1
            // 
            this.oleDbSelectCommand1.Connection = this.oleDbConnection1;
            // 
            // oleDbDataAdapter1
            // 
            this.oleDbDataAdapter1.DeleteCommand = this.oleDbDeleteCommand1;
            this.oleDbDataAdapter1.InsertCommand = this.oleDbInsertCommand1;
            this.oleDbDataAdapter1.SelectCommand = this.oleDbSelectCommand1;
            this.oleDbDataAdapter1.UpdateCommand = this.oleDbUpdateCommand1;
            // 
            // dataSet11
            // 
            this.dataSet11.DataSetName = "DataSet1";
            this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
            // 
            // axRMReportPreviewX1
            // 
            this.axRMReportPreviewX1.Dock = System.Windows.Forms.DockStyle.Bottom;
            this.axRMReportPreviewX1.Enabled = true;
            this.axRMReportPreviewX1.Location = new System.Drawing.Point(0, 52);
            this.axRMReportPreviewX1.Name = "axRMReportPreviewX1";
            this.axRMReportPreviewX1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axRMReportPreviewX1.OcxState")));
            this.axRMReportPreviewX1.Size = new System.Drawing.Size(648, 329);
            this.axRMReportPreviewX1.TabIndex = 1;
            this.axRMReportPreviewX1.OnBtnExitClick += new System.EventHandler(this.axRMReportPreviewX1_OnBtnExitClick);
            // 
            // panel1
            // 
            this.panel1.Controls.Add(this.button1);
            this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(648, 46);
            this.panel1.TabIndex = 2;
            this.panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.panel1_Paint);
            // 
            // button1
            // 
            this.button1.Location = new System.Drawing.Point(12, 12);
            this.button1.Name = "button1";
            this.button1.Size = new System.Drawing.Size(128, 23);
            this.button1.TabIndex = 1;
            this.button1.Text = "Show Report";
            this.button1.Click += new System.EventHandler(this.button1_Click_1);
            // 
            // FormUserPreview
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
            this.ClientSize = new System.Drawing.Size(648, 381);
            this.Controls.Add(this.panel1);
            this.Controls.Add(this.axRMReportPreviewX1);
            this.Name = "FormUserPreview";
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
            this.Text = "DataSet Demo";
            this.Load += new System.EventHandler(this.FormDataSet_Load);
            ((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.axRMReportPreviewX1)).EndInit();
            this.panel1.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
				
		}

		private void FormDataSet_Load(object sender, System.EventArgs e)
		{
			
		}

		private void axRMReportPreview1_Enter(object sender, System.EventArgs e)
		{
		
		}

        private void axRMReportPreviewX1_OnBtnExitClick(object sender, EventArgs e)
        {
            this.Close();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            this.dataSet11.Reset();

            this.oleDbDataAdapter1.SelectCommand.CommandText = "SELECT * from customer";
            this.oleDbDataAdapter1.Fill(this.dataSet11, "Customer");

            rmReport1.Init(this, TxRMReportType.rmrtReport);
            rmReport1.AddDataSet(this.dataSet11.Tables["Customer"], "db1");
            rmReport1.LoadFromFile("reports\\SimpleList.rmf");

            this.axRMReportPreviewX1.ShowToolbar = true;
            this.axRMReportPreviewX1.ConnectReport(rmReport1.GetReportComObject());
            rmReport1.ShowReport();
        }

	}
}
