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

📄 checkbrowse.cs

📁 固定资产的终端程序!里面有对数据的处理。 好东西
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Lib;
using System.Data;
using System.Data.SqlServerCe;
namespace AssetCheck
{
	/// <summary>
	/// CheckBrowse 的摘要说明。
	/// </summary>
	public class CheckBrowse : System.Windows.Forms.Form
	{
		public Code code=new Code(false);
		public static int iPosition=0;
		public static CurrencyManager cmCheckbrowse;
		private System.Windows.Forms.Button btnExit;
		private System.Windows.Forms.Button btnDelete;
		private System.Windows.Forms.Label labPositionCheck;
		private System.Windows.Forms.Panel panel1;
		public System.Windows.Forms.TextBox txtStartDate;
		private System.Windows.Forms.Label label7;
		public System.Windows.Forms.TextBox txtManager;
		private System.Windows.Forms.Label label6;
		public System.Windows.Forms.TextBox txtStatus;
		private System.Windows.Forms.Label label5;
		public System.Windows.Forms.TextBox txtdepartment;
		private System.Windows.Forms.Label label4;
		public System.Windows.Forms.TextBox txtSpec;
		private System.Windows.Forms.Label label3;
		public System.Windows.Forms.TextBox txtName;
		private System.Windows.Forms.Label label1;
		public System.Windows.Forms.TextBox txtCode;
		private System.Windows.Forms.Label label2;
		public static DataTable dtCheckbrowse;
		public CheckBrowse()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();
            code.OnGetCode+=new Lib.Code.GetCode(code_OnGetCode);
			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.btnExit = new System.Windows.Forms.Button();
			this.btnDelete = new System.Windows.Forms.Button();
			this.labPositionCheck = new System.Windows.Forms.Label();
			this.panel1 = new System.Windows.Forms.Panel();
			this.txtStartDate = new System.Windows.Forms.TextBox();
			this.label7 = new System.Windows.Forms.Label();
			this.txtManager = new System.Windows.Forms.TextBox();
			this.label6 = new System.Windows.Forms.Label();
			this.txtStatus = new System.Windows.Forms.TextBox();
			this.label5 = new System.Windows.Forms.Label();
			this.txtdepartment = new System.Windows.Forms.TextBox();
			this.label4 = new System.Windows.Forms.Label();
			this.txtSpec = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.txtName = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.txtCode = new System.Windows.Forms.TextBox();
			this.label2 = new System.Windows.Forms.Label();
			// 
			// btnExit
			// 
			this.btnExit.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold);
			this.btnExit.Location = new System.Drawing.Point(122, 188);
			this.btnExit.Size = new System.Drawing.Size(119, 27);
			this.btnExit.Text = "0 .退出";
			this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
			// 
			// btnDelete
			// 
			this.btnDelete.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold);
			this.btnDelete.Location = new System.Drawing.Point(2, 188);
			this.btnDelete.Size = new System.Drawing.Size(119, 27);
			this.btnDelete.Text = "<--.删除";
			this.btnDelete.Click += new System.EventHandler(this.btnDelete_Click);
			// 
			// labPositionCheck
			// 
			this.labPositionCheck.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold);
			this.labPositionCheck.Location = new System.Drawing.Point(10, 2);
			this.labPositionCheck.Size = new System.Drawing.Size(230, 20);
			// 
			// panel1
			// 
			this.panel1.BackColor = System.Drawing.Color.Black;
			this.panel1.Location = new System.Drawing.Point(9, 27);
			this.panel1.Size = new System.Drawing.Size(234, 2);
			// 
			// txtStartDate
			// 
			this.txtStartDate.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtStartDate.Location = new System.Drawing.Point(49, 160);
			this.txtStartDate.Size = new System.Drawing.Size(191, 26);
			this.txtStartDate.Text = "";
			// 
			// label7
			// 
			this.label7.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label7.Location = new System.Drawing.Point(2, 165);
			this.label7.Size = new System.Drawing.Size(73, 19);
			this.label7.Text = "日期:";
			// 
			// txtManager
			// 
			this.txtManager.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtManager.Location = new System.Drawing.Point(49, 133);
			this.txtManager.Size = new System.Drawing.Size(80, 26);
			this.txtManager.Text = "";
			// 
			// label6
			// 
			this.label6.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label6.Location = new System.Drawing.Point(3, 138);
			this.label6.Size = new System.Drawing.Size(87, 19);
			this.label6.Text = "保管:";
			// 
			// txtStatus
			// 
			this.txtStatus.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtStatus.Location = new System.Drawing.Point(175, 132);
			this.txtStatus.Size = new System.Drawing.Size(64, 26);
			this.txtStatus.Text = "";
			// 
			// label5
			// 
			this.label5.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label5.Location = new System.Drawing.Point(130, 136);
			this.label5.Size = new System.Drawing.Size(72, 19);
			this.label5.Text = "状况:";
			// 
			// txtdepartment
			// 
			this.txtdepartment.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtdepartment.Location = new System.Drawing.Point(49, 106);
			this.txtdepartment.Size = new System.Drawing.Size(190, 26);
			this.txtdepartment.Text = "";
			// 
			// label4
			// 
			this.label4.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label4.Location = new System.Drawing.Point(3, 110);
			this.label4.Size = new System.Drawing.Size(72, 19);
			this.label4.Text = "部门:";
			// 
			// txtSpec
			// 
			this.txtSpec.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtSpec.Location = new System.Drawing.Point(49, 80);
			this.txtSpec.Size = new System.Drawing.Size(190, 26);
			this.txtSpec.Text = "";
			// 
			// label3
			// 
			this.label3.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label3.Location = new System.Drawing.Point(3, 84);
			this.label3.Size = new System.Drawing.Size(72, 19);
			this.label3.Text = "型号:";
			// 
			// txtName
			// 
			this.txtName.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtName.Location = new System.Drawing.Point(49, 54);
			this.txtName.Size = new System.Drawing.Size(190, 26);
			this.txtName.Text = "";
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label1.Location = new System.Drawing.Point(3, 57);
			this.label1.Size = new System.Drawing.Size(72, 19);
			this.label1.Text = "名称:";
			// 
			// txtCode
			// 
			this.txtCode.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.txtCode.Location = new System.Drawing.Point(49, 28);
			this.txtCode.Size = new System.Drawing.Size(190, 26);
			this.txtCode.Text = "";
			// 
			// label2
			// 
			this.label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold);
			this.label2.Location = new System.Drawing.Point(3, 32);
			this.label2.Size = new System.Drawing.Size(72, 19);
			this.label2.Text = "条码:";
			// 
			// CheckBrowse
			// 
			this.ClientSize = new System.Drawing.Size(242, 215);
			this.ControlBox = false;
			this.Controls.Add(this.txtStartDate);
			this.Controls.Add(this.label7);
			this.Controls.Add(this.txtManager);
			this.Controls.Add(this.label6);
			this.Controls.Add(this.txtStatus);
			this.Controls.Add(this.label5);
			this.Controls.Add(this.txtdepartment);
			this.Controls.Add(this.label4);
			this.Controls.Add(this.txtSpec);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.txtName);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtCode);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.btnExit);
			this.Controls.Add(this.btnDelete);
			this.Controls.Add(this.labPositionCheck);
			this.Controls.Add(this.panel1);
			this.Text = "盘点浏览";
			this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CheckBrowse_KeyDown);
			this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CheckBrowse_KeyPress);
			this.Load += new System.EventHandler(this.CheckBrowse_Load);
			this.Closed += new System.EventHandler(this.CheckBrowse_Closed);

		}
		#endregion

		private void CheckBrowse_Load(object sender, System.EventArgs e)
		{
			labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
			GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());
			code.Open();
		}

		private void CheckBrowse_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyData==Keys.Down)
			{
				if (cmCheckbrowse.Position < cmCheckbrowse.Count-1)
				{
					cmCheckbrowse.Position++;
					GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());//MessageBox.Show(ID.ToString());
					labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
				}
			}
			if (e.KeyData==Keys.Up)
			{
				if (cmCheckbrowse.Position > 0)
				{
					cmCheckbrowse.Position--;
					GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());//MessageBox.Show(ID.ToString());
					labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
				}
			}
			if (e.KeyData==Keys.Left)
			{
				cmCheckbrowse.Position = 0;
				GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());
				labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
			}
			if (e.KeyData==Keys.Right)
			{
				cmCheckbrowse.Position =cmCheckbrowse.Count-1;
				GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());
				labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
			}
		}
		public void GetResult(string id)
		{
			if (cmCheckbrowse.Count==0)
			{
				return;
			}
			SqlCeDataReader rdr=null;
			try
			{
				rdr=E.ExecRDR("select *  from Asset where BarCodes='"+id+"'");
				
				if (rdr!=null)
				{
					if (rdr.Read())
					{
						try
						{
							txtCode.Text=rdr.GetString(0).ToString();
							txtName.Text=rdr.GetString(1).ToString();
							txtSpec.Text=rdr.GetString(2).ToString();
							txtdepartment.Text=rdr.GetString(3).ToString();
							txtManager.Text=rdr.GetString(4).ToString();
							txtStartDate.Text=rdr.GetString(5).ToString();
							txtStatus.Text=rdr.GetString(6).ToString();
						}
						catch
						{
							E.Beep("",50,2670,2);
							E.MessageShow(true,"出现异常!"); 		
							return;
						}
					}
					else
					{
						E.Beep("",50,2670,2);
						E.MessageShow(true,"没有找到关于条码:"+txtCode.Text.Trim()+"的数据!"); 		
						return;
					}
				}
				else
				{
					E.Beep("",50,2670,2);
					E.MessageShow(true,"查找数据失败,请重新扫输入!"); 		
					return;
				}
			}
			catch 
			{}
			finally
			{
				if (rdr!=null)
					rdr.Dispose();
			}
		}
		public void txtClear()
		{
			txtCode.Text="";
			txtName.Text="";
			txtSpec.Text="";
			txtdepartment.Text="";
			txtManager.Text="";
			txtStatus.Text="";
			txtStartDate.Text="";
		}

		private void CheckBrowse_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
		{
			if (e.KeyChar==(char)8)
			{
				btnDelete_Click(sender,e);
			}
			if ((e.KeyChar==(char)27) )
			{
				this.Close();
			}
			if ((e.KeyChar==(char)48) )
			{
				this.Close();
			}
		}

		private void btnDelete_Click(object sender, System.EventArgs e)
		{
			if (cmCheckbrowse.Count==0)
			{
				E.Beep("",50,2670,2);
				E.MessageShow(true,"没有可以删除的数据!");
				return;
			}
			string strQuery="";
			strQuery="确实要删除条码为:'"+txtCode.Text.Trim()+"''的盘点信息吗?";
			E.Beep("",50,2670,2);
			E.MessageShow(false,strQuery);
			if (YNMessage.YN)
			{
				E.ExecSQL("update asset set UserID='0' where BarCodes='"+dtCheckbrowse.Rows[cmCheckbrowse.Position][0]+"'");
				dtCheckbrowse.Rows.RemoveAt(cmCheckbrowse.Position);
				try
				{
					if (cmCheckbrowse.Count==0)
					{
						txtClear();
						labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
					}
					else
					{
						GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());
						labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
					}
				}
				catch
				{}
			}
		}

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

		private void code_OnGetCode(string str)
		{
			try
			{
				//str=str.Trim().Substring(3,str.Trim().Length-3);
				if (str.Trim()!="")
				{
					object[] obj=new object[1];
					int i=new int();
					E.SetDataTableQualification(dtCheckbrowse,"BarCodes='"+str.Trim()+"'");
					cmCheckbrowse.Position=cmCheckbrowse.Position;
					if (cmCheckbrowse.Count==0)
					{
						E.Beep("",50,2670,2);
						E.MessageShow(true,"没有找到关于条码: "+str.Trim()+" 的数据!");
						//MessageBox.Show("没有找到关于条码: "+str.Trim()+" 的数据!");
						E.SetDataTableQualification(dtCheckbrowse,"");
						cmCheckbrowse.Position=cmCheckbrowse.Position;
						return;
					}
					else if(cmCheckbrowse.Count==1)
					{
						
						obj[0]=str.Trim();
						E.SetDataTableQualification(dtCheckbrowse,"");
						cmCheckbrowse.Position=cmCheckbrowse.Position;
						i=E.DataTableFind(dtCheckbrowse,obj);
						if (i!=-1)
						{
							cmCheckbrowse.Position=i;
							GetResult(dtCheckbrowse.Rows[cmCheckbrowse.Position][0].ToString());
							labPositionCheck.Text=Convert.ToString(cmCheckbrowse.Position+1)+"/"+cmCheckbrowse.Count.ToString();
						}
					}
				}
			}
			catch
			{}
		}

		private void CheckBrowse_Closed(object sender, System.EventArgs e)
		{
			code.Dispose();
		}
	}
}

⌨️ 快捷键说明

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