示例#1
0
        /// <summary>
        /// 得到PL数据
        /// </summary>
        private async void GetPLDB()
        {
            item_show.Clear();
            List <Item_Number> item_number = new List <Item_Number>();//变量
            DataSet            ds          = new DataSet();
            OleDbConnection    conn;
            string             strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
            string             pathto        = GlobalVariable.currentDir.FullName;

            strConnection += "Data Source=" + @pathto + "\\PLDB.mdb";
            conn           = new OleDbConnection(strConnection);
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            string strSelect;

            #region pl
            strSelect = "SELECT * FROM  PL_FullName";
            using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
            {
                if (oa.Fill(ds, "Item") == 0)
                {
                    ds.Clear();
                    MainWindow mainwin = (MainWindow)System.Windows.Application.Current.MainWindow;
                    await mainwin.ShowMessageAsync("警告", "请检查血小板数据库");

                    return;
                }
                else
                {
                    foreach (DataRow dr in ds.Tables["Item"].Rows)
                    {
                        Item_Number item = new Item_Number();
                        item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                        item.FullName = dr["FULL_NAME"] == DBNull.Value ? string.Empty : (string)dr["FULL_NAME"];
                        item.Type     = dr["Type"] == DBNull.Value ? string.Empty : (string)dr["Type"];
                        item.Index    = dr["Index"] == DBNull.Value ? string.Empty : (string)dr["Index"];
                        item_number.Add(item);
                    }
                    for (int i = 0; i < item_number.Count; i++)
                    {
                        Item_Number_Show item = new Item_Number_Show();
                        item.Item     = item_number[i].Item;
                        item.FullName = item_number[i].FullName;
                        item.Index    = item_number[i].Index;
                        item.Type     = item_number[i].Type;
                        item_show.Add(item);
                    }
                }
            }
            #endregion
            ds.Clear();
            conn.Close();
            item_total = item_number;
        }
示例#2
0
        /// <summary>
        /// 更新生化仪数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public async void Updata_DS_Click(object sender, RoutedEventArgs e)
        {
            bool IsShowMessage = false;

            try
            {
                IsShowMessage = (bool)sender;//从非按钮过来的,不进行显示通知
            }
            catch
            {
                IsShowMessage = false;//从按钮过来的,显示通知
            }
            int                num = 0;
            string             strConnection;
            string             strSelect;
            string             insert;
            DataSet            ds = new DataSet();
            OleDbConnection    conn;
            MainWindow         mainwin     = (MainWindow)System.Windows.Application.Current.MainWindow;
            List <Item_Number> item_number = new List <Item_Number>();//缓存

            if (GlobalVariable.DSDEVICE != 0 && GlobalVariable.DSDEVICE != 1)
            {
                await mainwin.ShowMessageAsync("警告", "未连接生化仪");

                return;
            }
            else if (GlobalVariable.DSDEVICE == 0) //DS800运行
            {
                strConnection  = "Provider=Microsoft.Jet.OleDb.4.0;";
                strConnection += "Data Source=";
                strConnection += GlobalVariable.DSDEVICEADDRESS;

                conn = new OleDbConnection(strConnection);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                #region bio
                strSelect = "SELECT * FROM  BioItem";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FullName"] == DBNull.Value ? string.Empty : (string)dr["FullName"];
                            item.Type     = "bio";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                #region ele
                strSelect = "SELECT * FROM  ElecItem";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FullName"] == DBNull.Value ? string.Empty : (string)dr["FullName"];
                            item.Type     = "ele";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                #region cal
                strSelect = "SELECT * FROM  CalItem";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FullName"] == DBNull.Value ? string.Empty : (string)dr["FullName"];
                            item.Type     = "cal";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                conn.Close();
            }
            else if (GlobalVariable.DSDEVICE == 1) //DS400运行
            {
                strConnection  = "Provider=Microsoft.Jet.OleDb.4.0;";
                strConnection += "Data Source=";
                strConnection += GlobalVariable.DSDEVICEADDRESS;

                conn = new OleDbConnection(strConnection);
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                #region bio
                strSelect = "SELECT * FROM  ITEM_PARA_MAIN";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FULL_NAME"] == DBNull.Value ? string.Empty : (string)dr["FULL_NAME"];
                            item.Type     = "bio";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                #region ele
                strSelect = "SELECT * FROM  ITEM_PARA_ELECTROLYTE";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FULL_NAME"] == DBNull.Value ? string.Empty : (string)dr["FULL_NAME"];
                            item.Type     = "ele";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                #region cal
                strSelect = "SELECT * FROM  ITEM_CAL_PARA";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") != 0)
                    {
                        foreach (DataRow dr in ds.Tables["Item"].Rows)
                        {
                            Item_Number item = new Item_Number();
                            item.Item     = dr["Item"] == DBNull.Value ? string.Empty : (string)dr["Item"];
                            item.FullName = dr["FULL_NAME"] == DBNull.Value ? string.Empty : (string)dr["FULL_NAME"];
                            item.Type     = "cal";
                            item.Index    = string.Empty;
                            item.Device   = GlobalVariable.DSDeviceID;
                            item_number.Add(item);
                        }
                    }
                }
                ds.Clear();
                #endregion
                conn.Close();
            }
            strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
            string pathto = GlobalVariable.currentDir.FullName;
            strConnection += "Data Source=" + @pathto + "\\DSDB.mdb";
            conn           = new OleDbConnection(strConnection);
            if (conn.State == System.Data.ConnectionState.Closed)
            {
                conn.Open();
            }
            for (int i = 0; i < item_number.Count; ++i)
            {
                strSelect = "SELECT* FROM  item_info WHERE [Item]='" + item_number[i].Item + "' AND [Type]='" + item_number[i].Type + "' AND [Device]='" + item_number[i].Device + "'";
                using (OleDbDataAdapter oa = new OleDbDataAdapter(strSelect, conn))
                {
                    if (oa.Fill(ds, "Item") == 0)
                    {
                        //如果DS数据库没有这个ITEM,此时就添加进去
                        ++num;
                        ds.Clear();
                        insert = "insert into item_info ([Item],[FullName],[Index],[Type],[Device])" +
                                 "values (@Item,@FullName,@Index,@Type,@Device)";
                        using (OleDbCommand cmd = new OleDbCommand(insert, conn))
                        {
                            cmd.Parameters.Add("@Item", OleDbType.VarChar).Value     = item_number[i].Item;
                            cmd.Parameters.Add("@FullName", OleDbType.VarChar).Value = item_number[i].FullName;
                            cmd.Parameters.Add("@Index", OleDbType.VarChar).Value    = item_number[i].Index;
                            cmd.Parameters.Add("@Type", OleDbType.VarChar).Value     = item_number[i].Type;
                            cmd.Parameters.Add("@Device", OleDbType.VarChar).Value   = item_number[i].Device;
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
            }
            conn.Close();
            if (GlobalVariable.DSDEVICE == 0)
            {
                //DS800
                //GetDS800DB();
                GetDSDB();
            }
            else if (GlobalVariable.DSDEVICE == 1)
            {
                //DS400
                GetDSDB();
            }
            if (!IsShowMessage)
            {
                await mainwin.ShowMessageAsync("通知", "更新生化仪数据成功\r\n\r\n共更新" + num.ToString() + "条数据");
            }
        }