1492 lines
66 KiB
C#
1492 lines
66 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using CommonLib;
|
|
using System.Windows.Forms;
|
|
using Lskj.MyControl;
|
|
using System.Drawing;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using ControlLib.inh;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.MyControl.LookUpAdd;
|
|
using Lskj.MyControl.LookUp;
|
|
using Lskj.PubUtils;
|
|
using DevExpress.XtraTreeList;
|
|
using DevExpress.XtraTreeList.Nodes;
|
|
using DevExpress.XtraGrid.Views.Layout;
|
|
using DevExpress.XtraBars;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Lskj.Common
|
|
{
|
|
public class MySearchCreateControl
|
|
{
|
|
private CreateControlModel ccModel;
|
|
private PopupMenu pm_search = new PopupMenu();
|
|
private DropDownButton ddbSearch;
|
|
private BarManager barManager1 = new BarManager();
|
|
private DataTable dtSearchProject = new DataTable();
|
|
public string Check_Cond; //将查询条件单独提出,方便dataTable查询
|
|
public event EventHandler onSearchClick;
|
|
|
|
public SimpleButton SearchButton;
|
|
|
|
public MySearchCreateControl()
|
|
{
|
|
}
|
|
/// <summary>
|
|
/// 用户登录Id
|
|
/// </summary>
|
|
public string LoginId { get; set; }
|
|
/// <summary>
|
|
/// 用户登录名
|
|
/// </summary>
|
|
public string LoginName { get; set; }
|
|
|
|
public string ModuleId;
|
|
|
|
public string SearchSql { get; set; }
|
|
|
|
public bool IsColumnFix;
|
|
|
|
public Control ctr { get; set; }
|
|
|
|
public DataTable condDt { get; set; }
|
|
|
|
public GridControlEx gridEx;
|
|
|
|
public GridControl gce { get; set; }
|
|
public TreeList treeList { get; set; }
|
|
|
|
public TreeViewEx tvLeft { get; set; }
|
|
public DataRow tvLeftDataRow { get; set; }
|
|
|
|
public GridControl gcLeft { get; set; }
|
|
|
|
public int dllType { get; set; }
|
|
|
|
public string LeftGridSqlTag { get; set; }
|
|
|
|
public string[] otherParams { get; set; }
|
|
|
|
public bool isFixed { get; set; }
|
|
|
|
public String ActionSql { get; set; }
|
|
|
|
public bool RememberRow { get; set; }
|
|
//用于传入单据头容器控件
|
|
public Control condPanel { get; set; }
|
|
|
|
/// <summary>
|
|
/// 创建控件
|
|
/// </summary>
|
|
/// <param name="cmodel"></param>
|
|
/// <returns></returns>
|
|
public int CreateControlByModel(CreateControlModel cmodel)
|
|
{
|
|
this.ccModel = cmodel;
|
|
int yHeight = 0;
|
|
int xWidth = 0;
|
|
int y = 0;
|
|
int x = 0;
|
|
DataTable dt = new DataTable();
|
|
if (cmodel.dt != null && cmodel.dt.Rows.Count > 0)
|
|
dt = cmodel.dt;
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(cmodel.sql))
|
|
dt = SqlHelper.ExecuteDataSet(cmodel.sql).Tables[0];
|
|
}
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
string msg = row["fieldTypeId"] + "";
|
|
int fieldTypeId = 0;
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
fieldTypeId = Convert.ToInt32(row["fieldTypeId"]);
|
|
}
|
|
ControlModelTag cmodelTag = new ControlModelTag() { IsSave = true, IsClear = (row["edited"] + "" != "1"), IsEmpt = Convert.ToBoolean(row["nullable"]), fieldTypeId = fieldTypeId, TipMsg = row["userName"] + "" };
|
|
Control myctr = null;
|
|
//日期
|
|
if (fieldTypeId == ControlType.LabDate ||
|
|
fieldTypeId == ControlType.LabDateTime ||
|
|
fieldTypeId == ControlType.LabDateTimeShort ||
|
|
fieldTypeId == ControlType.LabTime ||
|
|
fieldTypeId == ControlType.LabShortTime)
|
|
{
|
|
//LabelDateEx labelText = new LabelDateEx();
|
|
//labelText.LabelText = row["userName"].ToString();
|
|
//labelText.Name = "txt_" + row["fieldName"];
|
|
//labelText.FormatType = cmodelTag.DateFormat = DateFormatType.GetFormatValue(fieldTypeId);
|
|
//labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
//string edited = row["edited"] + "";
|
|
//if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
// labelText.GetDateTimePicker.Enabled = false;
|
|
|
|
//labelText.GetDateTimePicker.ShowUpDown = fieldTypeId == ControlType.LabTime || fieldTypeId == ControlType.LabShortTime ? true : false;
|
|
//labelText.GetDateTimePicker.CloseUp += new EventHandler(myctr_CloseUp);
|
|
//labelText.GetDateTimePicker.KeyDown += new KeyEventHandler(myctr_KeyDown);
|
|
//myctr = labelText;
|
|
//labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
|
|
LabelDateEx labelText = new LabelDateEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
labelText.FormatType = cmodelTag.DateFormat = DateFormatType.GetFormatValue(fieldTypeId);
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
labelText.GetDateTimePicker.Enabled = false;
|
|
myctr = labelText;
|
|
labelText.GetDateTimePicker.ShowUpDown = fieldTypeId == ControlType.LabTime || fieldTypeId == ControlType.LabShortTime ? true : false;
|
|
labelText.GetDateTimePicker.Tag = cmodelTag;
|
|
labelText.GetDateTimePicker.CloseUp += new EventHandler(myctr_CloseUp);
|
|
labelText.GetDateTimePicker.KeyDown += new KeyEventHandler(myctr_KeyDown);
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
}
|
|
//文本
|
|
else if (fieldTypeId == ControlType.LabText || fieldTypeId == ControlType.LabTextInt)
|
|
{
|
|
LabelTextEx labelText = new LabelTextEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
labelText.GetTextBox.ReadOnly = true;
|
|
myctr = labelText;
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
labelText.GetTextBox.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
}
|
|
//下拉框
|
|
else if (fieldTypeId == ControlType.LabComboxValue || fieldTypeId == ControlType.LabComboxText)
|
|
{
|
|
LabelComboxEx labelText = new LabelComboxEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
string lookupSql = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
labelText.getComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
labelText.getComboBox.Enabled = false;
|
|
}
|
|
if (!string.IsNullOrEmpty(lookupSql))
|
|
{
|
|
string keyField = row["lookupKeyField"] + "";
|
|
string resultField = row["lookupResult"] + "";
|
|
labelText.setDataSource(lookupSql, keyField, resultField);
|
|
}
|
|
if (fieldTypeId == ControlType.LabComboxValue)
|
|
{
|
|
labelText.getComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
string defaultValue = GetDefaultValue(row["defaultValue"].ToString());
|
|
if (!string.IsNullOrEmpty(defaultValue))
|
|
{
|
|
labelText.getComboBox.SelectedValue = defaultValue;
|
|
}
|
|
else
|
|
{
|
|
labelText.getComboBox.Text = "";
|
|
labelText.getComboBox.SelectedValue = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string defaultValue = GetDefaultValue(row["defaultValue"].ToString());
|
|
if (String.IsNullOrEmpty(defaultValue))
|
|
{
|
|
labelText.getComboBox.Text = "";
|
|
//labelText.getComboBox.SelectedValue = null;
|
|
}
|
|
else
|
|
{
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
}
|
|
}
|
|
myctr = labelText;
|
|
}
|
|
//自动搜索
|
|
else if (fieldTypeId == ControlType.LabAutoSeacherValue
|
|
|| fieldTypeId == ControlType.LabAutoSeacherText)
|
|
{
|
|
LabelAutoSearcherEx autSearch = new LabelAutoSearcherEx();
|
|
autSearch.LabelText = row["userName"].ToString();
|
|
ControlLib.inh.AutoSearcher txtUserName = autSearch.GetAutoSearcher;
|
|
ControlLib.inh.SearcherPropertyCollector searcherPropertyCollector1 = new ControlLib.inh.SearcherPropertyCollector();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData1 = new ControlLib.inh.TFieldPropertyData();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData2 = new ControlLib.inh.TFieldPropertyData();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData3 = new ControlLib.inh.TFieldPropertyData();
|
|
txtUserName.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;
|
|
txtUserName.Tag = cmodelTag;
|
|
//取下拉列表数据
|
|
txtUserName.Name = "txt_" + row["fieldName"];
|
|
txtUserName.MaxLength = 50;
|
|
txtUserName.searcherPropertyCollector = searcherPropertyCollector1;
|
|
txtUserName.TabIndex = 12;
|
|
|
|
tFieldPropertyData1.FieldCaption = "编码";
|
|
tFieldPropertyData1.FieldName = row["lookupKeyField"] + "";
|
|
tFieldPropertyData1.FieldWidth = 50;
|
|
tFieldPropertyData1.ShowColumn = true;
|
|
|
|
tFieldPropertyData2.FieldCaption = "名称";
|
|
tFieldPropertyData2.FieldName = row["lookupResult"] + "";
|
|
tFieldPropertyData2.FieldWidth = 150;
|
|
tFieldPropertyData2.ShowColumn = true;
|
|
|
|
string sql = row["lookupSql"].ToString();
|
|
searcherPropertyCollector1.ConvertToChineseSpell = true;
|
|
searcherPropertyCollector1.FieldPropertyList = new ControlLib.inh.TFieldPropertyData[] { tFieldPropertyData1, tFieldPropertyData2 };
|
|
if (sql.IndexOf("remark", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
searcherPropertyCollector1.RemarkField = "remark";
|
|
tFieldPropertyData3.FieldCaption = "备注";
|
|
tFieldPropertyData3.FieldName = "remark";
|
|
tFieldPropertyData3.FieldWidth = 150;
|
|
tFieldPropertyData3.ShowColumn = true;
|
|
searcherPropertyCollector1.FieldPropertyList = new ControlLib.inh.TFieldPropertyData[] { tFieldPropertyData1, tFieldPropertyData2, tFieldPropertyData3 };
|
|
}
|
|
searcherPropertyCollector1.KeyField = row["lookupKeyField"] + "";
|
|
searcherPropertyCollector1.QueryField = row["lookupResult"] + "";
|
|
searcherPropertyCollector1.QuerySQL = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
//searcherPropertyCollector1.ReturnMaxCount = 50;
|
|
searcherPropertyCollector1.ReturnValueField = row["lookupKeyField"] + "";
|
|
searcherPropertyCollector1.SearchMatchWay = ControlLib.inh.TSearchMatchWay.swFuzzy;
|
|
searcherPropertyCollector1.ShowFormHeight = 230;
|
|
searcherPropertyCollector1.ShowFormWidth = 230;
|
|
searcherPropertyCollector1.SQL = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
autSearch.GetAutoSearcher.ReadOnly = true;
|
|
}
|
|
myctr = autSearch;
|
|
if (fieldTypeId == ControlType.LabAutoSeacherValue)
|
|
autSearch.GetAutoSearcher.SetValueSilent(GetDefaultValue(row["defaultValue"].ToString()), "");
|
|
else
|
|
autSearch.GetAutoSearcher.SetValueSilent("", GetDefaultValue(row["defaultValue"].ToString()));
|
|
autSearch.GetAutoSearcher.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
//autSearch.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
}
|
|
//创建文本域
|
|
else if (fieldTypeId == ControlType.LabRemark)
|
|
{
|
|
LabelTextarea labelText = new LabelTextarea();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Location = new Point(Convert.ToInt32(row["ControlLeft"]), Convert.ToInt32(row["controlTop"]));
|
|
labelText.Parent = cmodel.ctr;
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
labelText.Enabled = false;
|
|
}
|
|
myctr = labelText;
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
labelText.getTextBox.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
}
|
|
else if (fieldTypeId == ControlType.LabCheckDateEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeShort ||
|
|
fieldTypeId == ControlType.LabCheckTime ||
|
|
fieldTypeId == ControlType.LabCheckShortTime)
|
|
{
|
|
cmodelTag.DateFormat = DateFormatType.GetFormatValue(fieldTypeId);
|
|
LabelCheckDateEx labelText = new LabelCheckDateEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
labelText.GetDateTimePicker.ShowUpDown = fieldTypeId == ControlType.LabCheckDateEx ||
|
|
fieldTypeId == ControlType.LabShortTime ? true : false;
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
labelText.GetDateTimePicker.Enabled = false;
|
|
|
|
labelText.GetDateTimePicker.CloseUp += new EventHandler(myctr_CloseUp);
|
|
labelText.GetDateTimePicker.KeyDown += new KeyEventHandler(myctr_KeyDown);
|
|
|
|
myctr = labelText;
|
|
if (!string.IsNullOrEmpty(labelText.Text))
|
|
{
|
|
labelText.SetEnabled(true);
|
|
}
|
|
}
|
|
//多选控件
|
|
else if ((fieldTypeId == ControlType.LabMultiSelectText) || (fieldTypeId == ControlType.LabMultiSelectValue))
|
|
{
|
|
LabelLookUp labelLookup = new LabelLookUp();
|
|
labelLookup.LabelText = row["userName"].ToString();
|
|
labelLookup.Parent = cmodel.ctr;
|
|
labelLookup.Name = "txt_" + row["fieldName"];
|
|
labelLookup.SQL = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
labelLookup.ValueField = row["lookupKeyField"].ToString();
|
|
labelLookup.TextField = row["lookupResult"].ToString();
|
|
Dictionary<string, string> Columns = new Dictionary<string, string>();
|
|
Columns.Add(row["lookupKeyField"].ToString(), "编码");
|
|
Columns.Add(row["lookupResult"].ToString(), "名称");
|
|
if (labelLookup.SQL.IndexOf("Remark") != -1)
|
|
Columns.Add("Remark", "备注");
|
|
labelLookup.Columns = Columns;
|
|
labelLookup.IsMultiple = true;
|
|
myctr = labelLookup;
|
|
}
|
|
//下拉框
|
|
else if (fieldTypeId == ControlType.LabCheckComboxText
|
|
|| fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
LabelCheckComboxEx labelText = new LabelCheckComboxEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
string lookupSql = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
labelText.getComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
labelText.getComboBox.Enabled = false;
|
|
}
|
|
if (!string.IsNullOrEmpty(lookupSql))
|
|
{
|
|
string keyField = row["lookupKeyField"] + "";
|
|
string resultField = row["lookupResult"] + "";
|
|
labelText.setDataSource(lookupSql, keyField, resultField);
|
|
}
|
|
if (fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
labelText.getComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
|
string defaultValue = GetDefaultValue(row["defaultValue"].ToString());
|
|
if (!string.IsNullOrEmpty(defaultValue))
|
|
{
|
|
labelText.getComboBox.SelectedValue = defaultValue;
|
|
labelText.SetEnabled(true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
if (!string.IsNullOrEmpty(labelText.Text))
|
|
{
|
|
labelText.SetEnabled(true);
|
|
}
|
|
}
|
|
|
|
myctr = labelText;
|
|
}
|
|
//自动搜索
|
|
else if (fieldTypeId == ControlType.LabCheckAutoSeacherValue
|
|
|| fieldTypeId == ControlType.LabCheckAutoSeacherText)
|
|
{
|
|
LabelCheckAutoSearcherEx autSearch = new LabelCheckAutoSearcherEx();
|
|
autSearch.Name = "txt_" + row["fieldName"];
|
|
autSearch.LabelText = row["userName"].ToString();
|
|
ControlLib.inh.AutoSearcher txtUserName = autSearch.GetAutoSearcher;
|
|
ControlLib.inh.SearcherPropertyCollector searcherPropertyCollector1 = new ControlLib.inh.SearcherPropertyCollector();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData1 = new ControlLib.inh.TFieldPropertyData();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData2 = new ControlLib.inh.TFieldPropertyData();
|
|
ControlLib.inh.TFieldPropertyData tFieldPropertyData3 = new ControlLib.inh.TFieldPropertyData();
|
|
txtUserName.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Append;
|
|
txtUserName.Tag = cmodelTag;
|
|
//取下拉列表数据
|
|
txtUserName.MaxLength = 50;
|
|
//txtUserName.Name = "txt_" + row["fieldName"];
|
|
txtUserName.searcherPropertyCollector = searcherPropertyCollector1;
|
|
txtUserName.TabIndex = 12;
|
|
|
|
tFieldPropertyData1.FieldCaption = "编码";
|
|
tFieldPropertyData1.FieldName = row["lookupKeyField"] + "";
|
|
tFieldPropertyData1.FieldWidth = 50;
|
|
tFieldPropertyData1.ShowColumn = true;
|
|
|
|
tFieldPropertyData2.FieldCaption = "名称";
|
|
tFieldPropertyData2.FieldName = row["lookupResult"] + "";
|
|
tFieldPropertyData2.FieldWidth = 150;
|
|
tFieldPropertyData2.ShowColumn = true;
|
|
|
|
string sql = row["lookupSql"].ToString();
|
|
searcherPropertyCollector1.ConvertToChineseSpell = true;
|
|
searcherPropertyCollector1.FieldPropertyList = new ControlLib.inh.TFieldPropertyData[] { tFieldPropertyData1, tFieldPropertyData2 };
|
|
if (sql.IndexOf("remark", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
searcherPropertyCollector1.RemarkField = "remark";
|
|
tFieldPropertyData3.FieldCaption = "备注";
|
|
tFieldPropertyData3.FieldName = "remark";
|
|
tFieldPropertyData3.FieldWidth = 150;
|
|
tFieldPropertyData3.ShowColumn = true;
|
|
searcherPropertyCollector1.FieldPropertyList = new ControlLib.inh.TFieldPropertyData[] { tFieldPropertyData1, tFieldPropertyData2, tFieldPropertyData3 };
|
|
}
|
|
searcherPropertyCollector1.KeyField = row["lookupKeyField"] + "";
|
|
searcherPropertyCollector1.QueryField = row["lookupResult"] + "";
|
|
searcherPropertyCollector1.QuerySQL = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
//searcherPropertyCollector1.ReturnMaxCount = 50;
|
|
searcherPropertyCollector1.ReturnValueField = row["lookupKeyField"] + "";
|
|
searcherPropertyCollector1.SearchMatchWay = ControlLib.inh.TSearchMatchWay.swFuzzy;
|
|
searcherPropertyCollector1.ShowFormHeight = 230;
|
|
searcherPropertyCollector1.ShowFormWidth = 230;
|
|
searcherPropertyCollector1.SQL = PubClass.ReqSqlParam(row["lookupSql"].ToString(), cmodel.loginid, cmodel.loginname);
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
autSearch.GetAutoSearcher.ReadOnly = true;
|
|
}
|
|
myctr = autSearch;
|
|
if (fieldTypeId == ControlType.LabCheckAutoSeacherValue)
|
|
autSearch.GetAutoSearcher.SetValueSilent(GetDefaultValue(row["defaultValue"].ToString()), "");
|
|
else
|
|
autSearch.GetAutoSearcher.SetValueSilent("", GetDefaultValue(row["defaultValue"].ToString()));
|
|
//autSearch.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
if (!string.IsNullOrEmpty(autSearch.Text))
|
|
{
|
|
autSearch.SetEnabled(true);
|
|
}
|
|
autSearch.GetAutoSearcher.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
}
|
|
//文本
|
|
else
|
|
{
|
|
LabelTextEx labelText = new LabelTextEx();
|
|
labelText.LabelText = row["userName"].ToString();
|
|
labelText.Name = "txt_" + row["fieldName"];
|
|
//labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
labelText.GetTextBox.ReadOnly = true;
|
|
myctr = labelText;
|
|
myctr.Parent = cmodel.ctr;
|
|
myctr.Tag = cmodelTag;
|
|
labelText.GetTextBox.Tag = cmodelTag;
|
|
labelText.GetTextBox.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
//labelText.Text = GetDefaultValue(row["defaultValue"].ToString());
|
|
}
|
|
if (myctr != null)
|
|
{
|
|
int ControlLeft = 0;
|
|
int ControlTop = 0;
|
|
int controlWidth = 0;
|
|
int controlHeight = 0;
|
|
if (!string.IsNullOrEmpty(row["ControlLeft"] + ""))
|
|
{
|
|
ControlLeft = Convert.ToInt32(row["ControlLeft"]);
|
|
}
|
|
if (!string.IsNullOrEmpty(row["controlTop"] + ""))
|
|
{
|
|
ControlTop = Convert.ToInt32(row["controlTop"]);
|
|
}
|
|
if (!string.IsNullOrEmpty(row["controlWidth"] + ""))
|
|
{
|
|
controlWidth = Convert.ToInt32(row["controlWidth"]);
|
|
}
|
|
if (!string.IsNullOrEmpty(row["controlHeight"] + ""))
|
|
{
|
|
controlHeight = Convert.ToInt32(row["controlHeight"]);
|
|
}
|
|
if (controlWidth > 0)
|
|
{
|
|
myctr.Width = controlWidth;
|
|
}
|
|
if (controlHeight > 0)
|
|
{
|
|
myctr.Height = controlHeight;
|
|
}
|
|
myctr.Location = new Point(ControlLeft, ControlTop);
|
|
myctr.Tag = cmodelTag;
|
|
myctr.Parent = cmodel.ctr;
|
|
int hgt = myctr.Top + myctr.Height;
|
|
if (hgt > yHeight)
|
|
{
|
|
yHeight = hgt;
|
|
}
|
|
|
|
if (y == 0)
|
|
{
|
|
y = ControlTop;
|
|
}
|
|
else
|
|
{
|
|
if (ControlTop < y)
|
|
{
|
|
y = ControlTop;
|
|
}
|
|
}
|
|
if (ControlLeft >= x && ControlTop == y)
|
|
{
|
|
x = ControlLeft;
|
|
xWidth = ControlLeft + myctr.Width;
|
|
}
|
|
string edited = row["edited"] + "";
|
|
if (edited.IndexOf("1", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
myctr.Enabled = false;
|
|
}
|
|
}
|
|
}
|
|
SearchButton = new SimpleButton();
|
|
SearchButton.Text = "搜索(&Q)";
|
|
SearchButton.Name = "btnCondSearch";
|
|
SearchButton.Parent = cmodel.ctr;
|
|
SearchButton.Height = 24;
|
|
SearchButton.Width = 60;
|
|
SearchButton.Location = new Point(xWidth + 5, y - 2);
|
|
SearchButton.Click += new EventHandler(b_Click);
|
|
|
|
// 模版搜索
|
|
if (!string.IsNullOrWhiteSpace(ModuleId))
|
|
{
|
|
ddbSearch = new DropDownButton();
|
|
ddbSearch.DropDownArrowStyle = DropDownArrowStyle.Show;
|
|
ddbSearch.DropDownControl = this.pm_search;
|
|
ddbSearch.Parent = cmodel.ctr;
|
|
ddbSearch.Height = 24;
|
|
ddbSearch.Width = 75;
|
|
ddbSearch.Location = new Point(xWidth + 80, y - 2);
|
|
ddbSearch.Text = "模版搜索";
|
|
ddbSearch.Leave += new EventHandler(ddbSearch_Leave);
|
|
|
|
pm_search.Manager = this.barManager1;
|
|
pm_search.Name = "pm_search";
|
|
|
|
InitSearchProject();
|
|
}
|
|
return yHeight + 5;
|
|
}
|
|
|
|
private void ddbSearch_Leave(object sender, EventArgs e)
|
|
{
|
|
if (pm_search != null) pm_search.HidePopup();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化方案
|
|
/// </summary>
|
|
public void InitSearchProject()
|
|
{
|
|
if (pm_search == null) return;
|
|
pm_search.ItemLinks.Clear();
|
|
|
|
dtSearchProject = GetSearchProject();
|
|
|
|
foreach (DataRow item in dtSearchProject.Rows)
|
|
{
|
|
BarButtonItem bbi_item = new BarButtonItem();
|
|
bbi_item.Caption = item["ProjectName"] + "";
|
|
bbi_item.Tag = item["SearchValue"] + "";
|
|
bbi_item.ItemClick += new ItemClickEventHandler(bbi_item_ItemClick);
|
|
|
|
pm_search.AddItem(bbi_item);
|
|
}
|
|
|
|
BarButtonItem bbi_save = new BarButtonItem();
|
|
bbi_save.Caption = "保存方案";
|
|
bbi_save.ItemClick += new ItemClickEventHandler(bbi_save_ItemClick);
|
|
|
|
BarButtonItem bbi_manager = new BarButtonItem();
|
|
bbi_manager.Caption = "方案管理";
|
|
bbi_manager.ItemClick += new ItemClickEventHandler(bbi_manager_ItemClick);
|
|
|
|
pm_search.AddItem(bbi_save);
|
|
pm_search.AddItem(bbi_manager);
|
|
}
|
|
|
|
public DataTable GetSearchProject()
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Format("select * from P_SystemReportProjectTab where ProjectMode=1 and operatorId='{0}' and ModuleId='{1}'", LoginId, ModuleId);
|
|
return SqlHelper.ExecuteDataTable(sqlValue);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
ddbSearch.Visible = false;
|
|
}
|
|
return new DataTable();
|
|
}
|
|
public void bbi_item_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Item != null)
|
|
{
|
|
string[] searchSplits = (e.Item.Tag + "").Split(new char[] { '|', '=' });
|
|
for (int i = 0; i < searchSplits.Length; i += 2)
|
|
{
|
|
string fieldName = searchSplits[i];
|
|
string fieldValue = searchSplits[i + 1];
|
|
SetSearchControlText(fieldName, fieldValue);
|
|
}
|
|
if (SearchButton != null)
|
|
{
|
|
SearchButton.PerformClick();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
public void bbi_manager_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
FrmProject project = new FrmProject();
|
|
project.ModuleId = ModuleId;
|
|
project.OperatorId = LoginId;
|
|
project.PejectTable = dtSearchProject;
|
|
project.ShowDialog();
|
|
|
|
InitSearchProject();
|
|
}
|
|
|
|
public void bbi_save_ItemClick(object sender, ItemClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FrmPrompt prompt = new FrmPrompt();
|
|
if (sender is string) prompt.ProjectName = sender + "";
|
|
DialogResult result = prompt.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
string projectName = prompt.ProjectName;
|
|
string searchValue = GetSearchAllControlText();
|
|
|
|
string sqlValue = string.Format("select 1 from P_SystemReportProjectTab where isnull(ProjectName,'')='{0}' and operatorId='{1}'", projectName, LoginId);
|
|
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count == 0)
|
|
{
|
|
sqlValue = string.Format(@"insert into P_SystemReportProjectTab(OperatorId,OperateDate,ProjectName,ProjectMode,SearchValue,ModuleId)
|
|
values('{0}',getdate(),'{1}','1','{2}','{3}')", LoginId, projectName, searchValue, ModuleId);
|
|
int execResult = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
if (execResult > 0)
|
|
{
|
|
XtraMessageBox.Show("方案保存成功.");
|
|
InitSearchProject();
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("方案保存失败.");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("方案名称重复.");
|
|
bbi_save_ItemClick(projectName, null);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
#region 回车直接搜索
|
|
public void GetTextBox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
b_Click(sender, e);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 搜索时间
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
///
|
|
public void runQuery()
|
|
{
|
|
int oldRowHandle = 0;
|
|
TreeListNode oldNode = null;
|
|
if (gce != null)
|
|
{
|
|
if (gce.MainView is GridView)
|
|
{
|
|
oldRowHandle = (gce.MainView as GridView).FocusedRowHandle;
|
|
}
|
|
else if (gce.MainView is LayoutView)
|
|
{
|
|
oldRowHandle = (gce.MainView as LayoutView).FocusedRowHandle;
|
|
}
|
|
|
|
}
|
|
if (treeList != null)
|
|
{
|
|
oldNode = treeList.FocusedNode;
|
|
}
|
|
|
|
SetSearchSqlValue();
|
|
|
|
if (RememberRow == true)
|
|
{
|
|
if (gce != null)
|
|
{
|
|
if (gce.MainView is GridView)
|
|
{
|
|
(gce.MainView as GridView).ClearSelection();
|
|
if (oldRowHandle >= 0)
|
|
{
|
|
(gce.MainView as GridView).FocusedRowHandle = oldRowHandle;
|
|
(gce.MainView as GridView).SelectRow(oldRowHandle);
|
|
}
|
|
}
|
|
}
|
|
if (treeList != null)
|
|
{
|
|
treeList.SetFocusedNode(oldNode);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 替换查询条件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public string SetSearchSqlValue()
|
|
{
|
|
string sql = string.Empty;
|
|
sql = GetLeftValue(SearchSql);
|
|
sql = GetDefaultValue(sql);
|
|
|
|
if ((SearchButton.Tag != null) && (Convert.ToBoolean(SearchButton.Tag)))
|
|
{
|
|
sql = sql.Replace("#", "");
|
|
}
|
|
else
|
|
{
|
|
sql = Regex.Replace(sql, "#[^##]+#", " 1=1 ");
|
|
}
|
|
|
|
//sql = PubClass.ReqSqlParam(sql, LoginId, LoginName);
|
|
if (SearchSql.IndexOf("exec", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
//解析存储过程
|
|
List<string> list = PubClass.GetParamValue(sql);
|
|
foreach (string item in list)
|
|
{
|
|
string fileName = item.Replace("{", "").Replace("}", "");
|
|
Control[] ctrs = ctr.Controls.Find("txt_" + fileName, true);
|
|
if (ctrs.Length > 0)
|
|
{
|
|
sql = SetReplaceSql(sql, item, ctrs);
|
|
}
|
|
//根据变量寻找单据头组件进行替换
|
|
if (condPanel != null)
|
|
{
|
|
Control[] ctrs1 = condPanel.Controls.Find("txt_" + fileName, true);
|
|
if (ctrs1.Length > 0)
|
|
{
|
|
sql = SetReplaceSql(sql, item, ctrs1);
|
|
}
|
|
}
|
|
}
|
|
ActionSql = sql;
|
|
if (gce != null)
|
|
{
|
|
// 动态列每次查询时改变
|
|
if (IsColumnFix && gridEx != null)
|
|
{
|
|
gridEx.refreshSearchLookUp();
|
|
gridEx.SetDataSource(ActionSql, IsColumnFix);
|
|
}
|
|
else
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
if (gridEx!=null)
|
|
gridEx.refreshSearchLookUp();
|
|
gce.DataSource = dt;
|
|
}
|
|
}
|
|
if (treeList != null)
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
treeList.DataSource = dt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
StringBuilder strWhere = new StringBuilder();
|
|
foreach (DataRow dr in condDt.Rows)
|
|
{
|
|
string cond = dr["checkCond"] + "";
|
|
if (!string.IsNullOrEmpty(cond))
|
|
{
|
|
string fileName = dr["controlName"].ToString().Replace("{", "").Replace("}", "");
|
|
Control[] ctrs = ctr.Controls.Find("txt_" + fileName, true);
|
|
if (ctrs.Length > 0)
|
|
{
|
|
string strValue = SetReplaceSqlValue(cond, ctrs) + " ";
|
|
if (sql.IndexOf("{&", StringComparison.OrdinalIgnoreCase) != -1)
|
|
sql = sql.Replace("{&" + fileName + "}", strValue);
|
|
else
|
|
{
|
|
if (sql.IndexOf("{") != -1)
|
|
{
|
|
sql = SetReplaceSql(sql, "{" + fileName + "}", ctrs);
|
|
}
|
|
strWhere.Append(strValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
List<string> list = PubClass.GetParamValue(sql);
|
|
foreach (string item in list)
|
|
{
|
|
string fileName = item.Replace("{", "").Replace("}", "");
|
|
Control[] ctrs = ctr.Controls.Find("txt_" + fileName, true);
|
|
if (ctrs.Length > 0)
|
|
{
|
|
sql = SetReplaceSql(sql, item, ctrs);
|
|
}
|
|
|
|
//根据变量寻找单据头组件进行替换
|
|
if (condPanel != null)
|
|
{
|
|
Control[] ctrs1 = condPanel.Controls.Find("txt_" + fileName, true);
|
|
if (ctrs1.Length > 0)
|
|
{
|
|
sql = SetReplaceSql(sql, item, ctrs1);
|
|
}
|
|
}
|
|
}
|
|
sql = GetDefaultValue(sql + strWhere.ToString());
|
|
ActionSql = sql;
|
|
Check_Cond = strWhere + "";
|
|
if (gce != null)
|
|
{
|
|
// 动态列每次查询时改变
|
|
if (IsColumnFix && gridEx != null)
|
|
{
|
|
gridEx.refreshSearchLookUp();
|
|
gridEx.SetDataSource(ActionSql);
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
if (gridEx != null)
|
|
gridEx.refreshSearchLookUp();
|
|
gce.DataSource = dt;
|
|
}
|
|
catch(Exception ex){
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
}
|
|
if (treeList != null)
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
treeList.DataSource = dt;
|
|
}
|
|
}
|
|
|
|
return sql;
|
|
}
|
|
protected void b_Click(object sender, EventArgs e)
|
|
{
|
|
runQuery();
|
|
//查询完回调自定义事件
|
|
if (onSearchClick != null)
|
|
{
|
|
onSearchClick(sender, e);
|
|
}
|
|
}
|
|
|
|
private static string SetReplaceSqlValue(string sql, Control[] ctrs)
|
|
{
|
|
string item = "{value}";
|
|
Control c = ctrs[0];
|
|
ControlModelTag cmTag = c.Tag as ControlModelTag;
|
|
if (cmTag.fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
LabelCheckComboxEx lab = c as LabelCheckComboxEx;
|
|
string vaule = lab.getComboBox.SelectedValue + "";
|
|
if (lab.getComboBox.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckComboxText)
|
|
{
|
|
LabelCheckComboxEx lab = c as LabelCheckComboxEx;
|
|
string vaule = lab.getComboBox.Text + "";
|
|
if (lab.getComboBox.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckDateEx ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckDateTimeEx ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckDateTimeShort ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckTime ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckShortTime)
|
|
{
|
|
LabelCheckDateEx lab = c as LabelCheckDateEx;
|
|
string vaule = lab.GetDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (lab.GetDateTimePicker.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckAutoSeacherText)
|
|
{
|
|
LabelCheckAutoSearcherEx lab = c as LabelCheckAutoSearcherEx;
|
|
string vaule = lab.GetAutoSearcher.Text + "";
|
|
if (lab.GetAutoSearcher.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckAutoSeacherValue)
|
|
{
|
|
LabelCheckAutoSearcherEx lab = c as LabelCheckAutoSearcherEx;
|
|
string vaule = lab.GetAutoSearcher.ReturnValue + "";
|
|
if (lab.GetAutoSearcher.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabDate ||
|
|
cmTag.fieldTypeId == ControlType.LabDateTime ||
|
|
cmTag.fieldTypeId == ControlType.LabDateTimeShort ||
|
|
cmTag.fieldTypeId == ControlType.LabTime ||
|
|
cmTag.fieldTypeId == ControlType.LabShortTime)
|
|
{
|
|
LabelDateEx lab = c as LabelDateEx;
|
|
string vaule = lab.GetDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (lab.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabComboxValue)
|
|
{
|
|
LabelComboxEx lab = c as LabelComboxEx;
|
|
string vaule = lab.getComboBox.SelectedValue + "";
|
|
if (lab.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabAutoSeacherValue)
|
|
{
|
|
AutoSearcher lab = c as AutoSearcher;
|
|
string vaule = lab.ReturnValue;
|
|
if (lab.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabMultiSelectValue)
|
|
{
|
|
LabelLookUp lookup = c as LabelLookUp;
|
|
string value = lookup.ReturnValue;
|
|
if (value + "" != "")
|
|
sql = sql.Replace(item, value);
|
|
else
|
|
sql = string.Empty;
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace(item, ctrs[0].Text);
|
|
}
|
|
return sql;
|
|
}
|
|
|
|
private static string SetReplaceOtherValue(string sql, string item, string[] paramValues)
|
|
{
|
|
string result = "";
|
|
string idx = sql.Substring(sql.IndexOf("#p_") + 4, 2);
|
|
int i = 0;
|
|
if (int.TryParse(idx, out i))
|
|
{
|
|
result = result.Replace(result, paramValues[i]);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static string SetReplaceSql(string sql, string item, Control[] ctrs)
|
|
{
|
|
//MessageBox.Show(sql, item);
|
|
Control c = ctrs[0];
|
|
ControlModelTag cmTag = c.Tag as ControlModelTag;
|
|
if (cmTag.fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
LabelCheckComboxEx lab = c as LabelCheckComboxEx;
|
|
string vaule = lab.getComboBox.SelectedValue + "";
|
|
if (lab.getComboBox.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabComboxValue)
|
|
{
|
|
LabelComboxEx lab = c as LabelComboxEx;
|
|
string vaule = lab.getComboBox.SelectedValue + "";
|
|
if (lab.getComboBox.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckComboxText)
|
|
{
|
|
LabelCheckComboxEx lab = c as LabelCheckComboxEx;
|
|
string vaule = lab.getComboBox.Text + "";
|
|
if (lab.getComboBox.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckDateEx ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckDateTimeEx ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckDateTimeShort ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckTime ||
|
|
cmTag.fieldTypeId == ControlType.LabCheckShortTime)
|
|
{
|
|
LabelCheckDateEx lab = c as LabelCheckDateEx;
|
|
string vaule = lab.GetDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
if (lab.GetDateTimePicker.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckAutoSeacherText)
|
|
{
|
|
LabelCheckAutoSearcherEx lab = c as LabelCheckAutoSearcherEx;
|
|
string vaule = lab.GetAutoSearcher.Text + "";
|
|
if (lab.GetAutoSearcher.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabCheckAutoSeacherValue)
|
|
{
|
|
LabelCheckAutoSearcherEx lab = c as LabelCheckAutoSearcherEx;
|
|
string vaule = lab.GetAutoSearcher.ReturnValue + "";
|
|
if (lab.GetAutoSearcher.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if ((cmTag.fieldTypeId == ControlType.LabAutoSeacherValue) || (cmTag.fieldTypeId == ControlType.LabComboxValueParam))
|
|
{
|
|
AutoSearcher lab = c as AutoSearcher;
|
|
string vaule = lab.ReturnValue + "";
|
|
if (vaule == "")
|
|
vaule = "0";
|
|
if (lab.Enabled)
|
|
sql = sql.Replace(item, vaule);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else if ((cmTag.fieldTypeId == ControlType.LabMultiSelectValue) || (cmTag.fieldTypeId == ControlType.LabMultiSelectValueParam))
|
|
{
|
|
LabelLookUp lab = c as LabelLookUp;
|
|
string value = lab.ReturnValue;
|
|
if (lab.Enabled)
|
|
sql = sql.Replace(item, value);
|
|
else
|
|
sql = sql.Replace(item, "");
|
|
}
|
|
else
|
|
{
|
|
sql = sql.Replace(item, ctrs[0].Text);
|
|
}
|
|
return sql;
|
|
}
|
|
|
|
public string GetLeftValue(string sql)
|
|
{
|
|
if (string.IsNullOrEmpty(sql)) return sql;
|
|
if (dllType == DLLType.DllLeftTree && tvLeft != null)
|
|
{
|
|
TreeNode tn = tvLeft.GetTreeView.SelectedNode;
|
|
if (tn == null)
|
|
tn = tvLeft.GetTreeView.Nodes[0];
|
|
|
|
if (tvLeftDataRow == null)
|
|
tvLeftDataRow = tvLeft.Tag as DataRow;
|
|
string ids = string.Empty;
|
|
if (!sql.ToUpper().Contains("EXEC"))
|
|
{
|
|
ids = tvLeft.GetCheckValues();
|
|
sql = PubClass.ReplaceWhereCond(sql);
|
|
if (!string.IsNullOrEmpty(ids))
|
|
sql += " and " + tvLeftDataRow["fieldname"] + " in (" + ids.Trim(',') + ")";
|
|
else
|
|
{
|
|
if (tvLeft.GetTreeView.Focused)
|
|
sql += " and " + tvLeftDataRow["fieldname"] + " like '" + tn.Name + "%'";
|
|
else
|
|
sql += "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ids = tvLeft.GetCheckValuesWithNoQuote();
|
|
if (ids.Trim() == "")
|
|
ids = tn.Name;
|
|
}
|
|
if (sql.IndexOf("{parent.key}", StringComparison.OrdinalIgnoreCase) != -1)
|
|
sql = sql.Replace("{parent.key}", ids.Replace("'", "") + "");
|
|
}
|
|
else if (dllType == DLLType.DllLeftGrid && gcLeft != null)
|
|
{
|
|
GridView gv = gcLeft.DefaultView as GridView;
|
|
int[] rows = gv.GetSelectedRows();
|
|
if (rows.Length > 0)
|
|
{
|
|
if (tvLeftDataRow == null)
|
|
tvLeftDataRow = tvLeft.Tag as DataRow;
|
|
DataRow row = gv.GetDataRow(rows[0]);
|
|
if (sql.IndexOf("{parent.key}", StringComparison.OrdinalIgnoreCase) != -1)
|
|
sql = sql.Replace("{parent.key}", row[LeftGridSqlTag] + "");
|
|
else if (!sql.ToUpper().Contains("EXEC"))
|
|
{
|
|
sql = PubClass.ReplaceWhereCond(sql);
|
|
sql += " and " + tvLeftDataRow["fieldname"] + "='" + row[LeftGridSqlTag] + "'";
|
|
}
|
|
}
|
|
}
|
|
return sql;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置控件值
|
|
/// </summary>
|
|
/// <param name="fieldName"></param>
|
|
/// <param name="fieldValue"></param>
|
|
public void SetSearchControlText(string fieldName, string fieldValue)
|
|
{
|
|
try
|
|
{
|
|
Control[] ctrs = ctr.Controls.Find("txt_" + fieldName, true);
|
|
if (ctrs != null && ctrs.Length > 0)
|
|
{
|
|
Control control = ctrs[0];
|
|
ControlModelTag cmTag = control.Tag as ControlModelTag;
|
|
if (cmTag == null) return;
|
|
int fieldTypeId = cmTag.fieldTypeId;
|
|
//日期
|
|
if (fieldTypeId == ControlType.LabDate ||
|
|
fieldTypeId == ControlType.LabDateTime ||
|
|
fieldTypeId == ControlType.LabDateTimeShort ||
|
|
fieldTypeId == ControlType.LabTime ||
|
|
fieldTypeId == ControlType.LabShortTime)
|
|
{
|
|
LabelDateEx labelText = control as LabelDateEx;
|
|
labelText.Text = GetDefaultValue(fieldValue);
|
|
}
|
|
//文本
|
|
else if (fieldTypeId == ControlType.LabText || fieldTypeId == ControlType.LabTextInt)
|
|
{
|
|
LabelTextEx labelText = control as LabelTextEx;
|
|
labelText.Text = fieldValue;
|
|
}
|
|
//下拉框
|
|
else if (fieldTypeId == ControlType.LabComboxValue || fieldTypeId == ControlType.LabComboxText)
|
|
{
|
|
LabelComboxEx labelText = control as LabelComboxEx;
|
|
if (fieldTypeId == ControlType.LabComboxValue)
|
|
{
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
labelText.getComboBox.SelectedValue = fieldValue;
|
|
}
|
|
else
|
|
{
|
|
labelText.getComboBox.Text = "";
|
|
labelText.getComboBox.SelectedValue = "";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
labelText.getComboBox.Text = "";
|
|
}
|
|
else
|
|
{
|
|
labelText.Text = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
//自动搜索
|
|
else if (fieldTypeId == ControlType.LabAutoSeacherValue
|
|
|| fieldTypeId == ControlType.LabAutoSeacherText)
|
|
{
|
|
LabelAutoSearcherEx autSearch = control as LabelAutoSearcherEx;
|
|
if (fieldTypeId == ControlType.LabAutoSeacherValue)
|
|
autSearch.GetAutoSearcher.SetValueSilent(fieldValue, "");
|
|
else
|
|
autSearch.GetAutoSearcher.SetValueSilent("", fieldValue);
|
|
}
|
|
//创建文本域
|
|
else if (fieldTypeId == ControlType.LabRemark)
|
|
{
|
|
LabelTextarea labelText = control as LabelTextarea;
|
|
labelText.Text = fieldValue;
|
|
}
|
|
else if (fieldTypeId == ControlType.LabCheckDateEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeEx ||
|
|
fieldTypeId == ControlType.LabCheckDateTimeShort ||
|
|
fieldTypeId == ControlType.LabCheckTime ||
|
|
fieldTypeId == ControlType.LabCheckShortTime)
|
|
{
|
|
LabelCheckDateEx labelText = control as LabelCheckDateEx;
|
|
labelText.Text = fieldValue;
|
|
}
|
|
//多选控件
|
|
else if ((fieldTypeId == ControlType.LabMultiSelectText) || (fieldTypeId == ControlType.LabMultiSelectValue))
|
|
{
|
|
LabelLookUp labelLookup = control as LabelLookUp;
|
|
if (fieldTypeId == ControlType.LabMultiSelectValue)
|
|
{
|
|
labelLookup.SetValueText(fieldValue);
|
|
}
|
|
else
|
|
{
|
|
labelLookup.SetTextValue(fieldValue);
|
|
}
|
|
}
|
|
//下拉框
|
|
else if (fieldTypeId == ControlType.LabCheckComboxText
|
|
|| fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
LabelCheckComboxEx labelText = control as LabelCheckComboxEx;
|
|
if (fieldTypeId == ControlType.LabCheckComboxValue)
|
|
{
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
labelText.getComboBox.SelectedValue = fieldValue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
labelText.Text = fieldValue;
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(labelText.Text))
|
|
{
|
|
labelText.SetEnabled(true);
|
|
}
|
|
}
|
|
//自动搜索
|
|
else if (fieldTypeId == ControlType.LabCheckAutoSeacherValue
|
|
|| fieldTypeId == ControlType.LabCheckAutoSeacherText)
|
|
{
|
|
LabelCheckAutoSearcherEx autSearch = control as LabelCheckAutoSearcherEx;
|
|
if (fieldTypeId == ControlType.LabCheckAutoSeacherValue)
|
|
autSearch.GetAutoSearcher.SetValueSilent(fieldValue, "");
|
|
else
|
|
autSearch.GetAutoSearcher.SetValueSilent("", fieldValue);
|
|
if (!string.IsNullOrEmpty(autSearch.Text))
|
|
{
|
|
autSearch.SetEnabled(true);
|
|
}
|
|
}
|
|
//文本
|
|
else
|
|
{
|
|
LabelTextEx labelText = control as LabelTextEx;
|
|
labelText.Text = fieldValue;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
public string GetSearchControlText(string fieldName)
|
|
{
|
|
Control[] ctrs = ctr.Controls.Find("txt_" + fieldName, true);
|
|
if (ctrs != null && ctrs.Length > 0)
|
|
{
|
|
Control control = ctrs[0];
|
|
ControlModelTag cmTag = control.Tag as ControlModelTag;
|
|
if (cmTag == null)
|
|
return control.Text;
|
|
if (cmTag.fieldTypeId == ControlType.LabAutoSeacherText)
|
|
{
|
|
return control.Text;
|
|
}
|
|
else if ((cmTag.fieldTypeId == ControlType.LabAutoSeacherValue) ||
|
|
(cmTag.fieldTypeId == ControlType.LabComboxValueParam))
|
|
{
|
|
AutoSearcher te = control as AutoSearcher;
|
|
|
|
return te.ReturnValue.ToString();
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabComboxValue)
|
|
{
|
|
LabelComboxEx Cb = control as LabelComboxEx;
|
|
return Cb.getComboBox.SelectedValue + "";
|
|
}
|
|
else if ((cmTag.fieldTypeId == ControlType.LabComboxCheckListValue) || (cmTag.fieldTypeId == ControlType.LabComboxCheckListText))
|
|
{
|
|
LabelComboCheckList Cb = control as LabelComboCheckList;
|
|
string retValue = Cb.getComboBox.EditValue + "";
|
|
retValue = retValue.Replace(", ", ",");
|
|
return Cb.getComboBox.EditValue + "";
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabComboxText)
|
|
{
|
|
LabelComboxEx Cb = control as LabelComboxEx;
|
|
return Cb.getComboBox.Text;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabDate ||
|
|
cmTag.fieldTypeId == ControlType.LabDateTime ||
|
|
cmTag.fieldTypeId == ControlType.LabDateTimeShort ||
|
|
cmTag.fieldTypeId == ControlType.LabTime ||
|
|
cmTag.fieldTypeId == ControlType.LabShortTime)
|
|
{
|
|
LabelDateEx Cb = control as LabelDateEx;
|
|
return Cb.GetDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabTextInt)
|
|
{
|
|
if ((control.Text.Trim() == ""))
|
|
return "0";
|
|
else
|
|
return control.Text;
|
|
}
|
|
else if (cmTag.fieldTypeId == ControlType.LabMultiSelectValue)
|
|
{
|
|
LabelLookUp lookup = control as LabelLookUp;
|
|
return lookup.ReturnValue;
|
|
}
|
|
else
|
|
{
|
|
if (cmTag.fieldTypeId != 99)
|
|
{
|
|
return control.Text;
|
|
}
|
|
}
|
|
return "0";
|
|
}
|
|
return fieldName;
|
|
}
|
|
|
|
public string GetSearchAllControlText()
|
|
{
|
|
string searchValue = string.Empty;
|
|
if (ccModel != null)
|
|
{
|
|
foreach (DataRow item in ccModel.dt.Rows)
|
|
{
|
|
string fieldName = item["fieldName"] + "";
|
|
searchValue += fieldName + "=" + GetSearchControlText(fieldName) + "|";
|
|
}
|
|
}
|
|
return searchValue.TrimEnd('|');
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取默认值
|
|
/// </summary>
|
|
/// <param name="defaultValue"></param>
|
|
/// <returns></returns>
|
|
public string GetDefaultValue(string defaultValue)
|
|
{
|
|
string result = defaultValue;
|
|
if (defaultValue.IndexOf("loginid", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
List<string> list = PubClass.GetParamValue(defaultValue);
|
|
foreach (string s in list)
|
|
{
|
|
if (s.IndexOf("loginid", StringComparison.OrdinalIgnoreCase) != -1)
|
|
result = result.Replace(s, LoginId);
|
|
}
|
|
}
|
|
if (defaultValue.IndexOf("loginname", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
List<string> list = PubClass.GetParamValue(defaultValue);
|
|
foreach (string s in list)
|
|
{
|
|
if (s.IndexOf("loginname", StringComparison.OrdinalIgnoreCase) != -1)
|
|
result = result.Replace(s, LoginName);
|
|
}
|
|
}
|
|
if (defaultValue.IndexOf("groupid", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
List<string> list = PubClass.GetParamValue(defaultValue);
|
|
foreach (string s in list)
|
|
{
|
|
if (s.IndexOf("groupid", StringComparison.OrdinalIgnoreCase) != -1)
|
|
result = result.Replace(s, ERPInfo.Instance.GroupId);
|
|
}
|
|
}
|
|
if (result.IndexOf("{guid}", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
result = Guid.NewGuid().ToString();
|
|
}
|
|
if (result.IndexOf('@') != -1)
|
|
{
|
|
object obj = SqlHelper.ExecuteScalar(CommandType.Text, result.Replace("@", ""));
|
|
if (obj != null)
|
|
{
|
|
result = obj.ToString();
|
|
}
|
|
}
|
|
//代表传入其他参数格式{#p_1},{#p_2}..
|
|
if (defaultValue.IndexOf("#p_", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
if (otherParams == null)
|
|
return "";
|
|
List<string> list = PubClass.GetParamValue(defaultValue);
|
|
foreach (string s in list)
|
|
{
|
|
string idx = s.Replace("{#p_", "").Replace("}", "");
|
|
int i = 0;
|
|
if (int.TryParse(idx, out i))
|
|
{
|
|
result = result.Replace(s, otherParams[i - 1]);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
private void myctr_CloseUp(object sender, EventArgs e)
|
|
{
|
|
if (sender is DateTimePicker)
|
|
{
|
|
var picker = (sender as DateTimePicker);
|
|
picker.CustomFormat = picker.Tag != null
|
|
? (picker.Tag as ControlModelTag).DateFormat
|
|
: "yyyy-MM-dd";
|
|
string date = picker.Value.ToString("yyyy-MM-dd");
|
|
picker.Value = DateTime.Parse(date);
|
|
}
|
|
}
|
|
private void myctr_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
|
|
{
|
|
if (sender is DateTimePicker)
|
|
{
|
|
var picker = (sender as DateTimePicker);
|
|
if (e.KeyCode == Keys.Delete)
|
|
{
|
|
picker.CustomFormat = " ";
|
|
}
|
|
else
|
|
{
|
|
if (PubClass.HasNumerCode((int)e.KeyCode))
|
|
{
|
|
picker.CustomFormat = picker.Tag != null
|
|
? (picker.Tag as ControlModelTag).DateFormat
|
|
: "yyyy-MM-dd";
|
|
}
|
|
}
|
|
}
|
|
if (!(sender is AutoSearcher))
|
|
{
|
|
if (e.KeyCode == Keys.Return)
|
|
{
|
|
Control ctl = (sender as Control).Parent.Parent;
|
|
if (ctl != null)
|
|
ctl.Parent.SelectNextControl(ctl, true, false, true, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|