/// <summary> /// 质控品下拉框改变事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtQCName_SelectedIndexChanged(object sender, EventArgs e) { var qualityControls = lstQCInfo.Find(x => x.QCName == txtQCName.Text); QCRelationProjectInfo qcRelationProject = lstQCRelationProjects.Find(x => x.QCID == qualityControls.QCID && x.ProjectName == txtProjectName.Text); if (qcRelationProject != null) { txtLotNum.Text = qualityControls.LotNum; } }
/// <summary> /// 质控品名称下拉框改变事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cboQCName_SelectedIndexChanged(object sender, EventArgs e) { var qualityControls = lstQCInfo.Find(x => x.QCName == cboQCName.Text); QCRelationProjectInfo qcRelationProject = lstQCRelationProjects.Find(x => x.QCID == qualityControls.QCID && x.ProjectName == cboProjectName.Text); if (qcRelationProject != null) { txtTargetValue.Text = Convert.ToString(qcRelationProject.TargetMean); txtStandardDeviationValue.Text = Convert.ToString(qcRelationProject.TargetSD); txtHorizontalValue.Text = qualityControls.HorizonLevel; this.Dline(qcRelationProject); } }
/// <summary> /// 删除项目对应的信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SbutDeleteProject_Click(object sender, EventArgs e) { MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定要删除关联的项目吗?", "删除确认", messButton); if (dr != DialogResult.OK) { return; } QCRelationProjectInfo qcProjectInfo = new QCRelationProjectInfo(); if (this.gridView1.GetSelectedRows().Count() > 0) { int selectedHandle; selectedHandle = this.gridView1.GetSelectedRows()[0]; bool b = this.gridView1.GetRowCellValue(selectedHandle, "冻结").ToString() == "是" ? true : false; qcProjectInfo.QCID = Convert.ToInt32(this.gridView1.GetRowCellValue(selectedHandle, "质控品ID").ToString()); if (b == false) { MessageBoxDraw.ShowMsg("此质控品在激活情况下无法删除,请冻结后尝试删除!", MsgType.Warning); return; } if (this.gridView2.GetSelectedRows().Count() > 0) { int selectGridview2Handle; selectGridview2Handle = this.gridView2.GetSelectedRows()[0]; qcProjectInfo.ProjectName = this.gridView2.GetRowCellValue(selectGridview2Handle, "项目名称").ToString(); } int count = new QCMaintian().DeleteQCProjectInfo("DeleteQCProjectInfo", qcProjectInfo); if (count > 0) { lstQCRelationProjectInfo.RemoveAll(x => x.QCID == qcProjectInfo.QCID && x.ProjectName == qcProjectInfo.ProjectName); lstvQCInfo_Click(null, null); MessageBoxDraw.ShowMsg("删除成功!", MsgType.OK); } else { MessageBoxDraw.ShowMsg("该项目已下任务,不能删除", MsgType.Warning); } } }
/// <summary> /// 画SD图形 /// </summary> /// <param name="results"></param> private void Dline(QCRelationProjectInfo results) { try { if (results != null) { if (AccumulationTimeSeries == null) { AccumulationTimeSeries = new Series("QCSD", ViewType.Line); AccumulationTimeSeries.ArgumentScaleType = ScaleType.Qualitative; AccumulationTimeSeries.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//是否显示 chartControl1.Series.Add(AccumulationTimeSeries); } else { chartControl1.Series.Clear(); AccumulationTimeSeries = null; AccumulationTimeSeries = new Series("QCSD", ViewType.Line); AccumulationTimeSeries.ArgumentScaleType = ScaleType.Qualitative; AccumulationTimeSeries.LabelsVisibility = DevExpress.Utils.DefaultBoolean.True;//是否显示 chartControl1.Series.Add(AccumulationTimeSeries); } this._TemporaryQCProjectInfo = results; XYDiagram diagram = (XYDiagram)chartControl1.Diagram; if (diagram != null) { diagram.AxisY.ConstantLines.Clear(); chartControl1.Titles.Clear(); ChartTitle SD1title = new ChartTitle(); SD1title.Text = "● Mean/±1SD — 正常!" + " ● ±2SD警告!" + " ● ±3SD错误!"; SD1title.TextColor = Color.OrangeRed; SD1title.Font = new System.Drawing.Font("Tahoma", (float)10); chartControl1.Titles.Add(SD1title); double StandardDeviation1 = Math.Round((double)(results.TargetMean + results.TargetSD), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine1 = new ConstantLine("1SD", StandardDeviation1); diagram.AxisY.ConstantLines.Add(constantLine1); constantLine1.Color = Color.Blue; //直线颜色 constantLine1.Title.TextColor = Color.Blue; //直线文本字体颜色 constantLine1.LineStyle.Thickness = 2; double StandardDeviation2 = Math.Round((double)(results.TargetMean + results.TargetSD * 2), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine4 = new ConstantLine("2SD", StandardDeviation2); diagram.AxisY.ConstantLines.Add(constantLine4); constantLine4.Color = Color.Orange; //直线颜色 constantLine4.Title.TextColor = Color.Orange; //直线文本字体颜色 constantLine4.LineStyle.Thickness = 2; double StandardDeviation3 = Math.Round((double)(results.TargetMean + results.TargetSD * 3), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine5 = new ConstantLine("3SD", StandardDeviation3); diagram.AxisY.ConstantLines.Add(constantLine5); constantLine5.Color = Color.Red; //直线颜色 constantLine5.Title.TextColor = Color.Red; //直线文本字体颜色 constantLine5.LineStyle.Thickness = 2; double Mean = Math.Round(results.TargetMean, 1, MidpointRounding.AwayFromZero); ConstantLine constantLine2 = new ConstantLine("MEAN", Mean); diagram.AxisY.ConstantLines.Add(constantLine2); constantLine2.Color = Color.Green; constantLine2.Title.TextColor = Color.Green; constantLine2.LineStyle.Thickness = 2; double Negative1SD = Math.Round((double)(results.TargetMean - results.TargetSD), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine3 = new ConstantLine("-1SD", Negative1SD); diagram.AxisY.ConstantLines.Add(constantLine3); constantLine3.Color = Color.Blue; constantLine3.Title.TextColor = Color.Blue; constantLine3.LineStyle.Thickness = 2; constantLine3.Title.ShowBelowLine = true; double Negative2SD = Math.Round((double)(results.TargetMean - results.TargetSD * 2), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine6 = new ConstantLine("-2SD", Negative2SD); diagram.AxisY.ConstantLines.Add(constantLine6); constantLine6.Color = Color.Orange; constantLine6.Title.TextColor = Color.Orange; constantLine6.LineStyle.Thickness = 2; constantLine6.Title.ShowBelowLine = true; double Negative3SD = Math.Round((double)(results.TargetMean - results.TargetSD * 3), 1, MidpointRounding.AwayFromZero); ConstantLine constantLine7 = new ConstantLine("-3SD", Negative3SD); diagram.AxisY.ConstantLines.Add(constantLine7); constantLine7.Color = Color.Red; constantLine7.Title.TextColor = Color.Red; constantLine7.LineStyle.Thickness = 2; constantLine7.Title.ShowBelowLine = true; //设置Y轴的图像显示最大值和最小值 double VRMin = 0; double VRMax = 0; if (results.TargetSD <= 0.1) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 0.5), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 0.5), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 0.3) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 2), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 2), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 0.5) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 3), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 3), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 1) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 5), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 5), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 5) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 15), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 15), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 10) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 25), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 25), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 20) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 40), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 40), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 50) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 60), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 60), 1, MidpointRounding.AwayFromZero); } else if (results.TargetSD <= 100) { VRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 75), 1, MidpointRounding.AwayFromZero); VRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 75), 1, MidpointRounding.AwayFromZero); } diagram.AxisY.VisualRange.SetMinMaxValues(VRMin, VRMax); //设置Y轴的最大值和最小值 double WRMin = Math.Round((double)(results.TargetMean - 3 * results.TargetSD - 100), 1, MidpointRounding.AwayFromZero); double WRMax = Math.Round((double)(results.TargetMean + 3 * results.TargetSD + 100), 1, MidpointRounding.AwayFromZero); diagram.AxisY.WholeRange.SetMinMaxValues(WRMin, WRMax); diagram.AxisX.VisualRange.SetMinMaxValues(0, 10); diagram.AxisX.WholeRange.SetMinMaxValues(0, 10); //设置Y轴 diagram.AxisY.Title.Text = "质控品浓度结果".ToString(); diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True; diagram.AxisY.NumericScaleOptions.GridSpacing = 1; diagram.AxisY.NumericScaleOptions.AutoGrid = false; diagram.AxisY.VisualRange.Auto = false; diagram.AxisY.VisualRange.AutoSideMargins = false; diagram.AxisY.WholeRange.Auto = false; diagram.AxisY.WholeRange.AutoSideMargins = false; diagram.AxisY.MinorCount = 9; //是否允许沿其Y轴滚动窗格 diagram.EnableAxisYScrolling = true; diagram.EnableAxisYZooming = true; //设置X轴 diagram.AxisX.Title.Text = "质控时间".ToString(); diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True; diagram.AxisX.NumericScaleOptions.GridSpacing = 1; diagram.AxisX.NumericScaleOptions.AutoGrid = false; diagram.AxisX.VisualRange.Auto = false; diagram.AxisX.VisualRange.AutoSideMargins = false; //diagram.AxisX.WholeRange.Auto = false; //diagram.AxisX.WholeRange.AutoSideMargins = false; diagram.AxisX.MinorCount = 9; //是否允许沿其X轴滚动窗格 diagram.EnableAxisXScrolling = true; diagram.EnableAxisXZooming = true; // 启用X轴缩放 //diagram.EnableAxisXZooming = true; //diagram.Panes[0].EnableAxisXZooming = DevExpress.Utils.DefaultBoolean.False; //// 指定键盘和鼠标进行放大缩小 diagram.ZoomingOptions.UseKeyboard = false; diagram.ZoomingOptions.UseKeyboardWithMouse = true; diagram.ZoomingOptions.UseMouseWheel = true; } } } catch (Exception e) { LogInfo.WriteErrorLog("质控图异常:" + e.ToString(), Module.QualityControl); } }
/// <summary> /// 质控品信息保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { lstQCRelationProInfo.Clear(); if (txtQCName.Text.Trim() == null || txtQCName.Text.Trim() == string.Empty) { MessageBox.Show("质控品名称不能为空,请填写质控品名称!"); return; } if (txtLotNum.Text.Trim() == null || txtLotNum.Text.Trim() == string.Empty) { MessageBox.Show("质控品批号不能为空,请填写质控品批号!"); return; } if (txtManufacturer.Text.Trim() == null || txtManufacturer.Text.Trim() == string.Empty) { MessageBox.Show("质控品生产厂家不能为空,请填写生产厂家!"); return; } if (string.IsNullOrEmpty(cboPosition.Text))//ly { MessageBox.Show("质控品位置不能为空!"); return; } if (this.gridView1.SelectedRowsCount != 0) { foreach (int i in this.gridView1.GetSelectedRows()) { DataRow dr = this.gridView1.GetDataRow(i); try { if (!Regex.IsMatch(((string)dr.ItemArray[3]).Trim(), @"^(-?\d+)(\.\d+)?$") || !Regex.IsMatch(((string)dr.ItemArray[4]).Trim(), @"^(-?\d+)(\.\d+)?$")) { MessageBox.Show("质控品对应生化项目录入数据有误,请检查并修改!"); return; } } catch (Exception ex) { MessageBox.Show("质控品对应生化项目录入数据有误,请检查并修改!"); return; } } } else { MessageBox.Show("请选择对应的生化项目!"); return; } qcInfo.QCID = qCOldInfo.QCID; qcInfo.QCName = txtQCName.Text.Trim(); qcInfo.Pos = cboPosition.SelectedItem.ToString(); qcInfo.LotNum = txtLotNum.Text.Trim(); qcInfo.InvalidDate = Convert.ToDateTime(dtpInvalidDate.Text); qcInfo.HorizonLevel = combLevelConc.SelectedItem as string; qcInfo.Manufacturer = txtManufacturer.Text.Trim(); lstQCRelationProInfo.Clear(); int count = gridView1.RowCount; for (int i = 0; i < count; i++) { QCRelationProjectInfo QcRelationProjectinfo = new QCRelationProjectInfo(); if (gridView1.GetRowCellValue(i, "靶值").ToString() != "" && gridView1.GetRowCellValue(i, "SD").ToString() != "") { QcRelationProjectinfo.ProjectName = this.gridView1.GetRowCellValue(i, "项目名称").ToString(); QcRelationProjectinfo.SampleType = this.gridView1.GetRowCellValue(i, "样本类型").ToString(); QcRelationProjectinfo.TargetMean = float.Parse(this.gridView1.GetRowCellValue(i, "靶值").ToString()); QcRelationProjectinfo.TargetSD = float.Parse(this.gridView1.GetRowCellValue(i, "SD").ToString()); QcRelationProjectinfo.Target2SD = QcRelationProjectinfo.TargetSD * 2; QcRelationProjectinfo.Target3SD = QcRelationProjectinfo.TargetSD * 3; QcRelationProjectinfo.QCID = qCOldInfo.QCID; lstQCRelationProInfo.Add(QcRelationProjectinfo); } } if (strReturnInfo == "编辑中") { return; } strReturnInfo = "编辑中"; if (this.Text == "新增质控品") { qcAddDic.Clear(); qcAddDic.Add("AddQualityControl", new object[] { XmlUtility.Serializer(typeof(QualityControlInfo), qcInfo), XmlUtility.Serializer(typeof(List <QCRelationProjectInfo>), lstQCRelationProInfo) }); SendToServices(qcAddDic); } else { if (lstQCRelationProInfo.Count < QCRelateProInfo.Count) { MessageBox.Show("不能将原靶值或SD设置为空!"); return; } qcAddDic.Clear(); qcAddDic.Add("EditQualityControl", new object[] { XmlUtility.Serializer(typeof(QualityControlInfo), qCOldInfo), XmlUtility.Serializer(typeof(QualityControlInfo), qcInfo), XmlUtility.Serializer(typeof(List <QCRelationProjectInfo>), lstQCRelationProInfo), XmlUtility.Serializer(typeof(List <QCRelationProjectInfo>), QCRelateProInfo) }); SendToServices(qcAddDic); } }
/// <summary> /// 根据传递的条件删除质控品对应的项目信息 /// </summary> /// <returns></returns> public int DeleteQCProjectInfo(string strDBMethod, QCRelationProjectInfo qcProjectInfo) { return myBatis.DeleteQCProjectInfo(strDBMethod, qcProjectInfo); }