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

📄 factory.cs

📁 WINCE数据库sqlce 通讯stock 代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
		public void ScanKeys(object o, EventArgs e)
		{
			g_mi.Update();
			if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey8)) //执行扫描过程
			{
				MessageBOX.Text = "";
				if(ScanSize<40)
				{
					gScanner.TriggerScanner();
					Thread.Sleep(2000);
					
				}

				if(ScanSize>40)
				{
					Singularity();//异常信息的处理
					ScanData="";
					ScanSize=0;
					//return;
				}
				if(ScanSize==40)
				{				
					ScanData="";
					ScanSize=0;
					gScanner.TriggerScanner();
				}
			}
			if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey6))  //从工厂下载配额
			{				
				TPanel.Bounds=new Rectangle(27,24,184,104);
				TPanel.Visible=true;
			
			}

			if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey7))
			{
				

			}
			if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey5))//执行交易选择
			{
				MessageBOX.Text="";

				if(Edit()==true)  //判断交易信息是否完整
					return;

				if (MBID =="OK")
				{
					Manual();//执行手动交易过程

					MBID = null; //判断是手动交易还是扫描交易

					THID = null; //手动输入时获取的产品ID

					PKID = null; //手动输入时获取的产品包装层次ID

					LGSL = 0.0; //手动输入信息时获取产品基类包装数量

					
					TBox_ClientID.Items.Clear();
					TBox_ThName.Items.Clear();
					Clear(); //清屏
					Choose();
					Thread.Sleep(2000);

				}
				else if(MBID =="NO")
				{
					Scan();
					TBox_ClientID.Items.Clear();
					TBox_ThName.Items.Clear();
					Clear();//清屏
					MBID = "OK";
					Choose();
					Thread.Sleep(2000);
				}
				Thread.Sleep(2000);
				
			}
			if(g_mi.KeyPressed((int)Keys.Down)) //执行手动选择
			{
			}
		}

		//-------------------------ZJNET ADD 手动选择(2005.9.5)-----------------------------
		private void Choose()
		{
			string SqlText;

			if (MBID == "OK")
			{
				CEData lo;
				lo=new CEData();
				SqlCeConnection conn=lo.conn;
				
				//读取客户历史交易信息
				try
				{
					SqlText=null;
					SqlCeDataReader myReader=null;
					SqlText = "SELECT TAHAA,TAHAB FROM TAH";
					SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
					myReader=cmd.ExecuteReader();
					TBox_ClientID.Items.Clear();
					while (myReader.Read())
					{
						TBox_ClientID.Items.Add(myReader.GetString(1).ToString());
						//TBox_ClientID.SelectedIndex=0;
					}
					//TBox_ClientID.SelectedIndex=0;
					myReader.Close();
				}
				catch
				{
					//MessageBOX.Text=" 信息读取失败!";
					conn.Dispose();
				
				}
				//读取历史交易事物信息
				try
				{
					SqlText=null;
					SqlCeDataReader myReader=null;
					SqlText = "SELECT TAIAA,TAIAB FROM TAI";
					SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
					myReader=cmd.ExecuteReader();
					TBox_ThName.Items.Clear();
					while (myReader.Read())
					{		
						TBox_ThName.Items.Add(myReader.GetString(1));
						//TBox_ThName.SelectedIndex=0;
					}						
					myReader.Close();
					conn.Dispose();
					//TBox_ThName.SelectedIndex=0;
				}
				catch
				{
					//MessageBOX.Text=" 信息读取失败!";
					conn.Dispose();
				}
				conn.Dispose();
			}
		}

		//-------------------------------------------------------------------------------------------
		//--------------------------------主过程方法定义区(ZJNET ADD 2005-8-1)----------------------------------------
		//-------------------------------------------------------------------------------------------
		
		private bool  Edit()//判断事物交易信息加载是否完整 ZJNET 2005.8.5
		{
			if (TBox_ClientID.Text.Length==0)
			{  
				//MessageBOX.Text=" 客户信息加载错误!";
				return true;
			}
			if (TBox_ThName.Text.Length==0)
			{
				//MessageBOX.Text=" 事物信息加载错误!";	
				return true;
			}
			if (TBox_Pack.Text.Length==0)
			{
				//MessageBOX.Text=" 包装信息加载错误!";
				return true;
			}
			if (TBox_Amount.Text.Length==0)
			{
				//MessageBOX.Text=" 交易数量加载错误!";	
				return true;
			}
			else
			{
				return false;
			}
		}
		//----------------------------//交易后的清屏过程  ZJNET 2005.8.5
		private void Clear()
		{
			TBox_ClientID.Items.Clear();
			TBox_ThName.Items.Clear();
			TBox_Pack.Items.Clear();
			TBox_Amount.Text="";
			ScanData="";
			ScanSize=0;
	
		}

		//----------------------------------//异常信息的处理 ZJNET 2005.8.5(向异常物流信息表插入信息)
		private void Singularity()
		{
			CEData lo;
			lo=new CEData();
			SqlCeConnection conn=lo.conn;
			try
			{
				lo.ExeSQLNO("insert into TAB (TABAA,TABAB,TABAD,TABAF) VALUES ('"+Bit(ScanData)+"','"+DeviceID+"','"+DateTime.Now+"',0)");
				//MessageBOX.Text=" 异常信息已被记录!";
				MsgBox(rm.GetString("10010"),MsgTitle,3);
			}
			catch
			{   
				conn.Dispose();
			}
			conn.Dispose();
		}

		//----------------------------------------//扫描条码信息转换为128位的二进制字符串 ZJNET 2005.8.5
		private string Bit(string BarCode)
		{
			Conver rd = new Conver();
			string Code="";	
			string Str61,Str64;
			Str61 = rd.dtb(BarCode.Substring(0,19)).ToString();
			Str64 = rd.dtb(BarCode.Substring(19,19)).ToString();

			int N = Str61.Length;
			int M = Str64.Length;

			for (int i=0;i<61-N;i++)
			{
				Str61 = "0" + Str61.ToString();

			}
			for (int j=0;j<63-M;j++)
			{

				Str64 = "0" + Str64.ToString();
			}

			Code = Str61.ToString() + Str64.ToString();
			return Code;
		}

		//------------------------------------//扫描客户身份ID获取客户名称
		private void GetCupp()
		{
			CEData lo;
			lo=new CEData();
			Len = new SubStr();
			SqlCeConnection conn=lo.conn;

			string SqlText;	
			try
			{
				SqlText = null;
				SqlCeDataReader myReader=null;
				SqlText = "SELECT * FROM TAD WHERE TADAA='"+ScanData+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				myReader.Read();
				TBox_ClientID.Items.Clear();
				TBox_ClientID.Items.Add(myReader.GetString(2));
				TBox_ClientID.SelectedIndex=0;
				Cuppid = myReader.GetString(1);
				myReader.Close();
			}
			catch
			{
				//MessageBOX.Text=" 客户身份错误,交易失败!";
				//MsgBox(rm.GetString("10004"),MsgTitle,3);
				conn.Dispose();
				ScanData="";
				ScanSize=0;
				return;
			}
			conn.Dispose();
			ScanData="";
			ScanSize=0;
		}

		//---------------------------------根据扫描的条码从数据库中获取信息数据
		private void Getparms()
		{
			CEData lo;
			lo=new CEData();
			Len = new SubStr();
			SqlCeConnection conn=lo.conn;

			ProductID = Len.SubProductID(Bit(ScanData));

			MBID ="NO";

			string SqlText;
			
			//--------------------从词库中获取产品名称--------------------
			try
			{
				SqlText = null;
				SqlCeDataReader myReader=null;
				SqlText = "SELECT * FROM TAC WHERE TACAC='"+ProductID+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				myReader.Read();
				TBox_ThName.Items.Clear();
				TBox_ThName.Items.Add(myReader.GetString(2));
				TBox_ThName.SelectedIndex = 0;
				myReader.Close();
			}
			catch
			{
				//MessageBOX.Text=" 产品信息错误,交易失败!";
				conn.Dispose();
			}

			//--------------------从词库中获取产品包装层次---------------------
			try
			{
				SqlText = null;
				SqlCeDataReader myReader=null;
				SqlText = "SELECT * FROM TAE WHERE TAEAA = '"+ProductID+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				TBox_Pack.Items.Clear();
				while (myReader.Read())
				{
					TBox_Pack.Items.Add(myReader.GetString(2).ToString());	
				}
				TBox_Pack.SelectedIndex = 0;
				myReader.Close();
			}
			catch
			{
				//MessageBOX.Text=" 包装信息读取失败!";
				conn.Dispose();
			}
           
			//----------------------获取事物交易批次信息----------------------
			try
			{
				SqlText=null;
				SqlCeDataReader myReader=null;
				SqlText = "SELECT * FROM TAF WHERE TAFAA='"+ProductID.ToString()+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				myReader.Read();
				Path =myReader.GetValue(4).ToString(); 
				myReader.Close();
			}
			catch
			{
				ScanData="";
				ScanSize=0;
				Path = "";
				conn.Dispose();
			}
			conn.Dispose();
		}
		


		//--------------------------------------------------------------------------------
		//---------------------------执行交易过程(ZJNET ADD 2005.8.5)------------------------------------
		//--------------------------------------------------------------------------------


		//--------------------------------在没有扫描条件的情况下手动交易过程(ZJNET ADD 2005.8.12)------------------------
		private void Manual()
		{
			bool IsExit=false;  //是否跳出循环
			TryAgain:
				CEData lo;
			lo=new CEData();
			Len = new SubStr();
			string SqlText,LJ;
			string KHID;
			double JYSL=0.0;//手动输入的交易数量
			double NPE=0.0;//本地实际存在的配额信息
			


			MessageBOX.Text="";
			DateTime Atime = DateTime.Now;
			SqlCeConnection conn=lo.conn;
			SqlCeDataReader myReader=null;
			SqlCeTransaction myTrans;
			myTrans=conn.BeginTransaction();
			SqlCeCommand mycmd=conn.CreateCommand();
			mycmd.Connection=conn;
			mycmd.Transaction=myTrans;


		
			//从客户词库中取买方的客户ID
			try
			{
				SqlText=null;
				SqlText = "SELECT * FROM TAD WHERE TADAB='"+TBox_ClientID.Text+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				myReader.Read();
				KHID = myReader.GetValue(1).ToString();
				myReader.Close();
			}
			catch
			{
				//MessageBOX.Text=" 客户信息读取失败!";
				conn.Dispose();
				return;
			}

			//从配额中取出相应的配额数量
			try
			{
				SqlText=null;
				SqlText = "SELECT * FROM TAF WHERE TAFAA='"+THID+"'";
				SqlCeCommand cmd=new SqlCeCommand(SqlText,conn);
				myReader=cmd.ExecuteReader();
				myReader.Read();
				NPE = System.Convert.ToDouble(myReader.GetValue(2).ToString());
				JYLJ = myReader.GetValue(4).ToString();
				myReader.Close();
			}
			catch
			{
				NPE=0.0;
				//MessageBOX.Text=" 无产品配额信息 ,交易失败!";	
				MsgBox(rm.GetString("10005"),MsgTitle,3);
				conn.Dispose();
				if(IsExit)
					goto Exit;

				GoFactory();
				GoNet();  //开始通讯上传下载配额


				IsExit=true;
					
				goto TryAgain;

			Exit:
				//MessageBOX.Text=" 无交易配额!交易失败!";
				MsgBox(rm.GetString("10005"),MsgTitle,3);
				return;
			}


			if(TBox_Amount.Text.Trim().Length==0)
			{
				JYSL=0.0;
			}
			else
			{
				JYSL = System.Convert.ToDouble(TBox_Amount.Text.ToString());
			}

			//如果配额数量小于要交易的数量则给出提示信息
			if( NPE<(JYSL*LGSL) )
			{ 

				//MessageBOX.Text=" 产品配额信息不足!";
				conn.Dispose();
				
				if(IsExit)
					goto Exit;

				GoFactory();
				GoNet();  //开始通讯上传下载配额

⌨️ 快捷键说明

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