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

📄 booklost.cs

📁 C#的图书管理系统,用ASP自己开发的系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(416, 48);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(72, 16);
			this.label6.TabIndex = 5;
			this.label6.Text = "内容简介:";
			// 
			// label5
			// 
			this.label5.Location = new System.Drawing.Point(216, 48);
			this.label5.Name = "label5";
			this.label5.Size = new System.Drawing.Size(64, 16);
			this.label5.TabIndex = 4;
			this.label5.Text = "出版社:";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 48);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(64, 16);
			this.label4.TabIndex = 3;
			this.label4.Text = "作者:";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(216, 24);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(72, 16);
			this.label3.TabIndex = 2;
			this.label3.Text = "图书名称:";
			// 
			// textBox1
			// 
			this.textBox1.Location = new System.Drawing.Point(72, 24);
			this.textBox1.Name = "textBox1";
			this.textBox1.Size = new System.Drawing.Size(120, 21);
			this.textBox1.TabIndex = 1;
			this.textBox1.Text = "";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 24);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(72, 16);
			this.label2.TabIndex = 0;
			this.label2.Text = "图书编号:";
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("SimSun", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
			this.label1.Location = new System.Drawing.Point(232, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(200, 24);
			this.label1.TabIndex = 9;
			this.label1.Text = "作 废 登 记  ";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(416, 320);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(64, 24);
			this.button2.TabIndex = 10;
			this.button2.Text = "作废处理";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(504, 320);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(64, 24);
			this.button3.TabIndex = 11;
			this.button3.Text = "遗失处理";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// button4
			// 
			this.button4.Location = new System.Drawing.Point(592, 320);
			this.button4.Name = "button4";
			this.button4.Size = new System.Drawing.Size(64, 24);
			this.button4.TabIndex = 12;
			this.button4.Text = "退  出";
			// 
			// booklost
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(664, 350);
			this.Controls.Add(this.button4);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.list);
			this.Controls.Add(this.groupBox1);
			this.Name = "booklost";
			this.Text = "图书处理";
			((System.ComponentModel.ISupportInitialize)(this.list)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			
			codeStr=null;
			nameStr=null;
			authorStr=null;
			pressStr=null;
			memotxtStr=null;
			costStr=null;
			outdateStr=null;
			ordernameStr=null;
			if (this.textBox1.Text !="") codeStr =" a.code like '%" + this.textBox1.Text.Trim() +"%'" ;
			if (this.textBox2.Text !="") nameStr =" a.name like '%" + this.textBox2.Text.Trim() +"%'" ;
			if (this.textBox3.Text !="") authorStr =" a.author like '%" + this.textBox3.Text.Trim() +"%'" ;
			if (this.textBox4.Text !="") pressStr =" a.press like '%" + this.textBox4.Text.Trim() +"%'" ;
			if (this.textBox5.Text !="") memotxtStr =" a.memotxt like '%" + this.textBox5.Text.Trim() +"%'" ;
			if (this.textBox6.Text !="") costStr =" a.cost " +this.comboBox2.Text +   Convert.ToInt32(textBox6.Text.Trim())   ;
			if (this.checkBox1.Checked==true) outdateStr =" a.outdate between '" + dtp1.Text +"' and '" +dtp2.Text +"'";
			if (this.comboBox1.Text.Trim()!="" ) 
			{
				try
				{
					string sql = "select * from orders where name='"+ comboBox1.SelectedItem.ToString().Trim() +"'";
					OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
					ds = new DataSet();
					ad.Fill(ds,"orders");
					if(ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count == 1)
					{
						DataRow row = ds.Tables[0].Rows[0];
						ordernameStr = " a.ordercode = " +  row["id"].ToString()  ;
					}
				}
				catch(Exception ex)
				{
					MessageBox.Show(ex.Message.ToString());
				}
				
			}
			LoadListForList();
		}
		public void LoadListForList()
		{
			try
			{
				string sqltem=" and ";
				if (this.codeStr !=null || this.nameStr !=null || this.authorStr!=null || this.pressStr!=null || this.outdateStr !=null || this.costStr !=null || this.ordernameStr!=null || this.memotxtStr !=null )
				{               
					if (this.codeStr !=null) sqltem=sqltem + this.codeStr;
					if (this.nameStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.nameStr;}
						else {sqltem=sqltem +" and "+ this.nameStr;}
					}
					if (this.authorStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.authorStr;}
						else {sqltem=sqltem +" and "+ this.authorStr;}
					}
					if (this.pressStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.pressStr;}
						else {sqltem=sqltem +" and "+ this.pressStr;}
					}
					if (this.outdateStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.outdateStr;}
						else {sqltem=sqltem +" and "+ this.outdateStr;}
					}
					if (this.costStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.codeStr;}
						else {sqltem=sqltem +" and "+ this.costStr;}
					}
					if (this.ordernameStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.ordernameStr;}
						else {sqltem=sqltem +" and "+ this.ordernameStr;}
					}
					if (this.memotxtStr !=null) 
					{
						if (sqltem==" and ")
						{ sqltem=sqltem + this.memotxtStr;}
						else {sqltem=sqltem +" and "+ this.memotxtStr;}
					}
				}
				else { sqltem="";}
				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.ordercode=b.id   " +sqltem +" order by a.code  ";
				ds = new DataSet();
				OleDbDataAdapter  ad = new OleDbDataAdapter(sql,Public.conn);
				ad.Fill( ds,"book");
				this.list.SetDataBinding(ds.Tables[0],"");  
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message.ToString());
				return;
			}
		}
		private void LoadSelectItem()
		{

			//载入类别
			DataSet ds1 = Public.GetDireItem( );
			if(ds1 != null)
			{
					this.comboBox1.Items.Add("");
				for(int i=0;i<ds1.Tables[0].Rows.Count;i++)
				{
					DataRow row = ds1.Tables[0].Rows[i];
					this.comboBox1.Items.Add(row["name"].ToString());
				}
				comboBox1.SelectedIndex=0;
			}
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			if(this.list.CurrentCell.RowNumber < this.ds.Tables[0].Rows.Count + 1)
			{ 
				for(int i=0;i<ds.Tables[0].Rows.Count ;i++)
				{
					if (this.list.IsSelected(i)==true)
					{
						whereStr =whereStr +"'"+ this.list[i,1].ToString() +"',";
					}
				}
				if (whereStr!=null)
				{
					whereStr=whereStr.Substring(0,whereStr.Length-1);
					if(MessageBox.Show("真的作废吗?","提示",MessageBoxButtons.YesNo)==DialogResult.Yes )
					{
						string sql=" update book set lost ='作废'where code in(" + whereStr + ")";
						Public.ExeSql(sql);
						MessageBox.Show ("作废处理成功!");
					}
					if(this.list.DataSource != null) {
						((DataTable)this.list.DataSource).Rows.Clear();
					    LoadListForList();}
				}
			}
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
			if(this.list.CurrentCell.RowNumber < this.ds.Tables[0].Rows.Count + 1)
			{ 
				for(int i=0;i<ds.Tables[0].Rows.Count ;i++)
				{
					if (this.list.IsSelected(i)==true)
					{
						whereStr =whereStr +"'"+ this.list[i,1].ToString() +"',";
					}
				}
				if (whereStr!=null)
				{
					whereStr=whereStr.Substring(0,whereStr.Length-1);
					if(MessageBox.Show("真的遗失了吗?","提示",MessageBoxButtons.YesNo)==DialogResult.Yes )
					{
						string sql=" update book set lost ='遗失'where code in(" + whereStr + ")";
						Public.ExeSql(sql);
						MessageBox.Show ("遗失处理成功!");
					}
					if(this.list.DataSource != null) 
					{
						((DataTable)this.list.DataSource).Rows.Clear();
						LoadListForList();}
				}
			}
		}
	}
}

⌨️ 快捷键说明

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