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

📄 formlist.cs

📁 C#的图书管理系统,用ASP自己开发的系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data ;
using System.Data.OleDb ;
namespace bookmanager
{
	/// <summary>
	/// Summary description for FormList.
	/// </summary>
	public class FormList : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Button button2;
		public string codeStr  = null;   //书编号
		public string nameStr  = null;   //书名
		public string authorStr = null;   //作者
		public string pressStr   = null;   //出版社
		public string outdateStr  = null;   //出版时间
		public string costStr   = null;   //价格
		public string lostStr   = null;   //状态
		public string ordernameStr = null;   //类别
		public string memotxtStr      = null; //简介
		public string otherStr      = null; //简介
		public string autoId =null;
		private DataSet ds=null;
		private System.Windows.Forms.DataGrid list;  
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public FormList()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		 Public.SizeColumnsToContent(this.list,-1,ds.Tables[0],new string[]{"自动编号"});
            //LoadListForList();
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}
		public FormList(string str,bool okTrue)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.autoId =str;
			if(okTrue==true)
			{this.button1.Visible=true;}
			else
			{this.button1.Visible=false;}
			LoadListForList();
			Public.SizeColumnsToContent(this.list,-1,ds.Tables[0],new string[]{"自动编号"});
			//LoadListForList();
			//
			// 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 );
		}
		public void LoadListForList()
		{
			try
			{
				string sqltem ="";
				DataSet  ds1 = new DataSet();
	            sqltem=" select  code from lend where readerid ='" + this.autoId + "' and bakdate is null";
				Public.conn.Open();
				OleDbDataAdapter  ad = new OleDbDataAdapter(sqltem,Public.conn);
				ad.Fill( ds1,"book");
				sqltem ="(";
				if (ds1.Tables[0].Rows.Count  > 0) 
				{
						for(int i=0 ; i<ds1.Tables[0].Rows.Count  ;i++)
						{ sqltem=sqltem+" '"+ ds1.Tables[0].Rows[i][0].ToString() +"',";
                         
						}
                        sqltem=sqltem.Substring(0,sqltem.Length-1) +" )";
					if(this.list.DataSource != null) ((DataTable)this.list.DataSource).Rows.Clear();
					string sql = "select a.id as 自动编号,a.code as 编号,a.name as 名称,a.author as 作者,a.press as 出版社,a.outdate as 出版日期,a.memotxt as 内容简介,a.cost as 价格,a.lost as 状态,b.name as 图书类别  from book a,orders b  where a.lost='正常' and a.ordercode=b.id  and a.code in " + sqltem + " order by a.code  ";
				
					this.ds  = new DataSet();
					 ad = new OleDbDataAdapter(sql,Public.conn);
					 ad.Fill( this.ds,"book");
					Public.conn.Close();
					this.list.SetDataBinding(this.ds.Tables[0],"");
				}
			Public.conn.Close(); 
  
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message.ToString());
				Public.conn.Close();
				return;
			}
		}
		#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.list = new System.Windows.Forms.DataGrid();
			this.button1 = new System.Windows.Forms.Button();
			this.button2 = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.list)).BeginInit();
			this.SuspendLayout();
			// 
			// list
			// 
			this.list.CaptionVisible = false;
			this.list.DataMember = "";
			this.list.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.list.Location = new System.Drawing.Point(8, 8);
			this.list.Name = "list";
			this.list.ReadOnly = true;
			this.list.Size = new System.Drawing.Size(552, 256);
			this.list.TabIndex = 0;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(408, 272);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(72, 24);
			this.button1.TabIndex = 1;
			this.button1.Text = "确定";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(496, 272);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 24);
			this.button2.TabIndex = 2;
			this.button2.Text = "取消";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// FormList
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(568, 302);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.list);
			this.Name = "FormList";
			this.Text = "FormList";
			((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(this.list.CurrentCell.RowNumber < this.ds.Tables[0].Rows.Count + 1)
			{ 
               returnFrm.autoId = this.list[this.list.CurrentCell.RowNumber,0].ToString();
				for(int i=0;i<ds.Tables[0].Rows.Count ;i++)
				{
						if (this.list.IsSelected(i)==true)
						{
                          returnFrm.whereStr =returnFrm.whereStr +"'"+ this.list[i,1].ToString() +"',";
						}
				}
				if (returnFrm.whereStr!=null){returnFrm.whereStr=returnFrm.whereStr.Substring(0,returnFrm.whereStr.Length-1);}
				//leadfrm.DataBinder("");
             
				 this.Close();
			}
		}

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

⌨️ 快捷键说明

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