📄 frmcreateemisdb.cs
字号:
//修改保存
try
{
GlobalObject.Instance.LocalSession.WriteSQLScript("EMIS_CreateSP.sql",this.rtxtsp.Text);
}
catch(Exception em)
{
MessageBox.Show(em.ToString(),"异常",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
private void Btn_Excut1_Click(object sender, System.EventArgs e)
{
//执行创建存储过程脚本
ShowProgress("创建存储过程",true);
try
{
SQLPlusScript sQLPlusScript = new SQLPlusScript();
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Script\\"+"EMIS_CreateSP.sql";
string str = sQLPlusScript.Execute(@currAppPath);
this.SetFinishsp();
//写日志,显示日志
DataTable dtlog = new DataTable("Createsplog");
dtlog.Columns.Add("Version");
dtlog.Columns.Add("ReleaseDate");
dtlog.Columns.Add("Comment");
DataRow dr1 = dtlog.NewRow();
dr1["Version"] = "1.0.0.1";
dr1["ReleaseDate"] = System.DateTime.Now;
dr1["Comment"] = str;
dtlog.Rows.Add(dr1);
writesplog(dtlog);
//更新日志显示,更新txtLog中的内容
DataTable dtlogr = readsplog();
foreach(DataRow dr in dtlogr.Rows)
{
this.txtLogsp.Text += "版本号:"+dr["Version"].ToString()+"\r\n";
this.txtLogsp.Text += "发布时间:"+dr["ReleaseDate"].ToString()+"\r\n";
this.txtLogsp.Text += "版本说明:"+dr["Comment"].ToString()+"\r\n";
}
}
catch(Exception em)
{
MessageBox.Show(em.ToString(),"异常",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
ShowProgress("",false);
}
private void Btn_Excut_Click(object sender, System.EventArgs e)
{
//执行创建表脚本
this.ShowProgress("创建数据库",true);
try
{
SQLPlusScript sQLPlusScript = new SQLPlusScript();
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Script\\"+"EMIS_CreateTB.sql";
string str = sQLPlusScript.Execute(@currAppPath);
this.SetFinishbt();
//写日志,显示日志
DataTable dtlog = new DataTable("Createtblog");
dtlog.Columns.Add("Version");
dtlog.Columns.Add("ReleaseDate");
dtlog.Columns.Add("Comment");
DataRow dr1 = dtlog.NewRow();
dr1["Version"] = "1.0.0.1";
dr1["ReleaseDate"] = System.DateTime.Now;
dr1["Comment"] = str;
dtlog.Rows.Add(dr1);
writetblog(dtlog);
//更新日志显示,更新txtLog中的内容
DataTable dtlogr = readtblog();
foreach(DataRow dr in dtlogr.Rows)
{
this.txtLogtb.Text += "版本号:"+dr["Version"].ToString()+"\r\n";
this.txtLogtb.Text += "发布时间:"+dr["ReleaseDate"].ToString()+"\r\n";
this.txtLogtb.Text += "版本说明:"+dr["Comment"].ToString()+"\r\n";
}
}
catch(Exception em)
{
MessageBox.Show(em.ToString(),"异常",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
this.ShowProgress("",false);
}
private void btn_Finish_Click(object sender, System.EventArgs e)
{
//更改状态配置文件
GlobalObject.Instance.LocalSession.UpdateConfig("DBTask.config","TASK","TaskState","1",1);
//完成操作,向主界面发送消息
GlobalObject.Instance.LocalSession.SendMessage("CreateDBTask","FrmCreateEMISDB","TaskStepState",TaskStepState.Done);
}
/// <summary>
/// 打开创建表脚本
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "SQL文件|*.sql";
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Script\\";
openFileDialog1.InitialDirectory =currAppPath;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
string strLine = GlobalObject.Instance.LocalSession.ReadSQLScript(openFileDialog1.FileName);
textBox1.Text = openFileDialog1.FileName;
this.rtxttb.Text = strLine;
}
}
/// <summary>
/// 打开创建存储过程脚本
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button6_Click(object sender, System.EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "SQL文件|*.sql";
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Script\\";
openFileDialog1.InitialDirectory = currAppPath;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
string strLine = GlobalObject.Instance.LocalSession.ReadSQLScript(openFileDialog1.FileName);
textBox2.Text = openFileDialog1.FileName;
this.rtxtsp.Text = strLine;
}
}
/// <summary>
/// 读取日志信息,创建表
/// </summary>
/// <returns>数据表</returns>
private DataTable readtblog()
{
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"CreateTBlog.xml";
return GlobalObject.Instance.LocalSession.ReadDataFromDataFile("Createtblog.xml").Tables["Createtblog"];
}
/// <summary>
/// 写日志信息,创建表
/// </summary>
private void writetblog(DataTable dtlog)
{
DataSet ds = new DataSet();
ds.Tables.Add(dtlog);
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"Createtblog.xml";
GlobalObject.Instance.LocalSession.WriteDataToDataFile("Createtblog.xml",ds);
}
/// <summary>
/// 读取日志信息,创建表
/// </summary>
/// <returns>数据表</returns>
private DataTable readsplog()
{
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"Createsplog.xml";
return GlobalObject.Instance.LocalSession.ReadDataFromDataFile("Createsplog.xml").Tables["Createsplog"];
}
/// <summary>
/// 写日志信息,创建表
/// </summary>
private void writesplog(DataTable dtlog)
{
DataSet ds = new DataSet();
ds.Tables.Add(dtlog);
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"Createsplog.xml";
GlobalObject.Instance.LocalSession.WriteDataToDataFile("Createsplog.xml",ds);
}
/// <summary>
/// 打开窗体事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmCreateEMISDB_Load(object sender, System.EventArgs e)
{
//日志 创建表
//读取日志文件
DataTable dtlog = readtblog();
string currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"Createtblog.XML";
//根据日志信息,判断当前状态,是已经执行完成,还是未完成,设置按钮可用属性,写入txtLog
foreach(DataRow dr in dtlog.Rows)
{
if(dr["Version"].ToString()!="")
{
this.txtLogtb.Text += "版本号:"+dr["Version"].ToString()+"\r\n";
this.txtLogtb.Text += "发布时间:"+dr["ReleaseDate"].ToString()+"\r\n";
this.txtLogtb.Text += "版本说明:"+dr["Comment"].ToString()+"\r\n";
this.SetFinishbt();
}
else
{
this.txtLogtb.Text = "";
this.SetUnFinishbt();
}
}
//创建存储过程日志
//读取日志文件
dtlog = readsplog();
currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += ".\\Resources\\Log\\"+"Createsplog.XML";
//根据日志信息,判断当前状态,是已经执行完成,还是未完成,设置按钮可用属性,写入txtLog
foreach(DataRow dr in dtlog.Rows)
{
if(dr["Version"].ToString()!="")
{
this.txtLogsp.Text += "版本号:"+dr["Version"].ToString()+"\r\n";
this.txtLogsp.Text += "发布时间:"+dr["ReleaseDate"].ToString()+"\r\n";
this.txtLogsp.Text += "版本说明:"+dr["Comment"].ToString()+"\r\n";
this.SetFinishsp();
}
else
{
this.txtLogsp.Text = "";
this.SetUnFinishsp();
}
}
//预先读取脚本创建表
currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += @"\Resources\Script\"+"EMIS_CreateTB.sql";
this.textBox1.Text = currAppPath;
this.rtxttb.Text = GlobalObject.Instance.LocalSession.ReadSQLScript(currAppPath);
//预先读取脚本创建存储过程
currAppPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;;
currAppPath += @"\Resources\Script\"+"EMIS_CreateSP.sql";
this.textBox2.Text = currAppPath;
this.rtxtsp.Text = GlobalObject.Instance.LocalSession.ReadSQLScript(currAppPath);
}
/// <summary>
/// 设置按钮状态为完成状态(创建表)
/// </summary>
private void SetFinishbt()
{
this.Btn_Excut.Enabled = false;
this.Btn_Save.Enabled = false;
this.Btn_Cancel.Enabled = true;
}
/// <summary>
/// 设置按钮状态为未完成状态(创建表)
/// </summary>
private void SetUnFinishbt()
{
this.Btn_Excut.Enabled = true;
this.Btn_Save.Enabled = true;
this.Btn_Cancel.Enabled = false;
}
/// <summary>
/// 设置按钮状态为完成状态(创建存储过程)
/// </summary>
private void SetFinishsp()
{
this.Btn_Excut1.Enabled = false;
this.button4.Enabled = false;
this.Btn_Check.Enabled = false;
this.btn_Finish.Enabled = true;
}
/// <summary>
/// 设置按钮状态为未完成状态(创建存储过程)
/// </summary>
private void SetUnFinishsp()
{
this.Btn_Excut1.Enabled = true;
this.button4.Enabled = true;
this.Btn_Check.Enabled = true;
this.btn_Finish.Enabled = false;
}
/// <summary>
/// 修改保存按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Btn_Save_Click(object sender, System.EventArgs e)
{
try
{
GlobalObject.Instance.LocalSession.WriteSQLScript("EMIS_CreateTB.sql",this.rtxttb.Text);
}
catch(Exception em)
{
MessageBox.Show(em.ToString(),"异常",MessageBoxButtons.OK,MessageBoxIcon.Warning);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -