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

📄 wholesale.cs

📁 WINCE数据库sqlce 通讯stock 代码
💻 CS
📖 第 1 页 / 共 4 页
字号:
							//MessageBox.Show("您上次的文件不完整");
							net.SendFile(sOldFile,HeaderMsg(PDAID(),sOldFile,Pass(),""));	
							Thread.Sleep(WaitTime);
						}					
						else
						{
							//完整时
							//删除所有的临时文件
							DeleteFiles("\\","*.txt",21);
							//if(File.Exists(sOldFile)) File.Delete(sOldFile);
							break;
						}
					}
				}
			
				//初始化数据库操作
				CEFile sf=new CEFile();
			
				//导出数据库文件
				string sNewFile="";
				if(status)
				{
					sNewFile=sf.DB2TXT();
					Thread.Sleep(WaitTime);
					if(sNewFile.CompareTo("error")==0)
						status=false;
				}
				//发送新文件
				if(status)
				{
					for(int i=0;i<4;i++)
					{
						if(i==3)
						{
							//错误,退出
							status=false;
							break;
					
						}
						FileInfo fi=new FileInfo(sNewFile);
						//如果导出是空记录
						if(fi.Length==14)
						{
							fi.Delete();
							break;
						}
						//发送新文件(PDA->Server)
						net.SendFile(sNewFile,HeaderMsg(PDAID(),sNewFile,Pass(),""));
						Thread.Sleep(WaitTime);
						string sTemp=net.RecCmd();

						if(sTemp.Substring(0,5).CompareTo("Suces")!=0)
						{
							//MessageBox.Show("您发送的文件不完整!");
						}
						else
						{
							//文件完整时
							break;
						}
					}
				}
			
				//接收新文件
				string result="";
				if(status)
				{
					for(int i=0;i<4;i++)
					{
						if(i==3)
						{
							//错误,退出
							status=false;
							break;		
						}

						//接收新文件:Server->PDA
						result=net.DownFile(BC(PDAID(),30));
						Thread.Sleep(WaitTime);

						if(result.Substring(0,5).CompareTo("Empty")==0)
						{
							status=false;
							net.SendCmd(CB("Error",64));         //反馈错误
							break;
						}

						if(result.Substring(0,5).CompareTo("Error")!=0)
						{
							//接收成功
							//net.SendCmd(result+BC("",38));
							net.SendCmd(CB("Suces",64));		//反馈成功
							break;
						}
						else
						{
							status=false;
							net.SendCmd(CB("Error",64));         //反馈错误
							break;
						}

					}
				}
			
				//文本导入数据库
				if(status)
				{
				
					for(int i=0;i<4;i++)
					{
						if(i==3)
						{
							//导入不成功,退出
							status=false;
							break;
						}
						bool Dciku=false;
						//如果不需要更新词库
						if(result.Length<21)
						{
							status=false;
							break;
						}
						if(result.Substring(21,5)=="76514") 
							Dciku=true;
						//导入成功
						Thread.Sleep(WaitTime);
						if(sf.TXT2DB(result.Substring(0,21),Dciku))
						{
							if(File.Exists(result.Substring(0,21)))
								File.Delete(result.Substring(0,21));
							break;
						}
					}
				}

				if(status)
				{
					//断开网络
					net.Close();
					//MessageBOX.Text="下载完成!";
				}
				else
				{
					MessageBOX.Text="";
					net.Close();
					//MessageBox.Show("网络通讯出现问题,本次通讯取消!");
				
				}
			}
			catch(SocketException)
			{
				MessageBOX.Text="";
				//MessageBox.Show("配额不足!请联网重试!");
				MsgBox(rm.GetString("10005"),MsgTitle,3);

			}
			//延时30秒
			Thread.Sleep(2000);
		}
//------------------------------------------------通讯结束-----------------------------------------------
		public void ScanKeys(object o, EventArgs e)
		{
				g_mi.Update();
				//按下PDA左上方的按钮
				//if(g_mi.KeyPressed((int)GXInput.HardwareKeys.kHardwareKey5))//下载配额
				//{
					//GoNet();
				//}

				if(g_mi.KeyPressed((int)Keys.Down)) //执行手动选择
				{
					//string SqlText;
				}
				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; //手动输入信息时获取产品基类包装数量

						Clear(); //清屏
						TBox_ClientID.Items.Clear();
						TBox_ThName.Items.Clear();
						MBID = "OK";//判断是扫描还是手动交易方式
						Choose();
					}
					else if(MBID =="NO")
					{
						Scan();
						Clear();//清屏
						TBox_ClientID.Items.Clear();
						TBox_ThName.Items.Clear();
						MBID = "OK";//判断是扫描还是手动交易方式
						Choose();
					}
				}
				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();
					}
				}			
		}


//-------------------------------------------------------------------------------------------
//--------------------------------主过程方法定义区(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();
				MBID ="NO";
			}
			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);
                TBox_Pack.Items.Clear();
				myReader=cmd.ExecuteReader();
				while (myReader.Read())
				{
					TBox_Pack.Items.Add(myReader.GetString(2).ToString());	
				}
				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.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;//本地实际存在的配额信息
			double NUMSY=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();

⌨️ 快捷键说明

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