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

📄 frmreadertype.cs

📁 采用C#和SQL Server 2000开发 功能比较全面的图书馆管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			// sqlDeleteCommand1
			// 
			this.sqlDeleteCommand1.CommandText = @"DELETE FROM 读者类型 WHERE (类型 = @Original_类型) AND (图书册书 = @Original_图书册书 OR @Original_图书册书 IS NULL AND 图书册书 IS NULL) AND (期刊册书 = @Original_期刊册书 OR @Original_期刊册书 IS NULL AND 期刊册书 IS NULL) AND (续借次数 = @Original_续借次数 OR @Original_续借次数 IS NULL AND 续借次数 IS NULL) AND (限制图书 = @Original_限制图书 OR @Original_限制图书 IS NULL AND 限制图书 IS NULL) AND (限制期刊 = @Original_限制期刊 OR @Original_限制期刊 IS NULL AND 限制期刊 IS NULL)";
			this.sqlDeleteCommand1.Connection = this.sqlConnection1;
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类型", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类型", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_图书册书", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "图书册书", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_期刊册书", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "期刊册书", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_续借次数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "续借次数", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_限制图书", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "限制图书", System.Data.DataRowVersion.Original, null));
			this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_限制期刊", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "限制期刊", System.Data.DataRowVersion.Original, null));
			// 
			// sqlConnection1
			// 
			this.sqlConnection1.ConnectionString = "workstation id=JEFF;packet size=4096;integrated security=SSPI;data source=JEFF;pe" +
				"rsist security info=False;initial catalog=libbook";
			// 
			// sqlInsertCommand1
			// 
			this.sqlInsertCommand1.CommandText = "INSERT INTO 读者类型(类型, 图书册书, 期刊册书, 续借次数, 限制图书, 限制期刊) VALUES (@类型, @图书册书, @期刊册书, @续借" +
				"次数, @限制图书, @限制期刊); SELECT 类型, 图书册书, 期刊册书, 续借次数, 限制图书, 限制期刊 FROM 读者类型 WHERE (类型 =" +
				" @类型)";
			this.sqlInsertCommand1.Connection = this.sqlConnection1;
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类型", System.Data.SqlDbType.VarChar, 20, "类型"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@图书册书", System.Data.SqlDbType.SmallInt, 2, "图书册书"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@期刊册书", System.Data.SqlDbType.SmallInt, 2, "期刊册书"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@续借次数", System.Data.SqlDbType.Int, 4, "续借次数"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@限制图书", System.Data.SqlDbType.Bit, 1, "限制图书"));
			this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@限制期刊", System.Data.SqlDbType.Bit, 1, "限制期刊"));
			// 
			// sqlSelectCommand1
			// 
			this.sqlSelectCommand1.CommandText = "SELECT 类型, 图书册书, 期刊册书, 续借次数, 限制图书, 限制期刊 FROM 读者类型";
			this.sqlSelectCommand1.Connection = this.sqlConnection1;
			// 
			// sqlUpdateCommand1
			// 
			this.sqlUpdateCommand1.CommandText = @"UPDATE 读者类型 SET 类型 = @类型, 图书册书 = @图书册书, 期刊册书 = @期刊册书, 续借次数 = @续借次数, 限制图书 = @限制图书, 限制期刊 = @限制期刊 WHERE (类型 = @Original_类型) AND (图书册书 = @Original_图书册书 OR @Original_图书册书 IS NULL AND 图书册书 IS NULL) AND (期刊册书 = @Original_期刊册书 OR @Original_期刊册书 IS NULL AND 期刊册书 IS NULL) AND (续借次数 = @Original_续借次数 OR @Original_续借次数 IS NULL AND 续借次数 IS NULL) AND (限制图书 = @Original_限制图书 OR @Original_限制图书 IS NULL AND 限制图书 IS NULL) AND (限制期刊 = @Original_限制期刊 OR @Original_限制期刊 IS NULL AND 限制期刊 IS NULL); SELECT 类型, 图书册书, 期刊册书, 续借次数, 限制图书, 限制期刊 FROM 读者类型 WHERE (类型 = @类型)";
			this.sqlUpdateCommand1.Connection = this.sqlConnection1;
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@类型", System.Data.SqlDbType.VarChar, 20, "类型"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@图书册书", System.Data.SqlDbType.SmallInt, 2, "图书册书"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@期刊册书", System.Data.SqlDbType.SmallInt, 2, "期刊册书"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@续借次数", System.Data.SqlDbType.Int, 4, "续借次数"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@限制图书", System.Data.SqlDbType.Bit, 1, "限制图书"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@限制期刊", System.Data.SqlDbType.Bit, 1, "限制期刊"));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_类型", System.Data.SqlDbType.VarChar, 20, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "类型", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_图书册书", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "图书册书", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_期刊册书", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "期刊册书", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_续借次数", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "续借次数", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_限制图书", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "限制图书", System.Data.DataRowVersion.Original, null));
			this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_限制期刊", System.Data.SqlDbType.Bit, 1, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "限制期刊", System.Data.DataRowVersion.Original, null));
			// 
			// dataSet11
			// 
			this.dataSet11.DataSetName = "DataSet1";
			this.dataSet11.Locale = new System.Globalization.CultureInfo("zh-CN");
			// 
			// frmReaderType
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(506, 294);
			this.Controls.Add(this.GroupBox1);
			this.Name = "frmReaderType";
			this.Controls.SetChildIndex(this.dgdList, 0);
			this.Controls.SetChildIndex(this.GroupBox1, 0);
			((System.ComponentModel.ISupportInitialize)(this.dgdList)).EndInit();
			this.GroupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataSet11)).EndInit();
			this.ResumeLayout(false);

		}		#endregion		public override void Prepare()
		{
			this.Text = "读者类型设置";
			Label1.Text = "类型";
			Label2.Visible =false;
			Label3.Visible = false;
			txbTwo.Visible = false;
			txbThree.Visible = false;
		}

		public override void LoadData()
		{
			string strFilter = "";
			if ( txbOne.Text.Trim().Length != 0 )
				strFilter =  "where 类型 like '%" +txbOne.Text.Trim() + "%'";
			dataSet11.Clear();
			sqlConnection1.ConnectionString = DataBase.sConn;
			sqlDataAdapter1.SelectCommand.CommandText = "select * from 读者类型  " + strFilter;
			sqlDataAdapter1.Fill( dataSet11 );
			dtData = dataSet11.Tables[ "读者类型" ];
			bmData = this.BindingContext[ dataSet11, "读者类型" ];
			if ( bmData.Count != 0 )
			{
				bmData.Position = 0;
			}
		}

		public override void SetDataGrid()
		{
			LoadData();
			DataGridTableStyle ts = new DataGridTableStyle();
			DataGridTextBoxColumn aCol;
			int numCols = dtData.Columns.Count;
			for ( int i = 0; i < numCols; i ++ )
			{
				aCol = new DataGridTextBoxColumn();
				aCol.MappingName = dtData.Columns[ i ].ColumnName;
				aCol.HeaderText = dtData.Columns[ i ].ColumnName;
				aCol.NullText = "";
				aCol.ReadOnly = true;
				ts.GridColumnStyles.Add( aCol );
			}
			ts.AlternatingBackColor = Color.LightGray;
			ts.AllowSorting = false;
			ts.MappingName = dtData.TableName;
			dgdList.TableStyles.Clear();
			dgdList.TableStyles.Add( ts );
			DataView dv = dtData.DefaultView;
			dv.AllowNew = false;
			dv.AllowDelete = false;
			dgdList.DataSource = dv;
			bmData = this.BindingContext[ dataSet11, "读者类型" ];
			lblCount.Text = "记录数:" + dtData.Rows.Count.ToString();
		}

		public override void SetTextBoxState(bool bState)
		{
			GroupBox1.Enabled = !bState;
		}
		public override void Clear()
		{
			txbBookCount.Text = "";
			txbMagzineCount.Text = "";
			txbTimes.Text = "";
			cbbBook.Checked = false;
			cbbMagzine.Checked = false;
		}

		public override void SaveForAdd()
		{
			DataRow dr = dataSet11.Tables[ "读者类型" ].NewRow();
			try
			{
				dr[ "类型" ] = txbType.Text.Trim();
				dr[ "图书册书" ] = txbBookCount.Text.Trim();
				dr[ "期刊册书" ] = txbMagzineCount.Text.Trim();
				dr[ "续借次数" ] = txbTimes.Text.Trim();
				dr[ "限制图书" ] = cbbBook.Checked.ToString();
				dr[ "限制期刊" ] = cbbMagzine.Checked.ToString();
			}
			catch ( Exception ex )
			{
				MessageBox.Show( ex.ToString() );
			}
			try
			{
				dataSet11.Tables[ "读者类型" ].Rows.Add( dr );
				if ( dataSet11.HasChanges() )
				{
					sqlDataAdapter1.Update( dataSet11 );
				}
			}
			catch ( Exception ex )
			{
				MessageBox.Show( ex.ToString() );
			}

		}
		public override void SaveForUpdate()
		{
			try
			{
				int row = dgdList.CurrentCell.RowNumber;
				dgdList.CurrentCell = new DataGridCell( ( row + 1 ) % bmData.Count, 0 );
				if ( dataSet11.HasChanges() )
					sqlDataAdapter1.Update( dataSet11 );
			}
			catch ( Exception ex )
			{
				MessageBox.Show( ex.ToString() );
			}
		}		public override void DeleteData()
		{
			try
			{
				dataSet11.Tables[ "读者类型" ].Rows[ bmData.Position ].Delete();
				if ( dataSet11.HasChanges() )
					sqlDataAdapter1.Update( dataSet11 );
			}
			catch ( Exception ex )
			{
				MessageBox.Show( ex.ToString() );
			}
		}	}}

⌨️ 快捷键说明

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