using System;
using System.Collections.Generic;
using System.Text;
using H3;
public class D150516CGtools : H3.SmartForm.SmartFormController
{
public D150516CGtools(H3.SmartForm.SmartFormRequest request) : base(request)
{
}
protected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
{
base.OnLoad(response);
}
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
{
base.OnSubmit(actionName, postValue, response);
}
}
public class Utils {
public Utils() { }
/*=========================================================================================================================================*/
/*
根据用户id获取用户信息
入参: 用户id, 氚云引擎
出参: 当前用户id的全部用户信息
by: lins, date: 2020-08-01
*/
public static System.Data.DataTable getPersonnel(string userId, H3.IEngine engine){
string sql = " SELECT * ";
sql += " FROM I_D002033personnelManagement WHERE personnel = '" + userId + "' AND static = '有效'";
return engine.Query.QueryTable(sql, null);
}
/*=========================================================================================================================================*/
/*
将字符串类型转换为2位小数的双精度浮点类型
入参: 需要处理的字符串(以对象的形式传入)
出参: 处理后的双精度浮点
by: lins, date: 2020-08-17
*/
public static double toDoubleByString(object str){
//将字符串转换为双精度浮点后加0.0001
double dou = Convert.ToDouble(str) + 0.0001;
//将双精度浮点保留两位小数后返回
return Math.Round(dou, 3);
}
/*=========================================================================================================================================*/
/*
修改数据标题
*/
public static H3.SmartForm.LoadListViewResponse changeTitle(H3.SmartForm.LoadListViewResponse response, string titleCode , string titleValue) {
Dictionary < string, H3.SmartForm.ListViewColumn > columns=new Dictionary<string, H3.SmartForm.ListViewColumn>();
foreach(string key in response.Columns.Keys) {
if(key == titleCode) {
//将Name列的列名称改成 合同编码
H3.SmartForm.ListViewColumn newCol = new H3.SmartForm.ListViewColumn(
titleCode,//列编码(对应控件编码)
titleValue,//列名称
response.Columns[key].Visible,
response.Columns[key].Sortable,
response.Columns[key].Url,
response.Columns[key].Align,
response.Columns[key].IsLabel,
response.Columns[key].ShowMode
);
columns.Add(titleCode, newCol);
}
else {
columns.Add(key, response.Columns[key]);
}
}
response.Columns = columns;
return response;
}
/*=========================================================================================================================================*/
/*
通过关联表单获取人员单选
或通过人员单选获取关联表单
双向使用
*/
public static string getPersonnelByRelation(string relation, H3.IEngine engine){
string sql = " SELECT objectId FROM I_D002033personnelManagement WHERE personnel = '"+relation+"' AND static = '有效' ";
System.Data.DataTable dt = engine.Query.QueryTable(sql, null);
string param = "";
if(dt != null && dt.Rows.Count > 0){
param = dt.Rows[0]["objectId"] + string.Empty;
}
else{
sql = " SELECT personnel FROM I_D002033personnelManagement WHERE objectId = '"+relation+"' AND static = '有效' ";
dt = engine.Query.QueryTable(sql, null);
if(dt != null && dt.Rows.Count > 0){
param = dt.Rows[0]["personnel"] + string.Empty;
}
}
return param;
}
}
浙公网安备 33010602011771号