using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Data.OleDb;
using XcjwHIS.PubicBaseClasses;
using XcjwHIS.DatabaseAccessLayer;
namespace LISLoid.DeCode_Bak.row4
{
/// <summary>
/// DataDeCode (ACT9000)
/// </summary>
public class DataDeCode
{
public delegate void DataInsertEventHandler(object sender, EventArgs e);
/// <summary>
/// 数据插入数据库事件
/// </summary>
public event DataInsertEventHandler DataInsert;
/// <summary>
/// 解码进度事件
/// </summary>
public delegate void FrmTrayIconChangeEventHandler(int trye,int allcount,int nowcount);
public static event FrmTrayIconChangeEventHandler FrmTrayIcon;
/// <summary>
/// 存放最后得到的数据
/// </summary>
public string DataXML=null;
private string resultfilename=@"result\"+DateTime.Now.ToString("yyMMdd")+".txt";
/// <summary>
/// 数据库连接
/// </summary>
//private System.Data.OleDb.OleDbConnection conn=null;
public DataDeCode()
{
}
public void decode()
{
UTF8Encoding Unicode = new UTF8Encoding();
string allstr=null;
PublicClass.PublicClass_DataRow.bindbase();
if(PublicClass.PublicClass_DataRow.type=="0")//按空格字符用SPLIT截(单行读取)
{
#region 按空格字符用SPLIT截(单行读取)
if(PublicClass.PublicClass_DataRow.bt==null)return;
char[] c=Unicode.GetChars(PublicClass.PublicClass_DataRow.rowbyte);
allstr=Unicode.GetString(PublicClass.PublicClass_DataRow.bt);
string[] rowstr=allstr.Split(c[0]);
if(PublicClass.PublicClass_DataRow.lastrow<(rowstr.Length-1))
{
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
rowstr[PublicClass.PublicClass_DataRow.lastrow]=rowstr[PublicClass.PublicClass_DataRow.lastrow].Trim().Trim(c[1]);
string[] itemstr=rowstr[PublicClass.PublicClass_DataRow.lastrow].Split(new char[]{' '});
for(int n=0;n<itemstr.Length;n++)
{
string ret=itemstr[n].Trim();
this.loadXML(ret,PublicClass.PublicClass_DataRow.ds.Tables["item"].Rows[n][0].ToString(),PublicClass.PublicClass_DataRow.ds.Tables["item"].Rows[n][1].ToString(),n);
DataDeCode.FrmTrayIcon(0,(itemstr.Length-1),n);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
//if(this.DataInsert!=null)
// this.DataInsert(this,EventArgs.Empty);
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(PublicClass.PublicClass_DataRow.lastrow+1));
}
#endregion
}
else if(PublicClass.PublicClass_DataRow.type=="1")//按btye[]=9截 多行读取
{
if(PublicClass.PublicClass_DataRow.bt==null)return;
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
byte[] bb={9};
char[] ch=Unicode.GetChars(bb);
char[] c=Unicode.GetChars(PublicClass.PublicClass_DataRow.rowbyte);
allstr=Unicode.GetString(PublicClass.PublicClass_DataRow.bt);
string[] rowstr=allstr.Split(c[0]);
string biaobenhao=null;
int index=0;
int count=0;
int num=PublicClass.PublicClass_DataRow.lastrow;
if(PublicClass.PublicClass_DataRow.lastrow>=(rowstr.Length-1))return;
for(int i=PublicClass.PublicClass_DataRow.lastrow;i<rowstr.Length;i++)
{
num=num+1;
rowstr[i]=rowstr[i].Trim().Trim(c[1]);
string[] itemstr=rowstr[i].Split(ch[0]);
if(itemstr.Length<5)continue;
if(itemstr[1].Trim().Length>2 && itemstr[1].Trim().Substring(0,2)=="QC")
{
count=count+1;
continue;
}
if(i>PublicClass.PublicClass_DataRow.lastrow+(count>0?1:0))
{
if(biaobenhao!=itemstr[1])
break;
if(itemstr[3].Trim()=="0")
{
string date=itemstr[0].Trim().Replace("/","");
//this.imgToDB(itemstr[5].Trim(),date,itemstr[1].Trim(),itemstr[2].Trim());
}
else
{
this.loadXML(itemstr[4].Trim(),itemstr[2].Trim(),itemstr[2].Trim(),index++);
}
}
else
{
biaobenhao=itemstr[1];
this.loadXML(itemstr[0].Trim(),"日期号","date",index++);
this.loadXML(PublicClass.IsInt(itemstr[1].Trim()),"标本号","bb_num",index++);
this.loadXML(itemstr[4].Trim(),itemstr[2].Trim(),itemstr[2].Trim(),index++);
}
DataDeCode.FrmTrayIcon(0,(rowstr.Length-1),i);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(num-1));
try
{
if(this.DataInsert!=null)
this.DataInsert(this,EventArgs.Empty);
}
catch(System.Exception err)
{
PublicClass.write_errlog(PublicClass.errfilename,PublicClass.DataXML,"数据插入时出错:"+err.Message,PublicClass.DecodeType.datainsertclass);
}
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(num-1));
}
}
/// <summary>
/// 图片插入到数据库
/// </summary>
/// <param name="imgpath">图片路径</param>
/// <param name="date">日期</param>
/// <param name="repno">样本号</param>
/// <param name="picname">图片名</param>
public void imgToDB(string imgpath,string date,string repno,string picname)
{
try
{
FileStream fs = File.OpenRead(imgpath);
byte[] imageb = new byte[fs.Length];
fs.Read(imageb, 0, imageb.Length);
fs.Close();
System.Data.OleDb.OleDbParameter imgpara=new System.Data.OleDb.OleDbParameter("img",System.Data.OleDb.OleDbType.Binary,imageb.Length);
imgpara.Value=imageb;
System.Data.OleDb.OleDbConnection tmpconn=new System.Data.OleDb.OleDbConnection(DatabaseAccess.GetConnectionString(DatabaseType.IbmDb2LIS));
System.Data.OleDb.OleDbCommand olecmd=new System.Data.OleDb.OleDbCommand();
int Ispic=Convert.ToInt32(DatabaseAccess.GetDataResult(DatabaseType.IbmDb2LIS,"select count(*) from lis_as_7img where date='"+date+"' and repno='"+repno+"'"));
string sql=null;
if(Ispic>0)
{
if(picname=="1")
sql="update lis_as_7img set imgtext1=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="2")
sql="update lis_as_7img set imgtext2=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="3")
sql="update lis_as_7img set imgtext3=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="4")
sql="update lis_as_7img set imgtext4=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="5")
sql="update lis_as_7img set imgtext5=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="6")
sql="update lis_as_7img set imgtext6=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="7")
sql="update lis_as_7img set imgtext7=? where date='"+date+"' and repno='"+repno+"'";
}
else
{
if(picname=="1")
sql="insert into lis_as_7img(date,repno,imgname,imgtext1) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="2")
sql="insert into lis_as_7img(date,repno,imgname,imgtext2) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="3")
sql="insert into lis_as_7img(date,repno,imgname,imgtext3) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="4")
sql="insert into lis_as_7img(date,repno,imgname,imgtext4) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="5")
sql="insert into lis_as_7img(date,repno,imgname,imgtext5) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="6")
sql="insert into lis_as_7img(date,repno,imgname,imgtext6) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="7")
sql="insert into lis_as_7img(date,repno,imgname,imgtext7) values('"+date+"','"+repno+"','"+picname+"',?)";//
}
olecmd.CommandText=sql;
olecmd.Connection=tmpconn;
olecmd.Parameters.Add(imgpara);
tmpconn.Open();
olecmd.ExecuteNonQuery();
olecmd.Dispose();
tmpconn.Close();
}
catch(System.Exception err)
{
//MessageBox.Show(err.Message);
}
}
/// <summary>
/// 得到的数据存入XML中
/// </summary>
/// <param name="sd"></param>
/// <param name="name"></param>
/// <param name="codename"></param>
private void loadXML(string sd,string name,string codename,int num)
{
this.DataXML=DataXML+"<Data name=\""+name+"\" codename=\""+codename+"\" codenum=\""+num.ToString()+"\">"+sd+"</Data>";
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Data.OleDb;
using XcjwHIS.PubicBaseClasses;
using XcjwHIS.DatabaseAccessLayer;
namespace LISLoid.DeCode_Bak.row5
{
/// <summary>
/// DataDeCode (ACT9000)
/// </summary>
public class DataDeCode
{
public delegate void DataInsertEventHandler(object sender, EventArgs e);
/// <summary>
/// 数据插入数据库事件
/// </summary>
public event DataInsertEventHandler DataInsert;
/// <summary>
/// 解码进度事件
/// </summary>
public delegate void FrmTrayIconChangeEventHandler(int trye,int allcount,int nowcount);
public static event FrmTrayIconChangeEventHandler FrmTrayIcon;
/// <summary>
/// 存放最后得到的数据
/// </summary>
public string DataXML=null;
private string resultfilename=@"result\"+DateTime.Now.ToString("yyMMdd")+".txt";
/// <summary>
/// 数据库连接
/// </summary>
//private System.Data.OleDb.OleDbConnection conn=null;
public DataDeCode()
{
}
public void decode()
{
UTF8Encoding Unicode = new UTF8Encoding();
string allstr=null;
PublicClass.PublicClass_DataRow.bindbase();
if(PublicClass.PublicClass_DataRow.type=="0")//按空格字符用SPLIT截(单行读取)
{
#region 按空格字符用SPLIT截(单行读取)
if(PublicClass.PublicClass_DataRow.bt==null)return;
char[] c=Unicode.GetChars(PublicClass.PublicClass_DataRow.rowbyte);
allstr=Unicode.GetString(PublicClass.PublicClass_DataRow.bt);
string[] rowstr=allstr.Split(c[0]);
if(PublicClass.PublicClass_DataRow.lastrow<(rowstr.Length-1))
{
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
rowstr[PublicClass.PublicClass_DataRow.lastrow]=rowstr[PublicClass.PublicClass_DataRow.lastrow].Trim().Trim(c[1]);
string[] itemstr=rowstr[PublicClass.PublicClass_DataRow.lastrow].Split(new char[]{' '});
for(int n=0;n<itemstr.Length;n++)
{
string ret=itemstr[n].Trim();
this.loadXML(ret,PublicClass.PublicClass_DataRow.ds.Tables["item"].Rows[n][0].ToString(),PublicClass.PublicClass_DataRow.ds.Tables["item"].Rows[n][1].ToString(),n);
DataDeCode.FrmTrayIcon(0,(itemstr.Length-1),n);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
//if(this.DataInsert!=null)
// this.DataInsert(this,EventArgs.Empty);
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(PublicClass.PublicClass_DataRow.lastrow+1));
}
#endregion
}
else if(PublicClass.PublicClass_DataRow.type=="1")//按btye[]=9截 多行读取
{
if(PublicClass.PublicClass_DataRow.bt==null)return;
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
byte[] bb={9};
char[] ch=Unicode.GetChars(bb);
char[] c=Unicode.GetChars(PublicClass.PublicClass_DataRow.rowbyte);
allstr=Unicode.GetString(PublicClass.PublicClass_DataRow.bt);
string[] rowstr=allstr.Split(c[0]);
string biaobenhao=null;
int index=0;
int count=0;
int num=PublicClass.PublicClass_DataRow.lastrow;
if(PublicClass.PublicClass_DataRow.lastrow>=(rowstr.Length-1))return;
for(int i=PublicClass.PublicClass_DataRow.lastrow;i<rowstr.Length;i++)
{
num=num+1;
rowstr[i]=rowstr[i].Trim().Trim(c[1]);
string[] itemstr=rowstr[i].Split(ch[0]);
if(itemstr.Length<5)continue;
if(itemstr[1].Trim().Length>2 && itemstr[1].Trim().Substring(0,2)=="QC")
{
count=count+1;
continue;
}
if(i>PublicClass.PublicClass_DataRow.lastrow+(count>0?1:0))
{
if(biaobenhao!=itemstr[1])
break;
if(itemstr[3].Trim()=="0")
{
string date=itemstr[0].Trim().Replace("/","");
//this.imgToDB(itemstr[5].Trim(),date,itemstr[1].Trim(),itemstr[2].Trim());
}
else
{
this.loadXML(itemstr[4].Trim(),itemstr[2].Trim(),itemstr[2].Trim(),index++);
}
}
else
{
biaobenhao=itemstr[1];
this.loadXML(itemstr[0].Trim(),"日期号","date",index++);
this.loadXML(PublicClass.IsInt(itemstr[1].Trim()),"标本号","bb_num",index++);
this.loadXML(itemstr[4].Trim(),itemstr[2].Trim(),itemstr[2].Trim(),index++);
}
DataDeCode.FrmTrayIcon(0,(rowstr.Length-1),i);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(num-1));
try
{
if(this.DataInsert!=null)
this.DataInsert(this,EventArgs.Empty);
}
catch(System.Exception err)
{
PublicClass.write_errlog(PublicClass.errfilename,PublicClass.DataXML,"数据插入时出错:"+err.Message,PublicClass.DecodeType.datainsertclass);
}
PublicClass.updateNode(PublicClass.PublicClass_DataRow.filename,"lastrow",Convert.ToString(num-1));
}
}
/// <summary>
/// 图片插入到数据库
/// </summary>
/// <param name="imgpath">图片路径</param>
/// <param name="date">日期</param>
/// <param name="repno">样本号</param>
/// <param name="picname">图片名</param>
public void imgToDB(string imgpath,string date,string repno,string picname)
{
try
{
FileStream fs = File.OpenRead(imgpath);
byte[] imageb = new byte[fs.Length];
fs.Read(imageb, 0, imageb.Length);
fs.Close();
System.Data.OleDb.OleDbParameter imgpara=new System.Data.OleDb.OleDbParameter("img",System.Data.OleDb.OleDbType.Binary,imageb.Length);
imgpara.Value=imageb;
System.Data.OleDb.OleDbConnection tmpconn=new System.Data.OleDb.OleDbConnection(DatabaseAccess.GetConnectionString(DatabaseType.IbmDb2LIS));
System.Data.OleDb.OleDbCommand olecmd=new System.Data.OleDb.OleDbCommand();
int Ispic=Convert.ToInt32(DatabaseAccess.GetDataResult(DatabaseType.IbmDb2LIS,"select count(*) from lis_as_7img where date='"+date+"' and repno='"+repno+"'"));
string sql=null;
if(Ispic>0)
{
if(picname=="1")
sql="update lis_as_7img set imgtext1=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="2")
sql="update lis_as_7img set imgtext2=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="3")
sql="update lis_as_7img set imgtext3=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="4")
sql="update lis_as_7img set imgtext4=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="5")
sql="update lis_as_7img set imgtext5=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="6")
sql="update lis_as_7img set imgtext6=? where date='"+date+"' and repno='"+repno+"'";
else if(picname=="7")
sql="update lis_as_7img set imgtext7=? where date='"+date+"' and repno='"+repno+"'";
}
else
{
if(picname=="1")
sql="insert into lis_as_7img(date,repno,imgname,imgtext1) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="2")
sql="insert into lis_as_7img(date,repno,imgname,imgtext2) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="3")
sql="insert into lis_as_7img(date,repno,imgname,imgtext3) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="4")
sql="insert into lis_as_7img(date,repno,imgname,imgtext4) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="5")
sql="insert into lis_as_7img(date,repno,imgname,imgtext5) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="6")
sql="insert into lis_as_7img(date,repno,imgname,imgtext6) values('"+date+"','"+repno+"','"+picname+"',?)";//
else if(picname=="7")
sql="insert into lis_as_7img(date,repno,imgname,imgtext7) values('"+date+"','"+repno+"','"+picname+"',?)";//
}
olecmd.CommandText=sql;
olecmd.Connection=tmpconn;
olecmd.Parameters.Add(imgpara);
tmpconn.Open();
olecmd.ExecuteNonQuery();
olecmd.Dispose();
tmpconn.Close();
}
catch(System.Exception err)
{
//MessageBox.Show(err.Message);
}
}
/// <summary>
/// 得到的数据存入XML中
/// </summary>
/// <param name="sd"></param>
/// <param name="name"></param>
/// <param name="codename"></param>
private void loadXML(string sd,string name,string codename,int num)
{
this.DataXML=DataXML+"<Data name=\""+name+"\" codename=\""+codename+"\" codenum=\""+num.ToString()+"\">"+sd+"</Data>";
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using XcjwHIS.BussinessLogicLayer;
using XcjwHIS.DatabaseAccessLayer;
using XcjwHIS.PubicBaseClasses;
using XcjwHIS.PublicControls;
using System.Data;
using System.Threading;
namespace ClearData
{
/// <summary>
/// Datashow 的摘要说明。
/// </summary>
public class Datashow
{
public static string ErrStr=null;
public static bool ErrBool=false;
private static DataSet ds=null;
public static string DBcon="DB2ConnMZ";
public delegate void RuningEventHandler(string sql,int allcount,int nowcount);
public static event RuningEventHandler Runing;
public static string[] ListSql={"select","from","where","and","or","call","DB2ConnMZ","DB2ConnZY","DB2ConnLIS"};
public Datashow()
{
}
public static DataSet OutData(string sqlstr)
{
string[] sqls=OutSql(sqlstr);
int num=sqls.Length;
try
{
ds=new DataSet();
for(int i=0;i<num;i++)
{
Datashow.Runing(sqls[i],num,i);
if(sqls[i].Trim()!="")
{
#region
if(sqls[i].Trim()=="DB2ConnMZ")
{
DBcon="DB2ConnMZ";
}
else if(sqls[i].Trim()=="DB2ConnZY")
{
DBcon="DB2ConnZY";
}
else if(sqls[i].Trim()=="DB2ConnLIS")
{
DBcon="DB2ConnLIS";
}
else if(sqls[i].Trim().Length>2 && sqls[i].Trim().Substring(0,2)=="--")
{
}
else
{
int n1=sqls[i].Trim().IndexOf(" ");
string name=sqls[i].Trim().Substring(0,n1).Trim();
DataTable dt=null;
if(DBcon=="DB2ConnMZ")
{
if(name=="call" || name=="CALL")
{
int n2=sqls[i].Trim().IndexOf("(");
string name2=sqls[i].Trim().Substring(n1,n2-n1).Trim();
int n3=sqls[i].Trim().IndexOf(")");
string name3=sqls[i].Trim().Substring(n2+1,n3-n2-1);
string[] names=name3.Split(new char[]{','});
ParameterEx[] para=new ParameterEx[names.Length];
for(int k=0;k<para.Length;k++)
{
if(names[k].Trim()=="?")
{
para[k].Value=null;
para[k].ParaDirection=ParameterDirection.Output;
para[k].ParaSize=100;
}
else
{
para[k].Value=names[k].Trim();
}
}
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,name2,para,90);
}
else
{
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,sqls[i]);
}
}
else if(DBcon=="DB2ConnZY")
{
if(name=="call" || name=="CALL")
{
int n2=sqls[i].Trim().IndexOf("(");
string name2=sqls[i].Trim().Substring(n1,n2-n1).Trim();
int n3=sqls[i].Trim().IndexOf(")");
string name3=sqls[i].Trim().Substring(n2+1,n3-n2-1);
string[] names=name3.Split(new char[]{','});
ParameterEx[] para=new ParameterEx[names.Length];
for(int k=0;k<para.Length;k++)
{
if(names[k].Trim()=="?")
{
para[k].Value=null;
para[k].ParaDirection=ParameterDirection.Output;
para[k].ParaSize=100;
}
else
{
para[k].Value=names[k].Trim();
}
}
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,name2,para,90);
}
else
{
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,sqls[i]);
}
}
else if(DBcon=="DB2ConnLIS")
{
if(name=="call" || name=="CALL")
{
int n2=sqls[i].Trim().IndexOf("(");
string name2=sqls[i].Trim().Substring(n1,n2-n1).Trim();
int n3=sqls[i].Trim().IndexOf(")");
string name3=sqls[i].Trim().Substring(n2+1,n3-n2-1);
string[] names=name3.Split(new char[]{','});
ParameterEx[] para=new ParameterEx[names.Length];
for(int k=0;k<para.Length;k++)
{
if(names[k].Trim()=="?")
{
para[k].Value=null;
para[k].ParaDirection=ParameterDirection.Output;
para[k].ParaSize=100;
}
else
{
para[k].Value=names[k].Trim();
}
}
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,name2,para,90);
}
else
{
dt=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,sqls[i]);
}
}
ds.Tables.Add(dt);
}
#endregion
}
}
}
catch(System.Exception err)
{
ErrStr=err.Message;
ErrBool=true;
}
return ds;
}
public static string[] OutSql(string sqlstr)
{
string[] sqls=sqlstr.Split(new char[]{';'});
return sqls;
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using XcjwHIS.BussinessLogicLayer;
using XcjwHIS.DatabaseAccessLayer;
using XcjwHIS.PubicBaseClasses;
using XcjwHIS.PublicControls;
using System.Data;
using System.Threading;
using System.IO;
namespace ClearData
{
/// <summary>
/// FrmClearData 的摘要说明。
/// </summary>
public class FrmClearData : System.Windows.Forms.Form
{
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.TabControl tabControl2;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.Splitter splitter2;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.TreeView HISDB2treeView;
private System.Windows.Forms.TabControl HISDB2tabControl;
private System.Windows.Forms.TabPage HISDB2tpsqltext;
private System.Windows.Forms.RichTextBox db2sqlstr;
private System.Windows.Forms.TabPage HISDB2tpsql;
private System.Windows.Forms.RichTextBox ressqlstr;
private System.Windows.Forms.DataGrid dg1;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Splitter splitter3;
private System.Windows.Forms.RichTextBox richTextBox1;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.Windows.Forms.ToolBarButton toolBarButton6;
private System.Windows.Forms.ToolBarButton toolBarButton7;
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem menuItem12;
private System.Windows.Forms.MenuItem menuItem13;
private System.Windows.Forms.MenuItem menuItem14;
private System.Windows.Forms.MenuItem menuItem15;
private System.Windows.Forms.MenuItem menuItem16;
private System.Windows.Forms.MenuItem menuItem17;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.ToolBarButton toolBarButton8;
private System.Windows.Forms.ToolBarButton toolBarButton9;
private System.Windows.Forms.ToolBarButton toolBarButton10;
private System.Windows.Forms.ToolBarButton toolBarButton11;
private System.Windows.Forms.ToolBarButton toolBarButton12;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem menuItem21;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.ProgressBar progressBar1;
private System.ComponentModel.IContainer components;
[DllImport("User32.dll", EntryPoint = "FindWindow")] //找窗体
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("User32.dll", EntryPoint = "ShowWindow")] //显示窗体
private static extern bool ShowWindow(IntPtr hWnd, int type);
private Thread t;
private DataSet ds;
private string constr=null;
private int keynum=0;
private RichTextBox rtb
{
get
{
if(this.HISDB2tabControl.SelectedIndex==0)
return this.db2sqlstr;
else// if(this.HISDB2tabControl.SelectedIndex==1)
return this.ressqlstr;
// else
// return (new RichTextBox());
}
set
{
if(this.HISDB2tabControl.SelectedIndex==0)
this.db2sqlstr=value;
else// if(this.HISDB2tabControl.SelectedIndex==1)
this.ressqlstr=value;
// else
// return (new RichTextBox());
}
}
private string strtext
{
get
{
return this.rtb.Text;
}
set
{
this.rtb.Text=value;
}
}
public FrmClearData()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
Datashow.Runing+=new ClearData.Datashow.RuningEventHandler(Datashow_Runing);
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
private void Datashow_Runing(string sql,int allcount,int nowcount)
{
this.progressBar1.Maximum=allcount;
this.progressBar1.Value=nowcount+1;
this.SelectSql(sql);
}
private void SelectSql(string sql)
{
//this.db2sqlstr.SelectAll();
//this.db2sqlstr.SelectionColor=Color.Black;
int selectbegin=this.strtext.IndexOf(sql);
int selectlength=sql.Length;
this.rtb.Select(selectbegin,selectlength);
//this.rtb.SelectionColor=Color.Red;
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new FrmClearData());
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmClearData));
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.toolBar1 = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton4 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton6 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton3 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton7 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton5 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton8 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton9 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton10 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton11 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton12 = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.HISDB2treeView = new System.Windows.Forms.TreeView();
this.splitter1 = new System.Windows.Forms.Splitter();
this.HISDB2tabControl = new System.Windows.Forms.TabControl();
this.HISDB2tpsqltext = new System.Windows.Forms.TabPage();
this.splitter3 = new System.Windows.Forms.Splitter();
this.panel2 = new System.Windows.Forms.Panel();
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.db2sqlstr = new System.Windows.Forms.RichTextBox();
this.contextMenu1 = new System.Windows.Forms.ContextMenu();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.menuItem13 = new System.Windows.Forms.MenuItem();
this.menuItem12 = new System.Windows.Forms.MenuItem();
this.menuItem14 = new System.Windows.Forms.MenuItem();
this.menuItem15 = new System.Windows.Forms.MenuItem();
this.menuItem16 = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem17 = new System.Windows.Forms.MenuItem();
this.HISDB2tpsql = new System.Windows.Forms.TabPage();
this.panel3 = new System.Windows.Forms.Panel();
this.tabControl2 = new System.Windows.Forms.TabControl();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.dg1 = new System.Windows.Forms.DataGrid();
this.splitter2 = new System.Windows.Forms.Splitter();
this.ressqlstr = new System.Windows.Forms.RichTextBox();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem19 = new System.Windows.Forms.MenuItem();
this.menuItem20 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.progressBar1 = new System.Windows.Forms.ProgressBar();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
this.HISDB2tabControl.SuspendLayout();
this.HISDB2tpsqltext.SuspendLayout();
this.panel2.SuspendLayout();
this.panel1.SuspendLayout();
this.HISDB2tpsql.SuspendLayout();
this.panel3.SuspendLayout();
this.tabControl2.SuspendLayout();
this.tabPage3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dg1)).BeginInit();
this.SuspendLayout();
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 471);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(640, 22);
this.statusBar1.TabIndex = 0;
//
// statusBarPanel1
//
this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
this.statusBarPanel1.Text = "DB2数据查询客户端";
this.statusBarPanel1.Width = 624;
//
// toolBar1
//
this.toolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton4,
this.toolBarButton6,
this.toolBarButton2,
this.toolBarButton3,
this.toolBarButton7,
this.toolBarButton5,
this.toolBarButton8,
this.toolBarButton9,
this.toolBarButton10,
this.toolBarButton11,
this.toolBarButton12});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(640, 28);
this.toolBar1.TabIndex = 1;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 0;
this.toolBarButton1.Tag = "0";
this.toolBarButton1.ToolTipText = "打开";
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 8;
this.toolBarButton4.Tag = "1";
this.toolBarButton4.ToolTipText = "刷新数据库";
//
// toolBarButton6
//
this.toolBarButton6.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton2
//
this.toolBarButton2.ImageIndex = 1;
this.toolBarButton2.Tag = "2";
this.toolBarButton2.ToolTipText = "执行";
//
// toolBarButton3
//
this.toolBarButton3.Enabled = false;
this.toolBarButton3.ImageIndex = 3;
this.toolBarButton3.Tag = "3";
this.toolBarButton3.ToolTipText = "停止";
//
// toolBarButton7
//
this.toolBarButton7.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton5
//
this.toolBarButton5.ImageIndex = 5;
this.toolBarButton5.Tag = "4";
this.toolBarButton5.ToolTipText = "SQL语法帮助";
//
// toolBarButton8
//
this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton9
//
this.toolBarButton9.ImageIndex = 6;
this.toolBarButton9.Tag = "5";
this.toolBarButton9.ToolTipText = "注释";
//
// toolBarButton10
//
this.toolBarButton10.ImageIndex = 7;
this.toolBarButton10.Tag = "6";
this.toolBarButton10.ToolTipText = "撤消注释";
//
// toolBarButton11
//
this.toolBarButton11.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton12
//
this.toolBarButton12.ImageIndex = 9;
this.toolBarButton12.Tag = "7";
this.toolBarButton12.ToolTipText = "保存";
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// HISDB2treeView
//
this.HISDB2treeView.Dock = System.Windows.Forms.DockStyle.Left;
this.HISDB2treeView.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.HISDB2treeView.ImageList = this.imageList1;
this.HISDB2treeView.Location = new System.Drawing.Point(0, 28);
this.HISDB2treeView.Name = "HISDB2treeView";
this.HISDB2treeView.Size = new System.Drawing.Size(160, 443);
this.HISDB2treeView.TabIndex = 2;
this.HISDB2treeView.DoubleClick += new System.EventHandler(this.HISDB2treeView_DoubleClick);
//
// splitter1
//
this.splitter1.Location = new System.Drawing.Point(160, 28);
this.splitter1.Name = "splitter1";
this.splitter1.Size = new System.Drawing.Size(3, 443);
this.splitter1.TabIndex = 3;
this.splitter1.TabStop = false;
//
// HISDB2tabControl
//
this.HISDB2tabControl.Controls.Add(this.HISDB2tpsqltext);
this.HISDB2tabControl.Controls.Add(this.HISDB2tpsql);
this.HISDB2tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
this.HISDB2tabControl.Location = new System.Drawing.Point(163, 28);
this.HISDB2tabControl.Name = "HISDB2tabControl";
this.HISDB2tabControl.SelectedIndex = 0;
this.HISDB2tabControl.Size = new System.Drawing.Size(477, 443);
this.HISDB2tabControl.TabIndex = 4;
//
// HISDB2tpsqltext
//
this.HISDB2tpsqltext.Controls.Add(this.splitter3);
this.HISDB2tpsqltext.Controls.Add(this.panel2);
this.HISDB2tpsqltext.Controls.Add(this.panel1);
this.HISDB2tpsqltext.Location = new System.Drawing.Point(4, 21);
this.HISDB2tpsqltext.Name = "HISDB2tpsqltext";
this.HISDB2tpsqltext.Size = new System.Drawing.Size(469, 418);
this.HISDB2tpsqltext.TabIndex = 0;
this.HISDB2tpsqltext.Text = "SQLEditer";
//
// splitter3
//
this.splitter3.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter3.Location = new System.Drawing.Point(0, 312);
this.splitter3.Name = "splitter3";
this.splitter3.Size = new System.Drawing.Size(469, 3);
this.splitter3.TabIndex = 3;
this.splitter3.TabStop = false;
//
// panel2
//
this.panel2.Controls.Add(this.richTextBox1);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 312);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(469, 106);
this.panel2.TabIndex = 2;
//
// richTextBox1
//
this.richTextBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.richTextBox1.Location = new System.Drawing.Point(0, 0);
this.richTextBox1.Name = "richTextBox1";
this.richTextBox1.ReadOnly = true;
this.richTextBox1.Size = new System.Drawing.Size(469, 106);
this.richTextBox1.TabIndex = 0;
this.richTextBox1.Text = "------------错误信息显示---------";
//
// panel1
//
this.panel1.Controls.Add(this.db2sqlstr);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(469, 312);
this.panel1.TabIndex = 1;
//
// db2sqlstr
//
this.db2sqlstr.ContextMenu = this.contextMenu1;
this.db2sqlstr.Dock = System.Windows.Forms.DockStyle.Fill;
this.db2sqlstr.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.db2sqlstr.Location = new System.Drawing.Point(0, 0);
this.db2sqlstr.Name = "db2sqlstr";
this.db2sqlstr.Size = new System.Drawing.Size(469, 312);
this.db2sqlstr.TabIndex = 0;
this.db2sqlstr.Text = "";
this.db2sqlstr.TextChanged += new System.EventHandler(this.db2sqlstr_TextChanged);
//
// contextMenu1
//
this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem11,
this.menuItem13,
this.menuItem12,
this.menuItem14,
this.menuItem15,
this.menuItem16,
this.menuItem18,
this.menuItem17});
//
// menuItem11
//
this.menuItem11.Index = 0;
this.menuItem11.Text = "撤消(&U)";
this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
// menuItem13
//
this.menuItem13.Index = 1;
this.menuItem13.Text = "-";
//
// menuItem12
//
this.menuItem12.Index = 2;
this.menuItem12.Text = "剪切(&T)";
this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click);
//
// menuItem14
//
this.menuItem14.Index = 3;
this.menuItem14.Text = "复制(&C)";
this.menuItem14.Click += new System.EventHandler(this.menuItem14_Click);
//
// menuItem15
//
this.menuItem15.Index = 4;
this.menuItem15.Text = "粘贴(&P)";
this.menuItem15.Click += new System.EventHandler(this.menuItem15_Click);
//
// menuItem16
//
this.menuItem16.Index = 5;
this.menuItem16.Text = "清空(&D)";
this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click);
//
// menuItem18
//
this.menuItem18.Index = 6;
this.menuItem18.Text = "-";
//
// menuItem17
//
this.menuItem17.Index = 7;
this.menuItem17.Text = "全选(&A)";
this.menuItem17.Click += new System.EventHandler(this.menuItem17_Click);
//
// HISDB2tpsql
//
this.HISDB2tpsql.Controls.Add(this.panel3);
this.HISDB2tpsql.Controls.Add(this.splitter2);
this.HISDB2tpsql.Controls.Add(this.ressqlstr);
this.HISDB2tpsql.Location = new System.Drawing.Point(4, 21);
this.HISDB2tpsql.Name = "HISDB2tpsql";
this.HISDB2tpsql.Size = new System.Drawing.Size(469, 418);
this.HISDB2tpsql.TabIndex = 1;
this.HISDB2tpsql.Text = "RESULT";
//
// panel3
//
this.panel3.Controls.Add(this.tabControl2);
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel3.Location = new System.Drawing.Point(0, 91);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(469, 327);
this.panel3.TabIndex = 3;
//
// tabControl2
//
this.tabControl2.Controls.Add(this.tabPage3);
this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl2.Location = new System.Drawing.Point(0, 0);
this.tabControl2.Name = "tabControl2";
this.tabControl2.SelectedIndex = 0;
this.tabControl2.Size = new System.Drawing.Size(469, 327);
this.tabControl2.TabIndex = 1;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.dg1);
this.tabPage3.Location = new System.Drawing.Point(4, 21);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(461, 302);
this.tabPage3.TabIndex = 0;
this.tabPage3.Text = "结果";
//
// dg1
//
this.dg1.DataMember = "";
this.dg1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dg1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dg1.Location = new System.Drawing.Point(0, 0);
this.dg1.Name = "dg1";
this.dg1.Size = new System.Drawing.Size(461, 302);
this.dg1.TabIndex = 0;
//
// splitter2
//
this.splitter2.Dock = System.Windows.Forms.DockStyle.Top;
this.splitter2.Location = new System.Drawing.Point(0, 88);
this.splitter2.Name = "splitter2";
this.splitter2.Size = new System.Drawing.Size(469, 3);
this.splitter2.TabIndex = 2;
this.splitter2.TabStop = false;
//
// ressqlstr
//
this.ressqlstr.ContextMenu = this.contextMenu1;
this.ressqlstr.Dock = System.Windows.Forms.DockStyle.Top;
this.ressqlstr.Location = new System.Drawing.Point(0, 0);
this.ressqlstr.Name = "ressqlstr";
this.ressqlstr.Size = new System.Drawing.Size(469, 88);
this.ressqlstr.TabIndex = 0;
this.ressqlstr.Text = "";
this.ressqlstr.TextChanged += new System.EventHandler(this.db2sqlstr_TextChanged);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem7});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem10,
this.menuItem21,
this.menuItem3,
this.menuItem19,
this.menuItem20,
this.menuItem4});
this.menuItem1.Text = "文件";
//
// menuItem10
//
this.menuItem10.Index = 0;
this.menuItem10.Text = "配置连接数据库";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuItem21
//
this.menuItem21.Index = 1;
this.menuItem21.Text = "-";
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "打开";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem19
//
this.menuItem19.Index = 3;
this.menuItem19.Text = "保存";
this.menuItem19.Click += new System.EventHandler(this.menuItem19_Click);
//
// menuItem20
//
this.menuItem20.Index = 4;
this.menuItem20.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 5;
this.menuItem4.Text = "退出";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem5,
this.menuItem6});
this.menuItem2.Text = "调试";
//
// menuItem5
//
this.menuItem5.Index = 0;
this.menuItem5.Text = "运行(Alt+X)";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 1;
this.menuItem6.Text = "停止(Alt+Z)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 2;
this.menuItem7.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem8,
this.menuItem9});
this.menuItem7.Text = "帮助";
//
// menuItem8
//
this.menuItem8.Index = 0;
this.menuItem8.Text = "帮助";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 1;
this.menuItem9.Text = "关于";
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// progressBar1
//
this.progressBar1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.progressBar1.Location = new System.Drawing.Point(163, 463);
this.progressBar1.Name = "progressBar1";
this.progressBar1.Size = new System.Drawing.Size(477, 8);
this.progressBar1.TabIndex = 5;
//
// FrmClearData
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(640, 493);
this.Controls.Add(this.progressBar1);
this.Controls.Add(this.HISDB2tabControl);
this.Controls.Add(this.splitter1);
this.Controls.Add(this.HISDB2treeView);
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.statusBar1);
this.KeyPreview = true;
this.Menu = this.mainMenu1;
this.Name = "FrmClearData";
this.Text = "HISDB2-Client";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.FrmClearData_KeyDown);
this.Closing += new System.ComponentModel.CancelEventHandler(this.FrmClearData_Closing);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.FrmClearData_KeyPress);
this.Load += new System.EventHandler(this.FrmClearData_Load);
this.Closed += new System.EventHandler(this.FrmClearData_Closed);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
this.HISDB2tabControl.ResumeLayout(false);
this.HISDB2tpsqltext.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.HISDB2tpsql.ResumeLayout(false);
this.panel3.ResumeLayout(false);
this.tabControl2.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dg1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 连接数据库配置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem10_Click(object sender, System.EventArgs e)
{
string title=null;
IntPtr ParenthWnd = new IntPtr(0);
title="客户端配置";
ParenthWnd = FindWindow(null,title);
if (!ParenthWnd.Equals(IntPtr.Zero))
{
ShowWindow(ParenthWnd, 0);//显示已打开的窗体
ShowWindow(ParenthWnd, 5);//显示已打开的窗体
}
else
System.Diagnostics.Process.Start("ServerIniConfig.exe");
}
/// <summary>
/// sql语法帮助
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem8_Click(object sender, System.EventArgs e)
{
string title=null;
IntPtr ParenthWnd = new IntPtr(0);
title="Microsoft Jet SQL 参考";
ParenthWnd = FindWindow(null,title);
if (!ParenthWnd.Equals(IntPtr.Zero))
{
ShowWindow(ParenthWnd, 0);//显示已打开的窗体
ShowWindow(ParenthWnd, 5);//显示已打开的窗体
}
else
System.Diagnostics.Process.Start("SQL.chm");
}
private void bind_nodes()
{
try
{
TreeNode hisdbmz=new TreeNode();
TreeNode hisdbzy=new TreeNode();
TreeNode hisdblis=new TreeNode();
hisdbmz.Text="门诊";
hisdbmz.Tag="DB2ConnMZ";
hisdbmz.ForeColor=Color.Blue;
hisdbmz.ImageIndex=10;
hisdbzy.Text="住院";
hisdbzy.Tag="DB2ConnZY";
hisdbzy.ForeColor=Color.Blue;
hisdbzy.ImageIndex=10;
hisdblis.Text="LIS";
hisdblis.Tag="DB2ConnLIS";
hisdblis.ForeColor=Color.Blue;
hisdblis.ImageIndex=10;
this.HISDB2treeView.Nodes.Add(hisdbmz);
this.HISDB2treeView.Nodes.Add(hisdbzy);
this.HISDB2treeView.Nodes.Add(hisdblis);
TreeNode[] hismz=new TreeNode[6];
hismz[0]=new TreeNode("表");
hismz[1]=new TreeNode("视图");
hismz[2]=new TreeNode("存储过程");
hismz[3]=new TreeNode("索引");
hismz[4]=new TreeNode("函数");
hismz[5]=new TreeNode("触发器");
hisdbmz.Nodes.AddRange(hismz);
TreeNode[] hiszy=new TreeNode[6];
hiszy[0]=new TreeNode("表");
hiszy[1]=new TreeNode("视图");
hiszy[2]=new TreeNode("存储过程");
hiszy[3]=new TreeNode("索引");
hiszy[4]=new TreeNode("函数");
hiszy[5]=new TreeNode("触发器");
hisdbzy.Nodes.AddRange(hiszy);
TreeNode[] hislis=new TreeNode[6];
hislis[0]=new TreeNode("表");
hislis[1]=new TreeNode("视图");
hislis[2]=new TreeNode("存储过程");
hislis[3]=new TreeNode("索引");
hislis[4]=new TreeNode("函数");
hislis[5]=new TreeNode("触发器");
hisdblis.Nodes.AddRange(hislis);
this.bind_dbnames(hismz,hiszy,hislis);
}
catch(System.Exception err)
{
MessageBox.Show(err.Message);
}
}
private void bind_dbnames(TreeNode[] hismz,TreeNode[] hiszy,TreeNode[] hislis)
{
DataTable[] hismzdt=new DataTable[6];
DataTable[] hiszydt=new DataTable[6];
DataTable[] hislisdt=new DataTable[6];
try
{
hismzdt[0]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select tabschema,tabname from syscat.tables where tabschema in('DB2INST1','DB2INST2','DB2INST3') order by tabname ");
hismzdt[1]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select viewschema,viewname from syscat.views where viewschema in('DB2INST1','DB2INST2','DB2INST3') order by viewname");
hismzdt[2]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select procschema,procname from syscat.procedures where procschema in('DB2INST1','DB2INST2','DB2INST3') order by procname");
hismzdt[3]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select indschema,indname from syscat.indexes where indschema in('DB2INST1','DB2INST2','DB2INST3') order by indname");
hismzdt[4]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select funcschema,funcname from syscat.functions where funcschema in('DB2INST1','DB2INST2','DB2INST3') order by funcname");
hismzdt[5]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2,"select trigname from syscat.triggers");
TreeNode[] mztab=new TreeNode[hismzdt[0].Rows.Count];//表
for(int i=0;i<mztab.Length;i++)
{
mztab[i]=new TreeNode(hismzdt[0].Rows[i][1].ToString()+" ("+hismzdt[0].Rows[i][0].ToString()+")");
mztab[i].Tag=4;
mztab[i].ImageIndex=11;
}
hismz[0].Nodes.AddRange(mztab);
TreeNode[] mzview=new TreeNode[hismzdt[1].Rows.Count];//视图
for(int i=0;i<mzview.Length;i++)
{
mzview[i]=new TreeNode(hismzdt[1].Rows[i][1].ToString()+" ("+hismzdt[1].Rows[i][0].ToString()+")");
mzview[i].Tag=1;
}
hismz[1].Nodes.AddRange(mzview);
TreeNode[] mzproc=new TreeNode[hismzdt[2].Rows.Count];//存储过程
for(int i=0;i<mzproc.Length;i++)
{
mzproc[i]=new TreeNode(hismzdt[2].Rows[i][1].ToString()+" ("+hismzdt[2].Rows[i][0].ToString()+")");
mzproc[i].Tag=2;
}
hismz[2].Nodes.AddRange(mzproc);
TreeNode[] mzind=new TreeNode[hismzdt[3].Rows.Count];//索引
for(int i=0;i<mzind.Length;i++)
{
mzind[i]=new TreeNode(hismzdt[3].Rows[i][1].ToString()+" ("+hismzdt[3].Rows[i][0].ToString()+")");
}
hismz[3].Nodes.AddRange(mzind);
TreeNode[] mzfunc=new TreeNode[hismzdt[4].Rows.Count];//函数
for(int i=0;i<mzfunc.Length;i++)
{
mzfunc[i]=new TreeNode(hismzdt[4].Rows[i][1].ToString()+" ("+hismzdt[4].Rows[i][0].ToString()+")");
mzfunc[i].Tag=3;
}
hismz[4].Nodes.AddRange(mzfunc);
TreeNode[] mztirg=new TreeNode[hismzdt[5].Rows.Count];//触发器
for(int i=0;i<mztirg.Length;i++)
{
mztirg[i]=new TreeNode(hismzdt[5].Rows[i][0].ToString());
}
hismz[5].Nodes.AddRange(mztirg);
}
catch(System.Exception err)
{
MessageBox.Show(err.Message,"连接数据库配置不正确",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
try
{
hiszydt[0]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select tabschema,tabname from syscat.tables where tabschema in('DB2INST1','DB2INST2','DB2INST3') order by tabname ");
hiszydt[1]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select viewschema,viewname from syscat.views where viewschema in('DB2INST1','DB2INST2','DB2INST3') order by viewname");
hiszydt[2]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select procschema,procname from syscat.procedures where procschema in('DB2INST1','DB2INST2','DB2INST3') order by procname");
hiszydt[3]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select indschema,indname from syscat.indexes where indschema in('DB2INST1','DB2INST2','DB2INST3') order by indname");
hiszydt[4]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select funcschema,funcname from syscat.functions where funcschema in('DB2INST1','DB2INST2','DB2INST3') order by funcname");
hiszydt[5]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2ZY,"select trigname from syscat.triggers");
TreeNode[] zytab=new TreeNode[hiszydt[0].Rows.Count];//表
for(int i=0;i<zytab.Length;i++)
{
zytab[i]=new TreeNode(hiszydt[0].Rows[i][1].ToString()+" ("+hiszydt[0].Rows[i][0].ToString()+")");
zytab[i].Tag=4;
zytab[i].ImageIndex=11;
}
hiszy[0].Nodes.AddRange(zytab);
TreeNode[] zyview=new TreeNode[hiszydt[1].Rows.Count];//视图
for(int i=0;i<zyview.Length;i++)
{
zyview[i]=new TreeNode(hiszydt[1].Rows[i][1].ToString()+" ("+hiszydt[1].Rows[i][0].ToString()+")");
zyview[i].Tag=1;
}
hiszy[1].Nodes.AddRange(zyview);
TreeNode[] zyproc=new TreeNode[hiszydt[2].Rows.Count];//存储过程
for(int i=0;i<zyproc.Length;i++)
{
zyproc[i]=new TreeNode(hiszydt[2].Rows[i][1].ToString()+" ("+hiszydt[2].Rows[i][0].ToString()+")");
zyproc[i].Tag=2;
}
hiszy[2].Nodes.AddRange(zyproc);
TreeNode[] zyind=new TreeNode[hiszydt[3].Rows.Count];//索引
for(int i=0;i<zyind.Length;i++)
{
zyind[i]=new TreeNode(hiszydt[3].Rows[i][1].ToString()+" ("+hiszydt[3].Rows[i][0].ToString()+")");
}
hiszy[3].Nodes.AddRange(zyind);
TreeNode[] zyfunc=new TreeNode[hiszydt[4].Rows.Count];//函数
for(int i=0;i<zyfunc.Length;i++)
{
zyfunc[i]=new TreeNode(hiszydt[4].Rows[i][1].ToString()+" ("+hiszydt[4].Rows[i][0].ToString()+")");
zyfunc[i].Tag=3;
}
hiszy[4].Nodes.AddRange(zyfunc);
TreeNode[] zytirg=new TreeNode[hiszydt[5].Rows.Count];//触发器
for(int i=0;i<zytirg.Length;i++)
{
zytirg[i]=new TreeNode(hiszydt[5].Rows[i][0].ToString());
}
hiszy[5].Nodes.AddRange(zytirg);
}
catch(System.Exception err)
{
MessageBox.Show(err.Message,"连接数据库配置不正确",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
try
{
hislisdt[0]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select tabschema,tabname from syscat.tables where tabschema in('DB2INST1','DB2INST2','DB2INST3') order by tabname ");
hislisdt[1]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select viewschema,viewname from syscat.views where viewschema in('DB2INST1','DB2INST2','DB2INST3') order by viewname");
hislisdt[2]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select procschema,procname from syscat.procedures where procschema in('DB2INST1','DB2INST2','DB2INST3') order by procname");
hislisdt[3]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select indschema,indname from syscat.indexes where indschema in('DB2INST1','DB2INST2','DB2INST3') order by indname");
hislisdt[4]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select funcschema,funcname from syscat.functions where funcschema in('DB2INST1','DB2INST2','DB2INST3') order by funcname");
hislisdt[5]=DatabaseAccess.GetDataTable(DatabaseType.IbmDb2LIS,"select trigname from syscat.triggers");
TreeNode[] listab=new TreeNode[hislisdt[0].Rows.Count];//表
for(int i=0;i<listab.Length;i++)
{
listab[i]=new TreeNode(hislisdt[0].Rows[i][1].ToString()+" ("+hislisdt[0].Rows[i][0].ToString()+")");
listab[i].Tag=4;
listab[i].ImageIndex=11;
}
hislis[0].Nodes.AddRange(listab);
TreeNode[] lisview=new TreeNode[hislisdt[1].Rows.Count];//视图
for(int i=0;i<lisview.Length;i++)
{
lisview[i]=new TreeNode(hislisdt[1].Rows[i][1].ToString()+" ("+hislisdt[1].Rows[i][0].ToString()+")");
lisview[i].Tag=1;
}
hislis[1].Nodes.AddRange(lisview);
TreeNode[] lisproc=new TreeNode[hislisdt[2].Rows.Count];//存储过程
for(int i=0;i<lisproc.Length;i++)
{
lisproc[i]=new TreeNode(hislisdt[2].Rows[i][1].ToString()+" ("+hislisdt[2].Rows[i][0].ToString()+")");
lisproc[i].Tag=2;
}
hislis[2].Nodes.AddRange(lisproc);
TreeNode[] lisind=new TreeNode[hislisdt[3].Rows.Count];//索引
for(int i=0;i<lisind.Length;i++)
{
lisind[i]=new TreeNode(hislisdt[3].Rows[i][1].ToString()+" ("+hislisdt[3].Rows[i][0].ToString()+")");
}
hislis[3].Nodes.AddRange(lisind);
TreeNode[] lisfunc=new TreeNode[hislisdt[4].Rows.Count];//函数
for(int i=0;i<lisfunc.Length;i++)
{
lisfunc[i]=new TreeNode(hislisdt[4].Rows[i][1].ToString()+" ("+hislisdt[4].Rows[i][0].ToString()+")");
lisfunc[i].Tag=3;
}
hislis[4].Nodes.AddRange(lisfunc);
TreeNode[] listirg=new TreeNode[hislisdt[5].Rows.Count];//触发器
for(int i=0;i<listirg.Length;i++)
{
listirg[i]=new TreeNode(hislisdt[5].Rows[i][0].ToString());
}
hislis[5].Nodes.AddRange(listirg);
}
catch(System.Exception err)
{
MessageBox.Show(err.Message,"连接数据库配置不正确",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private void allblackColor()
{
int allnum=this.strtext.Length;
for(int i=0;i<allnum;i++)
{
//this.rtb.Select(i,1);
this.rtb.SelectionStart=i;
this.rtb.SelectionLength=1;
this.rtb.SelectionColor=Color.Black;
this.rtb.SelectionFont= new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
}
}
private void listsqlColor()
{
this.rtb.SelectionStart=0;
this.rtb.SelectionLength=this.strtext.Length;
//this.rtb.SelectAll();
this.rtb.SelectionColor=Color.Black;
//this.rtb.SelectionFont= new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
//this.rtb.SelectionStart=this.keynum;
//this.rtb.SelectionLength=0;
string[] Listsql=this.strtext.Split(new char[]{' ',';','*'});
int[] listnum=new int[Listsql.Length];
int uplist=0;
for(int i=0;i<listnum.Length;i++)
{
listnum[i]=uplist;
uplist=listnum[i]+Listsql[i].Length+1;
}
for(int i=0;i<Listsql.Length;i++)
{
for(int k=0;k<Datashow.ListSql.Length;k++)
{
if(Listsql[i].Trim()==Datashow.ListSql[k] ||Listsql[i].Trim()==Datashow.ListSql[k].ToUpper())
{
this.rtb.Select(listnum[i],Listsql[i].Length);
this.rtb.SelectionColor=Color.Blue;
this.rtb.SelectionStart=this.keynum;
this.rtb.SelectionLength=0;
break;
}
}
}
}
private void delsqlColor()
{
//this.allblackColor();
//this.rtb.SelectionStart=0;
//this.rtb.SelectionLength=this.strtext.Length;
//this.rtb.SelectAll();
//this.rtb.SelectionColor=Color.Black;
this.rtb.SelectionFont= new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.rtb.SelectionStart=this.keynum;
this.rtb.SelectionLength=0;
string[] sqls=this.strtext.Split(new char[]{';'});
int[] nums=new int[sqls.Length+1];
int upnum=0;
for(int i=0;i<nums.Length-1;i++)
{
nums[i]=upnum;
upnum=nums[i]+sqls[i].Length+1;
}
nums[sqls.Length]=upnum;
for(int i=0;i<sqls.Length;i++)
{
if(sqls[i].Trim()!="")
{
if(sqls[i].Length>2)
{
if(sqls[i].Trim().Substring(0,2)=="--")
{
this.rtb.Select(nums[i],sqls[i].Length+1);
this.rtb.SelectionColor=Color.Green;
System.Drawing.Font ft=new Font("",9, System.Drawing.FontStyle.Italic);
this.rtb.SelectionFont=ft;
this.rtb.SelectionStart=this.keynum;
this.rtb.SelectionLength=0;
}
}
}
}
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
int selectbeginnum=0;
int selectlength=0;
int selectendnum=0;
string selectbeginstr=null;
string selectstr="";
string selectendstr="";
int num1=-1;
switch(Convert.ToInt32(e.Button.Tag))
{
case 0:
this.menuItem3_Click(null,null);
break;
case 1:
this.HISDB2treeView.Nodes.Clear();
this.bind_nodes();
break;
case 2:
this.progressBar1.Value=0;
this.timer1.Enabled=true;
this.toolBarButton2.Enabled=false;
this.toolBarButton3.Enabled=true;
if(this.HISDB2tabControl.SelectedIndex==0)this.ressqlstr.Text=this.db2sqlstr.Text;
t = new Thread(new ThreadStart(startRun));
t.Start();
break;
case 3:
this.stopRun();
break;
case 4:
this.menuItem8_Click(null,null);
break;
case 5:
selectbeginnum=this.rtb.SelectionStart;
selectlength=this.rtb.SelectionLength;
selectendnum=selectbeginnum+selectlength;
selectbeginstr=this.strtext.Substring(0,selectbeginnum);
selectstr="";
selectendstr="";
if(selectlength!=0)
{
selectstr=this.strtext.Substring(selectbeginnum,selectlength);
}
selectendstr=this.strtext.Substring(selectendnum,this.strtext.Length-selectendnum);
num1=selectbeginstr.LastIndexOf("\n");
if(num1==-1)
{
selectbeginstr="--"+selectbeginstr;
}
else
{
selectbeginstr=selectbeginstr.Insert(num1+1,"--");
}
if(selectlength!=0)
{
selectstr=selectstr.Replace("\n","\n--");
}
this.strtext=selectbeginstr+selectstr+selectendstr;
this.delsqlColor();
break;
case 6:
selectbeginnum=this.rtb.SelectionStart;
selectlength=this.rtb.SelectionLength;
selectendnum=selectbeginnum+selectlength;
selectbeginstr=this.strtext.Substring(0,selectbeginnum);
selectstr="";
selectendstr="";
if(selectlength!=0)
{
selectstr=this.strtext.Substring(selectbeginnum,selectlength);
}
selectendstr=this.strtext.Substring(selectendnum,this.strtext.Length-selectendnum);
num1=selectbeginstr.LastIndexOf("\n");
if(num1==-1)
{
selectbeginstr=selectbeginstr.Replace("--","");
}
else
{
string bstr=selectbeginstr.Substring(0,num1);
selectbeginstr=bstr+selectbeginstr.Substring(num1).Replace("--","");
}
if(selectlength!=0)
{
selectstr=selectstr.Replace("--","");
}
this.strtext=selectbeginstr+selectstr+selectendstr;
this.delsqlColor();
break;
case 7:
this.menuItem19_Click(null,null);
break;
default:
break;
}
}
private void startRun()
{
ds=new DataSet();
ds=Datashow.OutData(this.ressqlstr.Text);
}
private void ShowData()
{
this.dg1.DataSource=null;
this.tabControl2.Controls.Clear();
for(int i=0;i<ds.Tables.Count;i++)
{
TabPage tp=new TabPage();
tp.Dock=DockStyle.Fill;
tp.Text = "结果"+Convert.ToString(i+1);
this.tabControl2.Controls.Add(tp);
DataGrid dg=new DataGrid();
dg.Dock=DockStyle.Fill;
dg.ReadOnly=true;
tp.Controls.Add(dg);
dg.DataSource=ds.Tables[i];
}
this.ShowError();
this.toolBarButton2.Enabled=true;
this.toolBarButton3.Enabled=false;
}
private void stopRun()
{
t.Abort();
this.timer1.Enabled=false;
Datashow.ErrStr="已停止运行";
Datashow.ErrBool=true;
this.ShowError();
this.toolBarButton2.Enabled=true;
this.toolBarButton3.Enabled=false;
}
private void ShowError()
{
if(Datashow.ErrBool==false)this.HISDB2tabControl.SelectedIndex=1;
else
{
this.HISDB2tabControl.SelectedIndex=0;
this.richTextBox1.Text+="\n"+Datashow.ErrStr;
}
Datashow.ErrStr="";
Datashow.ErrBool=false;
}
private void db2sqlstr_TextChanged(object sender, System.EventArgs e)
{
this.keynum=this.rtb.SelectionStart;
this.listsqlColor();
this.delsqlColor();
}
private void FrmClearData_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
}
private void FrmClearData_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyData==(Keys.Alt|Keys.X))
{
//MessageBox.Show("run");
ToolBarButton tbb=new ToolBarButton();
tbb.Tag=2;
this.toolBar1_ButtonClick(null,new ToolBarButtonClickEventArgs(tbb));
}
else if(e.KeyData==(Keys.Alt|Keys.Z))
{
//MessageBox.Show("stop");
this.stopRun();
}
else if(e.KeyData==Keys.F5)
{
ToolBarButton tbb=new ToolBarButton();
tbb.Tag=1;
this.toolBar1_ButtonClick(null,new ToolBarButtonClickEventArgs(tbb));
}
else if(e.KeyCode==Keys.F1)
{
this.menuItem8_Click(null,null);
}
}
private void FrmClearData_Load(object sender, System.EventArgs e)
{
this.db2sqlstr.Focus();
}
private void FrmClearData_Closed(object sender, System.EventArgs e)
{
}
private void FrmClearData_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
}
private void timer1_Tick(object sender, System.EventArgs e)
{
if(t.ThreadState==System.Threading.ThreadState.Stopped)
{
this.ShowData();
this.timer1.Enabled=false;
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
ToolBarButton tbb=new ToolBarButton();
tbb.Tag=2;
this.toolBar1_ButtonClick(null,new ToolBarButtonClickEventArgs(tbb));
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
this.stopRun();
}
private void HISDB2treeView_DoubleClick(object sender, System.EventArgs e)
{
try
{
int tag=Convert.ToInt32(this.HISDB2treeView.SelectedNode.Tag);
if(tag!=1 && tag!=2 && tag!=3 && tag!=4)return;
if(this.HISDB2tabControl.SelectedIndex==1)this.HISDB2tabControl.SelectedIndex=0;
string ntext=this.HISDB2treeView.SelectedNode.Text;
int ind=ntext.IndexOf(" ");
if(tag==4 || tag==1)
{
if(this.HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim()!=this.constr)
{
this.strtext+="\n"+HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim()+" ;";
this.constr=HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim();
}
this.strtext+="\n"+"select * from "+ntext.Substring(0,ind)+" ;";
}
else if(tag==3 || tag==2)
{
if(this.HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim()!=this.constr)
{
this.strtext+="\n"+HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim()+" ;";
this.constr=HISDB2treeView.SelectedNode.Parent.Parent.Tag.ToString().Trim();
}
this.strtext+="\n"+"call "+ntext.Substring(0,ind)+"()";
}
}
catch{}
}
#region 打开保存
/// <summary>
/// 打开
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem3_Click(object sender, System.EventArgs e)
{
Stream myStream;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
if((myStream = openFileDialog1.OpenFile())!= null)
{
byte[] bt=new byte[myStream.Length];
myStream.Read(bt,0,bt.Length);
System.Text.UTF8Encoding utf=new System.Text.UTF8Encoding();
this.strtext=utf.GetString(bt);
myStream.Close();
}
this.HISDB2tabControl.SelectedIndex=0;
}
}
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem19_Click(object sender, System.EventArgs e)
{
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
saveFileDialog1.FilterIndex = 2 ;
saveFileDialog1.RestoreDirectory = true ;
if(saveFileDialog1.ShowDialog() == DialogResult.OK)
{
if(this.HISDB2tabControl.SelectedIndex==1)
this.strtext=this.ressqlstr.Text;
StreamWriter sw=File.CreateText(saveFileDialog1.FileName);
sw.Write(this.strtext);
sw.Close();
}
}
#endregion
#region 右键菜单
/// <summary>
/// 撤消
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem11_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.Undo();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.Undo();
}
}
/// <summary>
/// 剪切
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem12_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.Cut();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.Cut();
}
}
/// <summary>
/// 复制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem14_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.Copy();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.Copy();
}
}
/// <summary>
/// 粘贴
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem15_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.Paste();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.Paste();
}
}
/// <summary>
/// 清空
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem16_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.Clear();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.Clear();
}
}
/// <summary>
/// 全选
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menuItem17_Click(object sender, System.EventArgs e)
{
if(this.HISDB2tabControl.SelectedIndex==0)
{
this.db2sqlstr.SelectAll();
}
else if(this.HISDB2tabControl.SelectedIndex==1)
{
this.ressqlstr.SelectAll();
}
}
#endregion
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 有关程序集的常规信息是通过下列
// 属性集控制的。更改这些属性值可修改与程序集
// 关联的信息。
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 程序集的版本信息由下列 4 个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 您可以指定所有这些值,也可以使用“修订号”和“内部版本号”的默认值,方法是按
// 如下所示使用 '*':
[assembly: AssemblyVersion("1.0.*")]
//
// 要对程序集进行签名,必须指定要使用的密钥。有关程序集签名的更多信息,请参考
// Microsoft .NET Framework 文档。
//
// 使用下面的属性控制用于签名的密钥。
//
// 注意:
// (*) 如果未指定密钥,则程序集不会被签名。
// (*) KeyName 是指已经安装在计算机上的
// 加密服务提供程序(CSP)中的密钥。KeyFile 是指包含
// 密钥的文件。
// (*) 如果 KeyFile 和 KeyName 值都已指定,则
// 发生下列处理:
// (1) 如果在 CSP 中可以找到 KeyName,则使用该密钥。
// (2) 如果 KeyName 不存在而 KeyFile 存在,则
// KeyFile 中的密钥安装到 CSP 中并且使用该密钥。
// (*) 要创建 KeyFile,可以使用 sn.exe(强名称)实用工具。
// 在指定 KeyFile 时,KeyFile 的位置应该相对于
// 项目输出目录,即
// %Project Directory%\obj\<configuration>。例如,如果 KeyFile 位于
// 该项目目录,应将 AssemblyKeyFile
// 属性指定为 [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) “延迟签名”是一个高级选项 - 有关它的更多信息,请参阅 Microsoft .NET Framework
// 文档。
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.10.3077"
SchemaVersion = "2.0"
ProjectGuid = "{E1E6FE67-B348-4367-B9DE-01B90C50DEB3}"
>
<Build>
<Settings
ApplicationIcon = "App.ico"
AssemblyKeyContainerName = ""
AssemblyName = "CutScreen"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "WinExe"
PreBuildEvent = ""
PostBuildEvent = ""
RootNamespace = "CutScreen"
RunPostBuildEvent = "OnBuildSuccess"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
NoStdLib = "false"
NoWarn = ""
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
/>
<Reference
Name = "System.Drawing"
AssemblyName = "System.Drawing"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
/>
<Reference
Name = "System.Windows.Forms"
AssemblyName = "System.Windows.Forms"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.Windows.Forms.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.Xml"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
<Reference
Name = "XcjwHIS"
AssemblyName = "XcjwHIS"
HintPath = "bin\Debug\XcjwHIS.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "App.ico"
BuildAction = "Content"
/>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "Form1.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "Form1.resx"
DependentUpon = "Form1.cs"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "picname.cs"
SubType = "Form"
BuildAction = "Compile"
/>
<File
RelPath = "picname.resx"
DependentUpon = "picname.cs"
BuildAction = "EmbeddedResource"
/>
<File
RelPath = "ScreenCameraClass.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "bin\Debug\01050.jpg"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\0sdf0.jpg"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\appface.bat"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\appface.dll"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\CutScreen.exe"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\CutScreen.pdb"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\cutscreen.xml"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\form.jpg"
BuildAction = "Content"
/>
<File
RelPath = "bin\Debug\skin\gtclassicex.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\luna.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\macosx.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\onion.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\opusos.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\pixos.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\plex.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\royale.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\slate.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\sundaze.urf"
BuildAction = "None"
/>
<File
RelPath = "bin\Debug\skin\trias.urf"
BuildAction = "None"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Runtime.InteropServices;
using System.Drawing.Imaging;
using System.IO;
using System.Xml;
using XcjwHIS.DatabaseAccessLayer;
using XcjwHIS.BussinessLogicLayer;
using XcjwHIS.PubicBaseClasses;
using XcjwHIS.PublicControls;
namespace CutScreen
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private string Cname=null;
private string Skinpath=null;
private int picWidth=100;
private int picHight=100;
private int intX=100;
private int intY=100;
private string picpath=null;
public static string lastnum="";
private System.Windows.Forms.Button button2;
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
this.bindSYS();
}
private void bindSYS()
{
this.readNode("cutscreen.xml","Cname",ref Cname);
this.readNode("cutscreen.xml","Skinpath",ref Skinpath);
string _picWidth=null;
string _picHight=null;
string _intX=null;
string _intY=null;
this.readNode("cutscreen.xml","picWidth",ref _picWidth);
this.readNode("cutscreen.xml","picHight",ref _picHight);
this.readNode("cutscreen.xml","intX",ref _intX);
this.readNode("cutscreen.xml","intY",ref _intY);
this.picWidth=Convert.ToInt32(_picWidth);
this.picHight=Convert.ToInt32(_picHight);
this.intX=Convert.ToInt32(_intX);
this.intY=Convert.ToInt32(_intY);
this.readNode("cutscreen.xml","picpath",ref picpath);
this.readNode("cutscreen.xml","lastnum",ref Form1.lastnum);
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button2 = new System.Windows.Forms.Button();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// button2
//
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.button2.Font = new System.Drawing.Font("宋体", 10.5F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.button2.Location = new System.Drawing.Point(8, 0);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(48, 16);
this.button2.TabIndex = 0;
this.button2.Text = "截图";
this.button2.Click += new System.EventHandler(this.button1_Click);
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(88, 72);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(248, 216);
this.pictureBox1.TabIndex = 1;
this.pictureBox1.TabStop = false;
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
this.ClientSize = new System.Drawing.Size(80, 16);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.button2);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "Form1";
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Text = "Form1";
this.TopMost = true;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
[DllImport("User32.dll", EntryPoint = "FindWindow")] //找窗体
private static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("User32.dll", EntryPoint = "ShowWindow")] //显示窗体
private static extern bool ShowWindow(IntPtr hWnd, int type);
private void button1_Click(object sender, System.EventArgs e)
{
picname pn=new picname();
pn.ShowDialog();
if(pn.bb==false)return;
IntPtr ParenthWnd = new IntPtr(0);
ParenthWnd = FindWindow(null,this.Cname);
ScreenCameraClass scc=new ScreenCameraClass();
//scc.CaptureScreenToFile("0sdf0.jpg",ImageFormat.Jpeg);
if (!ParenthWnd.Equals(IntPtr.Zero))
{
scc.CaptureWindowToFile(ParenthWnd,picpath+pn.pname+".jpg",ImageFormat.Jpeg,this.picWidth,this.picHight,this.intX,this.intY);
this.imgToDB(picpath+pn.pname+".jpg",pn.pname);
MessageBox.Show("截图成功!");
this.ShowImage("select img from lis_as_img1 where imgpath='"+pn.pname+"'");
this.updateNode("cutscreen.xml","lastnum",Form1.lastnum);
}
else
{
MessageBox.Show("你还没有运行["+this.Cname+"]这个软件,截图失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
public void imgToDB(string imgpath,string picname)
{ //参数sql中要求保存的imge变量名称为@images
// //调用方法如:imgToDB("update UserPhoto set Photo=@images where UserNo='" + temp + "'");
try
{
FileStream fs = File.OpenRead(imgpath);
byte[] imageb = new byte[fs.Length];
fs.Read(imageb, 0, imageb.Length);
fs.Close();
System.Data.OleDb.OleDbParameter imgpara=new System.Data.OleDb.OleDbParameter("img",System.Data.OleDb.OleDbType.Binary,imageb.Length);
imgpara.Value=imageb;
System.Data.OleDb.OleDbConnection tmpconn=new System.Data.OleDb.OleDbConnection(DatabaseAccess.GetConnectionString(DatabaseType.IbmDb2LIS));
System.Data.OleDb.OleDbCommand olecmd=new System.Data.OleDb.OleDbCommand();
int Ispic=Convert.ToInt32(DatabaseAccess.GetDataResult(DatabaseType.IbmDb2LIS,"select count(*) from lis_as_img1 where imgpath='"+picname+"'"));
string sql=null;
if(Ispic>0)
{
sql="update lis_as_img1 set img=? where imgpath='"+picname+"'";
}
else
{
sql="insert into lis_as_img1(imgpath,img) values('"+picname+"',?)";//
//string sql="update lis_as_img1 set img=? where id=1";
}
olecmd.CommandText=sql;
olecmd.Connection=tmpconn;
olecmd.Parameters.Add(imgpara);
tmpconn.Open();
olecmd.ExecuteNonQuery();
olecmd.Dispose();
tmpconn.Close();
}
catch(System.Exception err)
{
MessageBox.Show(err.Message);
}
}
private void ShowImage(string sql)
{
//调用方法如:ShowImage("select Photo from UserPhoto where UserNo='" + userno +"'");
//SqlCommand cmd = new SqlCommand(sql, conn);
//conn.Open();
byte[] b= (byte[])DatabaseAccess.GetDataResult(DatabaseType.IbmDb2LIS,sql);
if (b.Length>0)
{
MemoryStream stream = new MemoryStream(b, true);
stream.Write(b, 0, b.Length);
pictureBox1.Image = new Bitmap(stream);
stream.Close();
}
}
private const int WM_NCHITTEST = 0x84;
private const int HTCLIENT = 0x1;
private const int HTCAPTION = 0x2;
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_NCHITTEST:
base.WndProc(ref m);
if ((int)m.Result == HTCLIENT)
m.Result = (IntPtr)HTCAPTION;
return;
}
base.WndProc(ref m);
}
[DllImport("appface.dll")]
public static extern int SkinStart(string SkinFile,int nDefWinType,string CheckSum,int nType,
int hInstance,int nLen);
[DllImport("appface.dll")]
public static extern int SkinRemove() ;
[DllImport("appface.dll")]
public static extern int SkinWindowSet(IntPtr hWnd,int nSkintype);
[DllImport("appface.dll")]
public static extern int SkinWindowSetEx(IntPtr hWnd,int nSkintype,int nResourceId,
int nUrfLoadType,string SkinFile,int hInstance,int nLen);
private void Form1_Load(object sender, System.EventArgs e)
{
//if(!File.Exists(this.Skinpath))MessageBox.Show("皮肤加载错误!");
int a=SkinStart(this.Skinpath,4,"",1,0,0) ;
SkinWindowSetEx(this.Handle , //This value is not needed
602,
Color.Pink.ToArgb(), //The theme color
128, //The color transparent rate, 0 - 255
null,0,0) ;
}
public void readNode(string filename1,string nodename,ref string retval)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename1);
XmlNodeList xnl=xmlDoc.SelectSingleNode("COMDATA").ChildNodes;
foreach(XmlNode xn in xnl)
{
if(xn.NodeType!=XmlNodeType.Comment)
{
XmlElement xe=(XmlElement)xn;
if(xn.Name=="BaseConfig")
{
XmlNodeList xnll=xe.ChildNodes;
foreach(XmlNode xnn in xnll)
{
if(xnn.NodeType!=XmlNodeType.Comment)
{
XmlElement xee=(XmlElement)xnn;
if(xee.Name==nodename)
{
retval=xee.InnerText;
break;
}
}
}
}
}
}
}
public void updateNode(string filename1,string nodename, string val)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(filename1);
XmlNodeList xnl=xmlDoc.SelectSingleNode("COMDATA").ChildNodes;
foreach(XmlNode xn in xnl)
{
if(xn.NodeType!=XmlNodeType.Comment)
{
XmlElement xe=(XmlElement)xn;
if(xe.Name=="BaseConfig")
{
XmlNodeList xnll=xe.ChildNodes;
foreach(XmlNode xnn in xnll)
{
if(xnn.NodeType!=XmlNodeType.Comment)
{
XmlElement xee=(XmlElement)xnn;
if(xee.Name==nodename)
{
xee.InnerText=val;
}
}
}
}
}
}
xmlDoc.Save(filename1);
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace CutScreen
{
/// <summary>
/// picname 的摘要说明。
/// </summary>
public class picname : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public picname()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
this.label1.Text=Form1.lastnum;
this.textBox1.Focus();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(192, 24);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(8, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(184, 21);
this.textBox1.TabIndex = 1;
this.textBox1.Text = "";
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress);
//
// label1
//
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(88, 8);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 16);
this.label1.TabIndex = 2;
//
// label2
//
this.label2.ForeColor = System.Drawing.Color.Red;
this.label2.Location = new System.Drawing.Point(8, 8);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(72, 16);
this.label2.TabIndex = 3;
this.label2.Text = "上次编码:";
//
// picname
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(272, 56);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = new System.Drawing.Point(800, 500);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "picname";
this.Text = "输入图片编码";
this.Load += new System.EventHandler(this.picname_Load);
this.Activated += new System.EventHandler(this.picname_Activated);
this.Enter += new System.EventHandler(this.picname_Enter);
this.ResumeLayout(false);
}
#endregion
public bool bb=false;
public string pname=null;
private void button1_Click(object sender, System.EventArgs e)
{
if(this.textBox1.Text.Trim()=="")
{
MessageBox.Show("先输入一个图片编码!");
return;
}
if(this.textBox1.Text.Trim().Length<=7 || this.textBox1.Text.IndexOf("-")==-1)
{
MessageBox.Show("您输入图片编码有错误,正确格式如[070622-1]!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
string[] str=this.textBox1.Text.Split(new char[]{'-'});
if(str[0].Trim()!=DateTime.Now.ToString("yyMMdd"))
{
MessageBox.Show("编码前面的日期不是当前日期,应该是"+DateTime.Now.ToString("yyMMdd")+"!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
bb=true;
pname=this.textBox1.Text.Trim();
Form1.lastnum=this.textBox1.Text;
this.Close();
}
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if(e.KeyChar!=(char)13) return;
this.button1_Click(null,null);
}
private void picname_Load(object sender, System.EventArgs e)
{
this.textBox1.Focus();
}
private void picname_Activated(object sender, System.EventArgs e)
{
this.textBox1.Focus();
}
private void picname_Enter(object sender, System.EventArgs e)
{
this.textBox1.Focus();
}
}
}
using System;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;
namespace CutScreen
{
/// <summary>
/// ScreenCameraClass 的摘要说明。
/// </summary>
public class ScreenCameraClass
{
public ScreenCameraClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
private Image CaptureScreen()
{
return CaptureWindow( User32.GetDesktopWindow() );
}
/** <summary>
/// Creates an Image object containing a screen shot of a specific window?
/// </summary>
/// <param name="handle">The handle to the window. (In windows forms, this is obtained by the Handle property)</param>
/// <returns></returns>
private Image CaptureWindow(IntPtr handle)
{
// get te hDC of the target window
IntPtr hdcSrc = User32.GetWindowDC(handle);
// get the size
User32.RECT windowRect = new User32.RECT();
User32.GetWindowRect(handle,ref windowRect);
int width = windowRect.right - windowRect.left;
int height = windowRect.bottom - windowRect.top;
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,width,height);
// select the bitmap object
IntPtr hOld = GDI32.SelectObject(hdcDest,hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest,0,0,width,height,hdcSrc,0,0,GDI32.SRCCOPY);
// restore selection
GDI32.SelectObject(hdcDest,hOld);
// clean up
GDI32.DeleteDC(hdcDest);
User32.ReleaseDC(handle,hdcSrc);
// get a .NET image object for it
Image img = Image.FromHbitmap(hBitmap);
// free up the Bitmap object
GDI32.DeleteObject(hBitmap);
return img;
}
private Image CaptureWindow(IntPtr handle,int _width,int _height,int x,int y)
{
// get te hDC of the target window
IntPtr hdcSrc = User32.GetWindowDC(handle);
// get the size
User32.RECT windowRect = new User32.RECT();
User32.GetWindowRect(handle,ref windowRect);
int width = _width;
int height = _height;
// create a device context we can copy to
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
// create a bitmap we can copy it to,
// using GetDeviceCaps to get the width/height
IntPtr hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,width,height);
// select the bitmap object
IntPtr hOld = GDI32.SelectObject(hdcDest,hBitmap);
// bitblt over
GDI32.BitBlt(hdcDest,0,0,width,height,hdcSrc,x,y,GDI32.SRCCOPY);
// restore selection
GDI32.SelectObject(hdcDest,hOld);
// clean up
GDI32.DeleteDC(hdcDest);
User32.ReleaseDC(handle,hdcSrc);
// get a .NET image object for it
Image img = Image.FromHbitmap(hBitmap);
// free up the Bitmap object
GDI32.DeleteObject(hBitmap);
return img;
}
/** <summary>
/// Captures a screen shot of a specific window, and saves it to a file?
/// </summary>
/// <param name="handle"></param>
/// <param name="filename"></param>
/// <param name="format"></param>
public void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format)
{
Image img = CaptureWindow(handle);
img.Save(filename,format);
}
public void CaptureWindowToFile(IntPtr handle, string filename, ImageFormat format,int width,int height,int x,int y)
{
Image img = CaptureWindow(handle, width, height, x, y);
img.Save(filename,format);
}
/** <summary>
/// Captures a screen shot of the entire desktop, and saves it to a file?
/// </summary>
/// <param name="filename"></param>
/// <param name="format"></param>
public void CaptureScreenToFile(string filename, ImageFormat format)
{
Image img = CaptureScreen();
img.Save(filename,format);
}
/** <summary>
/// Helper class containing Gdi32 API functions
/// </summary>
private class GDI32
{
public const int SRCCOPY = 0x00CC0020; // BitBlt dwRop parameter
[DllImport("gdi32.dll")]
public static extern bool BitBlt(IntPtr hObject,int nXDest,int nYDest,
int nWidth,int nHeight,IntPtr hObjectSource,
int nXSrc,int nYSrc,int dwRop);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleBitmap(IntPtr hDC,int nWidth,
int nHeight);
[DllImport("gdi32.dll")]
public static extern IntPtr CreateCompatibleDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteDC(IntPtr hDC);
[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")]
public static extern IntPtr SelectObject(IntPtr hDC,IntPtr hObject);
}
/** <summary>
/// Helper class containing User32 API functions
/// </summary>
private class User32
{
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
}
[DllImport("user32.dll")]
public static extern IntPtr GetDesktopWindow();
[DllImport("user32.dll")]
public static extern IntPtr GetWindowDC(IntPtr hWnd);
[DllImport("user32.dll")]
public static extern IntPtr ReleaseDC(IntPtr hWnd,IntPtr hDC);
[DllImport("user32.dll")]
public static extern IntPtr GetWindowRect(IntPtr hWnd,ref RECT rect);
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Data.OleDb;
using XcjwHIS.PubicBaseClasses;
namespace LISLoid.DeCode_Bak.strings
{
/// <summary>
/// DataDeCode 的摘要说明。
/// </summary>
public class DataDeCode
{
public delegate void DataInsertEventHandler(object sender, EventArgs e);
/// <summary>
/// 数据插入数据库事件
/// </summary>
public event DataInsertEventHandler DataInsert;
/// <summary>
/// 解码进度事件
/// </summary>
public delegate void FrmTrayIconChangeEventHandler(int trye,int allcount,int nowcount);
public static event FrmTrayIconChangeEventHandler FrmTrayIcon;
/// <summary>
/// 存放最后得到的数据
/// </summary>
public string DataXML=null;
private string resultfilename=@"result\"+DateTime.Now.ToString("yyMMdd")+".txt";
/// <summary>
/// 数据库连接
/// </summary>
//private System.Data.OleDb.OleDbConnection conn=null;
public DataDeCode()
{
}
public void decode()
{
PublicClass.PublicClass_STRING.GetTxt();
string txtChar=PublicClass.PublicClass_STRING.PtxtChar;
int endnum=0,startnum=0;
endnum=txtChar.LastIndexOf(PublicClass.PublicClass_STRING.endstr);
if(endnum==-1)return;
startnum=txtChar.Substring(0,endnum).LastIndexOf(PublicClass.PublicClass_STRING.startstr);
if(endnum!=-1 && startnum!=-1)
{
txtChar=txtChar.Substring(startnum+PublicClass.PublicClass_STRING.startstr.Length,endnum-startnum-PublicClass.PublicClass_STRING.startstr.Length);
PublicClass.PublicClass_STRING.Chartxt=txtChar;
PublicClass.PublicClass_STRING.bindCharnum();
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
for(int i=0;i<PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows.Count;i++)
{
string retstr=null;
try
{
retstr=txtChar.Substring(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length,PublicClass.PublicClass_STRING.Charnum[i+1]-(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length));
}
catch{ retstr=txtChar.Substring(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length,txtChar.Length-(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length));}
retstr=retstr.Trim();
string[] delChar=PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][2].ToString().Split(new char[]{'|'});
for(int k=0;k<delChar.Length;k++)
{
if(delChar[k]!="")
retstr=retstr.Replace(delChar[k],"");//如果过滤字符的话,则一定要过滤干净
}
retstr=retstr.Trim(new char[]{' ','',' ',''});//好要扩展
retstr=retstr.Trim();
this.loadXML(PublicClass.changworld(retstr),PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][0].ToString(),PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString(),i);
DataDeCode.FrmTrayIcon(0,(PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows.Count-1),i);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
if(this.DataInsert!=null)
this.DataInsert(this,EventArgs.Empty);
PublicClass.updateNode(PublicClass.PublicClass_STRING.filename,"txtNum",Convert.ToString(PublicClass.PublicClass_STRING._endnum+PublicClass.PublicClass_STRING.endstr.Length));
PublicClass.PublicClass_STRING.txtNum=PublicClass.PublicClass_STRING._endnum+PublicClass.PublicClass_STRING.endstr.Length;
PublicClass.PublicClass_STRING.PtxtChar=PublicClass.PublicClass_STRING.PtxtChar.Substring(0,startnum);
}
}
/// <summary>
/// 得到的数据存入XML中
/// </summary>
/// <param name="sd"></param>
/// <param name="name"></param>
/// <param name="codename"></param>
private void loadXML(string sd,string name,string codename,int num)
{
this.DataXML=DataXML+"<Data name=\""+name+"\" codename=\""+codename+"\" codenum=\""+num.ToString()+"\">"+sd+"</Data>";
}
}
}
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Data.OleDb;
using XcjwHIS.PubicBaseClasses;
namespace LISLoid.DeCode_Bak.strings
{
/// <summary>
/// DataDeCode 的摘要说明。
/// </summary>
public class DataDeCode
{
public delegate void DataInsertEventHandler(object sender, EventArgs e);
/// <summary>
/// 数据插入数据库事件
/// </summary>
public event DataInsertEventHandler DataInsert;
/// <summary>
/// 解码进度事件
/// </summary>
public delegate void FrmTrayIconChangeEventHandler(int trye,int allcount,int nowcount);
public static event FrmTrayIconChangeEventHandler FrmTrayIcon;
/// <summary>
/// 存放最后得到的数据
/// </summary>
public string DataXML=null;
private string resultfilename=@"result\"+DateTime.Now.ToString("yyMMdd")+".txt";
/// <summary>
/// 数据库连接
/// </summary>
//private System.Data.OleDb.OleDbConnection conn=null;
public DataDeCode()
{
}
public void decode()
{
PublicClass.PublicClass_STRING.GetTxt();
string txtChar=PublicClass.PublicClass_STRING.PtxtChar;
int endnum=0,startnum=0;
endnum=txtChar.LastIndexOf(PublicClass.PublicClass_STRING.endstr);
if(endnum==-1)return;
startnum=txtChar.Substring(0,endnum).LastIndexOf(PublicClass.PublicClass_STRING.startstr);
if(endnum!=-1 && startnum!=-1)
{
txtChar=txtChar.Substring(startnum+PublicClass.PublicClass_STRING.startstr.Length,endnum-startnum-PublicClass.PublicClass_STRING.startstr.Length);
PublicClass.PublicClass_STRING.Chartxt=txtChar;
PublicClass.PublicClass_STRING.bindCharnum();
this.DataXML=null;
DataXML=DataXML+"<?xml version=\"1.0\" encoding=\"utf-8\"?>";
DataXML=DataXML+"<comdata>";
for(int i=0;i<PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows.Count;i++)
{
string retstr=null;
try
{
retstr=txtChar.Substring(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length,PublicClass.PublicClass_STRING.Charnum[i+1]-(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length));
}
catch{ retstr=txtChar.Substring(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length,txtChar.Length-(PublicClass.PublicClass_STRING.Charnum[i]+PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString().Length));}
retstr=retstr.Trim();
string[] delChar=PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][2].ToString().Split(new char[]{'|'});
for(int k=0;k<delChar.Length;k++)
{
if(delChar[k]!="")
retstr=retstr.Replace(delChar[k],"");//如果过滤字符的话,则一定要过滤干净
}
retstr=retstr.Trim(new char[]{' ','',' ',''});//好要扩展
retstr=retstr.Trim();
this.loadXML(PublicClass.changworld(retstr),PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][0].ToString(),PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows[i][1].ToString(),i);
DataDeCode.FrmTrayIcon(0,(PublicClass.PublicClass_STRING.ds.Tables["Node"].Rows.Count-1),i);
}
DataXML=DataXML+"</comdata>";
PublicClass.BindDataXML(DataXML);
PublicClass.outxml_Appendfile(resultfilename,DataXML);
if(this.DataInsert!=null)
this.DataInsert(this,EventArgs.Empty);
PublicClass.updateNode(PublicClass.PublicClass_STRING.filename,"txtNum",Convert.ToString(PublicClass.PublicClass_STRING._endnum+PublicClass.PublicClass_STRING.endstr.Length));
PublicClass.PublicClass_STRING.txtNum=PublicClass.PublicClass_STRING._endnum+PublicClass.PublicClass_STRING.endstr.Length;
PublicClass.PublicClass_STRING.PtxtChar=PublicClass.PublicClass_STRING.PtxtChar.Substring(0,startnum);
}
}
/// <summary>
/// 得到的数据存入XML中
/// </summary>
/// <param name="sd"></param>
/// <param name="name"></param>
/// <param name="codename"></param>
private void loadXML(string sd,string name,string codename,int num)
{
this.DataXML=DataXML+"<Data name=\""+name+"\" codename=\""+codename+"\" codenum=\""+num.ToString()+"\">"+sd+"</Data>";
}
}
}