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

📄 form1.cs

📁 会员管理系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using com.sungoal.MemberManage.Common;
using System.Text;
using com.sungoal.MemberManage.DataAccess;
using System.Data.OleDb;

namespace test
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.RichTextBox richTextBox1;
		private System.Windows.Forms.DataGrid dataGrid1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.richTextBox1 = new System.Windows.Forms.RichTextBox();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(208, 16);
			this.button1.Name = "button1";
			this.button1.TabIndex = 0;
			this.button1.Text = "button1";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// richTextBox1
			// 
			this.richTextBox1.Location = new System.Drawing.Point(8, 48);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(592, 120);
			this.richTextBox1.TabIndex = 2;
			this.richTextBox1.Text = "richTextBox1";
			// 
			// dataGrid1
			// 
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(8, 176);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(592, 312);
			this.dataGrid1.TabIndex = 3;
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(608, 493);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.richTextBox1);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.Load += new System.EventHandler(this.Form1_Load);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			ReadCardData.ReadCardInfoDataTable dt=new ReadCardData().ReadCardInfo;

			DataRow row=dt.NewRow();
			row[0]=	"asdcasd";
			row[1]=	"12345";
			row[2]=	"2004-09-21";
			row[3]=	200.55;
			row[4]=	"2004-12-31";
			row[5]=	"1";
			row[6]=	"dsfjkdshfkjdshfkasjd";
			
			dt.Rows.Add(row);

			//row.

			string[] insert=OleDBHelper.GetInsertSql(dt,"ReadCardInfo");
			string[] update=OleDBHelper.GetUpdateSql(dt,"ReadCardInfo","CardID");
			string delete=OleDBHelper.GetDeleteSql(dt,"ReadCardInfo","CardID");
			int d,u=0,i;

			using (OleDbConnection conn = new OleDbConnection(AppConfiguration.GetConnectionString())) 
			{
				conn.Open();
				using (OleDbTransaction trans = conn.BeginTransaction()) 
				{
					try 
					{						
						d=OleDBHelper.ExecuteSQL(delete,trans);
						i=OleDBHelper.ExecuteSQL(insert,trans);
//						u=OleDBHelper.ExecuteSQL(insert,trans);
																						 
						trans.Commit();
					}
					catch
					{
						trans.Rollback();
						throw ;
					}
					finally
					{
						conn.Close();
					}
				}
			}

			DataTable ds;
			ds=new ReadCardDAL().GetReadCardByParam(new Hashtable());
			//ds=new BookShelfDAL().GetBookShelfInfoByUserID("1").Tables[0];
			dataGrid1.DataSource=ds;


			StringBuilder ss=new StringBuilder();
			foreach(DataColumn dc in dt.Columns)
				ss.Append(dc.DataType).Append(";");
			richTextBox1.Text=insert[0].ToString()+"\n"+"\n"+
							  update[0]+"\n"+"\n"+
							  delete+"\n"+"\n"+
							  d.ToString()+"\n"+i.ToString()+"\n"+u.ToString()+"\n"+"\n"+
							  ds.TableName;

						
			
		}

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

⌨️ 快捷键说明

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