152 lines
5.1 KiB
C#
152 lines
5.1 KiB
C#
|
|
using SOH.Entities;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.ComponentModel;
|
|||
|
|
using System.Data;
|
|||
|
|
using System.Drawing;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows.Forms;
|
|||
|
|
using EAS.Services;
|
|||
|
|
using System.IO;
|
|||
|
|
using System.Reflection;
|
|||
|
|
|
|||
|
|
namespace SOH.JianYan
|
|||
|
|
{
|
|||
|
|
public partial class frm_YiQiAdd : Form
|
|||
|
|
{
|
|||
|
|
string _asstype;
|
|||
|
|
string _srcforder;
|
|||
|
|
int _yqlb;
|
|||
|
|
public frm_YiQiAdd()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
public void init()
|
|||
|
|
{
|
|||
|
|
var vser = ServiceContainer.GetService<SOH.BLL.IJianYan>();
|
|||
|
|
List<lis_jydl> jydl = vser.getjydl();
|
|||
|
|
cbb_yqdl.DataSource = jydl;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void init(string yq, string yqmc, string forder, string filename, int dl, string asstype)
|
|||
|
|
{
|
|||
|
|
init();
|
|||
|
|
txt_yq.Text = yq;
|
|||
|
|
txt_yqmc.Text = yqmc;
|
|||
|
|
txt_yqxh.Text = yq;
|
|||
|
|
cbb_yqdl.SelectedValue = dl;
|
|||
|
|
_asstype = asstype;
|
|||
|
|
_srcforder = forder;
|
|||
|
|
_yqlb = dl;
|
|||
|
|
}
|
|||
|
|
//public void init(SOH.JianYan.JianYanAttribute jy)
|
|||
|
|
private void frm_YiQiAdd_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void btn_OK_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
var vser = ServiceContainer.GetService<SOH.BLL.IJianYan>();
|
|||
|
|
jy_yiqi yq = vser.getJYYQ(txt_yq.Text);
|
|||
|
|
if (yq != null)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("仪器" + yq.yq + "(" + yq.yqmc + ")已经在电脑:" + yq.dnname + "上安装,不能重复安装,请修改仪器编号!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
string dstforder = Application.StartupPath + "\\DEC\\" + txt_yq.Text.Trim();
|
|||
|
|
if (!Directory.Exists(dstforder))
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(dstforder);
|
|||
|
|
}
|
|||
|
|
moveforder(_srcforder, dstforder);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
Directory.Delete(_srcforder);
|
|||
|
|
}
|
|||
|
|
catch { }
|
|||
|
|
string ComputName = System.Net.Dns.GetHostName();
|
|||
|
|
var r= vser.regJYYQ(txt_yq.Text, ComputName, txt_yqmc.Text, txt_yqxh.Text, _yqlb);
|
|||
|
|
if(r.State!=1)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show(r.Message);
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(dstforder + "\\local.ext");
|
|||
|
|
|
|||
|
|
if (conf.AppSettings.Settings.AllKeys.Contains("yqbm"))
|
|||
|
|
{
|
|||
|
|
conf.AppSettings.Settings["yqbm"].Value=txt_yq.Text;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
conf.AppSettings.Settings.Add("yqbm", txt_yq.Text);
|
|||
|
|
}
|
|||
|
|
conf.Save();
|
|||
|
|
var dectype = Assembly.LoadFrom(dstforder+ "\\SOH.JianYan.DEC_"+ txt_yqxh.Text + ".exe");
|
|||
|
|
IJY_YiQi jyyq = dectype.CreateInstance(_asstype) as IJY_YiQi;
|
|||
|
|
DataTable dtxm = jyyq.GetJYXM();
|
|||
|
|
DataTable dtjsxm = jyyq.GetJYXM_Calc();
|
|||
|
|
foreach(DataRow dr in dtxm.Rows)
|
|||
|
|
{
|
|||
|
|
jy_yiqi_xm xm = new jy_yiqi_xm();
|
|||
|
|
xm.yq = txt_yq.Text;
|
|||
|
|
xm.tdh = dr["tdh"].ToString();
|
|||
|
|
xm.xmdm = dr["xmdm"].ToString();
|
|||
|
|
xm.xmmc = dr["xmmc"].ToString();
|
|||
|
|
xm.dyckz = dr["dyckz"].ToString();
|
|||
|
|
xm.cksx = dr["cksx"].ToString();
|
|||
|
|
xm.ckxx = dr["ckxx"].ToString();
|
|||
|
|
xm.dysx = int.Parse(dr["dysx"].ToString());
|
|||
|
|
xm.dw = dr["dw"].ToString();
|
|||
|
|
vser.addyiqixm(xm);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
foreach(DataRow dr in dtjsxm.Rows)
|
|||
|
|
{
|
|||
|
|
jy_yiqi_xm_calc jsxm = new jy_yiqi_xm_calc();
|
|||
|
|
jsxm.jsxm = dr["jsxm"].ToString();
|
|||
|
|
jsxm.yq = txt_yq.Text;
|
|||
|
|
jsxm.xmmc = dr["xmmc"].ToString();
|
|||
|
|
jsxm.cksx = dr["cksx"].ToString();
|
|||
|
|
jsxm.bz = dr["bz"].ToString();
|
|||
|
|
jsxm.ckxx = dr["ckxx"].ToString();
|
|||
|
|
jsxm.dyckz = dr["dyckz"].ToString();
|
|||
|
|
jsxm.dysx = int.Parse(dr["dysx"].ToString());
|
|||
|
|
jsxm.dw = dr["dw"].ToString();
|
|||
|
|
vser.addyiqixmcalc(jsxm);
|
|||
|
|
}
|
|||
|
|
dectype = null;
|
|||
|
|
jyyq = null;
|
|||
|
|
dtxm = null;
|
|||
|
|
dtjsxm = null;
|
|||
|
|
GC.Collect();
|
|||
|
|
this.DialogResult = DialogResult.OK;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void moveforder(string srcforder, string dstforder)
|
|||
|
|
{
|
|||
|
|
//throw new NotImplementedException();
|
|||
|
|
foreach (string f in Directory.GetFiles(srcforder))
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (File.Exists(dstforder + "\\" + new FileInfo(f).Name))
|
|||
|
|
File.Delete(dstforder + "\\" + new FileInfo(f).Name);
|
|||
|
|
File.Move(f, dstforder + "\\" + new FileInfo(f).Name);
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{ }
|
|||
|
|
}
|
|||
|
|
foreach (string f in Directory.GetDirectories(srcforder))
|
|||
|
|
{
|
|||
|
|
moveforder(f, dstforder + "\\" + Path.GetFileName(f));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|