1168 lines
48 KiB
C#
1168 lines
48 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using ExcelPlus;
|
|
using Lskj.Common;
|
|
using CommonLib;
|
|
using CommonLib.utils;
|
|
using DevExpress.XtraEditors;
|
|
using Lskj.MyControl;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraGrid;
|
|
using DevExpress.Utils;
|
|
using System.Data.SqlClient;
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
|
namespace Lskj.PubPageModuleDetail
|
|
{
|
|
public partial class TabPageMaster : UserControl
|
|
{
|
|
/// <summary>
|
|
/// 模块ID、模块名称、操作员ID、操作员名称、权限、模块ID、表名
|
|
/// </summary>
|
|
private string DLLCoid, FormText, Privilege, ModuleId, OperatorId, OperatorName, PrimaryKey;
|
|
/// <summary>
|
|
/// 表格颜色
|
|
/// </summary>
|
|
private DataTable mGridColorList;
|
|
private DataTable mGridSum;
|
|
private DataRow mSystemRow;
|
|
private DataRow[] mNullableFields;
|
|
private string mAddCond, mModifyCond, mDeleteCond, mDragCond, mTableName;
|
|
private string mTreeTags; // 选中的数节点数据
|
|
private int mSearchHide;
|
|
private int mSeearchMode; // 查询模式,1.查询条件,2.下拉列表查询
|
|
private int mLeftType;
|
|
/// <summary>
|
|
/// 表格是否可以编辑
|
|
/// </summary>
|
|
private bool mGridEdited;
|
|
private bool mNeedModify;
|
|
/// <summary>
|
|
/// 是否为点击查询按钮获取数据
|
|
/// </summary>
|
|
public bool mIsSearch = true;
|
|
private bool inSummary = false;
|
|
|
|
public DataRow drLeft;
|
|
public MySearchCreateControl mcc = new MySearchCreateControl();
|
|
public MySearchCreateControl mccTop = new MySearchCreateControl();
|
|
public string BeforeSearchSQL;
|
|
|
|
public TreeViewEx tvLeft; // 左侧树
|
|
public GridView GridViewLeft; // 左侧表格
|
|
/// <summary>
|
|
/// DbDataAdapter
|
|
/// </summary>
|
|
private SqlDataAdapter GridAdapter { get; set; }
|
|
/// <summary>
|
|
/// 操作Dataset
|
|
/// </summary>
|
|
private DataSet GridDataSet { get; set; }
|
|
public DataTable dtColumns;
|
|
public GridControlEx GetGridControl;
|
|
public GridControl GridLeftEx;
|
|
|
|
#region 初始化
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
/// <param name="DLLCoid">模块编号</param>
|
|
/// <param name="FormText">模块名称</param>
|
|
/// <param name="OperatorId">操作员ID</param>
|
|
/// <param name="OperatorName">操作员名称</param>
|
|
/// <param name="Privilege">权限</param>
|
|
/// <param name="ModuleId">模块ID</param>
|
|
/// <param name="TableName">表名</param>
|
|
public TabPageMaster(string DLLCoid, string FormText, string OperatorId, string OperatorName, string Privilege, string ModuleId, string PrimaryKey)
|
|
{
|
|
this.DLLCoid = DLLCoid;
|
|
this.FormText = FormText;
|
|
this.Privilege = Privilege;
|
|
this.ModuleId = ModuleId;
|
|
this.PrimaryKey = PrimaryKey;
|
|
this.OperatorId = OperatorId;
|
|
this.OperatorName = OperatorName;
|
|
this.GetGridControl = gcMain;
|
|
this.GridDataSet = new DataSet();
|
|
|
|
DevExpress.XtraGrid.Localization.GridResLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraGridCHS();
|
|
DevExpress.XtraEditors.Controls.Localizer.Active = new Dxper.LocalizationCHS.Win.XtraEditorsCHS();
|
|
DevExpress.XtraLayout.Localization.LayoutLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraLayoutCHS();
|
|
DevExpress.XtraPrinting.Localization.PreviewLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraPrintingCHS();
|
|
|
|
InitializeComponent();
|
|
|
|
gcMain.gridView.IndicatorWidth = 40;
|
|
gcMain.gridView.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
|
gcMain.gridView.RowStyle += new RowStyleEventHandler(gridView_RowStyle);
|
|
gcMain.gridView.ShowingEditor += new CancelEventHandler(gridView_ShowingEditor);
|
|
gcMain.gridView.DoubleClick += new EventHandler(gridView_DoubleClick);
|
|
gcMain.gridView.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridView_CellValueChanged);
|
|
}
|
|
/// <summary>
|
|
/// 初始化数据
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
mSystemRow = SqlHelper.ExecuteDataSet(string.Format("select * from P_systemDlltab where DLLCoid='{0}'", DLLCoid)).Tables[0].Rows[0];
|
|
mGridColorList = SqlHelper.ExecuteDataSet(string.Format("select * from P_systemwordbookcolor where tab='{0}' and useflag=0 order by orderid", DLLCoid)).Tables[0];
|
|
|
|
mSystemRow["SQL"] = PubClass.ReqSqlParam(mSystemRow["SQL"] + "", OperatorId, OperatorName);
|
|
|
|
// 处理表格是否可以编辑
|
|
mNeedModify = mSystemRow["modifyEnable"] + "" == "1";
|
|
mGridEdited = (string.IsNullOrEmpty(mSystemRow["selfEdit"] + "") || mSystemRow["selfEdit"] + "" == "0" || mSystemRow["selfEdit"] + "" == "False") ? false : true;
|
|
gcMain.gridView.OptionsBehavior.Editable = mGridEdited;
|
|
btnSave.Enabled = mGridEdited;
|
|
|
|
mAddCond = mSystemRow["addCond"]+"";
|
|
mModifyCond = mSystemRow["modifyCond"]+"";
|
|
mDeleteCond = mSystemRow["deleteCond"]+"";
|
|
mDragCond = mSystemRow["dragCond"]+"";
|
|
mTableName = mSystemRow["SQLDT1"] + "";
|
|
mSearchHide = Convert.ToInt32(mSystemRow["searchHide"]+"");
|
|
mLeftType = Convert.ToInt32(mSystemRow["dllType"]);
|
|
pl_search.Visible = mSearchHide != 1;
|
|
|
|
//模板添加删除修改导入导出
|
|
btnAdd.Enabled = mSystemRow["addEnable"]+"" == "1";
|
|
btnDelete.Enabled = mSystemRow["deleteEnable"]+"" == "1";
|
|
btnSave.Enabled = mSystemRow["modifyEnable"] + "" == "1" && mGridEdited;
|
|
gcMain.gridView.OptionsBehavior.Editable = mSystemRow["modifyEnable"] + "" == "1" && mGridEdited;
|
|
btnImprt.Enabled = mSystemRow["importEnable"]+"" == "1";
|
|
btnExport.Enabled = mSystemRow["exportEnable"]+"" == "1";
|
|
|
|
btnCondSearch.Enabled = mSystemRow["searchEnable"]+"" == "1";
|
|
cbField.Enabled = mSystemRow["searchEnable"]+"" == "1";
|
|
txtKey.Enabled = mSystemRow["searchEnable"]+"" == "1";
|
|
|
|
// 隐藏操作条
|
|
if (!btnAdd.Enabled && !btnDelete.Enabled && !btnSave.Enabled)
|
|
{
|
|
pl_down.Visible = false;
|
|
}
|
|
|
|
// 加载筛选框
|
|
DataTable cbSearchFiled = SqlHelper.ExecuteDataSet("select username1,fieldname from P_systemwordbooktab where tab='" + DLLCoid + "' and ifSearch =0 and isnull(username1,'')<>''").Tables[0];
|
|
cbField.DataSource = cbSearchFiled;
|
|
cbField.DisplayMember = "username1";
|
|
cbField.ValueMember = "fieldname";
|
|
|
|
// 查询统计列
|
|
string isSumSql = "select * from p_systemwordbooktab where tab='" + DLLCoid + "' and isnull(vislble,0)=0 and isnull(calcExpr,'')<>''order by calcOrder asc";
|
|
mGridSum = SqlHelper.ExecuteDataSet(isSumSql).Tables[0];
|
|
|
|
this.InitColumns();
|
|
this.InitMenu();
|
|
this.SearchData();
|
|
}
|
|
#endregion
|
|
|
|
#region 基础操作
|
|
/// <summary>
|
|
/// 导入
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnImprt_Click(object sender, EventArgs e)
|
|
{
|
|
frmImport frm = new frmImport(gcMain.gridControl, mTableName);
|
|
frm.ShowDialog();
|
|
}
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnExport_Click(object sender, EventArgs e)
|
|
{
|
|
PubClass.SaveXls(gcMain.gridControl);
|
|
}
|
|
/// <summary>
|
|
/// 帮助文档
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnHelp_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(DLLCoid))
|
|
{
|
|
XtraMessageBox.Show("物料编码不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
return;
|
|
}
|
|
int id = 0;
|
|
object obj = SqlHelper.ExecuteScalar(CommandType.Text, "select dirid from P_fm_DirectoryTab where ParentId=3 and PID='" + DLLCoid + "'");
|
|
id = obj == null ? 0 : Convert.ToInt32(obj);
|
|
if (id == 0)
|
|
{
|
|
string sql = "insert into P_fm_DirectoryTab (sName,ParentId,creator,SpeciesNo,relationCode,PID) values('" + DLLCoid + "',3,1,'0201',0,'" + DLLCoid + "');select @@identity";
|
|
id = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sql));
|
|
}
|
|
string[] args =
|
|
{
|
|
FormText,
|
|
OperatorId,
|
|
OperatorName,
|
|
Privilege,
|
|
DLLCoid,
|
|
ModuleId,
|
|
id+""
|
|
};
|
|
IForm form = PubUtil.LoadDllForm2("Lskj.Attachment.dll", args);
|
|
form.SubForm.ShowDialog();
|
|
}
|
|
/// <summary>
|
|
/// 添加数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnAdd_Click(object sender, EventArgs e)
|
|
{
|
|
string fieldsqlid = string.Empty;
|
|
string fieldsqlname = string.Empty;
|
|
string strTag = string.Empty;
|
|
string jsonData = string.Empty;
|
|
|
|
if (!string.IsNullOrEmpty(mSystemRow["AddDllName"] + ""))
|
|
{
|
|
if (mLeftType == 1)
|
|
{
|
|
if (tvLeft.GetTreeView.SelectedNode == null)
|
|
{
|
|
XtraMessageBox.Show("请选择类别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
if (tvLeft.GetTreeView.SelectedNode.Nodes.Count > 0)
|
|
{
|
|
XtraMessageBox.Show("请选择根级节点", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
String bllNO = PubClass.GetBillNo(tvLeft.GetTreeView.SelectedNode.Tag + "", DLLCoid);
|
|
if (string.IsNullOrEmpty(bllNO))
|
|
{
|
|
XtraMessageBox.Show("请修改编码前缀", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
|
|
return;
|
|
}
|
|
fieldsqlid = tvLeft.GetTreeView.SelectedNode.Name;
|
|
fieldsqlname = tvLeft.GetTreeView.SelectedNode.Text;
|
|
strTag = tvLeft.GetTreeView.SelectedNode.Tag + "";
|
|
}
|
|
else if (mLeftType == 2)
|
|
{
|
|
int[] rows = GridViewLeft.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
{
|
|
XtraMessageBox.Show("请选择类别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
DataRow row = GridViewLeft.GetDataRow(rows[0]);
|
|
fieldsqlid = row[drLeft["fieldsqlid"] + ""] + "";
|
|
fieldsqlname = row[drLeft["fieldsqlname"] + ""] + "";
|
|
|
|
DataTable dtGcHeader = GridLeftEx.DataSource as DataTable;
|
|
if (dtGcHeader != null && dtGcHeader.Rows.Count > 0)
|
|
{
|
|
DataTable dtTemp = dtGcHeader.Clone();
|
|
dtTemp.ImportRow(row);
|
|
jsonData = dtTemp.ToJson();
|
|
}
|
|
}
|
|
|
|
string[] args = {
|
|
FormText,
|
|
OperatorId,
|
|
OperatorName,
|
|
Privilege,
|
|
DLLCoid,
|
|
"",
|
|
"",
|
|
"",
|
|
fieldsqlid,
|
|
fieldsqlname,
|
|
strTag,
|
|
"",
|
|
"",
|
|
"",
|
|
jsonData
|
|
};
|
|
IForm form = PubUtil.LoadDllForm(mSystemRow["AddDllName"] + "", args);
|
|
DialogResult result = form.SubForm.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
if (string.IsNullOrEmpty(BeforeSearchSQL))
|
|
{
|
|
InitData(PubClass.ReplaceWhereCond(BeforeSearchSQL));
|
|
}
|
|
else
|
|
{
|
|
Control[] ctr = pl_search.Controls.Find("btnCondSearch", true);
|
|
if ((ctr == null) || (ctr.Length < 1))
|
|
{
|
|
if (!string.IsNullOrEmpty(BeforeSearchSQL))
|
|
InitData(BeforeSearchSQL);
|
|
}
|
|
else
|
|
{
|
|
(ctr[0] as SimpleButton).PerformClick();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (mLeftType == 1)
|
|
{
|
|
TreeNode treeNode = tvLeft.GetTreeView.SelectedNode;
|
|
if (treeNode != null && treeNode.Nodes.Count > 0)
|
|
{
|
|
XtraMessageBox.Show("请选中末级节点!");
|
|
return;
|
|
}
|
|
}
|
|
AddRow(gcMain.gridView);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnDelete_Click(object sender, EventArgs e)
|
|
{
|
|
string noDeleteIds = string.Empty;
|
|
int[] rowid = gcMain.gridView.GetSelectedRows();
|
|
if (rowid.Length == 0)
|
|
{
|
|
XtraMessageBox.Show("没有选择要删除数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
|
|
if (XtraMessageBox.Show("您确定要删除选中 " + rowid.Length + "条 记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
string ids = string.Empty;
|
|
foreach (int rid in rowid)
|
|
{
|
|
DataRow dr = gcMain.gridView.GetDataRow(rid);
|
|
//判断删除条件是否符合
|
|
Boolean canDelete = string.IsNullOrEmpty(mDeleteCond);
|
|
string tempCond = mDeleteCond;
|
|
if (!canDelete)
|
|
{
|
|
tempCond = PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName);
|
|
tempCond = PubClass.ReqSqlWhere(dr, tempCond);
|
|
canDelete = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
|
}
|
|
if (canDelete)
|
|
{
|
|
//删除检查
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
|
new SqlParameter("@keyvalue",SqlDbType.VarChar,40),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = DLLCoid;
|
|
param[1].Value = dr[PrimaryKey];
|
|
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_VerifyCanDelete", "baseSave", param);
|
|
string msg = pMsg.Value.ToString();
|
|
int rVaule = Convert.ToInt32(returnValue.Value.ToString());
|
|
if (rVaule == 1)
|
|
{
|
|
ids += "'" + dr[PrimaryKey] + "',";
|
|
}
|
|
else
|
|
{
|
|
noDeleteIds += dr[PrimaryKey] + " >> " + msg + "\n";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
noDeleteIds += dr[PrimaryKey] + " >>不符删除合条件\n";
|
|
}
|
|
}
|
|
if (ids != string.Empty)
|
|
{
|
|
string sql = "delete from " + mSystemRow["SQLDT1"] + " where " + PrimaryKey + " in(" + ids.Trim(',') + ")";
|
|
SqlHelper.ExecuteNonQuery(sql);
|
|
//InitData(MyNotBmpSql);
|
|
// 移除表格选中数据
|
|
gcMain.gridView.DeleteSelectedRows();
|
|
string strHint = "记录删除成功";
|
|
if (!string.IsNullOrEmpty(noDeleteIds))
|
|
strHint = strHint + ",但是发现如下记录不符合删除条件\n" + noDeleteIds;
|
|
XtraMessageBox.Show(strHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
SqlHelper.AddLogTab(DLLCoid, FormText + "-->删除", FormText + "[" + ids + "]", FormText, OperatorName);
|
|
}
|
|
else
|
|
{
|
|
string strHint = "没有符合删除条件的记录";
|
|
if (!string.IsNullOrEmpty(noDeleteIds))
|
|
strHint = strHint + ",发现如下记录不符合删除条件\n" + noDeleteIds;
|
|
XtraMessageBox.Show(strHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (gridRequired())
|
|
{
|
|
try
|
|
{
|
|
GridAdapter.Update(gcMain.gridControl.DataSource as DataTable);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.Message.IndexOf("ix", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
XtraMessageBox.Show("系统检测到录入信息重复,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show(ex.Message);
|
|
return;
|
|
}
|
|
}
|
|
XtraMessageBox.Show("修改成功");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
PubClass.Preview(gcMain.gridControl);
|
|
}
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void btnCondSearch_Click(object sender, EventArgs e)
|
|
{
|
|
mIsSearch = true; // 设置当前查询模式为全部数据查询
|
|
SearchData();
|
|
}
|
|
/// <summary>
|
|
/// 表格颜色
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void gridView_RowStyle(object sender, RowStyleEventArgs e)
|
|
{
|
|
if (e.RowHandle >= 0)
|
|
{
|
|
DataRow row = gcMain.gridView.GetDataRow(e.RowHandle);
|
|
string cond = string.Empty;
|
|
string color = string.Empty;
|
|
string forecolor = string.Empty;
|
|
foreach (DataRow dr in mGridColorList.Rows)
|
|
{
|
|
List<string> condition = PubClass.GetParamValue(dr["condition"]+"");
|
|
cond = dr["condition"]+"";
|
|
foreach (string item in condition)
|
|
{
|
|
string filedName = item.Replace("{", "").Replace("}", "");
|
|
cond = cond.Replace(item, row[filedName] + "");
|
|
}
|
|
cond = PubClass.SqlToCode(cond);
|
|
color = dr["backcolor"] + "";
|
|
forecolor = dr["forcecolor"] + "";
|
|
|
|
string obj = Evaluator.Eval(cond) + "";
|
|
if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
if (!string.IsNullOrEmpty(color))
|
|
{
|
|
Color color1 = ColorTranslator.FromHtml(color);
|
|
e.Appearance.BackColor = color1;
|
|
}
|
|
if (!string.IsNullOrEmpty(forecolor))
|
|
{
|
|
Color foreColor = ColorTranslator.FromHtml(forecolor);
|
|
e.Appearance.ForeColor = foreColor;
|
|
|
|
}
|
|
FontStyle fst = new FontStyle();
|
|
if (dr["ifBold"]+"" == "1")
|
|
{
|
|
fst = fst | FontStyle.Bold;
|
|
}
|
|
if (dr["ifItalic"] + "" == "1")
|
|
{
|
|
fst = fst | FontStyle.Italic;
|
|
}
|
|
if (dr["ifStrickOut"] + "" == "1")
|
|
{
|
|
fst = fst | FontStyle.Strikeout;
|
|
}
|
|
if (dr["ifUnderLine"] + "" == "1")
|
|
{
|
|
fst = fst | FontStyle.Underline;
|
|
}
|
|
e.Appearance.Font = new Font(e.Appearance.Font, fst);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 表格编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void gridView_ShowingEditor(object sender, CancelEventArgs e)
|
|
{
|
|
e.Cancel = !btnSave.Enabled;
|
|
}
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void txtKey_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Return)
|
|
btnCondSearch.PerformClick();
|
|
}
|
|
#endregion
|
|
|
|
#region 左侧树、表格点击加载数据
|
|
/// <summary>
|
|
/// 左侧树点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void LeftTreeAfterSelect(object sender, TreeViewEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.Action == TreeViewAction.ByMouse)
|
|
{
|
|
mIsSearch = false; // 设置当前查询模式为部分数据查询
|
|
string strWhere = " and " + drLeft["fieldname"] + " like '" + e.Node.Name + "%'";
|
|
string sql = PubClass.ReplaceWhereCond(mSystemRow["SQL"] + "") + strWhere;
|
|
InitData(sql);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 左侧表格点击
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
public void LeftGridCellClick(object sender, RowCellClickEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
mIsSearch = false; // 设置当前查询模式为部分数据查询
|
|
DataRow row = (sender as GridView).GetDataRow(e.RowHandle);
|
|
string key = drLeft["fieldname"] + "";
|
|
string value = row[drLeft["fieldsqlid"] + ""] + "";
|
|
InitData(PubClass.ReplaceWhereCond(mSystemRow["SQL"] + "") + " and " + key + " = '" + value + "' ");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 表格拖动
|
|
/// <summary>
|
|
/// 拖动权限
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
/// <returns></returns>
|
|
private bool CanDragRowState(DataRow dr)
|
|
{
|
|
try
|
|
{
|
|
string tempCond = mDragCond;
|
|
bool canDrag = string.IsNullOrEmpty(mDragCond);
|
|
if (!string.IsNullOrEmpty(tempCond))
|
|
{
|
|
tempCond = PubClass.ReqSqlWhere(dr, PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
|
canDrag = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
|
}
|
|
return canDrag;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
public void DragGridCallBack(object sender)
|
|
{
|
|
if (XtraMessageBox.Show("您确定要拖动选中记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
|
{
|
|
GridView targetGridView = (sender as GridControl).FocusedView as GridView;
|
|
string tableName = mSystemRow["SQLDT1"] + "";
|
|
string unionField = drLeft["fieldsqlid"] + "";
|
|
string parmaryKey = PrimaryKey;
|
|
int[] sourceSelectRows = gcMain.gridView.GetSelectedRows();
|
|
int[] targetSelectRows = targetGridView.GetSelectedRows();
|
|
try
|
|
{
|
|
// 拖动结果
|
|
int dragSuccess = 0, dragError = 0, result = 0;
|
|
string ids = string.Empty;
|
|
foreach (int item in sourceSelectRows)
|
|
{
|
|
DataRow dr = gcMain.gridView.GetDataRow(item);
|
|
if (CanDragRowState(dr))
|
|
{
|
|
ids += "'" + dr[parmaryKey] + "',";
|
|
dragSuccess++;
|
|
}
|
|
else
|
|
{
|
|
dragError++;
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(ids) && targetSelectRows.Count() > 0)
|
|
{
|
|
DataRow drTarget = targetGridView.GetDataRow(targetSelectRows[0]);
|
|
string sqlValue = string.Format("UPDATE {0} SET {1}='{2}' WHERE {3} IN ({4})",
|
|
tableName, unionField, drTarget[unionField], parmaryKey, ids.Trim(','));
|
|
result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
// 刷新左侧表格数据
|
|
mcc.runQuery();
|
|
// 刷新主表格数据
|
|
if (mSystemRow["searchEnable"]+"" == "1")
|
|
{
|
|
if (mSeearchMode == 1)
|
|
{
|
|
sqlValue = mccTop.SetSearchSqlValue();
|
|
if (!string.IsNullOrEmpty(sqlValue))
|
|
{
|
|
InitData(sqlValue);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnCondSearch_Click(null, null);
|
|
}
|
|
}
|
|
}
|
|
XtraMessageBox.Show("拖动成功 " + dragSuccess + " 条," + "失败 " + dragError + " 条", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 修改数据
|
|
private void gridView_DoubleClick(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(mSystemRow["AddDllName"] + ""))
|
|
{
|
|
bool isReflash = UpdateModel();
|
|
if (isReflash)
|
|
{
|
|
//SearchCondData();
|
|
if (!string.IsNullOrEmpty(BeforeSearchSQL))
|
|
{
|
|
InitData(BeforeSearchSQL);
|
|
}
|
|
else
|
|
{
|
|
Control[] ctr = pl_search.Controls.Find("btnCondSearch", true);
|
|
if ((ctr == null) || (ctr.Length < 1))
|
|
{
|
|
if (string.IsNullOrEmpty(BeforeSearchSQL))
|
|
{
|
|
if (mSeearchMode == 1)
|
|
{
|
|
string sqlValue = mccTop.SetSearchSqlValue();
|
|
if (!string.IsNullOrEmpty(sqlValue))
|
|
{
|
|
InitData(sqlValue);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnCondSearch_Click(null, null);
|
|
}
|
|
}
|
|
else
|
|
InitData(BeforeSearchSQL);
|
|
}
|
|
else
|
|
{
|
|
(ctr[0] as SimpleButton).PerformClick();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public bool UpdateModel()
|
|
{
|
|
int[] rows = gcMain.gridView.GetSelectedRows();
|
|
if (rows.Length > 0)
|
|
{
|
|
DataRow dr = gcMain.gridView.GetDataRow(rows[0]);
|
|
//判断修改条件是否符合
|
|
Boolean canModify = string.IsNullOrEmpty(mModifyCond);
|
|
if (mNeedModify)
|
|
{
|
|
string tempCond = mModifyCond;
|
|
if (!canModify)
|
|
{
|
|
tempCond = PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName);
|
|
tempCond = PubClass.ReqSqlWhere(dr, tempCond);
|
|
canModify = tempCond.Trim() == "" ? true : Convert.ToBoolean(Evaluator.Eval(tempCond));
|
|
}
|
|
}
|
|
else
|
|
canModify = false;
|
|
|
|
string productId = dr[PrimaryKey].ToString();
|
|
string[] args = {
|
|
FormText,
|
|
OperatorId,
|
|
OperatorName,
|
|
Privilege,
|
|
DLLCoid,
|
|
"",
|
|
Convert.ToInt32( !canModify).ToString(),
|
|
productId,
|
|
"",
|
|
"",
|
|
""
|
|
};
|
|
IForm form = PubUtil.LoadDllForm(mSystemRow["AddDllName"] + "", args);
|
|
DialogResult dialogResult = form.SubForm.ShowDialog();
|
|
}
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
#region 添加数据
|
|
/// <summary>
|
|
/// 添加行
|
|
/// </summary>
|
|
/// <param name="view"></param>
|
|
protected void AddRow(DevExpress.XtraGrid.Views.Grid.GridView view)
|
|
{
|
|
int prevDataRowIndex = view.GetFocusedDataSourceRowIndex();
|
|
view.AddNewRow();
|
|
//默认值
|
|
foreach (GridColumn item in view.Columns)
|
|
{
|
|
if (item.Tag != null)
|
|
{
|
|
MyTagModel cmt = item.Tag as MyTagModel;
|
|
if (cmt != null)
|
|
{
|
|
string defaultValue = PubClass.GetDefaultValue(cmt.DefaultValue.ToString(), OperatorId, OperatorName);
|
|
if (defaultValue != "")
|
|
{
|
|
view.SetRowCellValue(view.FocusedRowHandle, item, defaultValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//关键字段赋值
|
|
if (mLeftType == 2)
|
|
{
|
|
int[] rows = GridViewLeft.GetSelectedRows();
|
|
if (rows.Length > 0)
|
|
{
|
|
DataRow row = GridViewLeft.GetDataRow(rows[0]);
|
|
GridColumn tmpcol = gcMain.gridView.Columns[drLeft["fieldname"] + ""];
|
|
view.SetRowCellValue(gcMain.gridView.FocusedRowHandle, tmpcol, row[drLeft["fieldsqlid"] + ""]);
|
|
view.UpdateCurrentRow();
|
|
view.ShowEditor();
|
|
}
|
|
}
|
|
if (mLeftType == 1)
|
|
{
|
|
TreeNode tn = tvLeft.GetTreeView.SelectedNode;
|
|
GridColumn tmpcol = gcMain.gridView.Columns[drLeft["fieldname"] + ""];
|
|
view.SetRowCellValue(gcMain.gridView.FocusedRowHandle, tmpcol, tn.Name);
|
|
view.UpdateCurrentRow();
|
|
view.ShowEditor();
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 保存数据
|
|
/// <summary>
|
|
/// 表格必须录入验证
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private bool gridRequired()
|
|
{
|
|
DataTable dtBillItem = gcMain.gridControl.DataSource as DataTable;
|
|
DataColumnCollection dtBillRow = dtBillItem.Columns;
|
|
GridView gridView = gcMain.gridView;
|
|
GridColumnCollection gridColumns = gridView.Columns;
|
|
|
|
foreach (DataRow drGrid in dtBillItem.Rows)
|
|
{
|
|
foreach (DataRow dr in mNullableFields)
|
|
{
|
|
string fieldName = dr["fieldName"] + "";
|
|
string fieldText = dr["username1"] + "";
|
|
if (string.IsNullOrEmpty(drGrid[fieldName] + ""))
|
|
{
|
|
XtraMessageBox.Show(string.Format("[{0}] 不能为空", fieldText));
|
|
gridView.Focus();
|
|
gridView.FocusedRowHandle = dtBillItem.Rows.IndexOf(drGrid);
|
|
gridView.FocusedColumn = gridColumns[fieldName];
|
|
gridView.SelectCell(gridView.FocusedRowHandle, gridColumns[fieldName]);
|
|
gridView.ShowEditorByMouse();
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询数据
|
|
/// <summary>
|
|
/// 查询所有数据
|
|
/// </summary>
|
|
private void SearchData()
|
|
{
|
|
string field = cbField.SelectedValue + "";
|
|
string strWhere = " ";
|
|
if (mLeftType == 1)
|
|
{
|
|
foreach (TreeNode tn in tvLeft.GetTreeView.Nodes)
|
|
GetCheckedState(tn);
|
|
}
|
|
if (!string.IsNullOrEmpty(field))
|
|
strWhere += " and (dbo.P_getpy(" + field + ") like '%" + txtKey.Text + "%' or " + field + " like '%" + txtKey.Text + "%')";
|
|
if (!string.IsNullOrEmpty(mTreeTags))
|
|
strWhere += " and " + drLeft["fieldname"] + " in (" + mTreeTags.Trim(',') + ")";
|
|
InitData(PubClass.ReplaceWhereCond(mSystemRow["SQL"] + "") + strWhere);
|
|
}
|
|
/// <summary>
|
|
/// 查询数据(按当前模式,树点击or表格点击or点击查询按钮)
|
|
/// </summary>
|
|
private void SearchCondData()
|
|
{
|
|
string sqlValue = mSystemRow["SQL"] + "";
|
|
// 假如为树形结构,并且为点击树查询数据
|
|
if (mLeftType == 1 && !mIsSearch)
|
|
{
|
|
TreeNode treeNode = tvLeft.GetTreeView.SelectedNode;
|
|
if (treeNode != null)
|
|
InitData(PubClass.ReplaceWhereCond(sqlValue) + " and " + PrimaryKey + " like '" + treeNode.Name + "%' ");
|
|
else
|
|
InitData(sqlValue);
|
|
}
|
|
// 假如左侧为表格数据,并且为点击表格查询数据
|
|
else if (mLeftType == 2 && !mIsSearch)
|
|
{
|
|
int[] rows = GridViewLeft.GetSelectedRows();
|
|
if (rows.Length == 0)
|
|
return;
|
|
DataRow row = GridViewLeft.GetDataRow(rows[0]);
|
|
InitData(PubClass.ReplaceWhereCond(sqlValue) + " and " + PrimaryKey + " like '" + row[drLeft["fieldsqlid"] + ""] + "%' ");
|
|
}
|
|
else
|
|
{
|
|
// 查询所有数据
|
|
InitData(sqlValue);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 辅助方法
|
|
/// <summary>
|
|
/// 加载表格列头
|
|
/// </summary>
|
|
/// <param name="tab"></param>
|
|
public void InitColumns()
|
|
{
|
|
SqlParameter[] p =
|
|
{
|
|
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
|
new SqlParameter("@operatorname",SqlDbType.VarChar,20)
|
|
};
|
|
p[0].Value = DLLCoid;
|
|
p[1].Value = OperatorName;
|
|
dtColumns = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "[p_getBaseModuleField]", "temp", p).Tables[0];
|
|
mNullableFields = dtColumns.Rows.OfType<DataRow>().Where(x => x["tagid"] + "" == "1").ToArray();
|
|
gcMain.ModuleKey = DLLCoid;
|
|
gcMain.ModuleType = 1;
|
|
gcMain.SetColumns2(dtColumns);
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public void InitMenu()
|
|
{
|
|
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", gcMain.gridControl);
|
|
gm.DirId = mSystemRow["dirid"] + "";
|
|
gm.filedKey = PrimaryKey;
|
|
gm.BindGridMenuWQ(DLLCoid);
|
|
gm.OnGridMenuClickRefreshData += new EventHandler(gm_OnGridMenuClickRefreshData);
|
|
}
|
|
/// <summary>
|
|
/// 初始化数据
|
|
/// </summary>
|
|
/// <param name="sqlValue"></param>
|
|
public void InitData(string sqlValue)
|
|
{
|
|
HandleBmp(sqlValue);
|
|
int oldRowHandle = (gcMain.gridControl.MainView as GridView).FocusedRowHandle;
|
|
BeforeSearchSQL = sqlValue;
|
|
//这个绑定数据源
|
|
GridAdapter = SqlHelper.ExecuteAdapter(CommandType.Text, sqlValue);
|
|
if (GridDataSet != null && GridDataSet.Tables.Count > 0)
|
|
GridDataSet.Clear();
|
|
GridAdapter.Fill(GridDataSet);
|
|
SqlCommandBuilder cb = new SqlCommandBuilder(GridAdapter);
|
|
gcMain.gridControl.DataSource = GridDataSet.Tables[0];
|
|
(gcMain.gridControl.MainView as GridView).ClearSelection();
|
|
(gcMain.gridControl.MainView as GridView).FocusedRowHandle = oldRowHandle;
|
|
(gcMain.gridControl.MainView as GridView).SelectRow(oldRowHandle);
|
|
}
|
|
/// <summary>
|
|
/// 顶部查询条件(保留之前的按列查询)
|
|
/// </summary>
|
|
public void SearchCreateTopControl()
|
|
{
|
|
string sql = string.Format("exec p_getControlLocation '{0}','{1}','{2}'", mSystemRow["condKey"], DLLCoid, OperatorName);
|
|
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
mSeearchMode = 1;
|
|
string condSql = string.Format("select * from p_systembillsourcecond where formKey='{0}'", mSystemRow["condKey"]);
|
|
mccTop.LoginId = OperatorId;
|
|
mccTop.LoginName = OperatorName;
|
|
mccTop.SearchSql = PubClass.ReplaceWhereCond(mSystemRow["SQL"] + "");
|
|
mccTop.ctr = pl_search;
|
|
mccTop.tvLeft = tvLeft;
|
|
mccTop.tvLeftDataRow = drLeft;
|
|
mccTop.gce = gcMain.gridControl;
|
|
mccTop.RememberRow = true;
|
|
mccTop.dllType = mLeftType;
|
|
mccTop.condDt = SqlHelper.ExecuteDataSet(condSql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
CreateControlModel cm = new CreateControlModel();
|
|
cm.dt = dt;
|
|
cm.ctr = pl_search;
|
|
cm.loginid = OperatorId;
|
|
cm.loginname = OperatorName;
|
|
int height = mccTop.CreateControlByModel(cm);
|
|
pl_search.Height = height;
|
|
Control[] ctl = pl_search.Controls.Find("btnCondSearch", true);
|
|
if ((ctl != null) && (ctl.Length > 0))
|
|
{
|
|
(ctl[0] as SimpleButton).Width = 72;
|
|
}
|
|
}
|
|
if (mSystemRow["searchEnable"]+"" == "1")
|
|
{
|
|
string sqlValue = mccTop.SetSearchSqlValue();
|
|
if (!string.IsNullOrEmpty(sqlValue))
|
|
{
|
|
//InitData(sqlValue);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
mSeearchMode = 2;
|
|
// 假如未配置查询条件,则显示之前的下拉查询条件
|
|
label1.Visible = true;
|
|
cbField.Visible = true;
|
|
txtKey.Visible = true;
|
|
btnCondSearch.Visible = true;
|
|
if (mSystemRow["searchEnable"]+"" == "1")
|
|
btnCondSearch_Click(null, null);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 处理图片
|
|
/// </summary>
|
|
/// <param name="sql"></param>
|
|
private string HandleBmp(string sql)
|
|
{
|
|
string notBmpSql = sql;
|
|
DataTable dtBmps = SqlHelper.ExecuteDataSet("select fieldname from P_systemwordbooktab where tab='" + DLLCoid + "' and fieldSqlTag=99").Tables[0];
|
|
foreach (DataRow row in dtBmps.Rows)
|
|
{
|
|
string fieldName = row["fieldname"] + "";
|
|
notBmpSql = notBmpSql.Replace(" ", "-").Replace("-", "").Replace(", ", ",").Replace(" ,", ",");
|
|
notBmpSql = notBmpSql.Replace("," + fieldName + ",", ",").Replace("," + fieldName, " ");
|
|
}
|
|
return sql;
|
|
}
|
|
/// <summary>
|
|
/// 处理删除按钮
|
|
/// </summary>
|
|
private void HandleDelButtonState(DataRow dr)
|
|
{
|
|
try
|
|
{
|
|
string tempCond = mDeleteCond;
|
|
bool canDel = string.IsNullOrEmpty(mDeleteCond);
|
|
if (!string.IsNullOrEmpty(tempCond))
|
|
{
|
|
tempCond = PubClass.ReqSqlWhere(dr, PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
|
canDel = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
|
}
|
|
btnDelete.Enabled = canDel && mSystemRow["deleteEnable"] + "" == "1";
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 验证是否可以编辑行
|
|
/// </summary>
|
|
/// <param name="dr"></param>
|
|
private void HandleEditRowState(DataRow dr)
|
|
{
|
|
try
|
|
{
|
|
string tempCond = mModifyCond;
|
|
bool canEdit = string.IsNullOrEmpty(mModifyCond);
|
|
if (!string.IsNullOrEmpty(tempCond))
|
|
{
|
|
tempCond = PubClass.ReqSqlWhere(dr, PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
|
canEdit = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
|
}
|
|
btnSave.Enabled = canEdit && mSystemRow["modifyEnable"] + "" == "1";
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 处理表格计算
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void gridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
|
{
|
|
if (inSummary) return;
|
|
inSummary = true;
|
|
try
|
|
{
|
|
DataRow gvRow = gcMain.gridView.GetDataRow(e.RowHandle);
|
|
foreach (DataRow row in mGridSum.Rows)
|
|
{
|
|
string calcExpr = row["calcExpr"]+"";
|
|
if (e.Column.FieldName != row["fieldName"]+"")
|
|
{
|
|
List<string> listParam = PubClass.GetParamValue(calcExpr);
|
|
foreach (string str in listParam)
|
|
{
|
|
string filed = str.Replace("{", "").Replace("}", "");
|
|
string filedValue = gvRow[filed]+"";
|
|
if (string.IsNullOrEmpty(filedValue))
|
|
filedValue = "0";
|
|
calcExpr = calcExpr.Replace(str, filedValue + "");
|
|
}
|
|
calcExpr = calcExpr.Replace("=", "==").Replace("<>", "!=").Replace("and", "&&").Replace("or", "|");
|
|
string result = Evaluator.Eval(calcExpr)+"";
|
|
gcMain.gridView.SetRowCellValue(e.RowHandle, gcMain.gridView.Columns[row["fieldName"]+""], Math.Round(double.Parse(result), 2, MidpointRounding.AwayFromZero));
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
inSummary = false;
|
|
}
|
|
/// <summary>
|
|
/// 获取树选中节点
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetTreeCheck()
|
|
{
|
|
mTreeTags = string.Empty;
|
|
foreach (TreeNode item in tvLeft.GetTreeView.Nodes)
|
|
{
|
|
GetCheckedState(item);
|
|
}
|
|
return mTreeTags;
|
|
}
|
|
/// <summary>
|
|
/// 选中节点之后,选中节点的所有子节点
|
|
/// </summary>
|
|
/// <param name="currNode"></param>
|
|
/// <param name="state"></param>
|
|
private void GetCheckedState(TreeNode currNode)
|
|
{
|
|
if (currNode.Checked)
|
|
mTreeTags += "" + currNode.Name + ",";
|
|
TreeNodeCollection nodes = currNode.Nodes;
|
|
if (nodes.Count > 0)
|
|
{
|
|
foreach (TreeNode tn in nodes)
|
|
{
|
|
if (tn.Checked)
|
|
mTreeTags += "'" + tn.Name + "',";
|
|
GetCheckedState(tn);
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 执行右键菜单后刷新表格数据
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void gm_OnGridMenuClickRefreshData(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(BeforeSearchSQL))
|
|
{
|
|
if (mSeearchMode == 1)
|
|
{
|
|
string sqlValue = mccTop.SetSearchSqlValue();
|
|
if (!string.IsNullOrEmpty(sqlValue))
|
|
{
|
|
InitData(sqlValue);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
btnCondSearch_Click(null, null);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InitData(BeforeSearchSQL);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|