Ejemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            dataTable.Columns.Add("Number", typeof(int));
            dataTable.Columns.Add("RotationID", typeof(Guid));
            dataTable.Columns.Add("RotationName", typeof(string));
            dataTable.Columns.Add("OperationName", typeof(string));
            dataTable.Columns.Add("TubesBatchName", typeof(string));
            dataTable.Columns.Add("TubesBatchID", typeof(string));
            dataTable.Columns.Add("State", typeof(string));
            dataTable.Columns.Add("PCRTestResult", typeof(string));
            dataTable.Columns.Add("Color", typeof(string));
            dataTable.Columns.Add("logTitle", typeof(string)).DefaultValue = "查看日志";
            dataGrid_view.ItemsSource = dataTable.DefaultView;

            UserInfoController userInfoController = new UserInfoController();
            RoleInfo           userRole           = userInfoController.GetRoleByUserName(SessionInfo.LoginName);
            ExperimentsInfo    experimentInfo     = new WanTai.Controller.HistoryQuery.ExperimentsController().GetExperimentById(experimentId);

            if (SessionInfo.LoginName == experimentInfo.LoginName || (userRole != null && userRole.RoleLevel > 1))
            {
                btnImportPCRResult.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                btnImportPCRResult.Visibility = System.Windows.Visibility.Hidden;
            }

            this.ExperimentName_label.Content = experimentName;
            initDataGrid();
        }
        private void dataGrid_view_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            DataGridCellInfo Cell = ((System.Windows.Controls.DataGrid)(e.Source)).CurrentCell;

            if (Cell.Column.Header.ToString() == "检测结果")
            {
                if (dataTable.Rows[dataGrid_view.SelectedIndex]["PCRTestItemID"] != null && dataTable.Rows[dataGrid_view.SelectedIndex]["PCRTestItemID"] != DBNull.Value)
                {
                    UserInfoController userInfoController = new UserInfoController();
                    RoleInfo           userRole           = userInfoController.GetRoleByUserName(SessionInfo.LoginName);
                    ExperimentsInfo    experimentInfo     = new WanTai.Controller.HistoryQuery.ExperimentsController().GetExperimentById(experimentId);
                    if (SessionInfo.LoginName == experimentInfo.LoginName || (userRole != null && userRole.RoleLevel > 1))
                    {
                        EditPCRTestResult editPCRResult = new EditPCRTestResult();
                        editPCRResult.SetCurrentData(dataTable.Rows[dataGrid_view.SelectedIndex]);
                        editPCRResult.ExperimentID = experimentId;
                        bool dialogResult = (bool)editPCRResult.ShowDialog();
                        if (dialogResult)
                        {
                            loadDataGrid();
                        }
                    }
                    else
                    {
                        ViewPCRTestResult viewPCRResult = new ViewPCRTestResult();
                        viewPCRResult.SetCurrentData(dataTable.Rows[dataGrid_view.SelectedIndex]);
                        viewPCRResult.ShowDialog();
                    }
                }
            }
            else
            {
                return;
            }
        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            UserInfoController userInfoController = new UserInfoController();
            RoleInfo           userRole           = userInfoController.GetRoleByUserName(SessionInfo.LoginName);
            ExperimentsInfo    experimentInfo     = new WanTai.Controller.HistoryQuery.ExperimentsController().GetExperimentById(pCRTestResultDataGridUserControl.ExperimentId);

            if (SessionInfo.LoginName == experimentInfo.LoginName || (userRole != null && userRole.RoleLevel > 1))
            {
                deleteRotationPCRTest_button.Visibility = System.Windows.Visibility.Visible;
            }
            else
            {
                deleteRotationPCRTest_button.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 4
0
        public bool SaveExcelFile(string fileName, Guid experimentId)
        {
            try
            {
                ConfigRotationController rotationController = new ConfigRotationController();
                List <RotationInfo>      rotationList       = rotationController.GetCurrentRotationInfos(experimentId);

                DataTable _pcrTable = new DataTable();
                _pcrTable.Columns.Add("Number", typeof(int));
                _pcrTable.Columns.Add("Color", typeof(string));
                _pcrTable.Columns.Add("TubeID", typeof(Guid));
                _pcrTable.Columns.Add("TubeBarCode", typeof(string));
                _pcrTable.Columns.Add("TubePosition", typeof(string));
                _pcrTable.Columns.Add("TubeType", typeof(int));
                _pcrTable.Columns.Add("TubeTypeColor", typeof(string));
                _pcrTable.Columns.Add("TubeTypeColorVisible", typeof(string));
                _pcrTable.Columns.Add("PoolingRuleName", typeof(string));
                _pcrTable.Columns.Add("TestingItemName", typeof(string));
                _pcrTable.Columns.Add("PCRPlateBarCode", typeof(string));
                _pcrTable.Columns.Add("PCRPosition", typeof(int));
                _pcrTable.Columns.Add("PCRTestItemID", typeof(Guid));
                _pcrTable.Columns.Add("PCRTestResult", typeof(string));
                _pcrTable.Columns.Add("PCRTestContent", typeof(string));
                _pcrTable.Columns.Add("SimpleTrackingResult", typeof(string));

                System.Collections.Generic.Dictionary <int, string> liquidTypeDictionary = new System.Collections.Generic.Dictionary <int, string>();
                List <LiquidType> LiquidTypeList = SessionInfo.LiquidTypeList = WanTai.Common.Configuration.GetLiquidTypes();
                foreach (LiquidType liquidType in LiquidTypeList)
                {
                    liquidTypeDictionary.Add(liquidType.TypeId, liquidType.Color);
                }

                string errorMessage = string.Empty;

                ExperimentsInfo expInfo        = new WanTai.Controller.HistoryQuery.ExperimentsController().GetExperimentById(experimentId);
                string          experimentName = expInfo.ExperimentName;
                //string fileName = folderPath + "\\" + experimentName + "_" + DateTime.Now.ToString("yyyyMMdd") + ".xls";
                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }

                WanTai.Controller.PCR.PCRTestResultViewListController pcrController = new WanTai.Controller.PCR.PCRTestResultViewListController();

                string extension = System.IO.Path.GetExtension(fileName);
                if (extension.Equals(".pdf"))
                {
                    DataSet ds = new DataSet();
                    //ds.DataSetName = "实验名称:" + experimentName + "   操作员:" + experimentLoginName + " 运行时间:" + experimentCreateDate;
                    foreach (RotationInfo rotation in rotationList)
                    {
                        _pcrTable.Clear();
                        pcrController.QueryTubesPCRTestResult(experimentId, rotation.RotationID, _pcrTable, liquidTypeDictionary, System.Windows.Media.Colors.Red, System.Windows.Media.Colors.Green, out errorMessage);

                        //DataTable dt = new DataTable("     " + rotation.RotationName + "     操作员:" + experimentLoginName + " 创建时间:" + rotation.CreateTime.ToString("yyyy年MM月dd日HH时mm分ss秒"));
                        DataTable dt = new DataTable("            " + rotation.RotationName);
                        dt.Columns.Add("行号");
                        dt.Columns.Add("类型");
                        dt.Columns.Add("采血管BarCode");
                        dt.Columns.Add("采血管位置");
                        dt.Columns.Add("混样方式");
                        dt.Columns.Add("检测项目");
                        dt.Columns.Add("PCR板BarCode");
                        dt.Columns.Add("PCR板Position");
                        dt.Columns.Add("检测结果");
                        dt.Columns.Add("实验记录");
                        dt.Columns.Add("Color");

                        foreach (DataRow row in _pcrTable.Rows)
                        {
                            int    tubeType    = (int)row["TubeType"];
                            string tubeTypeStr = string.Empty;
                            if (tubeType == (int)Tubetype.PositiveControl)
                            {
                                tubeTypeStr = "阳性对照物";
                            }
                            else if (tubeType == (int)Tubetype.NegativeControl)
                            {
                                tubeTypeStr = "阴性对照物";
                            }
                            else if (tubeType == (int)Tubetype.Complement)
                            {
                                tubeTypeStr = "补液";
                            }

                            DataRow dr = dt.NewRow();
                            dr["行号"]           = (int)row["Number"];
                            dr["类型"]           = tubeTypeStr;
                            dr["采血管BarCode"]   = row["TubeBarCode"].ToString();
                            dr["采血管位置"]        = row["TubePosition"].ToString();
                            dr["混样方式"]         = row["PoolingRuleName"].ToString();
                            dr["检测项目"]         = row["TestingItemName"].ToString();
                            dr["PCR板BarCode"]  = row["PCRPlateBarCode"].ToString();
                            dr["PCR板Position"] = row["PCRPosition"].ToString();
                            dr["检测结果"]         = row["PCRTestResult"].ToString();
                            dr["实验记录"]         = row["SimpleTrackingResult"].ToString();
                            dr["Color"]        = row["Color"];
                            dt.Rows.Add(dr);
                        }
                        ds.Tables.Add(dt);
                    }

                    return(ExportToPdf(ds, fileName, expInfo));
                }
                else if (extension.Equals(".xls"))
                {
                    using (OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties=\"Excel 8.0;HDR=YES;\""))
                    {
                        connection.Open();
                        OleDbCommand command = new OleDbCommand();
                        command.Connection = connection;

                        foreach (RotationInfo rotation in rotationList)
                        {
                            _pcrTable.Clear();
                            pcrController.QueryTubesPCRTestResult(experimentId, rotation.RotationID, _pcrTable, liquidTypeDictionary, System.Windows.Media.Colors.Red, System.Windows.Media.Colors.Green, out errorMessage);

                            string createTableSql = "create table [" + rotation.RotationName + "] ([行号] Integer,[类型] nvarchar,[采血管BarCode] nvarchar,[采血管位置] nvarchar,"
                                                    + "[混样方式] nvarchar,[检测项目] nvarchar,[PCR板BarCode] nvarchar,[PCR板Position] Integer,[检测结果] nvarchar,[实验记录] nvarchar)";
                            command.CommandText = createTableSql;
                            command.ExecuteNonQuery();

                            string insertSql = string.Empty;
                            foreach (DataRow row in _pcrTable.Rows)
                            {
                                int    tubeType    = (int)row["TubeType"];
                                string tubeTypeStr = string.Empty;
                                if (tubeType == (int)Tubetype.PositiveControl)
                                {
                                    tubeTypeStr = "阳性对照物";
                                }
                                else if (tubeType == (int)Tubetype.NegativeControl)
                                {
                                    tubeTypeStr = "阴性对照物";
                                }
                                else if (tubeType == (int)Tubetype.Complement)
                                {
                                    tubeTypeStr = "补液";
                                }

                                insertSql = string.Format("Insert into [" + rotation.RotationName + "] (行号,类型,采血管BarCode,采血管位置,混样方式,检测项目,PCR板BarCode,PCR板Position,检测结果,实验记录) "
                                                          + "values({0},'{1}','{2}','{3}','{4}','{5}','{6}',{7},'{8}','{9}')",
                                                          (int)row["Number"],
                                                          tubeTypeStr,
                                                          row["TubeBarCode"].ToString(),
                                                          row["TubePosition"].ToString(),
                                                          row["PoolingRuleName"].ToString(),
                                                          row["TestingItemName"].ToString(),
                                                          row["PCRPlateBarCode"].ToString(),
                                                          row["PCRPosition"].ToString(),
                                                          row["PCRTestResult"].ToString(),
                                                          row["SimpleTrackingResult"].ToString());
                                command.CommandText = insertSql;
                                command.ExecuteNonQuery();
                            }
                        }

                        connection.Close();
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }