using SOH.JianYan.YiQi.Base; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; namespace SOH.JianYan.DEC_RT6100 { public partial class RT6100 : SOH.JianYan.YiQi.Base.baseMain { string _yqbm; public RT6100() { InitializeComponent(); } private void btn_xz_Click(object sender, EventArgs e) { if (ofd_xz.ShowDialog() == DialogResult.OK) { txt_filename.Text = ofd_xz.FileName; } } private void RT6100_Load(object sender, EventArgs e) { System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\\local.ext"); if (conf.AppSettings.Settings.AllKeys.Contains("conn")) { txt_filename.Text = conf.AppSettings.Settings["conn"].Value; } if (conf.AppSettings.Settings.AllKeys.Contains("yqbm")) { _yqbm = conf.AppSettings.Settings["yqbm"].Value; } //this.Show(); } private void btn_cl_Click(object sender, EventArgs e) { btn_cl.Enabled = false; if (string.IsNullOrEmpty(_yqbm)) { MessageBox.Show("仪器编码没有维护,请联系管理员维护仪器编码!"); return; } if (txt_filename.Text == "") { MessageBox.Show("请先选择数据库文件!"); return; } if (!File.Exists(txt_filename.Text)) { MessageBox.Show("你选择的数据库文件不存在!"); return; } Data.DBHelpAccess acc = new Data.DBHelpAccess(); acc.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + txt_filename.Text + ";Persist Security Info=False"; string sql = "select sampleid,itemname,resultquantity,testdate from Table_Plate_Sample_Result where 1=1"; sql += " and TestDate=#" + dtp_bbrq.Value.ToString("yyyy-MM-dd") + "#"; if (txt_qjxx.Text != "") { int qjxx = 0; if (int.TryParse(txt_qjxx.Text, out qjxx)) { sql += " and sampleid>='" + qjxx.ToString("00000") + "'"; } } if (txt_qjsx.Text != "") { int qjsx = 0; if (int.TryParse(txt_qjsx.Text, out qjsx)) { sql += " and sampleid<='" + qjsx.ToString("00000") + "'"; } } DataTable dt; try { dt = acc.GetDataSet(sql); System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(Application.StartupPath + "\\local.ext"); if (conf.AppSettings.Settings.AllKeys.Contains("conn")) { conf.AppSettings.Settings["conn"].Value = txt_filename.Text; } else { conf.AppSettings.Settings.Add("conn", txt_filename.Text); } conf.Save(); } catch (Exception ex) { MessageBox.Show("请确定仪器程序已经关闭!" + ex.Message); return; } var bbhs = dt.AsEnumerable().Select(t => t.Field("sampleid")).Distinct().OrderBy(t => t).ToList(); bbhs.ForEach(t => { int it; if (int.TryParse(t, out it)) { DataRow[] drs = dt.Select("sampleid='" + t.ToString()+"'"); if (Lis_result.canmodify(_yqbm, new DateTime(dtp_bbrq.Value.Year, dtp_bbrq.Value.Month, dtp_bbrq.Value.Day), t.ToString())) { Lis_RiZhi.resultlog(DateTime.Now.ToString("yyyy-MM-dd") + "\t==============开始处理标本:" + t.ToString() + "======================="); txt_jg.Text += "==============开始处理标本:" + t.ToString() + "=======================\r\n"; foreach (DataRow dr in drs) { Lis_result.addresult(new DateTime(dtp_bbrq.Value.Year, dtp_bbrq.Value.Month, dtp_bbrq.Value.Day), _yqbm, t.ToString(), dr["itemname"].ToString(), dr["resultquantity"].ToString()); } Lis_RiZhi.resultlog(DateTime.Now.ToString("yyyy-MM-dd") + "\t==============开始计算标本:" + t.ToString() + "======================="); txt_jg.Text += "==============开始计算标本:" + t.ToString() + "=======================\r\n"; Lis_result.calcsample(_yqbm, new DateTime(dtp_bbrq.Value.Year, dtp_bbrq.Value.Month, dtp_bbrq.Value.Day), t.ToString()); Lis_RiZhi.resultlog(DateTime.Now.ToString("yyyy-MM-dd") + "\t==============完成计算标本:" + t.ToString() + "======================="); txt_jg.Text += "==============完成计算标本:" + t.ToString() + "=======================\r\n"; } else { txt_jg.Text += "==============标本已经审核不能入库:" + t.ToString() + "=======================\r\n"; Lis_RiZhi.resultlog("标本已经审核不能入库"); } } Application.DoEvents(); }); MessageBox.Show("处理完成!"); btn_cl.Enabled = true; } } }