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

📄 weixiujilu.java

📁 业务信息管理平台,适用于企业内部信息管理,合同管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
				String m="确定要录入本条维修记录么?";
				int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                if(ok==JOptionPane.YES_OPTION){
        			Connection dbConn;
       				Statement stat;
       				ResultSet resSet,resSet1;
					try { 
						Class.forName(Yewu.forName);
   						dbConn=DriverManager.getConnection(Yewu.jdbc);
						stat=dbConn.createStatement(); 
						StringBuffer buffer =new StringBuffer();
						buffer.append("select huichangshijian from weixiuTable where huichangshijian='").append(huichangshijiant.getText().trim()).append("'");
				
						resSet=stat.executeQuery(buffer.toString());
						if(resSet.next()){
							JOptionPane.showMessageDialog(null,"该信息已存在,勿重复录入!");	
						}else{
							String timestr="";	
 							//--------------------当前系统时间---------------------------------------
   							java.util.Date currentTime =new java.util.Date();   
   							java.text.SimpleDateFormat formatter;   
   							formatter=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");         
   							timestr+=formatter.format(currentTime);
  							//-----------------------------------------------------------------------
							StringBuffer str=new StringBuffer();
							if(manyiBox.isSelected()){
								str.append("insert into  weixiuTable(yewuname,kehuname,weixiuren,chuchangshijian,huichangshijian,manyi,kehufankui,weixiujingguo,kehuyijian,updateTime) values('").append(ss).append("','").append(kehumingchengt.getText().trim()).append("','").append(weixiurent.getText().trim()).append("','").append(chuchangshijiant.getText().trim()).append("','").append(huichangshijiant.getText().trim()).append("','1','").append(kehubeizhu.getText().trim()).append("','").append(weiuxiubeizhu.getText().trim()).append("','").append(manyibeizhu.getText().trim()).append("','").append(timestr).append("')");
							}else if(bumanyiBox.isSelected()){
								str.append("insert into  weixiuTable(yewuname,kehuname,weixiuren,chuchangshijian,huichangshijian,manyi,kehufankui,weixiujingguo,kehuyijian,updateTime) values('").append(ss).append("','").append(kehumingchengt.getText().trim()).append("','").append(weixiurent.getText().trim()).append("','").append(chuchangshijiant.getText().trim()).append("','").append(huichangshijiant.getText().trim()).append("','0','").append(kehubeizhu.getText().trim()).append("','").append(weiuxiubeizhu.getText().trim()).append("','").append(manyibeizhu.getText().trim()).append("','").append(timestr).append("')");
							}else{
								JOptionPane.showMessageDialog(null,"请选择客户是否满意!");
							}
							if(stat.executeUpdate(str.toString())>0){			
								JOptionPane.showMessageDialog(null,"录入成功!");	
 							}
						}
            			stat.close();
						dbConn.close(); //关闭数据库连接
					}catch(Exception ee){ 
						ee.printStackTrace(); 
						JOptionPane.showMessageDialog(null,"请检查时间格式和数据格式");		
					}
				
				}
			}	
		}
				
		if(e.getSource()==chongzhi){
			
			kehubeizhu.setText(null);
			manyibeizhu.setText(null);
			weixiurent.setText(null);
			huichangshijiant.setText(null);
			chuchangshijiant.setText(null);
			weiuxiubeizhu.setText(null);			 	
		}
		if(e.getSource()==xiugai){

			if(chuchangshijiant.getText().trim().length()==0){
				JOptionPane.showMessageDialog(null,"1.请选择出厂时间!");				
			}else if(huichangshijiant.getText().trim().length()==0){
				JOptionPane.showMessageDialog(null,"1.请选择回厂时间!");	
			}else if(weixiurent.getText().trim().length()>260){
				JOptionPane.showMessageDialog(null,"1.维修人字数不能超过26字!");	
			}else if(kehubeizhu.getText().trim().length()==0){
				JOptionPane.showMessageDialog(null,"2.客户反馈不能为空!");		
			}else if(kehubeizhu.getText().trim().length()>200){
				JOptionPane.showMessageDialog(null,"2.客户反馈字数不能超过200字!");		
			}else if(weiuxiubeizhu.getText().trim().length()==0){
				JOptionPane.showMessageDialog(null,"3.维修过程不能为空!");		
			}else if(weiuxiubeizhu.getText().trim().length()>500){
				JOptionPane.showMessageDialog(null,"3.维修经过字数不能超过500字!");		
			}else if(manyibeizhu.getText().trim().length()>200){
				JOptionPane.showMessageDialog(null,"4.客户建议字数不能超过200字!");		
			}else{
				String m="确定要修改本条信息么?";
				int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                if(ok==JOptionPane.YES_OPTION){
                	
                	String timestr="";	
 					//--------------------当前系统时间---------------------------------------
   					java.util.Date currentTime =new java.util.Date();   
   					java.text.SimpleDateFormat formatter;   
   					formatter=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");         
   					timestr+=formatter.format(currentTime);
  					//-----------------------------------------------------------------------
        			Connection dbConn;
       				Statement stat;
       				ResultSet resSet;
       			
				try { 
					Class.forName(Yewu.forName);
   					dbConn=DriverManager.getConnection(Yewu.jdbc);
					stat=dbConn.createStatement(); 
   						StringBuffer sql11=new StringBuffer();
   						 if(bumanyiBox.isSelected()){	
   						 	sql11.append("update weixiuTable set kehuname='").append(kehumingchengt.getText().trim()).append("',updateTime='").append(timestr).append("',weixiuren='").append(weixiurent.getText().trim()).append("',manyi='0',kehufankui='").append(kehubeizhu.getText().trim()).append("',weixiujingguo='").append(weiuxiubeizhu.getText().trim()).append("',kehuyijian='").append(manyibeizhu.getText().trim()).append("' where huichangshijian='").append(huichangshijiant.getText().trim()).append("'");
   						 }else if(manyiBox.isSelected()){
   							sql11.append("update weixiuTable set kehuname='").append(kehumingchengt.getText().trim()).append("',updateTime='").append(timestr).append("',weixiuren='").append(weixiurent.getText().trim()).append("',manyi='1',kehufankui='").append(kehubeizhu.getText().trim()).append("',weixiujingguo='").append(weiuxiubeizhu.getText().trim()).append("',kehuyijian='").append(manyibeizhu.getText().trim()).append("' where huichangshijian='").append(huichangshijiant.getText().trim()).append("'");
   						 	 	
   						 }else{
								JOptionPane.showMessageDialog(null,"请选择客户是否满意!");
						}
   					
   						if(stat.executeUpdate(sql11.toString())>0){
       						JOptionPane.showMessageDialog(null,"修改成功");
       					}	
   					
            		stat.close();
					dbConn.close(); //关闭数据库连接
				}catch(Exception ee){ 
					ee.printStackTrace(); 
				}
				
				}//JOptionPane.YES_OPTION
			}
		}

		if(e.getSource()==shanchu){

				String m="确定要删除么?(不可恢复 慎重操作!)";
				int ok=JOptionPane.showConfirmDialog(this,m,"确认",JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
                if(ok==JOptionPane.YES_OPTION){
        		Connection dbConn;
       			Statement stat;
				try { 
					Class.forName(Yewu.forName);
   					dbConn=DriverManager.getConnection(Yewu.jdbc);
					stat=dbConn.createStatement(); 
   					//---------------------------------------------------------------------------
   					StringBuffer sql=new StringBuffer();
   						sql.append("delete from weixiuTable where  huichangshijian='").append(huichangshijiant.getText().trim()).append("' ");	
   						if(stat.executeUpdate(sql.toString())>0){	
       						JOptionPane.showMessageDialog(null,"删除成功");
						
							kehubeizhu.setText(null);
							manyibeizhu.setText(null);
							weixiurent.setText(null);
							huichangshijiant.setText(null);
							chuchangshijiant.setText(null);
							weiuxiubeizhu.setText(null);
							manyiBox.setSelected(false);
							bumanyiBox.setSelected(false);
							weixiuChocie.removeAll();
       					}	
            		stat.close();
					dbConn.close(); //关闭数据库连接
				}catch(Exception ee){ 
					ee.printStackTrace(); 
				}
				
			}//JOptionPane.YES_OPTION
	   }
	   
	   if(e.getSource()==weixiuhuib){
	   		String timestr="";	
 			//--------------------当前系统时间---------------------------------------
   			java.util.Date currentTime =new java.util.Date();   
   			java.text.SimpleDateFormat formatter;   
   			formatter=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");         
   			timestr+=formatter.format(currentTime);
			//-----------------------------------------------------------------------	
   			huichangshijiant.setText(timestr);
	   }		
	}

	public void itemStateChanged(ItemEvent e){ //选择事件
	
		if(e.getSource()==weixiuChocie){
			String sss=weixiuChocie.getSelectedItem().trim();
			int iii=sss.indexOf(".");
		if(iii==0){
	
		}else{
		
			Connection dbConn;
       		Statement stat;
       		ResultSet resSet;
			try { 
				Class.forName(Yewu.forName);
   				dbConn=DriverManager.getConnection(Yewu.jdbc);
				stat=dbConn.createStatement(); 
   				StringBuffer str=new StringBuffer();
				str.append("select distinct kehuname,weixiuren,chuchangshijian,huichangshijian,manyi,kehufankui,weixiujingguo,kehuyijian from weixiuTable where huichangshijian='").append(this.getString2(weixiuChocie.getSelectedItem().trim(),"次:")).append("'");				
			
				resSet=stat.executeQuery(str.toString());
				StringVector vec=new StringVector();
				if(resSet.next()){
					vec.add(resSet.getString("kehuname"));
					vec.add(resSet.getString("weixiuren"));
					vec.add(resSet.getString("chuchangshijian"));
					vec.add(resSet.getString("huichangshijian"));
					vec.add(resSet.getString("manyi"));
					vec.add(resSet.getString("kehufankui"));
					vec.add(resSet.getString("weixiujingguo"));
					vec.add(resSet.getString("kehuyijian"));
				}
					
				kehumingchengt.setText(vec.get(0).trim());	
 				weixiurent.setText(vec.get(1).trim());
 				chuchangshijiant.setText(vec.get(2).trim());
 				huichangshijiant.setText(vec.get(3).trim());
 					String manyistr=vec.get(4);
 				if(manyistr.equals("0")){
 					   bumanyiBox.setSelected(true);		
 				}else if(manyistr.equals("1")){
 				    	manyiBox.setSelected(true);	
 				}	
 				kehubeizhu.setText(vec.get(5).trim());
 				weiuxiubeizhu.setText(vec.get(6).trim());
 				if(vec.get(7)==null){
 				}else{
 					manyibeizhu.setText(vec.get(7).trim());
 				}
            	stat.close();
				dbConn.close(); 
			 }catch(Exception ee){ 
				ee.printStackTrace(); 
				JOptionPane.showMessageDialog(null,"请检查时间格式和数据格式或数据库服务器未启动");		
			}
		}
			if(e.getSource()==manyiBox&&manyiBox.isSelected()==true){
				bumanyiBox.setSelected(false);
			}else if(e.getSource()==bumanyiBox&&bumanyiBox.isSelected()==true){
				manyiBox.setSelected(false);
			}
		}
	}
	public String getString2(String str,String str1 ){ 
		int index = str.indexOf(str1); //str1是想要开始截取的字符。str是被截取的字符。 
		return str.substring(index+2,str.length()).trim();
	}
}

⌨️ 快捷键说明

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