Example #1
0
        private void initDataGrid()
        {
            ConfigRotationController rotationController = new ConfigRotationController();
            List <RotationInfo>      rotationList       = rotationController.GetCurrentRotationInfos(experimentId);
            int startIndex = 1;

            foreach (RotationInfo rotation in rotationList)
            {
                System.Data.DataRow dRow = dataTable.NewRow();
                dRow["Number"]        = startIndex;
                dRow["RotationID"]    = rotation.RotationID;
                dRow["RotationName"]  = rotation.RotationName;
                dRow["OperationName"] = rotation.OperationName;
                dRow["TubesBatchID"]  = rotation.TubesBatchID;
                dRow["State"]         = rotationController.ConvertEnumStatusToText((RotationInfoStatus)rotation.State);
                dRow["logTitle"]      = "查看日志";
                if (rotation.TubesBatchID != null)
                {
                    TubesBatch tubeBatch = rotationController.GetTubesBatchByID((Guid)rotation.TubesBatchID);
                    if (tubeBatch != null)
                    {
                        dRow["TubesBatchName"] = tubeBatch.TubesBatchName;
                    }

                    if (new WanTai.Controller.PCR.PCRTestResultViewListController().CheckRotationHasPCRTestResult(rotation.RotationID, experimentId))
                    {
                        dRow["PCRTestResult"] = "查看";
                    }
                }

                if (startIndex % 2 == 0)
                {
                    dRow["Color"] = WindowCustomizer.alternativeColor;
                }
                else
                {
                    dRow["Color"] = WindowCustomizer.defaultColor;
                }

                dataTable.Rows.Add(dRow);
                startIndex++;
            }
        }
Example #2
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                errorMessage.Text = "";
                List <RotationInfo> rotationList = controller.GetCurrentRotationInfos(SessionInfo.ExperimentID);
                if (rotationList.Count() > 0)
                {
                    this.create_button.IsEnabled = false;
                    if (SessionInfo.NextButIndex == 1)
                    {
                        this.next_button.IsEnabled = true;
                    }
                    else
                    {
                        this.next_button.IsEnabled = false;
                    }
                    this.save_button.IsEnabled      = false;
                    operation_viewcolumn.Visibility = System.Windows.Visibility.Visible;
                    operation_column.Visibility     = System.Windows.Visibility.Hidden;

                    foreach (RotationInfo rotation in rotationList)
                    {
                        System.Data.DataRow dRow = dataTable.NewRow();
                        dRow["Sequence"] = dataTable.Rows.Count + 1;
                        if (rotation.TubesBatchID != null)
                        {
                            dRow["TubesBatchID"] = rotation.TubesBatchID;
                            TubesBatch _tubeBatch = controller.GetTubesBatchByID((Guid)rotation.TubesBatchID);
                            dRow["TubesBatchName"] = _tubeBatch.TubesBatchName;
                        }

                        dRow["OperationName"] = rotation.OperationName;
                        dRow["Operation"]     = new OperationConfiguration()
                        {
                            OperationID = rotation.OperationID, OperationName = rotation.OperationName
                        };
                        dRow["RotationName"]    = rotation.RotationName;
                        dRow["deleteIsVisible"] = Visibility.Hidden.ToString();
                        dataTable.Rows.Add(dRow);
                    }
                }
                else
                {
                    this.create_button.IsEnabled    = true;
                    this.next_button.IsEnabled      = false;
                    this.save_button.IsEnabled      = true;
                    isBelongtoCurrentTubeBatch      = true;
                    operation_viewcolumn.Visibility = System.Windows.Visibility.Hidden;
                    operation_column.Visibility     = System.Windows.Visibility.Visible;

                    operation_viewcolumn.Visibility = System.Windows.Visibility.Hidden;
                    operation_column.Visibility     = System.Windows.Visibility.Visible;

                    tubesBatch = controller.GetLastTubesBatch();

                    List <OperationConfiguration> operationList = controller.GetDisplayedOperationConfigurations();
                    operation_column.ItemsSource = operationList;
                    CreateOperation = operationList[0];
                }
            }
            catch
            {
                MessageBox.Show("系统错误!", "系统提示!");

                //this.errorMessage.Text = "系统错误!";
            }
        }
Example #3
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;
            }
        }