此模块可以用做公共模块使用,只用做简单修改即可使用;
用到的Form、SS脚本、DS脚本、数据库表以及主任审核相关性检查按钮的代码
- 相关性检查按钮代码:
1 var arrFolders = []; 2 var arrOris = []; 3 for(var row in dgFolders.DataSet.Tables[0].Rows) 4 { 5 if(row["SELECTED"] == "Y") 6 { 7 arrFolders = lims.AAdd(arrFolders,row["FOLDERNO"]); 8 arrOris = lims.AAdd(arrOris,row["ORIGREC"]); 9 } 10 } 11 if(lims.Len(arrOris) == 0) 12 { 13 arrFolders = dgFolders.GetSelectedRowsData("FOLDERNO"); 14 arrOris = dgFolders.GetSelectedRowsData("ORIGREC"); 15 } 16 var oOrdno = lims.CallServer("AppResultByDept.SS_GetOrdNO",[arrFolders]); 17 var reg = form.ShowModalDialog(lims.GetFormSource("AppResultByDept.DataRelationCheck"),[oOrdno]);
相关性配置页面:
- 调用Form实现初步添加公式信息,并且在公式里面实现对输入名称的非空判断、重名判断,实现多行操作、添加定位;
1 var reg = form.ShowModalDialog(lims.GetFormSource("TEST_MANAGER.AddDLCheck")); 2 if(reg == null | reg == "") 3 { 4 return ; 5 } 6 var dummy = lims.CallServer("TEST_MANAGER.ADD_DLCheck",[reg[0],reg[1]]); 7 if(lims.Len(dummy) > 0 && dummy[0] == true) 8 { 9 dgDLCheck.Refresh(); 10 dgDLCheck.Find(["ORIGREC"],[dummy[1]]); 11 }
1 var reg = form.ShowModalDialog(lims.GetFormSource("TEST_MANAGER.AddDLCheck")); 2 if(reg == null | reg == "") 3 { 4 return ; 5 } 6 var dummy = lims.CallServer("TEST_MANAGER.ADD_DLCheck",[reg[0],reg[1]]); 7 if(lims.Len(dummy) > 0 && dummy[0] == true) 8 { 9 dgDLCheck.Refresh(); 10 dgDLCheck.Find(["ORIGREC"],[dummy[1]]); 11 } 12 13 var DLCName = txtDLCName.Text; 14 var isTrue = lims.CallServer("TEST_MANAGER.DLCName_Check",[DLCName]); 15 if(isTrue == true) 16 { 17 Dialogs.MessageBox(form.Resources["名称已存在,请重新输入!"],"提示!","OK","WARNING"); 18 txtDLCName.Text = null; 19 txtDLCName.Focus(); 20 } 21 22 重名判断
- 调用公式:使用UD弹窗的方式调用公共Form,
1 var origrec = dgDLCheck.GetCurrentRowData("ORIGREC"); 2 var ReadOnly = true; 3 var bStyle = ""; 4 if(eventArgs["Column"].Id == 'DATALC_CALCNAME') 5 { 6 var calcName = dgDLCheck.GetCurrentRowData("DATALC_CALCNAME"); 7 var prompt = form.ShowModalDialog(lims.GetFormSource("TEST_MANAGER.DLC_CALCNAME"), [ calcName, origrec,"DATA_RELATION_CHECK"]); 8 dgDLCheck.Refresh(); 9 dgDLCheck.Find(["ORIGREC"],[origrec]); 10 } 11 else if(eventArgs["Column"].Id == 'DATALC_DESCRIPTION') 12 { 13 UpdateUD(eventArgs, dgDLCheck, "DATA_RELATION_CHECK", eventArgs["Column"].Id, !ReadOnly, bStyle); 14 }
- 公式Form,实现添加默认公式内容(从别处拷贝修改使用,只是修改了添加公式的代码,其他使用原先代码)
1 var origrecAnalytes = form.formArguments[1]; 2 var calcName = lims.CallServer("TEST_MANAGER.SS_Update_Calculation", [ "", "", origrecAnalytes,"" ]); 3 //此处第二个参数可以设置公式默认内容; 4 dgdCalcs.Data = lims.GetDataSource("TEST_MANAGER.getCalcVersions", [ calcName ]); 5 dgdCalcs.Refresh();
- 添加公式脚本SS_Update_Calculation,
1 /******************************************************************************** 2 Description.. : 3 4 Parameters... : - 5 6 Returns...... : - 7 8 Author....... : CAOSS 9 Date......... : 2015-08-27 10 ******************************************************************************** 11 _______________________________________________________________________________ 12 13 Modification. : 14 Author....... : 15 Date......... : 16 _______________________________________________________________________________ 17 ********************************************************************************/; 18 :PARAMETERS CalcName, Calculation, origrec, CALCDESC; 19 :DEFAULT CalcName, ""; 20 :DEFAULT Calculation, ""; 21 :DEFAULT origrec, -1; 22 :DEFAULT CALCDESC, ""; 23 24 :DECLARE CalcNames, CurrCalcName,CurrTestCodeAnalyte,CurrTestCode,CurrAnalyte,anaTestCode,testAnalyte,analyteMethod; 25 26 /*region add/update calculation; 27 :IF Empty(CALCDESC); 28 :IF Empty(CalcName); 29 CalcNames := SqlExecute("select Max(CALCNAME) from CALCS_ACTIONS where CALCNAME like 'CALC%'"); 30 :IF Empty(CalcNames[1,1]); 31 CurrCalcName := "CALC-" + "00001"; 32 :ELSE; 33 CurrCalcName := Val(Right(CalcNames[1,1], 5)) + 1; 34 CurrCalcName := "CALC-" + StrZero(CurrCalcName, 5, 0); 35 :ENDIF; 36 SqlExecute("insert into CALCS_ACTIONS (CALCNAME, CALCUL, CALCDESC, FROMDATE) 37 values (?CurrCalcName?, ?Calculation?, ?CurrCalcName?, ?Today()?)"); 38 39 SqlExecute("update DATA_RELATION_CHECK set DATALC_CALCNAME = ?CurrCalcName? where ORIGREC = ?origrec?"); 40 41 :ELSE; 42 SqlExecute("update CALCS_ACTIONS set CALCUL = ?Calculation? where CALCNAME = ?CalcName?"); 43 SqlExecute("update DATA_RELATION_CHECK set DATALC_CALCUL = ?Calculation? where DATALC_CALCNAME = ?CalcName?"); 44 :ENDIF; 45 :ELSE; 46 CalcNames := SqlExecute("select Max(CALCNAME) from CALCS_ACTIONS where CALCNAME Like 'CALC%'"); 47 48 CurrCalcName := Val(Right(CalcNames[1,1], 5)) + 1; 49 CurrCalcName := "CALC-" + StrZero(CurrCalcName, 5, 0); 50 51 SqlExecute("insert into CALCS_ACTIONS (CALCNAME, CALCDESC, CALCUL,FROMDATE) 52 select ?CurrCalcName?, ?CALCDESC?, CALCUL,?Today()? 53 from CALCS_ACTIONS 54 where ORIGREC = (select max(ORIGREC) 55 from CALCS_ACTIONS 56 where CALCDESC=?CALCDESC?)"); 57 SqlExecute("update DATA_RELATION_CHECK set DATALC_CALCUL = ?CALCUL? where DATALC_CALCNAME = ?CalcName?"); 58 SqlExecute("update DATA_RELATION_CHECK set DATALC_CALCNAME = ?CurrCalcName? where ORIGREC = ?origrec?"); 59 :ENDIF; 60 61 :RETURN CurrCalcName;
- 多个勾选,如果没有勾选,则默认选定当前选定行
1 var arrFolders = []; 2 var arrOris = []; 3 for(var row in dgFolders.DataSet.Tables[0].Rows) 4 { 5 if(row["SELECTED"] == "Y")//如果勾选的字段为Y,则执行下面的代码 6 { 7 arrFolders = lims.AAdd(arrFolders,row["FOLDERNO"]);//把所有满足条件的FOLDERNO添加到数组中 8 arrOris = lims.AAdd(arrOris,row["ORIGREC"]);//同上 9 } 10 } 11 if(lims.Len(arrOris) == 0)//如果没有符合条件的,则添加当前行到数组中; 12 { 13 arrFolders = dgFolders.GetSelectedRowsData("FOLDERNO"); 14 arrOris = dgFolders.GetSelectedRowsData("ORIGREC"); 15 }
- 循环传入一维数组(存有folderno)返回一维数组ordno;
1 :PARAMETERS fFOLDERNO; 2 :DEFAULT fFOLDERNO,""; 3 :DECLARE StrSql, Results,DataLoop,Result,DataLoop1; 4 DataLoop := 1; 5 Results := {}; 6 /*:RETURN LEN(fFOLDERNO); 7 :WHILE DataLoop <= LEN(fFOLDERNO); 8 StrSql := " SELECT ORDNO FROM ORDERS , FOLDERS 9 WHERE ORDERS.FOLDERNO = FOLDERS.FOLDERNO 10 AND FOLDERS.FOLDERNO = ?fFOLDERNO[DataLoop]? 11 AND ORDERS.QCTYPE='N/A'"; 12 Result := SQLEXECUTE(StrSql); 13 DataLoop1 := 1; 14 :WHILE DataLoop1 <= LEN(Result); 15 AADD(Results,Result[DataLoop1]); 16 DataLoop1 := DataLoop1 + 1; 17 :ENDWHILE; 18 /* :RETURN Results; 19 DataLoop := DataLoop + 1; 20 USRMES("Results",Results); 21 :ENDWHILE; 22 23 :RETURN Results;
- 传入参数ORDNO调用公式脚本
1 var reg = lims.CallServer("AppResultByDept.SS_SqlExeCalcul",[Data_Calcul[i],form.Variables["CURRENTORDNO"][k]]);
1 :PARAMETERS CALCUL, ORENO; 2 :DEFAULT CALCUL,""; 3 :DEFAULT ORENO,""; 4 :RETURN EXECUDF(CALCUL,ORENO);
- 使用数据集为DataGrid赋值
1 var dt : System.Data.DataTable = new System.Data.DataTable();//新建数据表格, 2 dt.Columns.Add("Name");//添加数据表格的格式 3 dt.Columns.Add("Ordno"); 4 dt.Columns.Add("Result"); 5 dt.Columns.Add("Color"); 6 for(var i= 0; i < lims.Len(Data_Calcul); i++) 7 { 8 var name = lims.CallServer("AppResultByDept.SS_GetCalculName",[Data_Calcul[i]]); 9 for(var k = 0; k < lims.Len(form.Variables["CURRENTORDNO"]) ; k++) 10 { 11 var reg = lims.CallServer("AppResultByDept.SS_SqlExeCalcul",[Data_Calcul[i],form.Variables["CURRENTORDNO"][k]]); 12 if(reg[0] == true) 13 { 14 dt.Rows.Add( name, reg[1] ,reg[2],"Green");//把这行满足公式的数据插入到数据表dt中去 15 } 16 else 17 { 18 dt.Rows.Add( name, reg[1] ,reg[2],"Red"); //把这行不满足公式的数据插入到数据表dt中去 19 } 20 } 21 } 22 var ds : System.Data.DataSet = new System.Data.DataSet();//新建数据集 23 ds.Tables.Add(dt); //把数据表中的内容添加到数据集中去; 24 dgCheckResult.DataSet = ds;//然后赋值给DataGrid显示结果
- 使用数据集为DataGrid设置行字体颜色
1 // 在显示数据的DataGrid中设置AttributesMember的值为能控制颜色的字段的Color, 2 // 此处在代码中对应的是dt.Columns.Add("Color");,然后在往数据表中填充数据的时候, 3 // 把该列的值设置成想要设置的颜色即可; 4 //如下: 5 dt.Columns.Add("Name"); 6 dt.Columns.Add("Ordno"); 7 dt.Columns.Add("Result"); 8 dt.Columns.Add("Color"); 9 dt.Rows.Add( name, reg[1] ,reg[2],"Green"); 10 //数据表有四列,只要设置第四列的值为颜色的英文即可,在DataGrid中不必添加Color字段, 11 //但是一定要满足第一行所说的设置属性