///用于多表更新
//Form1.cs
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient ;
using System.Reflection.Emit ;
using System.Reflection ;
namespace WindowsApplication1
{
public struct refTab
{
private string tabName;
private string tabKey;
public string TabName
{
get{return this.tabName ;}
}
public string TabKey
{
get{return this.tabKey ;}
}
public refTab(string tab,string zd)
{
this.tabName=tab;
this.tabKey=zd;
}
}
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
#region 变量定义
/// <summary>
/// 连接到源数据库的SqlConnection
/// </summary>
private SqlConnection sqlConnection1;
private SqlConnection dstCnn;
private System.Windows.Forms.DataGrid dataGrid1;
/// <summary>
/// 源数据库生成数据集---源数据集
/// </summary>
private DataSet srcDataset=null;
/// <summary>
/// 经过第一次整理后的源数据集
/// </summary>
private DataSet dstDataset=null;
/// <summary>
/// 目标数据库中的数据集与源数据集(dstDataset)合并之后的最终数据集
/// </summary>
private DataSet endDataset=null;
private System.Collections.Hashtable hshTab=new Hashtable();
private Hashtable hshTabSrc=new Hashtable();
private Hashtable hstTabVal=new Hashtable ();
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private bool complete=false;//是否已经完成分析
private ResultForm fs=null;//查看分析结果
private bool isok=false;//分析是否正确
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
#endregion
#region 目标数据库中各数据表对应的数据适配器变量定义
/// <summary>
/// 病程特点字典库适配器
/// </summary>
private SqlDataAdapter da_Bcdtzdk;
/// <summary>
/// 病人资料库适配器
/// </summary>
private SqlDataAdapter da_Brzlk;
/// <summary>
/// 发病诱因字典库适配器
/// </summary>
private SqlDataAdapter da_Fbyyzd;
/// <summary>
/// 发作类别字典库适配器
/// </summary>
private SqlDataAdapter da_Fzlbzdk;
/// <summary>
/// 犯罪处罚类别字典库适配器
/// </summary>
private SqlDataAdapter da_Fzcflbzdk;
/// <summary>
/// 功能影响字典库适配器
/// </summary>
private SqlDataAdapter da_Glyxzdk;
/// <summary>
/// 婚姻字典库适配器
/// </summary>
private SqlDataAdapter da_Fyzdk;
/// <summary>
/// 家族史字典库适配器
/// </summary>
private SqlDataAdapter da_Jzszd;
/// <summary>
/// 教育类别字典库适配器
/// </summary>
private SqlDataAdapter da_Jylbzdk;
/// <summary>
/// 教育专题目录库适配器
/// </summary>
private SqlDataAdapter da_Jyztmlk;
/// <summary>
/// 教育专题子目录库适配器
/// </summary>
private SqlDataAdapter da_Jyztzmlk;
/// <summary>
/// 经济状况字典库适配器
/// </summary>
private SqlDataAdapter da_Jjzkzdk;
/// <summary>
/// 求助方式字典库适配器
/// </summary>
private SqlDataAdapter da_Qzfszdk;
/// <summary>
/// 随访记录信息库适配器
/// </summary>
private SqlDataAdapter da_Sfjlxxk;
/// <summary>
/// 同患病字典库适配器
/// </summary>
private SqlDataAdapter da_Tfbzdk;
/// <summary>
/// 文化程度字典库适配器
/// </summary>
private SqlDataAdapter da_Whcdzdk;
/// <summary>
/// 物理治疗信息库适配器
/// </summary>
private SqlDataAdapter da_Wlzlxxk;
/// <summary>
/// 心理治疗信息库适配器
/// </summary>
private SqlDataAdapter da_Xlzlxxk;
/// <summary>
/// 性格字典库适配器
/// </summary>
private SqlDataAdapter da_Xgzdk;
/// <summary>
/// 药物治疗信息库适配器
/// </summary>
private SqlDataAdapter da_Ywzlxxk;
/// <summary>
/// 医院信息库适配器
/// </summary>
private SqlDataAdapter da_Yyxxk;
/// <summary>
/// 诊断字典库适配器
/// </summary>
private SqlDataAdapter da_Zdzdk;
/// <summary>
/// 职业字典库适配器
/// </summary>
private SqlDataAdapter da_Zyzdk;
/// <summary>
/// 治疗大类字典库
/// </summary>
private SqlDataAdapter da_Zldlzdk;
/// <summary>
/// 治疗类别字典库适配器
/// </summary>
private SqlDataAdapter da_Zllbzdk;
/// <summary>
/// 治疗史库适配器
/// </summary>
private SqlDataAdapter da_Zlsk;
/// <summary>
/// 治疗专题目录库适配器
/// </summary>
private SqlDataAdapter da_Zlztmlk;
/// <summary>
/// 治疗专题子目录库适配器
/// </summary>
private SqlDataAdapter da_Zlztzmlk;
/// <summary>
/// 治疗专题字典库适配器
/// </summary>
private SqlDataAdapter da_Zlztzdk;
/// <summary>
/// 住院记录库适配器
/// </summary>
private SqlDataAdapter da_Zyjlk;
/// <summary>
/// 自杀或攻击字典库适配器
/// </summary>
private SqlDataAdapter da_Zsgjzdk;
/// <summary>
/// 自知力字典库适配器
/// </summary>
private SqlDataAdapter da_Zzlzdk;
#endregion
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// 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.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.dataGrid1 = new System.Windows.Forms.DataGrid();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
this.SuspendLayout();
//
// dataGrid1
//
this.dataGrid1.CaptionText = "源表数据";
this.dataGrid1.DataMember = "";
this.dataGrid1.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(0, 0);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(624, 277);
this.dataGrid1.TabIndex = 0;
//
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button1.Location = new System.Drawing.Point(624, 32);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(40, 48);
this.button1.TabIndex = 1;
this.button1.Text = "分析数据格式";
this.button1.Click += new System.EventHandler(this.button1_Click_1);
//
// 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.Flat;
this.button2.Location = new System.Drawing.Point(624, 104);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(40, 48);
this.button2.TabIndex = 2;
this.button2.Text = "查看分析结果";
this.button2.Click += new System.EventHandler(this.button2_Click_1);
//
// button3
//
this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.button3.Location = new System.Drawing.Point(624, 192);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(40, 48);
this.button3.TabIndex = 3;
this.button3.Text = "执行导入操作";
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(664, 277);
this.Controls.Add(this.button3);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGrid1);
this.Name = "Form1";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "数据导入主窗体";
this.Closing += new System.ComponentModel.CancelEventHandler(this.Form1_Closing);
this.Load += new System.EventHandler(this.Form1_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
System.Windows.Forms.Application.Run(new Form1());
}
private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.sqlConnection1.Close ();
this.dstCnn.Close ();
// this.sqlConnection2 .Close ();
}
/// <summary>
/// 读取源数据库中的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Load(object sender, System.EventArgs e)
{
//读取原始数据
DataConnSetting dst=new DataConnSetting();
if(dst.ShowDialog ()==DialogResult.OK)
{
this.sqlConnection1.ConnectionString=dst.DbConnString ;
this.ReadSrcData ();
this.dstCnn=new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["DstConnStr"]);
}
else
{
Application.Exit ();
}
}
#region 对源数据集进行分析的子过程
/// <summary>
/// 对一个字典库关联到一个表的多个子段进行更新
/// </summary>
/// <param name="dstTabName">源表名</param>
/// <param name="dstPk">关键字</param>
/// <param name="endTabName">目标表名</param>
/// <param name="endPk">关键字</param>
/// <param name="refTabName">关联表</param>
/// <param name="refkey">字段名列表</param>
private void FeiXi(string dstTabName,string dstPk,string endTabName,string endPk,string refTabName ,params string[] refkey)
{
int maxId=0;
foreach(DataRow dr in this.endDataset.Tables[endTabName].Rows )
{
int curId=(int)dr[endPk];
if(curId>maxId)
maxId=curId;
}
Hashtable hst=new Hashtable();
foreach(DataRow dr in this.dstDataset.Tables[dstTabName].Rows )
{
int curId=(int)dr[dstPk];
int dstId=curId+maxId;
dr[dstPk]=dstId;
hst.Add(curId,dstId);
}
//更新关联行
foreach(DataRow refdr in this.dstDataset.Tables[refTabName].Rows )
{
foreach(string opc in refkey)
{
string val=refdr[opc].ToString ().Trim ();
if(hst.Contains(val))
{
refdr[opc]=hst[val].ToString ();
}
}
}
this.dstDataset.Tables[refTabName].AcceptChanges ();
}
/// <summary>
/// 得到源数据库中的每个表的最小ID取值,就是当前数据集中的每个表的最小ID值
/// </summary>
private void FeiXi(string dstTabName,string dstPk,string endTabName,string endPk,params refTab[] tabs)
{
int maxId=0;
if(tabs!=null)
{
foreach(refTab tab in tabs)
{
string tabName=tab.TabName ;
string tabKey=tab.TabKey ;
this.dstDataset.Tables[tabName].AcceptChanges ();
}
}
foreach(DataRow dr in this.endDataset.Tables[endTabName].Rows )
{
int curId=(int)dr[endPk];
if(curId>maxId)
maxId=curId;
}
foreach(DataRow dr in this.dstDataset.Tables[dstTabName].Rows )
{
int curId=(int)dr[dstPk];
dr[dstPk]=curId+maxId;
if(tabs!=null)
{
foreach(refTab tab in tabs)
{
string tabName=tab.TabName ;
string tabKey=tab.TabKey ;
foreach(DataRow refdr in this.dstDataset.Tables[tabName].Rows )
{
if(refdr[tabKey].ToString ().Trim ()==curId.ToString ()&&refdr.RowState!=DataRowState.Modified )
{
refdr[tabKey]=curId+maxId;
}
}
}
}
}
if(tabs!=null)
{
foreach(refTab tab in tabs)
{
string tabName=tab.TabName ;
string tabKey=tab.TabKey ;
this.dstDataset.Tables[tabName].AcceptChanges ();
}
}
}
/// <summary>
/// 读取数据源数据
/// </summary>
private void ReadSrcData()
{
string selCmdTxt="select * from d_病程特点字典库;select * from d_病人资料库;";
selCmdTxt+="select * from d_发病诱因字典;select * from d_发作类别字典库;";
selCmdTxt+="select * from d_犯罪处罚类别字典库;select * from d_功能影响字典库;";
selCmdTxt+="select * from d_婚姻字典库;";
selCmdTxt+="select * from d_家族史字典;select * from d_教育类别字典库;";
SqlDataAdapter da=new SqlDataAdapter(selCmdTxt,this.sqlConnection1 );
this.srcDataset=new DataSet();
da.TableMappings.Add("Table","病程特点字典库");
da.TableMappings .Add("Table1","病人资料库");
da.TableMappings .Add("Table2","发病诱因字典");
da.TableMappings .Add("Table3","发作类别字典库");
da.TableMappings .Add("Table4","犯罪处罚类别字典库");
da.TableMappings.Add("Table5","功能影响字典库");
da.TableMappings.Add("Table6","婚姻字典库");
da.TableMappings.Add("Table7","家族史字典");
da.TableMappings.Add("Table8","教育类别字典库");
da.Fill(this.srcDataset);
string selCmdTxt2="select * from d_教育专题目录库;";
selCmdTxt2+="select * from d_教育专题子目录库;select * from d_经济状况字典库;";
selCmdTxt2+="select * from d_求助方式字典库;select * from d_随访记录信息库;";
selCmdTxt2+="select * from d_同患病字典库;select * from d_文化程度字典库;";
SqlDataAdapter da2=new SqlDataAdapter(selCmdTxt2,this.sqlConnection1 );
da2.TableMappings.Add("Table","教育专题目录库");
da2.TableMappings.Add("Table1","教育专题子目录库");
da2.TableMappings.Add("Table2","经济状况字典库");
da2.TableMappings.Add("Table3","求助方式字典库");
da2.TableMappings.Add("Table4","随访记录信息库");
da2.TableMappings.Add("Table5","同患病字典库");
da2.TableMappings.Add("Table6","文化程度字典库");
DataSet ds2=new DataSet();
da2.Fill(ds2);
string selCmdTxt3="select * from d_物理治疗信息库;select * from d_心理治疗信息库;";
selCmdTxt3+="select * from d_性格字典库;select * from d_药物治疗信息库;";
selCmdTxt3+="select * from d_医院信息库;select * from d_诊断字典库;";
selCmdTxt3+="select * from d_职业字典库;";
SqlDataAdapter da3=new SqlDataAdapter(selCmdTxt3,this.sqlConnection1 );
da3.TableMappings.Add("Table","物理治疗信息库");
da3.TableMappings.Add("Table1","心理治疗信息库");
da3.TableMappings.Add("Table2","性格字典库");
da3.TableMappings.Add("Table3","药物治疗信息库");
da3.TableMappings.Add("Table4","医院信息库");
da3.TableMappings.Add("Table5","诊断字典库");
da3.TableMappings.Add("Table6","职业字典库");
DataSet ds3=new DataSet();
da3.Fill(ds3);
string selCmdTxt4="select * from d_治疗大类字典库;select * from d_治疗类别字典库;";
selCmdTxt4+="select * from d_治疗史库;select * from d_治疗专题目录库;";
selCmdTxt4+="select * from d_治疗专题子目录库;select * from d_治疗专题字典库;";
selCmdTxt4+="select * from d_住院记录库;select * from d_自杀或攻击字典库;";
selCmdTxt4+="select * from d_自知力字典库";
SqlDataAdapter da4=new SqlDataAdapter(selCmdTxt4,this.sqlConnection1 );
da4.TableMappings.Add("Table","治疗大类字典库");
da4.TableMappings.Add("Table1","治疗类别字典库");
da4.TableMappings.Add("Table2","治疗史库");
da4.TableMappings.Add("Table3","治疗专题目录库");
da4.TableMappings.Add("Table4","治疗专题子目录库");
da4.TableMappings.Add("Table5","治疗专题字典库");
da4.TableMappings.Add("Table6","住院记录库");
da4.TableMappings.Add("Table7","自杀或攻击字典库");
da4.TableMappings.Add("Table8","自知力字典库");
DataSet ds4=new DataSet();
da4.Fill(ds4);
foreach(DataTable dt in ds2.Tables )
{
DataTable dct=dt.Copy();
this.srcDataset.Tables.Add(dct);
}
ds2.Tables.Clear ();
ds2=null;
foreach(DataTable dt in ds3.Tables )
{
DataTable dct=dt.Copy ();
this.srcDataset.Tables.Add(dct);
}
ds3.Tables.Clear ();
ds3=null;
foreach(DataTable dt in ds4.Tables )
{
DataTable dct=dt.Copy ();
this.srcDataset.Tables.Add(dct);
}
ds4.Tables.Clear ();
ds4=null;
this.dataGrid1.DataSource=this.srcDataset ;
}
/// <summary>
/// 根据表名对其相关表进行处理
/// </summary>
/// <param name="tabName"></param>
#endregion
/// <summary>
/// 执行分析
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click_1(object sender, System.EventArgs e)
{
if(!this.complete )
{
this.Cursor=System.Windows.Forms.Cursors.WaitCursor ;
this.InitDataAdapter();//----为生成目标数据准备
this.FillEndDataset();//----添充目标数据集
this.RuleDstDataset ();//生成新的数据集
this.Cursor =System.Windows.Forms.Cursors.Default ;
MessageBox.Show("分析完成!");
this.button1.Enabled=false;
if(this.isok)//如果分析没有出错
{
this.complete=true;
this.dstDataset.AcceptChanges();
}
}
}
private void button2_Click_1(object sender, System.EventArgs e)
{
if(this.isok)
{
if(this.fs==null)
{
this.fs=new ResultForm();
fs.DstDataset=this.endDataset ;
fs.Show ();
}
else
{
this.fs.Activate ();
}
}
else
{
MessageBox.Show("先执行分析动作");
}
}
private void button3_Click(object sender, System.EventArgs e)
{
//将数据导入到目标数据库
//将dstDataset 数据集中的数据存入目标数据库中
//按顺序将分析后的数据存入目标库中
//先更新字典库
//病程特点字典库
//SqlDataAdapter da=new SqlDataAdapter("select * from d_病程特点字典库");
if(this.complete )
{
this.dataImport ();
this.button3.Enabled=false;
//
//生成更新数据库的insertCommmand 语句
//
}
else
{
MessageBox.Show("请先执行分析动作");
}
}
#region 处理经过整理后数据集(dstDataset)并存入最终的数据集(endDataset)
/// <summary>
/// 初始化数据适配器
/// 为每个数据适配器生成相应的SQL语句
/// </summary>
private void InitDataAdapter()
{
string dbName=this.dstCnn.Database ;
string sql_Open="set identity_insert {0}.dbo.{1} on;";
string sql_Close="set identity_insert {2}.dbo.{3} off";
string sql_Add="";//插入语句
string tabName="";//表名
string sqlCmd="";//加上开关语名之后的命令语句也是最后的InsertCommand.CommandText
//--适配器的命令语句:Select与Insert语句
#region 病程特点字典库--适配器的命令语句:Select与Insert语句
tabName="d_病程特点字典库";
this.da_Bcdtzdk=new SqlDataAdapter();
this.da_Bcdtzdk.SelectCommand=new SqlCommand("select * from d_病程特点字典库",this.dstCnn );
sql_Add="insert into d_病程特点字典库(ID,病程特点) values(@ID,@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd0=new SqlCommand (sqlCmd,this.dstCnn );
addCmd0.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd0.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.VarChar ,200));
addCmd0.Parameters["@ID"].SourceColumn="ID";
addCmd0.Parameters["@BCDT"].SourceColumn="病程特点";
this.da_Bcdtzdk .InsertCommand=addCmd0;
#endregion
#region 病人资料库--适配器的命令语句:Select与Insert语句
tabName="d_病人资料库";
this.da_Brzlk =new SqlDataAdapter();
this.da_Brzlk.SelectCommand=new SqlCommand("select * from d_病人资料库",this.dstCnn );
sql_Add="insert into d_病人资料库(ID,医院编号,患者姓名,拼音码,门诊号,性别,出生年月,婚姻,职业,经济收入,文化程度,吸烟,药物乱用,住址,电话,身份证号码,填表人,录入时间) values(@ID,@YYBH,@XM,@PYM,@MZH,@XB,@CSNY,@FY,@ZY,@JJSR,@WHCD,@XY,@YWLY,@ZZ,@DH,@SFZ,@TBR,@SJ);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd1=new SqlCommand(sqlCmd,this.dstCnn );
addCmd1.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int));
addCmd1.Parameters.Add(new SqlParameter("@YYBH",SqlDbType.Int));
addCmd1.Parameters.Add(new SqlParameter("@XM",SqlDbType.VarChar ,8));
addCmd1.Parameters.Add(new SqlParameter("@PYM",SqlDbType.VarChar ,4));
addCmd1.Parameters.Add(new SqlParameter("@MZH",SqlDbType.VarChar,20));
addCmd1.Parameters.Add(new SqlParameter("@XB",SqlDbType.Bit ));
addCmd1.Parameters.Add(new SqlParameter("@CSNY",SqlDbType.VarChar ,50));
addCmd1.Parameters.Add(new SqlParameter("@FY",SqlDbType.Int));
addCmd1.Parameters.Add(new SqlParameter("@ZY",SqlDbType.Int ));
addCmd1.Parameters.Add(new SqlParameter("@JJSR",SqlDbType.Int ));
addCmd1.Parameters.Add(new SqlParameter("@WHCD",SqlDbType.Int ));
addCmd1.Parameters.Add(new SqlParameter("@XY",SqlDbType.Bit ));
addCmd1.Parameters.Add(new SqlParameter("@YWLY",SqlDbType.Bit ));
addCmd1.Parameters.Add(new SqlParameter("@ZZ",SqlDbType.VarChar ,200));
addCmd1.Parameters.Add(new SqlParameter("@DH",SqlDbType.VarChar ,20));
addCmd1.Parameters.Add(new SqlParameter("@SFZ",SqlDbType.VarChar ,20));
addCmd1.Parameters.Add(new SqlParameter("@TBR",SqlDbType.VarChar ,8));
addCmd1.Parameters.Add(new SqlParameter("@SJ",SqlDbType.VarChar ,50));
addCmd1.Parameters["@ID"].SourceColumn="ID";
addCmd1.Parameters["@YYBH"].SourceColumn="医院编号";
addCmd1.Parameters["@XM"].SourceColumn="患者姓名";
addCmd1.Parameters["@PYM"].SourceColumn="拼音码";
addCmd1.Parameters["@MZH"].SourceColumn="门诊号";
addCmd1.Parameters["@XB"].SourceColumn="性别";
addCmd1.Parameters["@CSNY"].SourceColumn="出生年月";
addCmd1.Parameters["@FY"].SourceColumn="婚姻";
addCmd1.Parameters["@ZY"].SourceColumn="职业";
addCmd1.Parameters["@JJSR"].SourceColumn="经济收入";
addCmd1.Parameters["@WHCD"].SourceColumn="文化程度";
addCmd1.Parameters["@XY"].SourceColumn="吸烟";
addCmd1.Parameters["@YWLY"].SourceColumn="药物乱用";
addCmd1.Parameters["@ZZ"].SourceColumn="住址";
addCmd1.Parameters["@DH"].SourceColumn="电话";
addCmd1.Parameters["@SFZ"].SourceColumn="身份证号码";
addCmd1.Parameters["@TBR"].SourceColumn="填表人";
addCmd1.Parameters["@SJ"].SourceColumn="录入时间";
this.da_Brzlk .InsertCommand=addCmd1;
#endregion
#region 发病诱因字典--适配器的命令语句:Select与Insert语句
tabName="d_发病诱因字典";
this.da_Fbyyzd =new SqlDataAdapter ();
this.da_Fbyyzd .SelectCommand=new SqlCommand("select * from d_发病诱因字典",this.dstCnn );
SqlCommand addCmd2=new SqlCommand();
addCmd2.Connection=this.dstCnn ;
sql_Add="insert into d_发病诱因字典(ID,发病诱因) values(@ID,@YY);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
addCmd2.CommandText=sqlCmd;
addCmd2.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd2.Parameters.Add(new SqlParameter("@YY",SqlDbType.VarChar ,100));
addCmd2.Parameters["@ID"].SourceColumn="ID";
addCmd2.Parameters["@YY"].SourceColumn="发病诱因";
this.da_Fbyyzd .InsertCommand=addCmd2;
#endregion
#region 发作类别字典库--适配器的命令语句:Select与Insert语句
tabName="d_发作类别字典库";
this.da_Fzlbzdk =new SqlDataAdapter();
this.da_Fzlbzdk.SelectCommand=new SqlCommand("select * from d_发作类别字典库",this.dstCnn );
SqlCommand addCmd3=new SqlCommand();
addCmd3.Connection=this.dstCnn ;
sql_Add="insert into d_发作类别字典库(ID,发作类别) values(@ID,@FZ);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
addCmd3.CommandText=sqlCmd;
addCmd3.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd3.Parameters.Add(new SqlParameter("@FZ",SqlDbType.VarChar ,50));
addCmd3.Parameters["@ID"].SourceColumn="ID";
addCmd3.Parameters["@FZ"].SourceColumn="发作类别";
this.da_Fzlbzdk.InsertCommand=addCmd3;
#endregion
#region 犯罪处罚类别字典库--适配器的命令语句:Select与Insert语句
tabName="d_犯罪处罚类别字典库";
this.da_Fzcflbzdk =new SqlDataAdapter();
this.da_Fzcflbzdk.SelectCommand=new SqlCommand("select * from d_犯罪处罚类别字典库",this.dstCnn );
sql_Add="insert into d_犯罪处罚类别字典库(ID,犯罪处罚类别) values(@ID,@CF);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd4=new SqlCommand(sqlCmd,this.dstCnn );
addCmd4.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd4.Parameters.Add(new SqlParameter("@CF",SqlDbType.VarChar ,50));
addCmd4.Parameters["@ID"].SourceColumn="ID";
addCmd4.Parameters["@CF"].SourceColumn="犯罪处罚类别";
this.da_Fzcflbzdk.InsertCommand=addCmd4;
#endregion
#region 功能影响字典库--适配器的命令语句:Select与Insert语句
tabName="d_功能影响字典库";
this.da_Glyxzdk =new SqlDataAdapter();
this.da_Glyxzdk.SelectCommand=new SqlCommand("select * from d_功能影响字典库",this.dstCnn );
sql_Add="insert into d_功能影响字典库(ID,影响描述) values(@ID,@YX);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd5=new SqlCommand(sqlCmd,this.dstCnn );
addCmd5.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd5.Parameters.Add(new SqlParameter("@YX",SqlDbType.VarChar ,50));
addCmd5.Parameters["@ID"].SourceColumn="ID";
addCmd5.Parameters["@YX"].SourceColumn="影响描述";
this.da_Glyxzdk .InsertCommand=addCmd5;
#endregion
#region 婚姻字典库--适配器的命令语句:Select与Insert语句
tabName="d_婚姻字典库";
this.da_Fyzdk =new SqlDataAdapter();
this.da_Fyzdk .SelectCommand=new SqlCommand("select * from d_婚姻字典库",this.dstCnn );
sql_Add="insert into d_婚姻字典库(FYID,婚姻状况) values(@ID,@FY);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd6=new SqlCommand(sqlCmd,this.dstCnn );
addCmd6.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd6.Parameters.Add(new SqlParameter("@FY",SqlDbType.VarChar ,50));
addCmd6.Parameters["@ID"].SourceColumn="FYID";
addCmd6.Parameters["@FY"].SourceColumn="婚姻状况";
this.da_Fyzdk .InsertCommand=addCmd6;
#endregion
#region 家族史字典--适配器的命令语句:Select与Insert语句
tabName="d_家族史字典";
this.da_Jzszd =new SqlDataAdapter();
this.da_Jzszd .SelectCommand=new SqlCommand("select * from d_家族史字典",this.dstCnn );
sql_Add="insert into d_家族史字典(ID,家族史) values(@ID,@JS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd7=new SqlCommand(sqlCmd,this.dstCnn );
addCmd7.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd7.Parameters.Add(new SqlParameter("@JS",SqlDbType.VarChar ,100));
addCmd7.Parameters["@ID"].SourceColumn="ID";
addCmd7.Parameters["@JS"].SourceColumn="家族史";
this.da_Jzszd.InsertCommand=addCmd7;
#endregion
#region 教育类别字典库--适配器的命令语句:Select与Insert语句
tabName="d_教育类别字典库";
this.da_Jylbzdk =new SqlDataAdapter();
this.da_Jylbzdk .SelectCommand=new SqlCommand("select * from d_教育类别字典库",this.dstCnn );
sql_Add="insert into d_教育类别字典库(ID,JYDES) values(@ID,@JS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd8=new SqlCommand(sqlCmd,this.dstCnn );
addCmd8.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ,4,"ID"));
addCmd8.Parameters.Add(new SqlParameter("@JS",SqlDbType.VarChar ,50,"JYDES"));
this.da_Jylbzdk .InsertCommand=addCmd8;
#endregion
#region 教育专题目录库--适配器的命令语句:Select与Insert语句
tabName="d_教育专题目录库";
this.da_Jyztmlk =new SqlDataAdapter();
this.da_Jyztmlk .SelectCommand=new SqlCommand("select * from d_教育专题目录库",this.dstCnn );
sql_Add="insert into d_教育专题目录库(ID,CLSID,TITLE,DOCTXT,DOCTIME) values(@ID,@CLS,@TIT,@DOC,@TM);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd9=new SqlCommand(sqlCmd,this.dstCnn );
addCmd9.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd9.Parameters.Add(new SqlParameter("@CLS",SqlDbType.Int ));
addCmd9.Parameters.Add(new SqlParameter("@TIT",SqlDbType.VarChar ,50 ));
addCmd9.Parameters.Add(new SqlParameter("@DOC",SqlDbType.Text ));
addCmd9.Parameters.Add(new SqlParameter("@TM",SqlDbType.VarChar ,50 ));
addCmd9.Parameters["@ID"].SourceColumn="ID";
addCmd9.Parameters["@CLS"].SourceColumn="CLSID";
addCmd9.Parameters["@TIT"].SourceColumn="TITLE";
addCmd9.Parameters["@DOC"].SourceColumn="DOCTXT";
addCmd9.Parameters["@TM"].SourceColumn="DOCTIME";
this.da_Jyztmlk.InsertCommand=addCmd9;
#endregion
#region 教育专题子目录库--适配器的命令语句:Select与Insert语句
tabName="d_教育专题子目录库";
this.da_Jyztzmlk =new SqlDataAdapter();
this.da_Jyztzmlk .SelectCommand=new SqlCommand("select * from d_教育专题子目录库",this.dstCnn );
sql_Add="insert into d_教育专题子目录库(ID,FARID,SONORDER,TITLE,DOC,DOCTM) values(@ID,@FAR,@SON,@TIT,@DOC,@TM);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd10=new SqlCommand(sqlCmd,this.dstCnn );
addCmd10.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd10.Parameters.Add(new SqlParameter("@FAR",SqlDbType.Int ));
addCmd10.Parameters.Add(new SqlParameter("@SON",SqlDbType.Int ));
addCmd10.Parameters.Add(new SqlParameter("@TIT",SqlDbType.VarChar ,50 ));
addCmd10.Parameters.Add(new SqlParameter("@DOC",SqlDbType.Text ));
addCmd10.Parameters.Add(new SqlParameter("@TM",SqlDbType.VarChar ,50 ));
addCmd10.Parameters["@ID"].SourceColumn="ID";
addCmd10.Parameters["@FAR"].SourceColumn="FARID";
addCmd10.Parameters["@SON"].SourceColumn="SONORDER";
addCmd10.Parameters["@TIT"].SourceColumn="TITLE";
addCmd10.Parameters["@DOC"].SourceColumn="DOC";
addCmd10.Parameters["@TM"].SourceColumn="DOCTM";
this.da_Jyztzmlk.InsertCommand=addCmd10;
#endregion
#region 经济状况字典库--适配器的命令语句:Select与Insert语句
tabName="d_经济状况字典库";
this.da_Jjzkzdk =new SqlDataAdapter();
this.da_Jjzkzdk .SelectCommand=new SqlCommand("select * from d_经济状况字典库",this.dstCnn );
sql_Add="insert into d_经济状况字典库(JJZD,经济状况) values(@ID,@JS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd11=new SqlCommand(sqlCmd,this.dstCnn );
addCmd11.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd11.Parameters.Add(new SqlParameter("@JS",SqlDbType.VarChar ,100));
addCmd11.Parameters["@ID"].SourceColumn="JJZD";
addCmd11.Parameters["@JS"].SourceColumn="经济状况";
this.da_Jjzkzdk.InsertCommand=addCmd11;
#endregion
#region 求助方式字典库--适配器的命令语句:Select与Insert语句
tabName="d_求助方式字典库";
this.da_Qzfszdk =new SqlDataAdapter();
this.da_Qzfszdk .SelectCommand=new SqlCommand("select * from d_求助方式字典库",this.dstCnn );
sql_Add="insert into d_求助方式字典库(ID,求助方式) values(@ID,@JS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd12=new SqlCommand(sqlCmd,this.dstCnn );
addCmd12.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd12.Parameters.Add(new SqlParameter("@JS",SqlDbType.VarChar ,50));
addCmd12.Parameters["@ID"].SourceColumn="ID";
addCmd12.Parameters["@JS"].SourceColumn="求助方式";
this.da_Qzfszdk.InsertCommand=addCmd12;
#endregion
#region 随访记录信息库--适配器的命令语句:Select与Insert语句
tabName="d_随访记录信息库";
this.da_Sfjlxxk =new SqlDataAdapter();
this.da_Sfjlxxk.SelectCommand=new SqlCommand("select * from d_随访记录信息库",this.dstCnn );
sql_Add="insert into d_随访记录信息库(";
sql_Add+="ID,病人编号,随访日期,社会休闲功能,职业功能,社会家庭交互作用,";
sql_Add+="认知功能,量表,躁狂量表,汉密顿抑郁量表,症状,实验室检查,";
sql_Add+="自知力,同患病,循环间隔,自杀观念,自杀事件,攻击行为,";
sql_Add+="犯罪处罚,体重,代谢综合症,糖尿病,催乳素水平升高症,";
sql_Add+="脂质代谢异常,QTc延长,EPS) values(";
sql_Add+="@ID,@BRBH,@RQ,@XX,@ZY,@JT,";
sql_Add+="@RZGL,@LB,@CKLB,@HMDLB,@ZZ,@SYS,";
sql_Add+="@ZZL,@TFB,@XFJG,@ZSGN,@ZSSJ,@GJXW,";
sql_Add+="@FZCF,@TZ,@DXZHZ,@TNB,@SGZ,";
sql_Add+="@DXYC,@QTC,@EPS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd13=new SqlCommand(sqlCmd,this.dstCnn );
addCmd13.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int,4,"ID"));
addCmd13.Parameters.Add(new SqlParameter("@BRBH",SqlDbType.Int,4,"病人编号"));
addCmd13.Parameters.Add(new SqlParameter("@RQ",SqlDbType.VarChar ,50,"随访日期"));
addCmd13.Parameters.Add(new SqlParameter("@XX",SqlDbType.Int,4,"社会休闲功能"));
addCmd13.Parameters.Add(new SqlParameter("@ZY",SqlDbType.Int,4,"职业功能"));
addCmd13.Parameters.Add(new SqlParameter("@JT",SqlDbType.Int,4,"社会家庭交互作用"));
addCmd13.Parameters.Add(new SqlParameter("@RZGL",SqlDbType.Int,4,"认知功能"));
addCmd13.Parameters.Add(new SqlParameter("@LB",SqlDbType.Int,4,"量表"));
addCmd13.Parameters.Add(new SqlParameter("@CKLB",SqlDbType.Int,4,"躁狂量表"));
addCmd13.Parameters.Add(new SqlParameter("@HMDLB",SqlDbType.Int,4,"汉密顿抑郁量表"));
addCmd13.Parameters.Add(new SqlParameter("@ZZ",SqlDbType.VarChar ,200,"症状"));
addCmd13.Parameters.Add(new SqlParameter("@SYS",SqlDbType.VarChar ,200,"实验室检查"));
addCmd13.Parameters.Add(new SqlParameter("@ZZL",SqlDbType.Int ,4,"自知力"));
addCmd13.Parameters.Add(new SqlParameter("@TFB",SqlDbType.VarChar,200,"同患病"));
addCmd13.Parameters.Add(new SqlParameter("@XFJG",SqlDbType.Int ,4,"循环间隔"));
addCmd13.Parameters.Add(new SqlParameter("@ZSGN",SqlDbType.Int,4,"自杀观念"));
addCmd13.Parameters.Add(new SqlParameter("@ZSSJ",SqlDbType.Int ,4,"自杀事件"));
addCmd13.Parameters.Add(new SqlParameter("@GJXW",SqlDbType.Int,4,"攻击行为"));
addCmd13.Parameters.Add(new SqlParameter("@FZCF",SqlDbType.Int,4,"犯罪处罚"));
addCmd13.Parameters.Add(new SqlParameter("@TZ",SqlDbType.Float ,9,"体重"));
addCmd13.Parameters.Add(new SqlParameter("@DXZHZ",SqlDbType.Bit ,1,"代谢综合症"));
addCmd13.Parameters.Add(new SqlParameter("@TNB",SqlDbType.Bit ,1,"糖尿病"));
addCmd13.Parameters.Add(new SqlParameter("@SGZ",SqlDbType.Bit ,1,"催乳素水平升高症"));
addCmd13.Parameters.Add(new SqlParameter("@DXYC",SqlDbType.Bit ,1,"脂质代谢异常"));
addCmd13.Parameters.Add(new SqlParameter("@QTC",SqlDbType.Int,4,"QTc延长"));
addCmd13.Parameters.Add(new SqlParameter("@EPS",SqlDbType.VarChar ,4,"EPS"));
this.da_Sfjlxxk .InsertCommand=addCmd13;
#endregion
#region 同患病字典库--适配器的命令语句:Select与Insert语句
tabName="d_同患病字典库";
this.da_Tfbzdk =new SqlDataAdapter();
this.da_Tfbzdk.SelectCommand=new SqlCommand("select * from d_同患病字典库",this.dstCnn );
sql_Add="insert into d_同患病字典库(ID,同患病) values(@ID,@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd14=new SqlCommand (sqlCmd,this.dstCnn );
addCmd14.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd14.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.VarChar ,100));
addCmd14.Parameters["@ID"].SourceColumn="ID";
addCmd14.Parameters["@BCDT"].SourceColumn="同患病";
this.da_Tfbzdk .InsertCommand=addCmd14;
#endregion
#region 文化程度字典库--适配器的命令语句:Select与Insert语句
tabName="d_文化程度字典库";
this.da_Whcdzdk =new SqlDataAdapter();
this.da_Whcdzdk.SelectCommand=new SqlCommand("select * from d_文化程度字典库",this.dstCnn );
sql_Add="insert into d_文化程度字典库(ID,文化程度) values(@ID,@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd15=new SqlCommand (sqlCmd,this.dstCnn );
addCmd15.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd15.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.VarChar ,100));
addCmd15.Parameters["@ID"].SourceColumn="ID";
addCmd15.Parameters["@BCDT"].SourceColumn="文化程度";
this.da_Whcdzdk.InsertCommand=addCmd15;
#endregion
#region 物理治疗信息库--适配器的命令语句:Select与Insert语句
tabName="d_物理治疗信息库";
this.da_Wlzlxxk =new SqlDataAdapter();
this.da_Wlzlxxk .SelectCommand=new SqlCommand("select * from d_物理治疗信息库",this.dstCnn );
sql_Add="insert into d_物理治疗信息库(ID,物理类别,治疗记录编号,开始时间,次数,电量,持续时间,不良反应,疗效,患者自诉感觉)";
sql_Add+=" values(@ID,@WLLB,@JLBH,@KSSJ,@CS,@DL,@CSSJ,@FY,@LX,@GJ);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd16=new SqlCommand (sqlCmd,this.dstCnn );
addCmd16.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd16.Parameters.Add(new SqlParameter("@WLLB",SqlDbType.Int ));
addCmd16.Parameters.Add(new SqlParameter("@JLBH",SqlDbType.Int ));
addCmd16.Parameters.Add(new SqlParameter("@KSSJ",SqlDbType.VarChar ,50 ));
addCmd16.Parameters.Add(new SqlParameter("@CS",SqlDbType.Int ));
addCmd16.Parameters.Add(new SqlParameter("@DL",SqlDbType.VarChar,50 ));
addCmd16.Parameters.Add(new SqlParameter("@CSSJ",SqlDbType.VarChar ,50));
addCmd16.Parameters.Add(new SqlParameter("@FY",SqlDbType.VarChar ,200));
addCmd16.Parameters.Add(new SqlParameter("@LX",SqlDbType.VarChar ,200));
addCmd16.Parameters.Add(new SqlParameter("@GJ",SqlDbType.VarChar ,100));
addCmd16.Parameters["@ID"].SourceColumn="ID";
addCmd16.Parameters["@WLLB"].SourceColumn="物理类别";
addCmd16.Parameters["@JLBH"].SourceColumn="治疗记录编号";
addCmd16.Parameters["@KSSJ"].SourceColumn="开始时间";
addCmd16.Parameters["@CS"].SourceColumn="次数";
addCmd16.Parameters["@DL"].SourceColumn="电量";
addCmd16.Parameters["@CSSJ"].SourceColumn="持续时间";
addCmd16.Parameters["@FY"].SourceColumn="不良反应";
addCmd16.Parameters["@LX"].SourceColumn="疗效";
addCmd16.Parameters["@GJ"].SourceColumn="患者自诉感觉";
this.da_Wlzlxxk .InsertCommand=addCmd16;
#endregion
#region 心理治疗信息库--适配器的命令语句:Select与Insert语句
tabName="d_心理治疗信息库";
this.da_Xlzlxxk =new SqlDataAdapter();
this.da_Xlzlxxk .SelectCommand=new SqlCommand("select * from d_心理治疗信息库",this.dstCnn );
sql_Add="insert into d_心理治疗信息库(ID,心理类别,治疗记录编号,开如时间,次数,间隔时间,疗效,患者自诉感觉)";
sql_Add+=" values(@ID,@XLLB,@JLBH,@KSSJ,@CS,@CSSJ,@LX,@GJ);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd17=new SqlCommand (sqlCmd,this.dstCnn );
addCmd17.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd17.Parameters.Add(new SqlParameter("@XLLB",SqlDbType.Int ));
addCmd17.Parameters.Add(new SqlParameter("@JLBH",SqlDbType.Int ));
addCmd17.Parameters.Add(new SqlParameter("@KSSJ",SqlDbType.VarChar ,50 ));
addCmd17.Parameters.Add(new SqlParameter("@CS",SqlDbType.Int ));
addCmd17.Parameters.Add(new SqlParameter("@CSSJ",SqlDbType.VarChar ,50));
addCmd17.Parameters.Add(new SqlParameter("@LX",SqlDbType.VarChar ,200));
addCmd17.Parameters.Add(new SqlParameter("@GJ",SqlDbType.VarChar ,100));
addCmd17.Parameters["@ID"].SourceColumn="ID";
addCmd17.Parameters["@XLLB"].SourceColumn="心理类别";
addCmd17.Parameters["@JLBH"].SourceColumn="治疗记录编号";
addCmd17.Parameters["@KSSJ"].SourceColumn="开如时间";
addCmd17.Parameters["@CS"].SourceColumn="次数";
addCmd17.Parameters["@CSSJ"].SourceColumn="间隔时间";
addCmd17.Parameters["@LX"].SourceColumn="疗效";
addCmd17.Parameters["@GJ"].SourceColumn="患者自诉感觉";
this.da_Xlzlxxk .InsertCommand=addCmd17;
#endregion
#region 性格字典库--适配器的命令语句:Select与Insert语句
tabName="d_性格字典库";
this.da_Xgzdk =new SqlDataAdapter();
this.da_Xgzdk.SelectCommand=new SqlCommand("select * from d_性格字典库",this.dstCnn );
sql_Add="insert into d_性格字典库(ID,性格) values(@ID,@XG);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd18=new SqlCommand (sqlCmd,this.dstCnn );
addCmd18.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd18.Parameters.Add(new SqlParameter("@XG",SqlDbType.VarChar ,50));
addCmd18.Parameters["@ID"].SourceColumn="ID";
addCmd18.Parameters["@XG"].SourceColumn="性格";
this.da_Xgzdk.InsertCommand=addCmd18;
#endregion
#region 药物治疗信息库--适配器的命令语句:Select与Insert语句
tabName="d_药物治疗信息库";
this.da_Ywzlxxk =new SqlDataAdapter();
this.da_Ywzlxxk .SelectCommand=new SqlCommand("select * from d_药物治疗信息库",this.dstCnn );
sql_Add="insert into d_药物治疗信息库(ID,药物编号,治疗记录编号,开始时间,剂量,血药浓度,不良反应,疗效,停止时间,激越处理)";
sql_Add+=" values(@ID,@YWBH,@JLBH,@KSSJ,@JL,@XYLD,@FY,@LX,@TZSJ,@JY);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd19=new SqlCommand (sqlCmd,this.dstCnn );
addCmd19.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd19.Parameters.Add(new SqlParameter("@YWBH",SqlDbType.Int ));
addCmd19.Parameters.Add(new SqlParameter("@JLBH",SqlDbType.Int ));
addCmd19.Parameters.Add(new SqlParameter("@KSSJ",SqlDbType.VarChar ,50 ));
addCmd19.Parameters.Add(new SqlParameter("@JL",SqlDbType.VarChar,50 ));
addCmd19.Parameters.Add(new SqlParameter("@XYLD",SqlDbType.VarChar,50 ));
addCmd19.Parameters.Add(new SqlParameter("@FY",SqlDbType.VarChar ,200));
addCmd19.Parameters.Add(new SqlParameter("@LX",SqlDbType.VarChar ,200));
addCmd19.Parameters.Add(new SqlParameter("@TZSJ",SqlDbType.VarChar,50 ));
addCmd19.Parameters.Add(new SqlParameter("@JY",SqlDbType.Bit));
addCmd19.Parameters["@ID"].SourceColumn="ID";
addCmd19.Parameters["@YWBH"].SourceColumn="药物编号";
addCmd19.Parameters["@JLBH"].SourceColumn="治疗记录编号";
addCmd19.Parameters["@KSSJ"].SourceColumn="开始时间";
addCmd19.Parameters["@JL"].SourceColumn="剂量";
addCmd19.Parameters["@XYLD"].SourceColumn="血药浓度";
addCmd19.Parameters["@FY"].SourceColumn="不良反应";
addCmd19.Parameters["@LX"].SourceColumn="疗效";
addCmd19.Parameters["@TZSJ"].SourceColumn="停止时间";
addCmd19.Parameters["@JY"].SourceColumn="激越处理";
this.da_Ywzlxxk .InsertCommand=addCmd19;
#endregion
#region 医院信息库--适配器的命令语句:Select与Insert语句
tabName="d_医院信息库";
this.da_Yyxxk =new SqlDataAdapter();
this.da_Yyxxk.SelectCommand=new SqlCommand("select * from d_医院信息库",this.dstCnn );
sql_Add="insert into d_医院信息库(ID,医院名,联系电话,介绍信息) values(@ID,@MZ,@DH,@XX);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd20=new SqlCommand (sqlCmd,this.dstCnn );
addCmd20.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd20.Parameters.Add(new SqlParameter("@MZ",SqlDbType.VarChar ,50));
addCmd20.Parameters.Add(new SqlParameter("@DH",SqlDbType.VarChar ,20));
addCmd20.Parameters.Add(new SqlParameter("@XX",SqlDbType.Text ));
addCmd20.Parameters["@ID"].SourceColumn="ID";
addCmd20.Parameters["@MZ"].SourceColumn="医院名";
addCmd20.Parameters["@DH"].SourceColumn="联系电话";
addCmd20.Parameters["@XX"].SourceColumn="介绍信息";
this.da_Yyxxk.InsertCommand=addCmd20;
#endregion
#region 诊断字典库--适配器的命令语句:Select与Insert语句
tabName="d_诊断字典库";
this.da_Zdzdk =new SqlDataAdapter();
this.da_Zdzdk.SelectCommand=new SqlCommand("select * from d_诊断字典库",this.dstCnn );
sql_Add="insert into d_诊断字典库(ID,诊断) values(@ID,@XG);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd21=new SqlCommand (sqlCmd,this.dstCnn );
addCmd21.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd21.Parameters.Add(new SqlParameter("@XG",SqlDbType.VarChar ,200));
addCmd21.Parameters["@ID"].SourceColumn="ID";
addCmd21.Parameters["@XG"].SourceColumn="诊断";
this.da_Zdzdk.InsertCommand=addCmd21;
#endregion
#region 职业字典库--适配器的命令语句:Select与Insert语句
tabName="d_职业字典库";
this.da_Zyzdk =new SqlDataAdapter();
this.da_Zyzdk .SelectCommand=new SqlCommand("select * from d_职业字典库",this.dstCnn );
sql_Add="insert into d_职业字典库(ZYID,职业描述) values(@ID,@XG);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd22=new SqlCommand (sqlCmd,this.dstCnn );
addCmd22.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd22.Parameters.Add(new SqlParameter("@XG",SqlDbType.VarChar ,100));
addCmd22.Parameters["@ID"].SourceColumn="ZYID";
addCmd22.Parameters["@XG"].SourceColumn="职业描述";
this.da_Zyzdk .InsertCommand=addCmd22;
#endregion
#region 治疗大类字典库--适配器的命令语句:Select语句(不许插入)
this.da_Zldlzdk=new SqlDataAdapter();
this.da_Zldlzdk.SelectCommand=new SqlCommand("select * from d_治疗大类字典库",this.dstCnn );
#endregion
#region 治疗类别字典库--适配器的命令语句:Select与Insert语句
tabName="d_治疗类别字典库";
this.da_Zllbzdk =new SqlDataAdapter();
this.da_Zllbzdk .SelectCommand=new SqlCommand("select * from d_治疗类别字典库",this.dstCnn );
sql_Add="insert into d_治疗类别字典库(ID,治疗类别描述,治疗大类) values(@ID,@XG,@DL);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd23=new SqlCommand (sqlCmd,this.dstCnn );
addCmd23.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd23.Parameters.Add(new SqlParameter("@XG",SqlDbType.VarChar ,100));
addCmd23.Parameters.Add(new SqlParameter("@DL",SqlDbType.Int ));
addCmd23.Parameters["@ID"].SourceColumn="ID";
addCmd23.Parameters["@XG"].SourceColumn="治疗类别描述";
addCmd23.Parameters["@DL"].SourceColumn="治疗大类";
this.da_Zllbzdk .InsertCommand=addCmd23;
#endregion
#region 治疗史库--适配器的命令语句:Select与Insert语句
tabName="d_治疗史库";
this.da_Zlsk=new SqlDataAdapter();
this.da_Zlsk.SelectCommand=new SqlCommand("Select * from d_治疗史库",this.dstCnn );
sql_Add="insert into d_治疗史库(ID,病人编号,幼年不良经历,性格,家族史,";
sql_Add+="慢性内科疾病,长期内科用药,发病时间,发病诱因,首次求助方式,";
sql_Add+="首诊时间,首诊诊断,确诊时间,诊断,";
sql_Add+="首发躁狂,前驱症状期,自杀观念,自杀事件,攻击行为,";
sql_Add+="病程特点) values(@ID,@BRBH,@JL,@XG,@JS,";
sql_Add+="@MXJB,@CQYY,@FBSJ,@FBYY,@FS,";
sql_Add+="@SZSJ,@SZZD,@QZSJ,@ZD,";
sql_Add+="@CK,@ZZQ,@ZSGN,@ZSSJ,@GJXW,";
sql_Add+="@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd24=new SqlCommand(sqlCmd,this.dstCnn );
addCmd24.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int,4,"ID" ));
addCmd24.Parameters.Add(new SqlParameter("@BRBH",SqlDbType.Int,4,"病人编号" ));
addCmd24.Parameters.Add(new SqlParameter("@JL",SqlDbType.Bit,1,"幼年不良经历" ));
addCmd24.Parameters.Add(new SqlParameter("@XG",SqlDbType.Int,4,"性格" ));
addCmd24.Parameters.Add(new SqlParameter("@JS",SqlDbType.Int,4,"家族史" ));
addCmd24.Parameters.Add(new SqlParameter("@MXJB",SqlDbType.VarChar,200,"慢性内科疾病"));
addCmd24.Parameters.Add(new SqlParameter("@CQYY",SqlDbType.VarChar ,200,"长期内科用药"));
addCmd24.Parameters.Add(new SqlParameter("@FBSJ",SqlDbType.VarChar ,50,"发病时间"));
addCmd24.Parameters.Add(new SqlParameter("@FBYY",SqlDbType.Int,4,"发病诱因"));
addCmd24.Parameters.Add(new SqlParameter("@FS",SqlDbType.Int,4,"首次求助方式"));
addCmd24.Parameters.Add(new SqlParameter("@SZSJ",SqlDbType.VarChar ,50,"首诊时间"));
addCmd24.Parameters.Add(new SqlParameter("@SZZD",SqlDbType.VarChar ,50,"首诊诊断"));
addCmd24.Parameters.Add(new SqlParameter("@QZSJ",SqlDbType.VarChar ,50,"确诊时间"));
addCmd24.Parameters.Add(new SqlParameter("@ZD",SqlDbType.VarChar ,200,"诊断"));
addCmd24.Parameters.Add(new SqlParameter("@CK",SqlDbType.Bit ,1,"首发躁狂"));
addCmd24.Parameters.Add(new SqlParameter("@ZZQ",SqlDbType.VarChar ,50,"前驱症状期"));
addCmd24.Parameters.Add(new SqlParameter("@ZSGN",SqlDbType.Int ,4,"自杀观念"));
addCmd24.Parameters.Add(new SqlParameter("@ZSSJ",SqlDbType.Int,4,"自杀事件"));
addCmd24.Parameters.Add(new SqlParameter("@GJXW",SqlDbType.Int,4,"攻击行为"));
addCmd24.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.Int ,4,"病程特点"));
this.da_Zlsk.InsertCommand=addCmd24;
#endregion
#region 治疗专题目录库--适配器的命令语句:Select与Insert语句
tabName="d_治疗专题目录库";
this.da_Zlztmlk =new SqlDataAdapter();
this.da_Zlztmlk .SelectCommand=new SqlCommand("select * from d_治疗专题目录库",this.dstCnn );
sql_Add="insert into d_治疗专题目录库(ID,CLSID,TITLE,DOC,DOCTM) values(@ID,@CLS,@TIT,@DOC,@TM);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd25=new SqlCommand(sqlCmd,this.dstCnn );
addCmd25.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd25.Parameters.Add(new SqlParameter("@CLS",SqlDbType.Int ));
addCmd25.Parameters.Add(new SqlParameter("@TIT",SqlDbType.VarChar ,100 ));
addCmd25.Parameters.Add(new SqlParameter("@DOC",SqlDbType.Text ));
addCmd25.Parameters.Add(new SqlParameter("@TM",SqlDbType.VarChar ,50 ));
addCmd25.Parameters["@ID"].SourceColumn="ID";
addCmd25.Parameters["@CLS"].SourceColumn="CLSID";
addCmd25.Parameters["@TIT"].SourceColumn="TITLE";
addCmd25.Parameters["@DOC"].SourceColumn="DOC";
addCmd25.Parameters["@TM"].SourceColumn="DOCTM";
this.da_Zlztmlk.InsertCommand=addCmd25;
#endregion
#region 治疗专题子目录库--适配器的命令语句:Select与Insert语句
tabName="d_治疗专题子目录库";
this.da_Zlztzmlk =new SqlDataAdapter();
this.da_Zlztzmlk .SelectCommand=new SqlCommand("select * from d_治疗专题子目录库",this.dstCnn );
sql_Add="insert into d_治疗专题子目录库(ID,Parent,SONORDER,TITLE,DOC,DOCTM) values(@ID,@FAR,@SON,@TIT,@DOC,@TM);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd26=new SqlCommand(sqlCmd,this.dstCnn );
addCmd26.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd26.Parameters.Add(new SqlParameter("@FAR",SqlDbType.Int ));
addCmd26.Parameters.Add(new SqlParameter("@SON",SqlDbType.Int ));
addCmd26.Parameters.Add(new SqlParameter("@TIT",SqlDbType.VarChar ,100 ));
addCmd26.Parameters.Add(new SqlParameter("@DOC",SqlDbType.Text ));
addCmd26.Parameters.Add(new SqlParameter("@TM",SqlDbType.VarChar ,50 ));
addCmd26.Parameters["@ID"].SourceColumn="ID";
addCmd26.Parameters["@FAR"].SourceColumn="Parent";
addCmd26.Parameters["@SON"].SourceColumn="SONORDER";
addCmd26.Parameters["@TIT"].SourceColumn="TITLE";
addCmd26.Parameters["@DOC"].SourceColumn="DOC";
addCmd26.Parameters["@TM"].SourceColumn="DOCTM";
this.da_Zlztzmlk.InsertCommand=addCmd26;
#endregion
#region 治疗专题字典库--适配器的命令语句:Select与Insert语句
tabName="d_治疗专题字典库";
this.da_Zlztzdk =new SqlDataAdapter();
this.da_Zlztzdk .SelectCommand=new SqlCommand("select * from d_治疗专题字典库",this.dstCnn );
sql_Add="insert into d_治疗专题字典库(ID,ZTCLS) values(@ID,@JS);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd27=new SqlCommand(sqlCmd,this.dstCnn );
addCmd27.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ,4,"ID"));
addCmd27.Parameters.Add(new SqlParameter("@JS",SqlDbType.VarChar ,50,"ZTCLS"));
this.da_Zlztzdk .InsertCommand=addCmd27;
#endregion
#region 住院记录库--适配器的命令语句:Select与Insert语句
tabName="d_住院记录库";
this.da_Zyjlk =new SqlDataAdapter();
this.da_Zyjlk .SelectCommand=new SqlCommand("select * from d_住院记录库",this.dstCnn );
sql_Add="insert into d_住院记录库(ID,病人编号,发作时间,入院时间,出院时间,发作类型) values(@ID,@BH,@FZSJ,@RYSJ,@CYSJ,@FZLX);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd28=new SqlCommand(sqlCmd,this.dstCnn );
addCmd28.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int,4,"ID" ));
addCmd28.Parameters.Add(new SqlParameter("@BH",SqlDbType.Int,4,"病人编号" ));
addCmd28.Parameters.Add(new SqlParameter("@FZSJ",SqlDbType.VarChar ,50,"发作时间"));
addCmd28.Parameters.Add(new SqlParameter("@RYSJ",SqlDbType.VarChar ,50,"入院时间"));
addCmd28.Parameters.Add(new SqlParameter("@CYSJ",SqlDbType.VarChar ,50,"出院时间"));
addCmd28.Parameters.Add(new SqlParameter("@FZLX",SqlDbType.Int,4,"发作类型"));
this.da_Zyjlk .InsertCommand=addCmd28;
#endregion
#region 自杀或攻击字典库--适配器的命令语句:Select与Insert语句
tabName="d_自杀或攻击字典库";
this.da_Zsgjzdk =new SqlDataAdapter();
this.da_Zsgjzdk.SelectCommand=new SqlCommand("select * from d_自杀或攻击字典库",this.dstCnn );
sql_Add="insert into d_自杀或攻击字典库(ID,自杀或攻击类别) values(@ID,@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd29=new SqlCommand (sqlCmd,this.dstCnn );
addCmd29.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd29.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.VarChar ,50));
addCmd29.Parameters["@ID"].SourceColumn="ID";
addCmd29.Parameters["@BCDT"].SourceColumn="自杀或攻击类别";
this.da_Zsgjzdk .InsertCommand=addCmd29;
#endregion
#region 自知力字典库--适配器的命令语句:Select与Insert语句
tabName="d_自知力字典库";
this.da_Zzlzdk =new SqlDataAdapter();
this.da_Zzlzdk.SelectCommand=new SqlCommand("select * from d_自知力字典库",this.dstCnn );
sql_Add="insert into d_自知力字典库(ID,自知力类别) values(@ID,@BCDT);";
sqlCmd=sql_Open+sql_Add+sql_Close;
sqlCmd=string.Format(sqlCmd,dbName,tabName,dbName,tabName);
SqlCommand addCmd30=new SqlCommand (sqlCmd,this.dstCnn );
addCmd30.Parameters.Add(new SqlParameter("@ID",SqlDbType.Int ));
addCmd30.Parameters.Add(new SqlParameter("@BCDT",SqlDbType.VarChar ,50));
addCmd30.Parameters["@ID"].SourceColumn="ID";
addCmd30.Parameters["@BCDT"].SourceColumn="自知力类别";
this.da_Zzlzdk .InsertCommand=addCmd30;
#endregion
}
/// <summary>
/// 填充最终的数据集(endDataset)
/// </summary>
private void FillEndDataset()
{
this.endDataset=new DataSet ();
this.da_Bcdtzdk.Fill(this.endDataset ,"病程特点字典库");
this.da_Brzlk .Fill(this.endDataset,"病人资料库");
this.da_Fbyyzd.Fill(this.endDataset,"发病诱因字典");
this.da_Fzlbzdk.Fill(this.endDataset,"发作类别字典库");
this.da_Fzcflbzdk.Fill(this.endDataset,"犯罪处罚类别字典库");
this.da_Glyxzdk.Fill(this.endDataset,"功能影响字典库");
this.da_Fyzdk.Fill(this.endDataset,"婚姻字典库");
this.da_Jzszd.Fill(this.endDataset,"家族史字典");
this.da_Jylbzdk.Fill(this.endDataset,"教育类别字典库");
this.da_Jyztmlk.Fill(this.endDataset,"教育专题目录库");
this.da_Jyztzmlk.Fill(this.endDataset,"教育专题子目录库");
this.da_Jjzkzdk.Fill(this.endDataset,"经济状况字典库");
this.da_Qzfszdk .Fill(this.endDataset,"求助方式字典库");
this.da_Sfjlxxk.Fill(this.endDataset,"随访记录信息库");
this.da_Tfbzdk .Fill(this.endDataset,"同患病字典库");
this.da_Whcdzdk.Fill(this.endDataset,"文化程度字典库");
this.da_Wlzlxxk.Fill(this.endDataset,"物理治疗信息库");
this.da_Xlzlxxk.Fill(this.endDataset,"心理治疗信息库");
this.da_Xgzdk.Fill(this.endDataset,"性格字典库");
this.da_Ywzlxxk.Fill(this.endDataset,"药物治疗信息库");
this.da_Yyxxk .Fill(this.endDataset,"医院信息库");
this.da_Zdzdk .Fill(this.endDataset,"诊断字典库");
this.da_Zyzdk.Fill(this.endDataset,"职业字典库");
this.da_Zldlzdk.Fill(this.endDataset,"治疗大类字典库");
this.da_Zllbzdk.Fill(this.endDataset,"治疗类别字典库");
this.da_Zlsk.Fill(this.endDataset,"治疗史库");
this.da_Zlztmlk.Fill(this.endDataset,"治疗专题目录库");
this.da_Zlztzmlk.Fill(this.endDataset,"治疗专题子目录库");
this.da_Zlztzdk.Fill(this.endDataset,"治疗专题字典库");
this.da_Zyjlk.Fill(this.endDataset,"住院记录库");
this.da_Zsgjzdk.Fill(this.endDataset,"自杀或攻击字典库");
this.da_Zzlzdk.Fill(this.endDataset,"自知力字典库");
}
/// <summary>
/// 对最终数据集进行整理----规格化
/// 对源数据集(dstDataset)中的数据字典中的各个子项中取值与
/// 目标数据集(endDataset)的数据字典中的相对应的子项取值
/// 相同的子项目进行合并操作
///
/// </summary>
private void RuleDstDataset()
{
this.dstDataset=this.srcDataset.Copy ();
this.dstDataset.AcceptChanges ();//不可以掉
#region 对治疗大类字典库进行规格化
refTab rf=new refTab("治疗类别字典库","治疗大类");
this.FeiXi("治疗大类字典库","ID","治疗大类字典库","ID",rf);
this.RuleZiDian("治疗大类字典库","ID","类别","治疗类别字典库","治疗大类");
#endregion
#region 对病程特点字典库进行规格化
rf=new refTab("治疗史库","病程特点");
this.FeiXi("病程特点字典库","ID","病程特点字典库","ID",rf);
this.RuleZiDian("病程特点字典库","ID","病程特点","治疗史库","病程特点");
#endregion
#region 对发病诱因字典库规格化
rf=new refTab("治疗史库","发病诱因");
this.FeiXi("发病诱因字典","ID","发病诱因字典","ID",rf);
this.RuleZiDian("发病诱因字典","ID","发病诱因","治疗史库","发病诱因");
#endregion
#region 对发作类别字典库规格化
rf=new refTab("住院记录库","发作类型");
this.FeiXi("发作类别字典库","ID","发作类别字典库","ID",rf);
this.RuleZiDian("发作类别字典库","ID","发作类别","住院记录库","发作类型");
#endregion
#region 犯罪处罚类别字典库
rf=new refTab("随访记录信息库","犯罪处罚");
this.FeiXi("犯罪处罚类别字典库","ID","犯罪处罚类别字典库","ID",rf);
this.RuleZiDian("犯罪处罚类别字典库","ID","犯罪处罚类别","随访记录信息库","犯罪处罚");
#endregion
#region 对功能影响字典库
this.FeiXi("功能影响字典库","ID","功能影响字典库","ID","随访记录信息库","社会休闲功能","职业功能","社会家庭交互作用","认知功能");
this.RuleZiDian("功能影响字典库","ID","影响描述","随访记录信息库","社会休闲功能","职业功能","社会家庭交互作用","认知功能");
#endregion
#region 婚姻字典库规格化
rf=new refTab("病人资料库","婚姻");
this.FeiXi("婚姻字典库","FYID","婚姻字典库","FYID",rf);
this.RuleZiDian("婚姻字典库","FYID","婚姻状况","病人资料库","婚姻");
#endregion
#region 对家族史字典规格化
rf=new refTab("治疗史库","家族史");
this.FeiXi("家族史字典","ID","家族史字典","ID",rf);
this.RuleZiDian("家族史字典","ID","家族史","治疗史库","家族史");
#endregion
#region 经济状况字典库规格化
rf=new refTab("病人资料库","经济收入");
this.FeiXi("经济状况字典库","JJZD","经济状况字典库","JJZD",rf);
this.RuleZiDian("经济状况字典库","JJZD","经济状况","病人资料库","经济收入");
#endregion
#region 求助方式字典库规格化
rf=new refTab("治疗史库","首次求助方式");
this.FeiXi("求助方式字典库","ID","求助方式字典库","ID",rf);
this.RuleZiDian("求助方式字典库","ID","求助方式","治疗史库","首次求助方式");
#endregion
#region 对文化程度字典库规格化
rf=new refTab("病人资料库","文化程度");
this.FeiXi("文化程度字典库","ID","文化程度字典库","ID",rf);
this.RuleZiDian("文化程度字典库","ID","文化程度","病人资料库","文化程度");
#endregion
#region 性格字典库规格化
rf=new refTab("治疗史库","性格");
this.FeiXi("性格字典库","ID","性格字典库","ID",rf);
this.RuleZiDian("性格字典库","ID","性格","治疗史库","性格");
#endregion
#region 职业字典库规格化
rf=new refTab("病人资料库","职业");
this.FeiXi("职业字典库","ZYID","职业字典库","ZYID",rf);
this.RuleZiDian("职业字典库","ZYID","职业描述","病人资料库","职业");
#endregion
#region 对自杀或攻击字典库
this.FeiXi("自杀或攻击字典库","ID","自杀或攻击字典库","ID","治疗史库","自杀观念","攻击行为");
this.RuleZiDian("自杀或攻击字典库","ID","自杀或攻击类别","治疗史库","自杀观念","攻击行为");
#endregion
rf=new refTab("治疗类别字典库","治疗大类");
this.FeiXi("治疗大类字典库","ID","治疗大类字典库","ID",rf);
this.RuleZiDian("治疗大类字典库","ID","类别","治疗类别字典库","治疗大类");
#region 对自知力字典库进行规格化
rf=new refTab("随访记录信息库","自知力");
this.FeiXi("自知力字典库","ID","自知力字典库","ID",rf);
this.RuleZiDian("自知力字典库","ID","自知力类别","随访记录信息库","自知力");
#endregion
#region 对治疗类别字典库进行规格化
rf=new refTab("物理治疗信息库","物理类别");
refTab ref2=new refTab("心理治疗信息库","心理类别");
refTab ref3=new refTab("药物治疗信息库","药物编号");
this.FeiXi("治疗类别字典库","ID","治疗类别字典库","ID",rf,ref2,ref3);
this.RuleZiDian("治疗类别字典库","ID","治疗类别描述","物理治疗信息库","物理类别");
this.RuleZiDian("治疗类别字典库","ID","治疗类别描述","心理治疗信息库","心理类别");
this.RuleZiDian("治疗类别字典库","ID","治疗类别描述","药物治疗信息库","药物编号");
#endregion
#region 教育类别字典库
rf=new refTab("教育专题目录库","CLSID");
this.FeiXi("教育类别字典库","ID","教育类别字典库","ID",rf);
this.RuleZiDian("教育类别字典库","ID","JYDES","教育专题目录库","CLSID");
#endregion
#region 治疗专题字典库
this.RuleZiDian("治疗专题字典库","ID","ZTCLS","治疗专题目录库","CLSID");
#endregion
this.FeiXi("同患病字典库","ID","同患病字典库","ID");
this.RuleTfbZdk();
//诊断字典库
this.FeiXi ("诊断字典库","ID","诊断字典库","ID");
this.RuleZdzdk ();
//医院信息库
this.FeiXi("医院信息库","ID","医院信息库","ID","病人资料库","医院编号");
this.RuleZiDian("医院信息库","ID","医院名","病人资料库","医院编号");
//添加其它表
refTab cp1=new refTab("随访记录信息库","病人编号");
refTab cp2=new refTab("住院记录库","病人编号");
refTab cp3=new refTab("治疗史库","病人编号");
this.FeiXi("病人资料库","ID","病人资料库","ID",cp1,cp2,cp3);
this.TableRowAdd("病人资料库","病人资料库");
cp1=new refTab("药物治疗信息库","治疗记录编号");
cp2=new refTab("物理治疗信息库","治疗记录编号");
cp3=new refTab("药物治疗信息库","治疗记录编号");
this.FeiXi("住院记录库","ID","住院记录库","ID",cp1,cp2,cp3);
this.TableRowAdd("住院记录库","住院记录库");
this.FeiXi("治疗史库","ID","治疗史库","ID");
this.TableRowAdd("治疗史库","治疗史库");
this.FeiXi("随访记录信息库","ID","随访记录信息库","ID");
this.TableRowAdd("随访记录信息库","随访记录信息库");
/
this.FeiXi("药物治疗信息库","ID","药物治疗信息库","ID");
this.TableRowAdd("药物治疗信息库","药物治疗信息库");
this.FeiXi("物理治疗信息库","ID","物理治疗信息库","ID");
this.TableRowAdd("物理治疗信息库","物理治疗信息库");
this.FeiXi("心理治疗信息库","ID","心理治疗信息库","ID");
this.TableRowAdd("心理治疗信息库","心理治疗信息库");
cp1=new refTab("教育专题子目录库","FARID");
this.FeiXi("教育专题目录库","ID","教育专题目录库","ID",cp1);
this.TableRowAdd("教育专题目录库","教育专题目录库");
this.FeiXi("教育专题子目录库","ID","教育专题子目录库","ID");
this.TableRowAdd("教育专题子目录库","教育专题子目录库");
cp1=new refTab("治疗专题子目录库","Parent");
this.FeiXi("治疗专题目录库","ID","治疗专题目录库","ID",cp1);
this.TableRowAdd("治疗专题目录库","治疗专题目录库");
this.FeiXi("治疗专题子目录库","ID","治疗专题子目录库","ID");
this.TableRowAdd("治疗专题子目录库","治疗专题子目录库");
this.isok=true;
}
/// <summary>
/// 修改同患病字典库
/// </summary>
private void RuleTfbZdk()
{
string zdName="同患病字典库";
string valKey="同患病";
string zdPryKey="ID";
string refTabName="随访记录信息库";
System.Collections.Hashtable hst=new Hashtable();
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[valKey].ToString ().Trim ();
foreach(DataRow endDr in this.endDataset.Tables[zdName].Rows )
{
string endstr=endDr[valKey].ToString ().Trim ();
if(endstr==idstr)//取值相同
{
hst.Add(srcDr[zdPryKey].ToString (),endDr[zdPryKey].ToString ().Trim ());
}
}
}
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[zdPryKey].ToString ().Trim ();
if(!hst.Contains(idstr))
{
添加新行到字典库
DataRow dr=this.endDataset.Tables[zdName].NewRow ();
foreach(DataColumn dc in this.endDataset.Tables[zdName].Columns )
{
dr[dc.ColumnName]=srcDr[dc.ColumnName ];
}
this.endDataset.Tables[zdName].Rows .Add(dr);
}
}
//更新关联行
foreach(DataRow drc in this.dstDataset.Tables[refTabName].Rows )
{
string resstr=drc["同患病"].ToString ();
string[] opcstr=resstr.Trim ().Split(new char[]{','});
for(int i=0;i<opcstr.Length ;i++)
{
if(hst.Contains(opcstr[i])&&opcstr[i]!="")
{
opcstr[i]=hst[opcstr[i]].ToString ();
}
}
resstr="";
for(int i=0;i<opcstr.Length ;i++)
{
resstr+=opcstr[i].Trim()+",";
}
drc["同患病"]=resstr;
}
this.dstDataset.Tables[refTabName].AcceptChanges ();
hst.Clear ();
}
/// <summary>
/// 修改诊断字典库
/// </summary>
private void RuleZdzdk()
{
string zdName="诊断字典库";
string valKey="诊断";
string zdPryKey="ID";
System.Collections.Hashtable hst=new Hashtable();
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[valKey].ToString ().Trim ();
foreach(DataRow endDr in this.endDataset.Tables[zdName].Rows )
{
string endstr=endDr[valKey].ToString ().Trim ();
if(endstr==idstr)//取值相同
{
hst.Add(srcDr[zdPryKey].ToString (),endDr[zdPryKey].ToString ().Trim ());
}
}
}
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[zdPryKey].ToString ().Trim ();
if(!hst.Contains(idstr))
{
添加新行到字典库
DataRow dr=this.endDataset.Tables[zdName].NewRow ();
foreach(DataColumn dc in this.endDataset.Tables[zdName].Columns )
{
dr[dc.ColumnName]=srcDr[dc.ColumnName ];
}
this.endDataset.Tables[zdName].Rows .Add(dr);
}
}
}
/// <summary>
/// 向dstTabName中添加srcTabName的行
/// </summary>
///<param name="srcTabName" >源数据集dstDataset中的表名</param>
///<param name="dstTabName">目标数据集endDataset中的表名</param>
private void TableRowAdd(string srcTabName,string dstTabName)
{
int ks=dstDataset.Tables[srcTabName].Columns.Count ;
foreach(DataRow dr in dstDataset.Tables[srcTabName].Rows )
{
DataRow nwDr=this.endDataset.Tables[dstTabName].NewRow ();
foreach(DataColumn dc in dstDataset.Tables[srcTabName].Columns )
{
nwDr[dc.ColumnName]=dr[dc.ColumnName];
}
this.endDataset.Tables[dstTabName].Rows.Add(nwDr);
}
}
/// <summary>
/// 规格字典及其关联表
/// </summary>
/// <param name="zdName">字典表</param>
/// <param name="zdPryKey">关键字段名</param>
/// <param name="valKey">相应的取值字段名</param>
/// <param name="refTabName">关联表</param>
/// <param name="zdList">关联字段名列表</param>
private void RuleZiDian(string zdName,string zdPryKey,string valKey,string refTabName,params string[] zdList)
{
System.Collections.Hashtable hst=new Hashtable();
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[valKey].ToString ().Trim ();
foreach(DataRow endDr in this.endDataset.Tables[zdName].Rows )
{
string endstr=endDr[valKey].ToString ().Trim ();
if(endstr==idstr)//取值相同
{
hst.Add(srcDr[zdPryKey].ToString (),endDr[zdPryKey].ToString ().Trim ());
}
}
}
foreach(DataRow srcDr in this.dstDataset.Tables[zdName].Rows )
{
string idstr=srcDr[zdPryKey].ToString ().Trim ();
if(!hst.Contains(idstr))
{
添加新行到字典库
DataRow dr=this.endDataset.Tables[zdName].NewRow ();
foreach(DataColumn dc in this.endDataset.Tables[zdName].Columns )
{
dr[dc.ColumnName]=srcDr[dc.ColumnName ];
}
this.endDataset.Tables[zdName].Rows .Add(dr);
}
}
//更新关联行
foreach(DataRow drc in this.dstDataset.Tables[refTabName].Rows )
{
foreach(string zdc in zdList)
{
string bc=drc[zdc].ToString ();
if(hst.Contains(bc))
{
drc[zdc]=hst[bc].ToString ();
}
}
}
this.dstDataset.Tables[refTabName].AcceptChanges ();
hst.Clear ();
}
/// <summary>
/// 将目标数据集(endDataset)的数据存回数据库中
/// 执行更新操作da_XXXXX.Update();
///
/// </summary>
private void dataImport()
{
//事物开始
if(this.dstCnn.State==ConnectionState.Closed )
this.dstCnn.Open ();
System.Data.SqlClient.SqlTransaction trans=this.dstCnn.BeginTransaction (System.Data.IsolationLevel.Serializable,"DhzTrans");
//更新字典库
this.da_Bcdtzdk.InsertCommand.Transaction=trans;
this.da_Bcdtzdk.Update (this.endDataset,"病程特点字典库");
this.da_Fbyyzd.InsertCommand.Transaction=trans;
this.da_Fbyyzd .Update(this.endDataset,"发病诱因字典");
this.da_Fzlbzdk.InsertCommand.Transaction=trans;
this.da_Fzlbzdk.Update(this.endDataset,"发作类别字典库");
this.da_Fzcflbzdk.InsertCommand.Transaction=trans;
this.da_Fzcflbzdk.Update(this.endDataset,"犯罪处罚类别字典库");
this.da_Glyxzdk.InsertCommand.Transaction=trans;
this.da_Glyxzdk.Update(this.endDataset,"功能影响字典库");
this.da_Fyzdk.InsertCommand.Transaction=trans;
this.da_Fyzdk.Update(this.endDataset,"婚姻字典库");
this.da_Jzszd.InsertCommand.Transaction=trans;
this.da_Jzszd.Update(this.endDataset,"家族史字典");
this.da_Jjzkzdk.InsertCommand.Transaction=trans;
this.da_Jjzkzdk .Update(this.endDataset,"经济状况字典库");
this.da_Qzfszdk.InsertCommand.Transaction=trans;
this.da_Qzfszdk.Update(this.endDataset,"求助方式字典库");
this.da_Tfbzdk.InsertCommand.Transaction=trans;
this.da_Tfbzdk.Update(this.endDataset,"同患病字典库");
this.da_Whcdzdk.InsertCommand.Transaction=trans;
this.da_Whcdzdk.Update(this.endDataset,"文化程度字典库");
this.da_Xgzdk.InsertCommand.Transaction=trans;
this.da_Xgzdk.Update(this.endDataset,"性格字典库");
this.da_Zdzdk.InsertCommand.Transaction=trans;
this.da_Zdzdk.Update(this.endDataset,"诊断字典库");
this.da_Zyzdk.InsertCommand.Transaction=trans;
this.da_Zyzdk.Update(this.endDataset,"职业字典库");
this.da_Zsgjzdk.InsertCommand.Transaction=trans;
this.da_Zsgjzdk.Update(this.endDataset,"自杀或攻击字典库");
this.da_Zzlzdk.InsertCommand.Transaction=trans;
this.da_Zzlzdk.Update(this.endDataset,"自知力字典库");
//治疗大类字典库不用更新
this.da_Zllbzdk.InsertCommand.Transaction=trans;
this.da_Zllbzdk.Update(this.endDataset,"治疗类别字典库");
//教育专题
this.da_Jylbzdk.InsertCommand.Transaction=trans;
this.da_Jylbzdk.Update(this.endDataset,"教育类别字典库");
this.da_Jyztmlk.InsertCommand.Transaction=trans;
this.da_Jyztmlk.Update(this.endDataset,"教育专题目录库");
this.da_Jyztzmlk.InsertCommand.Transaction=trans;
this.da_Jyztzmlk.Update(this.endDataset,"教育专题子目录库");
//治疗专题
this.da_Zlztzdk.InsertCommand.Transaction=trans;
this.da_Zlztzdk.Update(this.endDataset,"治疗专题字典库");
this.da_Zlztmlk.InsertCommand.Transaction=trans;
this.da_Zlztmlk .Update(this.endDataset,"治疗专题目录库");
this.da_Zlztzmlk.InsertCommand.Transaction=trans;
this.da_Zlztzmlk .Update(this.endDataset,"治疗专题子目录库");
//病人资料库
this.da_Yyxxk.InsertCommand.Transaction=trans;
this.da_Yyxxk.Update(this.endDataset,"医院信息库");
this.da_Brzlk.InsertCommand.Transaction=trans;
this.da_Brzlk.Update(this.endDataset,"病人资料库");
this.da_Zlsk.InsertCommand.Transaction=trans;
this.da_Zlsk.Update(this.endDataset,"治疗史库");
this.da_Sfjlxxk.InsertCommand.Transaction=trans;
this.da_Sfjlxxk.Update(this.endDataset,"随访记录信息库");
this.da_Zyjlk.InsertCommand.Transaction=trans;
this.da_Zyjlk.Update(this.endDataset,"住院记录库");
//XX治疗
this.da_Ywzlxxk.InsertCommand.Transaction=trans;
this.da_Ywzlxxk.Update(this.endDataset,"药物治疗信息库");
this.da_Wlzlxxk.InsertCommand.Transaction=trans;
this.da_Wlzlxxk.Update(this.endDataset,"物理治疗信息库");
this.da_Xlzlxxk.InsertCommand.Transaction=trans;
this.da_Xlzlxxk.Update(this.endDataset,"心理治疗信息库");
trans.Commit ();
MessageBox.Show("导入成功!");
//
}
#endregion
}
}