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

📄 frmsfsj.java

📁 用JAVA SWT编写的住院管理系统。用SQLServer数据库
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
						}		
					    countSFGY++;
					}//end else	
					tempSFY = strSFY;
				}//end while			

				//添加最末一行的合计
				//取得最末一行				
				TableItem itemGYNUM = new TableItem(tblSFGY,0);
				itemGYNUM.setText(new String[]{	
						String.valueOf(countSFGY),"合计"});			
				//计算各列的和
				double XJNUM = 0;
				double ZPNUM = 0;
				String tempXJNUM = "";
				String tempZPNUM = "";				
				for(int m = 1;m < countSFGY;m++)
				{
                    tempXJNUM = tblSFGY.getItem(m-1).getText(2);
                    tempZPNUM = tblSFGY.getItem(m-1).getText(3);
                    if(tempXJNUM != "")
                    {
                    	XJNUM = XJNUM + Double.parseDouble(tempXJNUM); 
                    }
                    if(tempZPNUM != "")
                    {
                    	ZPNUM = ZPNUM + Double.parseDouble(tempZPNUM);
                    }		
				}
							
				//格式化字符串:如果求得的和是.0就替换成空字符串
				String tempXJFormat = "";				
				String tempZPFormat = "";		
				TableItem itemNUM1 = tblSFGY.getItem(tblSFGY.getItemCount()-1);
				if (strDF.format(XJNUM).equals(".0"))//strDF.format(XJNUM)是.0就格式化成""
				{
					tempXJFormat = "";			
				}
				else
				{
					tempXJFormat = strDF.format(XJNUM);
				}
				if (strDF.format(ZPNUM).equals(".0"))//strDF.format(ZPNUM)是.0就格式化成""
				{
					tempZPFormat = "";	
				}
				else
				{
					tempZPFormat = strDF.format(ZPNUM);
				}
				itemNUM1.setText(2,tempXJFormat);
				itemNUM1.setText(3,tempZPFormat);			
				
			}//end else
		}//end try
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}//end getSFGYData
	
	//-----------显示收费员上交费用的详细信息-----------//
	/**
	* 方法名:	getSFXXData
	* 编写者:	冉勇
	* 功  能:	取得收费员上交费用的详细信息(收费详细SFXX)
	* 输入参数:收费员ID和上交时间,没上交则为"2079-6-6"
	* 输出参数:上交费用的详细信息
	* 备  注:
	*/
	public void getSFXXData(String strSFY,String strSubmitTimetemp)
	{	
		try
		{
			int temp = db.getSFXX(strSFY,strSubmitTimetemp);
			if(temp == 0)
			{
				MessageBox msBox = new MessageBox(shell,SWT.OK|SWT.ICON_ERROR);
            	msBox.setText(" 错误");
            	msBox.setMessage("数据库查询出错");
            	msBox.open();
            	return;
			}
			else
			{	
				int countSFXX=1;								
				while(db.prs.next())
				{		
					//向表添加内容
					TableItem itemSFXX = new TableItem(tblSFXX,0);
					itemSFXX.setText(new String[]{
					String.valueOf(countSFXX),
					db.prs.getString("JFRQ"),
					db.prs.getString("BRXM"),
					//格式化数据
					strDF.format(Double.parseDouble(db.prs.getString("JE"))),
					db.prs.getString("ZYH"),
					db.prs.getString("JFXS")
					 });
					countSFXX++;
				}//end while
				
				//添加最末一行的合计
				//取得最末一行				
				TableItem itemXXNUM = new TableItem(tblSFXX,0);
				itemXXNUM.setText(new String[]{	
						String.valueOf(countSFXX),"合计"});			
				//计算各列的和
				double JENUM = 0;
				String tempJENUM = "";
				for(int n = 1;n < countSFXX;n++)
				{
                    tempJENUM = tblSFXX.getItem(n-1).getText(3);
                    if(tempJENUM != "")					//如果为空会抛出异常
                    {
                    	JENUM = JENUM + Double.parseDouble(tempJENUM); 
                    }		
				}
				//格式化数据
				//System.out.println(strDF.format(JENUM));
				TableItem itemNUM2 = tblSFXX.getItem(tblSFXX.getItemCount()-1);
				itemNUM2.setText(3,strDF.format(JENUM));
				
			}//end else
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}
	}//end getSFXXData
	
	//-------------装label button 的composite-----------//
	/**
	* 方法名:	createComposite
	* 编写者:	冉勇
	* 功  能:	创建装label button 的composite
	* 输入参数:
	* 输出参数:装label button 的composite
	* 备  注:
	*/
	public void createComposite()						
	{
		//创建composite
		comSHELL=new Composite(shell,SWT.SHADOW_ETCHED_IN);	
		
		//设置composite显示格式
		GridData griddataCom=new GridData(GridData.FILL_HORIZONTAL);
		griddataCom.horizontalSpan=3;
		griddataCom.horizontalAlignment=GridData.BEGINNING;
		comSHELL.setLayoutData(griddataCom);
		
		//设置composite布局
		GridLayout gridlayoutCom = new GridLayout();
		gridlayoutCom.numColumns = 7;
		comSHELL.setLayout(gridlayoutCom);	
		
		//添加各组件到composite
		lblJSSJ= new Label(comSHELL,SWT.None);			
		lblJSSJ.setText("本次上交时间:");
		GridData griddataLLblJSSJ=new GridData(GridData.FILL_HORIZONTAL);
		griddataLLblJSSJ.widthHint = 130;
		lblJSSJ.setLayoutData(griddataLLblJSSJ);
		lblJSSJ.setAlignment(SWT.CENTER);
		lblJSSJ.setForeground(colGreen);	
		
		//添加comJSSJ,装时间文本框和时间下拉框,双击文本框显示下拉框												
		comJSSJ=new Composite(comSHELL,SWT.SHADOW_ETCHED_IN); 														
		GridData griddataComJSSJ=new GridData(GridData.FILL_HORIZONTAL);
		griddataComJSSJ.widthHint = 125;
		comJSSJ.setLayoutData(griddataComJSSJ);
		
		//运用堆栈式布局
    	final StackLayout stacklayoutCom = new StackLayout();
     	comJSSJ.setLayout(stacklayoutCom);	
     	
     	//时间文本框
		txtJSSJ = new Text(comJSSJ,SWT.BORDER | SWT.READ_ONLY);	
		//获取当前服务器时间并显示
		String datastr=db.getNowDate();					
		txtJSSJ.setText(datastr);		
		GridData griddataTxtJSSJ=new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
		txtJSSJ.setLayoutData(griddataTxtJSSJ);	
		
		//创建收费概要信息,初始化收费概要表
		getSFGYData(strSubmitTime);	
			
		
		//时间下拉框
		cmbJSSJ=new Combo(comJSSJ,SWT.SINGLE | SWT.READ_ONLY);
		
		//获取选中的值
		getSelectComboData();
		
		//初始设置最上层为文本框,鼠标双击文本框变为下拉框									
    	stacklayoutCom.topControl = txtJSSJ;				
    	txtJSSJ.addMouseListener(new MouseAdapter()		
    	{
        	public void mouseDoubleClick(MouseEvent e) 
        	{    
        		//设置最上层为下拉框  
           		stacklayoutCom.topControl = cmbJSSJ;	
            	comJSSJ.layout();
            						
            	//先把cmbJSSJ内容清空,取得以前提交的时间并添加到下拉框
            	tblSFGY.removeAll();
            	tblSFXX.removeAll();
            	cmbJSSJ.removeAll();					
        		createCmbtime();	
        		
        		//确定按钮不可用					
        		btnQD.setEnabled(false);				
  				lblJSSJ.setText("历次上交记录:");
  				lblJSSJ.setAlignment(SWT.CENTER);
        		lblBLANK.setText("要提交请先刷新!");
        		lblBLANK.setAlignment(SWT.CENTER);  
        		
        		//选中第一个并显示在收费概要表
        		String strCombo = cmbJSSJ.getText();
        		getSFGYData(strCombo);
        		
        		//把提交时间设置成选中的Combo值,是否已经提交设置成true
        		strSubmitTime = strCombo;
        		isSubmitTag = true;
        		
        	}
    	});//end of addMouseListener
			
		//提示标签
		GridData griddataBlank=new GridData(GridData.FILL_HORIZONTAL);
		griddataBlank.horizontalSpan=2;
		griddataBlank.widthHint = 230;
		lblBLANK=new Label(comSHELL,SWT.None);
		lblBLANK.setText("双击左边的文本框查看历次上交记录!");
		lblBLANK.setAlignment(SWT.CENTER); 
		lblBLANK.setForeground(colGreen);	
 		lblBLANK.setLayoutData(griddataBlank);
		
		//按钮控件开始
		//刷新按钮,重新读取要上交的数据
		btnSX=new Button(comSHELL,SWT.None);			
		btnSX.setText(" 刷  新 ");
		//刷新按钮单击事件
		btnSX.addMouseListener(new  MouseAdapter()		
		{
			public void mouseDown(MouseEvent e)
			{
				//清空显示概要信息记录和收费详细记录的表
				tblSFGY.removeAll();					
				tblSFXX.removeAll();
				
				//提交时间设置成未提交,取得未提交概要信息					
				strSubmitTime = notSubmitTime;			
				getSFGYData(notSubmitTime);	
				
				//获取当前服务器时间并显示在文本框		
				String strData=db.getNowDate();			
				txtJSSJ.setText(strData);
							
				//把时间文本框应用在最上层							
				stacklayoutCom.topControl = txtJSSJ;	
            	comJSSJ.layout();		
            					
            	lblJSSJ.setText("本次上交时间:");
            	lblJSSJ.setAlignment(SWT.CENTER);
            	lblBLANK.setText("双击左边的文本框查看历次上交记录!");
            	lblBLANK.setAlignment(SWT.CENTER); 
            	//收费概要表无内容设置确定按钮不可用,有内容则设置确定按钮可用
           		if (tblSFGY.getItemCount() ==0)				
				{
					btnQD.setEnabled(false);
				}
		        else  		
           		{
           			btnQD.setEnabled(true);					
				}
			}	
		});//end of addMouseListener
		
		//确定按钮,确定提交页面数据
		btnQD=new Button(comSHELL,SWT.None);			
		btnQD.setText(" 确  定 ");
		
		//初始化时如果收费概要表为空就把确定按钮设置成不可用
		if (tblSFGY.getItemCount() ==0)						
		{
			btnQD.setEnabled(false);
		}
		
		//确定按钮单击事件
		btnQD.addMouseListener(new  MouseAdapter()		
		{
			public void mouseDown(MouseEvent e)
			{
				String strUpdateTime = txtJSSJ.getText();
				if (tblSFGY.getItemCount() !=0)//SFGY表内容不为空,第一行有数据
				{
					try
					{
						int temp = db.updateSFSJ(strUpdateTime);
						if(temp == 0)
						{
							MessageBox msBox = new MessageBox(shell,SWT.OK|SWT.ICON_ERROR);
			            	msBox.setText(" 错误");
			            	msBox.setMessage("数据库更新出错!");
			            	msBox.open();
			            	return;
						}
						else
						{
							tblSFGY.removeAll();
							tblSFXX.removeAll();
							btnQD.setEnabled(false);
							MessageBox msOK = new MessageBox(shell,SWT.OK);
							msOK.setText(" 更新成功");
							msOK.setMessage("恭喜您:上交成功!");
							msOK.open();
							return;						
						}//end else
					}//end try
					catch(Exception ee)
					{
						System.out.println(ee.getMessage());
					}
				}//end if
				else					//SFGY表内容为空
				{
					MessageBox dataNULL = new MessageBox(shell,SWT.OK);
					dataNULL.setText("友情提示!");
					dataNULL.setMessage("没有要提交的数据!您可以查看以前提交的记录。");
					dataNULL.open();
					return;
				}//end else
			}		
		});//end of addMouseListener
		
		//返回按钮,退出程序并返回系统主菜单
		btnFH=new Button(comSHELL,SWT.None);			
		btnFH.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
		btnFH.setText(" 返  回 ");
		
		//添加返回按钮单击事件
		btnFH.addSelectionListener(new SelectionAdapter() 
		{
			public void widgetSelected(SelectionEvent e) 
			{
				//返回到主界面
				shell.getDisplay().dispose();
				shell.dispose();
			    FrmMenu.main();
                return;	
			}
		});
	}//End of createComposite()
	
	//-----------Combo获得已经提交的时间---------------//
	/**
	* 方法名:	createCmbtime
	* 编写者:	冉勇
	* 功  能:  获得已经提交的时间()
	* 输入参数:
	* 输出参数:已经提交的时间
	* 备  注:
	*/
	public void createCmbtime()
	{
		try
		{
			int temp = db.getCmbtime();
			if(temp == 0)
			{
				MessageBox msBox = new MessageBox(shell,SWT.OK|SWT.ICON_ERROR);
            	msBox.setText(" 错误");
            	msBox.setMessage("数据库查询出错");
            	msBox.open();
            	return;
			}
			else
			{
				while(db.prs.next())
				{
					String cmbItems = db.prs.getString("SJSJ");
					cmbJSSJ.add(cmbItems);
				}
				cmbJSSJ.select(0);
			}	
		}
		catch(Exception e)
		{
			System.out.println(e.getMessage());
		}		
	}//end of createCmbtime
	
	//-----------获得Combo选中的时间---------------//
	/**
	* 方法名:	getSelectComboData
	* 编写者:	冉勇
	* 功  能:  获得Combo选中的时间
	* 输入参数:
	* 输出参数:Combo选中的时间
	* 备  注:
	*/
	public void getSelectComboData()
	{
		//获取选中的值
		cmbJSSJ.addSelectionListener(new SelectionAdapter()
		{
			public void widgetSelected(SelectionEvent e)	
			{
				//取得选中的值
				String strTimeKey = cmbJSSJ.getText();	
				
				//清空显示收费概要信息和详细信息的表
				tblSFGY.removeAll();					
				tblSFXX.removeAll();	
				
				//根据选择的时间取得收费概要信息				
				getSFGYData(strTimeKey);
				
				//选择了下拉框,则标记是为true;把全局的提交时间设置成当前选中的值			
				isSubmitTag = true;						
				strSubmitTime = cmbJSSJ.getText();		
			}
		});//end of addSelectionListener
	}//end of getSelectComboData
	
}//End Of FrmSFSJ.java

⌨️ 快捷键说明

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