Exemple #1
0
        private void frm_选择机构_Load(object sender, EventArgs e)
        {
            string sql = "select 资源id,简称 from 机构";

            dataGridView1.DataSource       = OracleHelper.GetDataTable(sql);
            dataGridView1.Columns[1].Width = 240;
        }
Exemple #2
0
        //2指定样本编号范围查询
        private DataTable GetSampleInfo(string sampleNoRange, int flag)
        {
            string[] s  = sampleNoRange.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
            string   no = "";

            foreach (string item in s)
            {
                no = no + item + ",";
            }
            no = no.Remove(no.Length - 1);

            string sql = "";

            sql = sqlstart + @" And j.样本序号  in(" + no + ")";
            sql = sql + @" And j.核收时间   between   trunc(sysdate) and   sysdate" + sqlend;
            writelog.Write("sqllog", sql, "log");
            DataTable dt = OracleHelper.GetDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        private void SelDevice_Load(object sender, EventArgs e)
        {
            string       DeviceId;
            IniFile      ConfigIni = new IniFile("SOLVESET.INI");
            ListViewItem Litem     = new  ListViewItem();

            DeviceId = ConfigIni.IniReadValue("EQUIPMENT", "Agencies");
            tmpTable = OracleHelper.GetDataTable("Select ID, 名称 From 检验仪器 Where 通讯类型 in(1,2,3,4) and 机构id='" + DeviceId + "' and ID Not In (Select Column_Value From Table(f_Split_String('" + strSelDevice + "')))");
            foreach (DataRow i in tmpTable.Rows)
            {
                Litem     = lv_device.Items.Add(i["名称"].ToString(), 0);
                Litem.Tag = i["id"].ToString();
            }
        }
Exemple #4
0
        //3时间范围查询,查询当天到所有结果
        private DataTable GetSampleInfo()
        {
            string sql = "";

            sql = sqlstart + @" And j.核收时间   between   trunc(sysdate) and   sysdate" + sqlend;

            writelog.Write("sqllog", sql, "log");
            DataTable dt = OracleHelper.GetDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
Exemple #5
0
        public DataTable GetSampleInfoXC8001(string sampleNO, string StrDeviceID)
        {
            string sql = "";

            if (sampleNO.Length > 0)
            {
                sql = sqlstart + @" And j.样本条码 = '" + sampleNO.Trim() + "'" + sqlend;
            }
            sql = sql.Replace("<StrDeviceID>", StrDeviceID);
            writelog.Write("sqllog", sql, "log");
            DataTable dt = OracleHelper.GetDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
Exemple #6
0
        //1指定单个样本条码查询
        public DataTable GetSampleInfo(string sampleNO)
        {
            string sql = "";

            if (sampleNO.Length > 0)
            {
                sql = sqlstart + @" And j.样本条码 = '" + sampleNO.Trim() + "'" + sqlend;
            }

            writelog.Write("sqllog", sql, "log");
            DataTable dt = OracleHelper.GetDataTable(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(dt);
            }
            else
            {
                return(null);
            }
        }
Exemple #7
0
        /// <summary>
        /// 保存标准检验结果到数据库
        /// </summary>
        public void SaveTextResult(string DeviceID, string ResultVale, List <string> GraphVale, DataRow drSampleNO)
        {
            aItem       = ResultVale.Split('|');
            blnAuditing = false;

            /*
             * GetUpperBound可以获取数组的最高下标。
             * GetLowerBound可以获取数组的最低下标。
             * string[,] myStrArr2=new string[,]{{"油","盐"},{"围城","晨露"},{"毛毛熊","Snoopy"}};
             * for(int i=myStrArr2.GetLowerBound(0);i<=myStrArr2.GetUpperBound(0);i++)
             * {
             * for(int i=myStrArr2.GetLowerBound(1);i<=myStrArr2.GetUpperBound(1);i++)
             * {
             * //处理每一个元素
             * }
             * }
             * 0表示二维数组的第一维,1表示数组的第二维
             */
            if (aItem.GetUpperBound(0) < 5)
            {
                return;
            }
            strData     = aItem[0];
            strSampleNO = aItem[1].Split('^')[0] != null?Convert.ToInt32(aItem[1].Split('^')[0]).ToString() : null;

            strSampleType = aItem[1].Split('^')[1];
            strBarCode    = aItem[1].Split('^')[2];
            strSample     = aItem[3];

            strBeginDate  = Convert.ToDateTime(strData).ToString("yyyy-MM-dd");
            strEndDate    = Convert.ToDateTime(strData).ToString("yyyy-MM-dd") + " 23:59:59";
            strDeviceName = OracleHelper.GetDataTable("select max(名称) from 检验仪器 where id='" + DeviceID + "'").Rows[0][0].ToString();
            if (String.IsNullOrEmpty(strBarCode))
            {
                blnQryWithSampleNO = true;
            }
            else
            {
                dsTemp = dsHandle.GetDataSet(@"j.id,申请来源,j.性别,年龄数字|| 年龄单位 as 年龄,i.出生日期,样本类型,j.记录状态", "检验记录 j,个人信息 i", "j.个人id=i.id(+) and 合并id is null and 仪器id='" + DeviceID + "' and 样本条码='" + strBarCode + "'");
                if (dsTemp.Tables[0].Rows.Count != 0)
                {
                    blnQryWithSampleNO = false;
                }
                else
                {
                    blnQryWithSampleNO = true;
                }
            }
            if (blnQryWithSampleNO)
            {
                dsTemp = dsHandle.GetDataSet(@"j.id,申请来源,j.性别,年龄数字|| 年龄单位 as 年龄,i.出生日期,样本类型,j.记录状态", "检验记录 j,个人信息 i", "j.个人id=i.id(+) and 仪器id='" + DeviceID + "' and 合并id is null and 样本序号='" + strSampleNO + "' and 核收时间 between to_date('" + strBeginDate + "','yyyy-mm-dd') and to_date('" + strEndDate + "','yyyy-MM-dd hh24:mi:ss')");
            }
            if (dsTemp == null)
            {
                writeLog.Write(strDeviceName, "dsTemp数据集为空,不保存该条数据的记录!错误查看最外层的log文件,程序自动回滚!", "log"); return;
            }
            blnWaif = false;
            if (dsTemp.Tables[0].Rows.Count == 0)    //如果未找到标本,则插入一条无主样本
            {
                blnWaif = true;
                OracleParameter[] parms = new OracleParameter[]
                {
                    new OracleParameter("机构id_In", OracleType.VarChar),
                    new OracleParameter("Id_In", OracleType.VarChar),
                    new OracleParameter("申请来源_In", OracleType.Int32),
                    new OracleParameter("单据性质_In", OracleType.Int32),
                    new OracleParameter("采集方式id_In", OracleType.VarChar),
                    new OracleParameter("样本类型_In", OracleType.VarChar),
                    new OracleParameter("样本序号_In", OracleType.VarChar),
                    new OracleParameter("核收时间_In", OracleType.DateTime),
                    new OracleParameter("仪器id_In", OracleType.VarChar)
                };
                strSampleId    = dsHandle.GetDataSet("max(机构id) as 机构id,newid", "检验仪器", "id='" + DeviceID + "'").Tables[0].Rows[0][1].ToString();
                parms[0].Value = dsHandle.GetDataSet("max(机构id) as 机构id,newid", "检验仪器", "id='" + DeviceID + "'").Tables[0].Rows[0][0].ToString();
                parms[1].Value = strSampleId;
                parms[2].Value = 0;
                parms[3].Value = 0;
                parms[4].Value = null;
                parms[5].Value = strSample;
                parms[6].Value = strSampleNO;
                parms[7].Value = Convert.ToDateTime(strData);
                parms[8].Value = DeviceID;
                OracleHelper.RunProcedure("p_检验记录_Insert", parms, ref strError);
                if (strError != "")
                {
                    writeLog.Write(strDeviceName, "执行<p_检验记录_insert>错误:" + strError, "log");
                }
                else
                {
                    writeLog.Write(strDeviceName, DateTime.Now.ToString() + "写入无主样本!\r\n检验id=" + strSampleId + ",标本号=" + strSampleNO + ",仪器id=" + DeviceID, "log");
                }
            }
            else
            {
                strSampleId = dsTemp.Tables[0].Rows[0]["id"].ToString();
                strSex      = dsTemp.Tables[0].Rows[0]["性别"].ToString();
                strAge      = dsTemp.Tables[0].Rows[0]["年龄"].ToString();
                strState    = dsTemp.Tables[0].Rows[0]["记录状态"].ToString();
                strSample   = dsTemp.Tables[0].Rows[0]["样本类型"].ToString();
                blnAuditing = dsTemp.Tables[0].Rows[0]["记录状态"].ToString() == "4";
                strBirth    = dsTemp.Tables[0].Rows[0]["出生日期"].ToString();

                writeLog.Write(strDeviceName, DateTime.Now.ToString() + "找到样本!\r\n检验id=" + strSampleId + ",标本号=" + strSampleNO + ",仪器id=" + DeviceID, "log");
            }
            if (!blnAuditing)     //未审核标本则更新检查结果
            {
                strResult = "";
                Int32 j;
                for (j = 5; j <= aItem.GetUpperBound(0); ++j)
                {
                    if (aItem[j].Contains("^"))
                    {
                        strResult = strResult + "|" + aItem[j].Split('^')[0].ToString() + "," + aItem[j].Split('^')[1].ToString();
                    }
                }
                if (strResult != "")
                {
                    strResult = strResult.Substring(1);
                    OracleParameter[] parms = new OracleParameter[]
                    {
                        new OracleParameter("记录id_In", OracleType.VarChar),
                        new OracleParameter("仪器id_In", OracleType.VarChar),
                        new OracleParameter("检验时间_In", OracleType.DateTime),
                        new OracleParameter("样本类型_In", OracleType.VarChar),
                        new OracleParameter("性别_In", OracleType.Int32),
                        new OracleParameter("出生日期_In", OracleType.DateTime),
                        new OracleParameter("检验指标_In", OracleType.VarChar),
                        new OracleParameter("备注_In", OracleType.VarChar)
                    };
                    parms[0].Value = strSampleId;
                    parms[1].Value = DeviceID;
                    parms[2].Value = Convert.ToDateTime(aItem[0].ToString());
                    parms[3].Value = strSample;
                    parms[4].Value = strSex == "男" ? 1 : (strSex == "女" ? 2 : 0);
                    parms[5].Value = strBirth == "" ? null : strBirth;
                    parms[6].Value = strResult;
                    //因调用p_检验普通结果_Batchupdate会将“检验备注”清空,固需传入以前检验备注的值
                    parms[7].Value = OracleHelper.GetOracleValue("select 检验备注 from 检验记录 where ID = '" + strSampleId + "'");    //检验备注
                    // OracleHelper.RunProcedure("p_检验普通结果_batup_bs330e", parms, ref strError);
                    OracleHelper.RunProcedure("p_检验普通结果_batchupdate", parms, ref strError);
                    if (!String.IsNullOrEmpty(strError))
                    {
                        writeLog.Write(strDeviceName, "执行<p_检验普通结果_Batchupdate>:" + strError, "log");
                        writeLog.Write(strDeviceName, "  parms[0]:" + strSampleId, "log");
                        writeLog.Write(strDeviceName, "  parms[1]:" + DeviceID, "log");
                        writeLog.Write(strDeviceName, "  parms[2]:" + Convert.ToDateTime(aItem[0].ToString()), "log");
                        writeLog.Write(strDeviceName, "  parms[3]:" + strSample, "log");
                        writeLog.Write(strDeviceName, "  parms[4]:" + (strSex == "男" ? 1 : (strSex == "女" ? 2 : 0)), "log");
                        writeLog.Write(strDeviceName, "  parms[5]:" + (strBirth == "" ? null : strBirth), "log");
                        writeLog.Write(strDeviceName, "  parms[6]:" + strResult, "log");
                    }
                    else
                    {
                        writeLog.Write(strDeviceName, DateTime.Now.ToString() + "更新检验结果!\r\n检验id=" + strSampleId + ",标本号=" + strSampleNO + ",仪器id=" + DeviceID + ",结果:" + strResult, "log");
                        SaveResult.Appstr = strSampleId;

                        if (GraphVale != null && GraphVale.Count > 0)
                        {
                            OracleHelper.SaveImage(strSampleId, GraphVale);
                        }
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// 获取仪器解析规则及项目通道
        /// </summary>
        /// <param name="StrDevice">仪器ID</param>
        public void GetRules(string StrDevice)
        {
            DataSet dsTestItem = new DataSet();
            DataSet dsRules    = new DataSet();


            DrTestTimeSignField   = null;       //检验时间标识
            DrTestTimeField       = null;       //检验时间
            DrSampleNoSignField   = null;
            DrSampleNoField       = null;
            DrBarCodeSignField    = null;
            DrBarCodeField        = null;
            DrSampleTypeSignField = null;
            DrSampleTypeField     = null;
            DrOperatorSignField   = null;
            DrOperatorField       = null;
            DrSpecimenSignField   = null;
            DrSpecimenField       = null;

            DrResultSignField   = null;
            DrResultInfoField   = null;
            DrResultCountField  = null;
            DrSingleResultField = null;
            DrChannelField      = null;
            DrResultField       = null;

            dsRules = dsHandle.GetDataSet(@"Extractvalue(Column_Value, '/item/item_code') As item_code, Extractvalue(Column_Value, '/item/separated_first') As separated_first, 
                                                   Extractvalue(Column_Value, '/item/no_first') As no_first, Extractvalue(Column_Value, '/item/separated_second') As separated_second,
                                                   Extractvalue(Column_Value, '/item/no_second') As no_second, Extractvalue(Column_Value, '/item/start_bits') As start_bits,
                                                   Extractvalue(Column_Value, '/item/length') As length, Extractvalue(Column_Value, '/item/sign') As sign,Extractvalue(Column_Value, '/item/format') As format",
                                          "Table(Xmlsequence(Extract((Select 解析规则 From 检验仪器 Where ID = '" + strInstrument_id + "'), '/root/item'))) ", "");
            //检验指标通道
            //ds_ItemChannel = dsHandle.GetDataSet("通道编码,项目id,nvl(小数位数,2) as 小数位数,nvl(换算比,0) as 换算比", "仪器检测项目", "仪器id = '" + strInstrument_id + "'");
            tItemChannel = OracleHelper.GetDataTable(@"Select 通道编码, m.项目id, Nvl(小数位数, 2) As 小数位数, Nvl(换算比, 0) As 换算比, Nvl(加算值, 0) As 加算值, j.结果类型
                                        From 仪器检测项目 m, 检验项目 j
                                        Where m.项目id = j.项目id and m.仪器Id='" + StrDevice + "'");
            ds_ItemChannel.CaseSensitive = true;
            //检验图像通道
            //ds_GraphChannel = dsHandle.GetDataSet("CHANNEL_NO,GRAPH_TYPE", "TEST_GRAPH_CHANNEL", "instrument_id = '" + strInstrument_id + "'");
            //ds_GraphChannel.CaseSensitive = true;

            FindRow = dsRules.Tables[0].Select("item_code = '01'");         //检验日期标识
            if (FindRow.Length != 0)
            {
                DrTestTimeSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '02'");             //检验日期
            if (FindRow.Length != 0)
            {
                DrTestTimeField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '03'");       //常规样本号标识
            if (FindRow.Length != 0)
            {
                DrSampleNoSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '04'");           //常规样本号
            if (FindRow.Length != 0)
            {
                DrSampleNoField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '05'");      //质控样本号
            if (FindRow.Length != 0)
            {
                DrQCSampleField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '06'");        //条码号标识
            if (FindRow.Length != 0)
            {
                DrBarCodeSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '07'");        //条码号
            if (FindRow.Length != 0)
            {
                DrBarCodeField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '08'");        //样本类型标识
            if (FindRow.Length != 0)
            {
                DrSampleTypeSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '09'");        //样本类型
            if (FindRow.Length != 0)
            {
                DrSampleTypeField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '10'");        //检验人标识
            if (FindRow.Length != 0)
            {
                DrOperatorSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '11'");        //检验人
            if (FindRow.Length != 0)
            {
                DrOperatorField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '12'");        //标本标识
            if (FindRow.Length != 0)
            {
                DrSpecimenSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '13'");        //标本
            if (FindRow.Length != 0)
            {
                DrSpecimenField = FindRow[0];
            }

            FindRow = dsRules.Tables[0].Select("item_code = '14'");        //结果标识
            if (FindRow.Length != 0)
            {
                DrResultSignField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '15'");        //结果信息
            if (FindRow.Length != 0)
            {
                DrResultInfoField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '16'");        //结果数
            if (FindRow.Length != 0)
            {
                DrResultCountField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '17'");      //单个结果
            if (FindRow.Length != 0)
            {
                DrSingleResultField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '18'");        //通道号
            if (FindRow.Length != 0)
            {
                DrChannelField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '19'");        //结果值
            if (FindRow.Length != 0)
            {
                DrResultField = FindRow[0];
            }
            FindRow = dsRules.Tables[0].Select("item_code = '20'");        //盘号
            //if (FindRow.Length != 0) Field_Row[4] = FindRow[0];
            FindRow = dsRules.Tables[0].Select("item_code = '21'");        //杯号
            //if (FindRow.Length != 0) Field_Row[5] = FindRow[0];

            strDevice = OracleHelper.GetDataTable("select 名称 from 检验仪器 where id='" + strInstrument_id + "'").Rows[0]["名称"].ToString();
        }
Exemple #9
0
        /// <summary>
        /// 默认解析方式
        /// </summary>
        /// <param name="a"></param>
        /// <param name="e"></param>
        public void GetResult(object a, EventArgs e)
        {
            try
            {
                string    strTestTime;        //检验时间
                string    strSampleNo;        //标本号
                string    strBarCode    = ""; //条码
                string    strOperator   = ""; //检验医师
                string    strSampleType = ""; //检验类型
                string    StrSpecimen   = ""; //标本类型
                string    ChannelType;        //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                string    testItemID = "";    //通道项目ID
                DataRow[] FindRow;            //解析设置
                TestGraph  = new List <string>();
                saveResult = new SaveResult();
                IsUpdate();                             //重新检查是否有新数据
                tItemChannel = OracleHelper.GetDataTable(@"Select 通道编码, m.项目id, Nvl(小数位数, 2) As 小数位数, Nvl(换算比, 0) As 换算比, Nvl(加算值, 0) As 加算值, j.结果类型
                                                                                From 仪器检测项目 m, 检验项目 j
                                                                                Where m.项目id = j.项目id and m.仪器Id='" + strInstrumentID + "'");
                if (dsResult.Tables[0].Rows.Count == 0) //判断是否有新标本
                {
                    writeLog.Write(DateTime.Now.ToString() + "未检测到新数据!", "log");
                    return;
                }

                DataTable _dsResult = SelectDistinct(dsResult.Tables[0], "nSid");
                foreach (DataRow dr in _dsResult.Rows) //循环标本号
                {
                    strTestTime = DateTime.Parse(dr["dDate"].ToString()).ToString("yyyy-MM-dd") + " " + DateTime.Now.ToString("HH:mm:ss");;
                    strSampleNo = dr["nSid"].ToString();
                    string TestResultValue = "";
                    foreach (DataRow dr1 in dsResult.Tables[0].Select("nSid='" + dr["nSid"].ToString() + "'"))//循环标本号里面的检验项目
                    {
                        string _channelNo = dr1["sItem"].ToString();
                        FindRow = tItemChannel.Select("通道编码='" + _channelNo.Trim() + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writeLog.Write(strDevice, "未设置通道:" + _channelNo, "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + dr1["Result"].ToString() + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    try
                    {
                        saveResult.SaveTextResult(strInstrumentID, TestResultValue, TestGraph, null);
                        saveResult.UpdateData();
                        writeLog.Write(strDevice, "解析结果: " + TestResultValue, "result");
                    }
                    catch (Exception ex)
                    {
                        writeLog.Write(strDevice, "保存失败: " + ex.ToString(), "log");
                    }
                    //System.Windows.Forms.MessageBox.Show(TestResultValue);
                }
            }
            catch (Exception exp1)
            {
                writeLog.Write(strDevice, "处理失败: " + exp1.ToString(), "log");
            }
        }
Exemple #10
0
        /// <summary>
        /// 判断是否有重复
        /// </summary>
        public void IsUpdate()
        {
            ds     = dsHandle.GetDataSet(@"解析类型,通讯程序名,
                                                        Extractvalue(通讯参数, '/root/db_type') as db_type,
                                                        Extractvalue(通讯参数, '/root/db_name') as db_name,
                                                        Extractvalue(通讯参数, '/root/user_name') as user_name,
                                                        Extractvalue(通讯参数, '/root/password') as password,
                                                        Extractvalue(通讯参数, '/root/server_name') as server_name,
                                                        Extractvalue(通讯参数, '/root/parastr') as parastr,
                                                        Extractvalue(通讯参数, '/root/selectstr') as selectstr", "检验仪器", "id = '" + strInstrumentID + "'");
            sqlstr = ds.Tables[0].Rows[0]["selectstr"].ToString();
            if (sqlstr.IndexOf("[SAMPLE_NO]") > 0)
            {
                sqlstr = sqlstr.Replace("[SAMPLE_NO]", strTestNO);
            }
            try
            {
                conDB.Open();
            }
            catch (Exception e)
            {
                //conDB.Close();
                writeLog.Write("数据库连接失败!" + e.Message, "log");
                strError = "数据库连接失败!" + e.Message;
                return;
            }
            if (conDB.State != ConnectionState.Open)
            {
                return;
            }

            DataTable dtSample  = OracleHelper.GetDataTable(@"select   wm_concat(样本序号) 样本序号
                                                                                          from 检验记录
                                                                                          where id in (select 记录id from 检验普通结果 where 结果标志 is not null)
                                                                                                   and 仪器id = '" + strInstrumentID + @"'
                                                                                                   and to_char(核收时间, 'yyyy-mm-dd') = to_char(sysdate, 'yyyy-mm-dd')");
            string    _sampleNo = dtSample.Rows[0]["样本序号"].ToString();

            if (string.IsNullOrEmpty(sqlstr))
            {
                sqlstr = @"SELECT dDate, nSid, sItem, fConc, sConc
                                  FROM Result
                                 where Format(dDate, \""yyyy-mm-dd\"") = Format(date() - 1, \""yyyy-mm-dd\"")
                                   and nSid not in (parameter)
                                 order by nsid";
            }
            sqlstr   = sqlstr.Replace("parameter", _sampleNo == "" ? "-1" : _sampleNo);//替换样本号
            dsResult = new DataSet();
            try
            {
                OleDbDataAdapter ada = new OleDbDataAdapter(sqlstr, conDB);
                ada.Fill(dsResult, "Table");
            }
            catch
            {
                dsResult = null;
            }
            finally
            {
                conDB.Close();
            }
        }
Exemple #11
0
        /// <summary>
        /// 提取数据
        /// </summary>
        public void Start()
        {
            try
            {
                conDB.Open();
            }
            catch (Exception e)
            {
                //conDB.Close();
                writeLog.Write("数据库连接失败!" + e.Message, "log");
                strError = "数据库连接失败!" + e.Message;
                return;
            }
            if (conDB.State != ConnectionState.Open)
            {
                return;
            }

            DataTable dtSample  = OracleHelper.GetDataTable(@"select   wm_concat(样本序号) 样本序号
                                                                                          from 检验记录
                                                                                          where id in (select 记录id from 检验普通结果 where 结果标志 is not null)
                                                                                                   and 仪器id = '" + strInstrumentID + @"'
                                                                                                   and to_char(核收时间, 'yyyy-mm-dd') = to_char(sysdate, 'yyyy-mm-dd')");
            string    _sampleNo = dtSample.Rows[0]["样本序号"].ToString();

            if (string.IsNullOrEmpty(sqlstr))
            {
                sqlstr = @"SELECT dDate, nSid, sItem, fConc, sConc
                                  FROM Result
                                 where Format(dDate, \""yyyy-mm-dd\"") = Format(date() - 1, \""yyyy-mm-dd\"")
                                   and nSid not in (parameter)
                                 order by nsid";
            }
            sqlstr   = sqlstr.Replace("parameter", _sampleNo == "" ? "-1" : _sampleNo);//替换样本号
            dsResult = new DataSet();
            try
            {
                OleDbDataAdapter ada = new OleDbDataAdapter(sqlstr, conDB);
                ada.Fill(dsResult, "Table");
            }
            catch (System.Data.OleDb.OleDbException sqlex)
            {
                strError = sqlex.Message;
                writeLog.Write(strError, "log");
                return;
            }
            catch (Exception ex)
            {
                strError = ex.Message;
                writeLog.Write(strError, "log");
                return;
            }
            finally
            {
                conDB.Close();
            }


            object socketListen = strError;

            GetResult(strError, null);
            aTimer.Elapsed  += new ElapsedEventHandler(GetResult);
            aTimer.Interval  = 10000;
            aTimer.AutoReset = true;
            aTimer.Enabled   = true;
        }
Exemple #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string Return_Value;

            System.Windows.Forms.Form.CheckForIllegalCrossThreadCalls = false;//线程处理后的错误处理控件任然可以赋值
            Return_Value = INIExists(inifile);
            if (!String.IsNullOrEmpty(Return_Value))
            {
                MessageBox.Show(Return_Value);
            }
            StringBuilder objStrBd = new StringBuilder(256);

            GetPrivateProfileString("EQUIPMENT", "INSTRUMENTID", "", objStrBd, 256, FileName);
            instrument_id = objStrBd.ToString();

            textBox2.Text = INIHelper.getInstance().IniReadValue("EQUIPMENT", "Encode");
            string orgID = INIHelper.getInstance().IniReadValue("EQUIPMENT", "Agencies");
            string sql   = "select 资源id,简称 from 机构 where 资源id='in_机构id'";

            sql = sql.Replace("in_机构id", orgID);
            DataTable orgName = OracleHelper.GetDataTable(sql);

            if (orgName.Rows.Count > 0)
            {
                textBox1.Text = orgName.Rows[0]["简称"].ToString();
            }
            using (OracleConnection _connection = new OracleConnection(OracleHelper.GetConnectionstring()))
            {
                DataTable    dt   = new DataTable();
                ListViewItem item = new ListViewItem();
                try
                {
                    _connection.Open();
                    OracleDataAdapter da = new OracleDataAdapter();
                    da.SelectCommand = new OracleCommand("select id,名称 from 检验仪器 where instr('" + instrument_id + "',id)>0", _connection);
                    da.Fill(dt);
                    bolLongin = true;
                }
                catch (Exception exs)
                {
                    LoginForm log = new LoginForm();
                    if (log.ShowDialog() == DialogResult.OK)
                    {
                        bolLongin = true;
                    }
                    else
                    {
                        Application.Exit();
                    }
                }
                finally { _connection.Close(); }

                lv_Device.Items.Clear();
                foreach (DataRow i in dt.Rows)
                {
                    item     = lv_Device.Items.Add(i["名称"].ToString(), 1);
                    item.Tag = i["id"].ToString();
                    lv_Device.Columns[2].Text = "0";
                }
            }

            if (lv_Device.Items.Count > 0)
            {
                but_begin.Enabled = false;
                but_end.Enabled   = true;
                bolCon            = true;
                backgroundWorker1.RunWorkerAsync();
            }

            this.WindowState         = FormWindowState.Minimized;
            this.Visible             = false;
            this.notifyIcon1.Visible = true;
            this.SizeChanged        += new System.EventHandler(this.Form1_SizeChanged);
        }