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

📄 form1.cs

📁 套接字网络编程
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.checkBox2.TabIndex = 3;
			this.checkBox2.Text = "逻辑与";
			// 
			// label10
			// 
			this.label10.Location = new System.Drawing.Point(8, 112);
			this.label10.Name = "label10";
			this.label10.Size = new System.Drawing.Size(80, 23);
			this.label10.TabIndex = 0;
			this.label10.Text = "资历简介:";
			// 
			// label9
			// 
			this.label9.Location = new System.Drawing.Point(8, 88);
			this.label9.Name = "label9";
			this.label9.Size = new System.Drawing.Size(80, 23);
			this.label9.TabIndex = 0;
			this.label9.Text = "收费标准:";
			// 
			// label8
			// 
			this.label8.Location = new System.Drawing.Point(8, 64);
			this.label8.Name = "label8";
			this.label8.Size = new System.Drawing.Size(80, 23);
			this.label8.TabIndex = 0;
			this.label8.Text = "业务范围:";
			// 
			// label7
			// 
			this.label7.Location = new System.Drawing.Point(8, 40);
			this.label7.Name = "label7";
			this.label7.Size = new System.Drawing.Size(80, 23);
			this.label7.TabIndex = 0;
			this.label7.Text = "工作性质:";
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(8, 16);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(80, 23);
			this.label6.TabIndex = 0;
			this.label6.Text = "律师姓名:";
			// 
			// groupBox3
			// 
			this.groupBox3.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.richTextBox1});
			this.groupBox3.Location = new System.Drawing.Point(248, 8);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new System.Drawing.Size(248, 120);
			this.groupBox3.TabIndex = 8;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "查询结果";
			// 
			// richTextBox1
			// 
			this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.richTextBox1.Location = new System.Drawing.Point(3, 17);
			this.richTextBox1.Name = "richTextBox1";
			this.richTextBox1.Size = new System.Drawing.Size(242, 100);
			this.richTextBox1.TabIndex = 4;
			this.richTextBox1.Text = "";
			// 
			// button6
			// 
			this.button6.Location = new System.Drawing.Point(416, 192);
			this.button6.Name = "button6";
			this.button6.Size = new System.Drawing.Size(72, 24);
			this.button6.TabIndex = 0;
			this.button6.Text = "清理结果";
			this.button6.Click += new System.EventHandler(this.button6_Click);
			// 
			// saveFileDialog1
			// 
			this.saveFileDialog1.FileName = "doc1";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(496, 309);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.button6,
																		  this.button5,
																		  this.button4,
																		  this.groupBox3,
																		  this.groupBox2,
																		  this.button3,
																		  this.groupBox1,
																		  this.statusBar1,
																		  this.button2,
																		  this.button1});
			this.MaximizeBox = false;
			this.Name = "Form1";
			this.Text = "律师办案查询系统";
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			this.groupBox1.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox3.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		private void button1_Click(object sender, System.EventArgs e)
		{   int port=0;
			IPAddress myIP=IPAddress.Parse("127.0.0.1");
			try
			{
				myIP=IPAddress.Parse(textBox3.Text);}
			catch{MessageBox.Show("您输入的IP地址格式不正确!");}
			client =new TcpClient();
			try{
			port=Int32.Parse(textBox2.Text);
			}
			catch{MessageBox.Show("请输入整数。");}
			try
			{
				if(textBox1.Text!=""&&textBox3.Text=="")
				{
					client.Connect(textBox1.Text,port);
					statusBarPanel1.Text="与服务器建立连接";
					Thread thread=new Thread(new ThreadStart(read));
					thread.Start();	
						
						
						
				}
				if(textBox3.Text!=""&&textBox1.Text=="")
				{
					client.Connect(myIP,port);
					statusBarPanel1.Text="与服务器建立连接";
					Thread thread=new Thread(new ThreadStart(read));
					thread.Start();
				}
						
					
						


				if(textBox3.Text!=""&&textBox1.Text!="")
				{
					client.Connect(myIP,port);
					statusBarPanel1.Text="与服务器建立连接";
					Thread thread=new Thread(new ThreadStart(read));
					thread.Start();
				}
			}//try{if(textBox1.Text!=""&&textBox3.Text=="")
			catch(Exception ee){MessageBox.Show(ee.Message);}


		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			netStream=client.GetStream();
            string close="@@@@@";			
			byte[]  by=System.Text.Encoding.BigEndianUnicode.GetBytes(close.ToCharArray());
			netStream.Write(by,0,by.Length);
			netStream.Flush();
			try
			{
				client.Close();
				statusBarPanel1.Text="与服务器断开连接";
			}
			catch{}

		}

		private void button3_Click(object sender, System.EventArgs e)
	 	{   string query=null;
		
			if(checkBox1.Checked)
			{
				query=textBox4.Text+"\r\n"+"10000"+"\r\n";

			}
			if(checkBox2.Checked)
			{query=textBox5.Text+"\r\n"+"01000"+"\r\n";
				
			}
			if(checkBox3.Checked)
			{
				query=textBox6.Text+"\r\n"+"00100"+"\r\n";
			}
			if(checkBox4.Checked)
			{
				query=textBox7.Text+"\r\n"+"00010"+"\r\n";
			}
			if(checkBox5.Checked)
			{
				query=textBox8.Text+"\r\n"+"00001"+"\r\n";
			}
			//************************************************
			if(checkBox1.Checked&&checkBox2.Checked)
			{query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+"11000"+"\r\n";
					
			}
			if(checkBox1.Checked&&checkBox3.Checked)
			{query=textBox4.Text+"\r\n"+textBox6.Text+"\r\n"+"10100"+"\r\n";
						
			}
			if(checkBox1.Checked&&checkBox4.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox7.Text+"\r\n"+"10010"+"\r\n";		
			}
			if(checkBox1.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox8.Text+"\r\n"+"10001"+"\r\n";	
			}
			//******************************************************
			if(checkBox2.Checked&&checkBox3.Checked)
			{
				query=textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+"01100"+"\r\n";		
			}
			if(checkBox2.Checked&&checkBox4.Checked)
			{
				query=textBox5.Text+"\r\n"+textBox7.Text+"\r\n"+"01010"+"\r\n";			
			}
			if(checkBox2.Checked&&checkBox5.Checked)
			{
				query=textBox5.Text+"\r\n"+textBox8.Text+"\r\n"+"01001"+"\r\n";			
			}
			//********************************************************
			if(checkBox3.Checked&&checkBox4.Checked)
			{
				query=textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+"00110"+"\r\n";		
			}
			if(checkBox3.Checked&&checkBox5.Checked)
			{
				query=textBox6.Text+"\r\n"+textBox8.Text+"\r\n"+"00101"+"\r\n";		
			}
			//********************************************************
			if(checkBox4.Checked&&checkBox5.Checked)
			{
				query=textBox7.Text+"\r\n"+textBox8.Text+"\r\n"+"00011"+"\r\n";		
			}
			//********************************************************
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox3.Checked)
			{query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+"11100"+"\r\n";
					
			}
			
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox4.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox7.Text+"\r\n"+"11010"+"\r\n";	
			}
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox8.Text+"\r\n"+"11001"+"\r\n";	
			}
			//**********************************************************
			if(checkBox1.Checked&&checkBox3.Checked&&checkBox4.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+"10110"+"\r\n";	
			}
			if(checkBox1.Checked&&checkBox3.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox6.Text+"\r\n"+textBox8.Text+"\r\n"+"10101"+"\r\n";	
			}
			//**********************************************************
			if(checkBox1.Checked&&checkBox4.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox7.Text+"\r\n"+textBox8.Text+"\r\n"+"10011"+"\r\n";	
			}
			//***********************************************************

			if(checkBox2.Checked&&checkBox3.Checked&&checkBox4.Checked)
			{
				query=textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+"01110"+"\r\n";		
			}
			if(checkBox2.Checked&&checkBox3.Checked&&checkBox5.Checked)
			{
				query=textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox8.Text+"\r\n"+"01101"+"\r\n";		
			}
			//************************************************************
			if(checkBox5.Checked&&checkBox3.Checked&&checkBox4.Checked)
			{
				query=textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+textBox8.Text+"\r\n"+"00111"+"\r\n";			
			}
			//***********************************************************
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox3.Checked&&checkBox4.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+"11110"+"\r\n";		
			}
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox3.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox8.Text+"\r\n"+"11101"+"\r\n";		
			}
              //************************************************************
			if(checkBox5.Checked&&checkBox2.Checked&&checkBox3.Checked&&checkBox4.Checked)
			{query=textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+textBox8.Text+"\r\n"+"01111"+"\r\n";
							
			}
			//***************************************************************
			if(checkBox1.Checked&&checkBox2.Checked&&checkBox3.Checked&&checkBox4.Checked&&checkBox5.Checked)
			{
				query=textBox4.Text+"\r\n"+textBox5.Text+"\r\n"+textBox6.Text+"\r\n"+textBox7.Text+"\r\n"+textBox8.Text+"\r\n"+"11111"+"\r\n";	
			}
			//***************************************************************
             netStream=client.GetStream();
			
			byte[]  by=System.Text.Encoding.BigEndianUnicode.GetBytes(query.ToCharArray());
			netStream.Write(by,0,by.Length);
			netStream.Flush();
			

		}
		private void read()
		{
			
			while(true)
			{
				stream=client.GetStream();
				byte[] bb=new byte[100];
					
				int i=stream.Read(bb,0,100);
				string ss=System.Text.Encoding.BigEndianUnicode.GetString(bb);
				richTextBox1.AppendText(ss);
			}
			 
		  
			
		
		}

		private void button5_Click(object sender, System.EventArgs e)
		{   saveFileDialog1.Filter="文本文件(*.TXT)|*.txt|WORD文档(*.DOC)|*.doc|所有文件(*.*)|*.*";
			StreamWriter sw=null;
			if(saveFileDialog1.ShowDialog()==DialogResult.OK)
			{
				try
				{
					sw=new StreamWriter(saveFileDialog1.FileName,false,System.Text.Encoding.Unicode);
					sw.Write(richTextBox1.Text);}
				catch(Exception excep){MessageBox.Show(excep.Message);}
				finally{if(sw!=null){sw.Close();}
				}//对应finally{

			} //对应if(saveFileDialog1.ShowDialog()==DialogResult.OK)
  

		}

		private void button6_Click(object sender, System.EventArgs e)
		{
			richTextBox1.Clear();
		}

		
	}
}

⌨️ 快捷键说明

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