2686 lines
118 KiB
C#
2686 lines
118 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using System.Data.SqlClient;
|
||
using System.Data.Common;
|
||
using System.Data.Linq;
|
||
using System.Linq;
|
||
using System.Diagnostics;
|
||
using System.Collections;
|
||
using System.Text.RegularExpressions;
|
||
|
||
using DevExpress.XtraGrid;
|
||
using DevExpress.XtraGrid.Views.Grid;
|
||
using DevExpress.XtraGrid.Columns;
|
||
using DevExpress.Utils;
|
||
using DevExpress.XtraEditors;
|
||
using DevExpress.XtraEditors.Repository;
|
||
using DevExpress.XtraEditors.Controls;
|
||
|
||
using ExcelPlus;
|
||
using CommonLib;
|
||
using CommonLib.utils;
|
||
using Lskj.Common;
|
||
using CommonLib.data;
|
||
using System.Reflection;
|
||
using Lskj.MyControl;
|
||
using DevExpress.XtraTab;
|
||
using DevExpress.XtraBars;
|
||
using Lskj.MyControl.PrintMoude;
|
||
using Lskj.MyControl.TreeGridControl;
|
||
|
||
namespace Lskj.PubModuleDetail
|
||
{
|
||
public partial class FrmMain : FormBase
|
||
{
|
||
|
||
private bool inSummary = false;
|
||
private DataTable dtSum = new DataTable();//统计列
|
||
private MySearchCreateControl mcc = new MySearchCreateControl();
|
||
private MySearchCreateControl mccTop = new MySearchCreateControl();
|
||
private int bottomHeight = 50;
|
||
private int ModulePriv = 0;
|
||
|
||
#region 私有属性
|
||
/// <summary>
|
||
/// 左边显示类型
|
||
/// </summary>
|
||
private int LeftType { get; set; }
|
||
/// <summary>
|
||
/// 树控件表名
|
||
/// </summary>
|
||
private string TreeSql { get; set; }
|
||
/// <summary>
|
||
/// DbDataAdapter
|
||
/// </summary>
|
||
private SqlDataAdapter da { get; set; }
|
||
/// <summary>
|
||
/// 操作Dataset
|
||
/// </summary>
|
||
private DataSet ds { get; set; }
|
||
/// <summary>
|
||
/// 调用方案
|
||
/// </summary>
|
||
private int n { get; set; }
|
||
/// <summary>
|
||
/// 系统配置表
|
||
/// </summary>
|
||
private DataRow dtSystemDlltab;
|
||
/// <summary>
|
||
/// 数据库字段配置
|
||
/// </summary>
|
||
private DataRow dtSystemwordbooktabTag3;
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
private List<ToolStripMenuItem> tsmMenuList = new List<ToolStripMenuItem>();
|
||
/// <summary>
|
||
/// 条件颜色
|
||
/// </summary>
|
||
private DataTable dtSysColorList;
|
||
/// <summary>
|
||
/// 搜索字段
|
||
/// </summary>
|
||
private DataTable cbSearchFiled;
|
||
private DataTable dtColumns;
|
||
/// <summary>
|
||
/// 必须录入字段
|
||
/// </summary>
|
||
private DataRow[] nullableFields;
|
||
// 不包含图片SQL,暂时解决方案:查询的时候,假如配置了bmp图片,则替换bmp字段,用于表格查询,双击显示数据则使用配置的字段
|
||
private string MyNotBmpSql;
|
||
private bool isSearch = true; // 是否为点击查询按钮获取数据
|
||
//表格编辑
|
||
private Boolean gridEdited;
|
||
private string addCond; // 添加条件
|
||
private string modifyCond; //修改条件
|
||
private string deleteCond; //删除条件
|
||
private string dragCond; // 拖动条件
|
||
private string printCond = string.Empty;
|
||
private string exportCond = string.Empty;
|
||
private string mParmaryKey;
|
||
private bool needModified;
|
||
private bool isOpen = true; // 右侧数据是否打开
|
||
private bool mInitFinish = false;
|
||
|
||
private string basePrintType, baseModuleFile, basePrintSQL, basePrintSQL1, basePrintSQL2;
|
||
private BarButtonItem bbi_import, bbi_export, bbi_print, bbi_word;
|
||
|
||
private int searchHide;//是否显示搜索
|
||
private int leftWidth; //宽度
|
||
private int mRightGridMode; // 右边参数模式,1.面板模式,2.标签模式
|
||
private int mRightGridDataMode; // 右边表格模式,1.明细列表数据,2.报表明细模式
|
||
private int mSeearchMode; // 查询模式,1.查询条件,2.下拉列表查询
|
||
|
||
private string beforeSearchSQL;
|
||
private GridView gridViewLeft;
|
||
|
||
public string ModuleDllId { get; set; }
|
||
public string LeftCond;
|
||
public string[] Params;
|
||
private int mEnterOrder; // 0.默认列跳转,1为行跳转
|
||
|
||
|
||
/// <summary>
|
||
/// 主打印sql
|
||
/// </summary>
|
||
private string _mainPrintSql;
|
||
/// <summary>
|
||
/// 打印其他参数条件
|
||
/// </summary>
|
||
private string _printModeCond;
|
||
/// <summary>
|
||
/// 打印完成后添加数据用到的参数
|
||
/// </summary>
|
||
private List<string> _printSaveParams;
|
||
/// <summary>
|
||
/// 是否直接打印
|
||
/// </summary>
|
||
private bool _isExcPrint;
|
||
#endregion
|
||
|
||
#region 缓存数据
|
||
/// <summary>
|
||
/// 基础档案、报表明细列表数据
|
||
/// </summary>
|
||
private DataTable moduleDetailTable = new DataTable();
|
||
private DataTable moduleDetailBottomTable = new DataTable();
|
||
#endregion
|
||
|
||
#region 构造函数
|
||
public FrmMain()
|
||
{
|
||
//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();
|
||
tvLeft.GetTreeView.AfterCheck += new TreeViewEventHandler(tvLeft_AfterCheck);
|
||
tvLeft.GetTreeView.AfterSelect += new TreeViewEventHandler(tvLeft_AfterSelect);
|
||
ds = new DataSet();
|
||
|
||
gcMain.gridView.IndicatorWidth = 40;
|
||
gcMain.gridView.DoubleClick += new EventHandler(GridViewpub_DoubleClick);
|
||
gcMain.gridView.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(gridView_SelectionChanged);
|
||
gcMain.gridView.ShowingEditor += new CancelEventHandler(gridView_ShowingEditor);
|
||
gcMain.gridView.RowCellClick += new RowCellClickEventHandler(gridView_RowCellClick);
|
||
//gcMain.gridView.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(gridView1_FocusedRowChanged);
|
||
//gcMain.gridView.RowStyle += new RowStyleEventHandler(gvList_RowCellStyle);
|
||
gcMain.gridView.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridBillInfo_CellValueChanged);
|
||
}
|
||
|
||
void gridView_RowCellClick(object sender, RowCellClickEventArgs e)
|
||
{
|
||
SetDetailData();
|
||
}
|
||
#endregion
|
||
|
||
#region 选择树
|
||
protected void tvLeft_AfterSelect(object sender, TreeViewEventArgs e)
|
||
{
|
||
if (e.Action == TreeViewAction.ByMouse)
|
||
{
|
||
isSearch = false; // 设置当前查询模式为部分数据查询
|
||
string strWhere = " and " + dtSystemwordbooktabTag3["fieldname"] + " like '" + e.Node.Name + "%'";
|
||
string sql = PubClass.ReplaceWhereCond(MyNotBmpSql) + strWhere;
|
||
|
||
// 替换查询条件
|
||
List<string> list = PubClass.GetParamValue(sql);
|
||
foreach (string item in list)
|
||
{
|
||
string fileName = item.Replace("{", "").Replace("}", "");
|
||
Control[] ctrs = pl_search.Controls.Find("txt_" + fileName, true);
|
||
if (ctrs.Length > 0)
|
||
{
|
||
sql = MySearchCreateControl.SetReplaceSql(sql, item, ctrs);
|
||
}
|
||
}
|
||
|
||
InitData(sql);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 生成行号
|
||
protected void GridViewpub_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
|
||
{
|
||
e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
|
||
if (e.Info.IsRowIndicator)
|
||
{
|
||
if (e.RowHandle >= 0)
|
||
{
|
||
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定树
|
||
protected void tvLeft_AfterCheck(object sender, TreeViewEventArgs e)
|
||
{
|
||
if (e.Action == TreeViewAction.ByMouse)
|
||
{
|
||
//取消节点选中状态之后,取消所有父节点的选中状态
|
||
if (e.Node.Checked)
|
||
{
|
||
setChildNodeCheckedState(e.Node, true);
|
||
}
|
||
else
|
||
{
|
||
//取消节点选中状态之后,取消所有父节点的选中状态
|
||
setChildNodeCheckedState(e.Node, false);
|
||
//如果节点存在父节点,取消父节点的选中状态
|
||
if (e.Node.Parent != null)
|
||
{
|
||
setParentNodeCheckedState(e.Node, false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 取消节点选中状态之后,取消所有父节点的选中状态
|
||
/// </summary>
|
||
/// <param name="currNode"></param>
|
||
/// <param name="state"></param>
|
||
private void setParentNodeCheckedState(TreeNode currNode, bool state)
|
||
{
|
||
TreeNode parentNode = currNode.Parent;
|
||
parentNode.Checked = state;
|
||
if (currNode.Parent.Parent != null)
|
||
{
|
||
setParentNodeCheckedState(currNode.Parent, state);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 选中节点之后,选中节点的所有子节点
|
||
/// </summary>
|
||
/// <param name="currNode"></param>
|
||
/// <param name="state"></param>
|
||
private void setChildNodeCheckedState(TreeNode currNode, bool state)
|
||
{
|
||
TreeNodeCollection nodes = currNode.Nodes;
|
||
if (nodes.Count > 0)
|
||
foreach (TreeNode tn in nodes)
|
||
{
|
||
tn.Checked = state;
|
||
setChildNodeCheckedState(tn, state);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 初始化数据
|
||
private void FrmGridTree_Load(object sender, EventArgs e)
|
||
{
|
||
string moduleName = System.IO.Path.GetFileName(this.GetType().Assembly.Location);
|
||
gridViewLeft = gridLeft.gridView;
|
||
gridViewLeft.FocusedRowChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventHandler(gridViewLeft_FocusedRowChanged);
|
||
this.Text = FormText;
|
||
DLLCoid = string.IsNullOrEmpty(ModuleDllId) ? DLLCoid : ModuleDllId;
|
||
//ModulePriv = PubClass.GetPrivModule(DLLCoid, moduleName, OperatorId, OperatorName);
|
||
if (!string.IsNullOrEmpty(ModuleId) && ModuleId != "0")
|
||
{
|
||
ModulePriv = PubClass.GetPrivModuleByMenuid(ModuleId, moduleName, OperatorId, OperatorName);
|
||
}
|
||
else
|
||
{
|
||
ModulePriv = PubClass.GetPrivModule(DLLCoid, moduleName, OperatorId, OperatorName);
|
||
}
|
||
gcMain.gridView.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
||
dtSystemDlltab = SqlHelper.ExecuteDataSet("select * from P_systemDlltab where DLLCoid='" + DLLCoid + "'").Tables[0].Rows[0];
|
||
bottomHeight = 50;
|
||
if (dtSystemDlltab.Table.Columns.Contains("bottomheight"))
|
||
bottomHeight = Convert.ToInt32("0" + dtSystemDlltab["bottomHeight"]);
|
||
dtSystemDlltab["SQL"] = PubClass.ReqSqlParam(dtSystemDlltab["SQL"] + "", OperatorId, OperatorName);
|
||
LeftType = Convert.ToInt32(dtSystemDlltab["dllType"]);
|
||
HandleBmp(dtSystemDlltab["SQL"].ToString());
|
||
gridEdited = (string.IsNullOrEmpty(dtSystemDlltab["selfEdit"] + "") || dtSystemDlltab["selfEdit"] + "" == "0" || dtSystemDlltab["selfEdit"] + "" == "False") ? false : true;
|
||
gcMain.gridView.OptionsBehavior.Editable = gridEdited;
|
||
btnSave.Enabled = gridEdited;
|
||
addCond = dtSystemDlltab["addCond"].ToString().Trim();
|
||
modifyCond = dtSystemDlltab["modifyCond"].ToString().Trim();
|
||
deleteCond = dtSystemDlltab["deleteCond"].ToString().Trim();
|
||
dragCond = dtSystemDlltab["dragCond"].ToString().Trim();
|
||
if (dtSystemDlltab.Table.Columns.Contains("exportCond"))
|
||
exportCond = dtSystemDlltab["exportCond"].ToString();
|
||
if (dtSystemDlltab.Table.Columns.Contains("printCond"))
|
||
printCond = dtSystemDlltab["printCond"].ToString();
|
||
if (dtSystemDlltab.Table.Columns.Contains("printType"))
|
||
basePrintType = dtSystemDlltab["printType"] + "";
|
||
if (dtSystemDlltab.Table.Columns.Contains("baseModuleFile"))
|
||
baseModuleFile = dtSystemDlltab["baseModuleFile"] + "";
|
||
if (dtSystemDlltab.Table.Columns.Contains("basePrintSQL"))
|
||
basePrintSQL = dtSystemDlltab["basePrintSQL"] + "";
|
||
if (dtSystemDlltab.Table.Columns.Contains("basePrintSQL1"))
|
||
basePrintSQL1 = dtSystemDlltab["basePrintSQL1"] + "";
|
||
if (dtSystemDlltab.Table.Columns.Contains("basePrintSQL2"))
|
||
basePrintSQL2 = dtSystemDlltab["basePrintSQL2"] + "";
|
||
if (dtSystemDlltab.Table.Columns.Contains("EnterOrder"))
|
||
mEnterOrder = string.IsNullOrEmpty(dtSystemDlltab["EnterOrder"] + "") ? 0 : Convert.ToInt32(dtSystemDlltab["EnterOrder"] + "");
|
||
|
||
InitPrintMenu();
|
||
InitOperMenu();
|
||
|
||
if (ModulePriv != 1)
|
||
{
|
||
gridEdited = false;
|
||
gcMain.gridView.OptionsBehavior.Editable = false;
|
||
addCond = addCond == "" ? " 1<>1 " : addCond + " and 1<>1";
|
||
modifyCond = modifyCond == "" ? "1<>1" : modifyCond + " and 1<>1";
|
||
deleteCond = deleteCond == "" ? "1<>1" : deleteCond + " and 1<>1";
|
||
dragCond = dragCond == "" ? "1<>1" : dragCond + " and 1<>1 ";
|
||
printCond = printCond == "" ? "1<>1" : printCond + " and 1<>1";
|
||
exportCond = exportCond == "" ? "1<>1" : exportCond + " and 1<>1";
|
||
BtnAdd.Visible = false;
|
||
btnSave.Visible = false;
|
||
BtnDel.Visible = false;
|
||
BtnAdd.Enabled = false;
|
||
btnSave.Enabled = false;
|
||
BtnDel.Enabled = false;
|
||
|
||
if (bbi_import != null) bbi_import.Enabled = false;
|
||
if (bbi_export != null) bbi_export.Enabled = false;
|
||
if (bbi_print != null) bbi_print.Enabled = false;
|
||
}
|
||
|
||
searchHide = Convert.ToInt32(dtSystemDlltab["searchHide"].ToString());
|
||
leftWidth = Convert.ToInt32(dtSystemDlltab["leftWidth"].ToString());
|
||
DataTable dtTag3 = SqlHelper.ExecuteDataSet("select * from P_systemwordbooktab where tab='" + DLLCoid + "' and fieldsqlTag=3").Tables[0];
|
||
if (dtTag3 != null && dtTag3.Rows.Count > 0)
|
||
dtSystemwordbooktabTag3 = dtTag3.Rows[0];
|
||
DataRow drRow = SqlHelper.ExecuteDataSet("select top 1 * from P_systemwordbooktab where tab='" + DLLCoid + "' order by orderid").Tables[0].Rows[0];
|
||
dtSysColorList = SqlHelper.ExecuteDataSet("select * from P_systemwordbookcolor where tab='" + DLLCoid + "' and isnull(useflag,0)=0 order by orderid").Tables[0];
|
||
mParmaryKey = drRow["fieldname"] + "";
|
||
//加载表格
|
||
InitColumns();
|
||
|
||
//初始化菜单
|
||
if (ModulePriv == 1)
|
||
InitMenu();
|
||
cbSearchFiled = SqlHelper.ExecuteDataSet("select * from P_systemwordbooktab where tab='" + DLLCoid + "' and ifSearch =0 and isnull(username1,'')<>''").Tables[0];
|
||
//加载筛选框
|
||
cbField.DataSource = cbSearchFiled;
|
||
cbField.DisplayMember = "username1";
|
||
cbField.ValueMember = "fieldname";
|
||
if (searchHide == 1)
|
||
{
|
||
pl_search.Visible = false;
|
||
}
|
||
if (leftWidth > 0)
|
||
{
|
||
plLeft.Width = leftWidth;
|
||
}
|
||
//左边树结构
|
||
if (LeftType == 1)
|
||
{
|
||
tvLeft.Visible = true;
|
||
gridLeft.Visible = panel1.Visible = pl_right_where.Visible = false;
|
||
|
||
PubClass.BindTree(dtSystemwordbooktabTag3["fieldsql"] + "", tvLeft.GetTreeView);
|
||
gcMain.gridView.OptionsSelection.MultiSelect = true;
|
||
GridDragTree gridDragTree = null;
|
||
if (ModulePriv == 1)
|
||
gridDragTree = new GridDragTree(this, gcMain.gridControl, tvLeft.GetTreeView, Drag_EventHandler, dtSystemwordbooktabTag3, dtSystemDlltab["SQLDT1"] + "", mParmaryKey);
|
||
}
|
||
else if (LeftType == 2)
|
||
{
|
||
tvLeft.Visible = false;
|
||
gridLeft.Visible = true;
|
||
|
||
gridLeft.RowColorCondtion = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemwordbookcolor where tab='{0}' and isnull(useflag,0)=0 order by orderid", dtSystemwordbooktabTag3["fieldKey"] + "")).Tables[0];
|
||
|
||
string sql = "select * from p_systemwordbookgrid where fieldid=" + dtSystemwordbooktabTag3["id"] + " order by orderid";
|
||
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
||
for (int i = 0; i < dt.Rows.Count; i++)
|
||
{
|
||
DataRow row = dt.Rows[i];
|
||
GridColumn gridColumn = new GridColumn();
|
||
gridColumn.FieldName = row["fieldname"] + "";
|
||
gridColumn.Name = row["fieldname"] + "";
|
||
gridColumn.VisibleIndex = i;
|
||
gridColumn.Caption = row["username"].ToString();
|
||
gridColumn.Width = Convert.ToInt32(row["width"]);
|
||
gridColumn.Visible = Convert.ToInt32(row["visible"]) == 0;
|
||
gridColumn.OptionsColumn.AllowEdit = false;
|
||
if (Convert.ToInt32(row["width"]) <= 0)
|
||
gridColumn.Visible = false;
|
||
gridViewLeft.Columns.Add(gridColumn);
|
||
}
|
||
SearchCraeteControl();
|
||
gcMain.gridView.OptionsSelection.MultiSelect = true;
|
||
GridDrag2GridUpdate g2g = null;
|
||
if (ModulePriv == 1)
|
||
g2g = new GridDrag2GridUpdate(gcMain.gridControl, gridLeft.gridControl, DragGridCallBack);
|
||
|
||
string width = Lskj.PubUtils.INIHelper.Read("base_width_" + DLLCoid);
|
||
if (!string.IsNullOrEmpty(width))
|
||
{
|
||
panel1.Width = Convert.ToInt32(width);
|
||
splitterControl1.SplitPosition = Convert.ToInt32(width);
|
||
}
|
||
mInitFinish = true;
|
||
}
|
||
else
|
||
{
|
||
plLeft.Visible = false;
|
||
splitterControl1.Visible = false;
|
||
}
|
||
SearchCreateTopControl();
|
||
//模板添加删除修改导入导出
|
||
BtnAdd.Enabled = dtSystemDlltab["addEnable"].ToString() == "1";
|
||
BtnDel.Enabled = dtSystemDlltab["deleteEnable"].ToString() == "1";
|
||
btnSave.Enabled = dtSystemDlltab["modifyEnable"].ToString() == "1" && gridEdited;
|
||
gcMain.gridView.OptionsBehavior.Editable = dtSystemDlltab["modifyEnable"].ToString() == "1" && gridEdited;
|
||
if (bbi_import != null) bbi_import.Enabled = dtSystemDlltab["importEnable"] + "" == "1";
|
||
if (bbi_export != null) bbi_export.Enabled = dtSystemDlltab["exportEnable"] + "" == "1";
|
||
needModified = dtSystemDlltab["modifyEnable"].ToString() == "1";
|
||
btnCondSearch_1.Enabled = dtSystemDlltab["searchEnable"].ToString() == "1";
|
||
cbField.Enabled = dtSystemDlltab["searchEnable"].ToString() == "1";
|
||
txtKey.Enabled = dtSystemDlltab["searchEnable"].ToString() == "1";
|
||
// 隐藏操作条
|
||
if (!BtnAdd.Enabled && !BtnDel.Enabled && !btnSave.Enabled)
|
||
{
|
||
panel6.Visible = false;
|
||
}
|
||
|
||
if (ModulePriv != 1)
|
||
needModified = false;
|
||
|
||
HandleAddButtonState();
|
||
|
||
//查询统计列
|
||
string isSumSql = "select * from p_systemwordbooktab where tab='" + DLLCoid + "' and isnull(vislble,0)=0 and isnull(calcExpr,'')<>''order by calcOrder asc";
|
||
dtSum = SqlHelper.ExecuteDataSet(isSumSql).Tables[0];
|
||
gcMain.SumFieldsTable = dtSum;
|
||
|
||
// 加载右侧多标签,默认加载为上下结构的表格
|
||
LoadDllDetailWithPanelPage();
|
||
// 加载底部多标签
|
||
LoadDllDeatilWithBottomTabPage();
|
||
|
||
SetDetailData();
|
||
GetPrintOtherParam();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 创建查询条件
|
||
/// </summary>
|
||
public void SearchCraeteControl()
|
||
{
|
||
string sql = string.Format("exec p_getControlLocation '{0}','{1}','{2}'", dtSystemwordbooktabTag3["fieldKey"], DLLCoid, OperatorName);
|
||
string SearchSql = PubClass.ReqSqlParam(dtSystemwordbooktabTag3["fieldsql"] + " " + LeftCond, OperatorId, OperatorName);
|
||
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
||
if (dt != null && dt.Rows.Count > 0)
|
||
{
|
||
string condSql = string.Format("select * from p_systembillsourcecond where formKey='{0}'", dtSystemwordbooktabTag3["fieldKey"]);
|
||
mcc.LoginId = OperatorId;
|
||
mcc.LoginName = OperatorName;
|
||
mcc.SearchSql = PubClass.ReplaceWhereCond(SearchSql);
|
||
mcc.ctr = pl_right_where;
|
||
mcc.gce = gridLeft.gridControl;
|
||
mcc.dllType = LeftType;
|
||
mcc.otherParams = Params;
|
||
mcc.condDt = SqlHelper.ExecuteDataSet(condSql).Tables[0];
|
||
CreateControlModel cm = new CreateControlModel();
|
||
cm.dt = dt;
|
||
cm.ctr = pl_right_where;
|
||
cm.loginid = OperatorId;
|
||
cm.loginname = OperatorName;
|
||
int height = mcc.CreateControlByModel(cm);
|
||
pl_right_where.Height = height;
|
||
Control[] ctl = pl_right_where.Controls.Find("btnCondSearch", true);
|
||
if ((ctl != null) && (ctl.Length > 0))
|
||
{
|
||
(ctl[0] as SimpleButton).Width = 72;
|
||
}
|
||
mcc.runQuery();
|
||
}
|
||
else
|
||
{
|
||
gridLeft.gridControl.DataSource = SqlHelper.ExecuteDataSet(dtSystemwordbooktabTag3["fieldsql"] + "").Tables[0];
|
||
pl_right_where.Visible = false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 顶部查询条件(保留之前的按列查询)
|
||
/// </summary>
|
||
public void SearchCreateTopControl()
|
||
{
|
||
string sql = string.Format("exec p_getControlLocation '{0}','{1}','{2}'", dtSystemDlltab["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}'", dtSystemDlltab["condKey"]);
|
||
mccTop.LoginId = OperatorId;
|
||
mccTop.ModuleId = ModuleId;
|
||
mccTop.LoginName = OperatorName;
|
||
mccTop.SearchSql = PubClass.ReplaceWhereCond(MyNotBmpSql);
|
||
mccTop.ctr = pl_search;
|
||
mccTop.tvLeft = tvLeft;
|
||
mccTop.tvLeftDataRow = dtSystemwordbooktabTag3;
|
||
mccTop.gridEx = gcMain;
|
||
mccTop.gce = gcMain.gridControl;
|
||
mccTop.RememberRow = true;
|
||
mccTop.dllType = LeftType;
|
||
mccTop.otherParams = Params;
|
||
mccTop.onSearchClick += new EventHandler(mSearch_onSearchClick);
|
||
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 (dtSystemDlltab["searchEnable"].ToString() == "1")
|
||
{
|
||
string sqlValue = mccTop.SetSearchSqlValue();
|
||
if (!string.IsNullOrEmpty(sqlValue))
|
||
{
|
||
InitData(sqlValue);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
mSeearchMode = 2;
|
||
// 假如未配置查询条件,则显示之前的下拉查询条件
|
||
label1.Visible = true;
|
||
cbField.Visible = true;
|
||
txtKey.Visible = true;
|
||
btnCondSearch_1.Visible = true;
|
||
if (dtSystemDlltab["searchEnable"].ToString() == "1")
|
||
btnSearch_Click(null, null);
|
||
}
|
||
}
|
||
public void mSearch_onSearchClick(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(mccTop.ActionSql))
|
||
{
|
||
this.beforeSearchSQL = mccTop.ActionSql;
|
||
}
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
public void InitMenu()
|
||
{
|
||
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", gcMain.gridControl);
|
||
gm.DirId = dtSystemDlltab["dirid"] + "";
|
||
gm.filedKey = mParmaryKey;
|
||
gm.BindGridMenuWQ(DLLCoid);
|
||
gm.OnGridMenuClickRefreshData += new EventHandler(gm_OnGridMenuClickRefreshData);
|
||
|
||
if (dtSystemwordbooktabTag3 == null)
|
||
return;
|
||
string DllCoidLeft = dtSystemwordbooktabTag3["fieldkey"].ToString();
|
||
GridMenu gm1 = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DllCoidLeft, "", gridLeft.gridControl);
|
||
gm1.DirId = dtSystemDlltab["dirid"] + "";
|
||
//gm1.filedKey = dtSystemwordbooktaNo["fieldname"].ToString();
|
||
gm1.BindGridMenuWQ(DllCoidLeft);
|
||
gm1.OnGridMenuClickRefreshData += new EventHandler(gm1_OnGridMenuClickRefreshData);
|
||
}
|
||
|
||
void gm1_OnGridMenuClickRefreshData(object sender, EventArgs e)
|
||
{
|
||
mcc.runQuery();
|
||
|
||
string dragState = gridViewLeft.Tag + "";
|
||
if ((dragState == "0") || (dragState == ""))
|
||
{
|
||
isSearch = false; // 设置当前查询模式为部分数据查询
|
||
DataRow row = gridViewLeft.GetFocusedDataRow();
|
||
if (row != null)
|
||
{
|
||
InitData(PubClass.ReplaceWhereCond(MyNotBmpSql) + " and " + dtSystemwordbooktabTag3["fieldsqlid"] + " = '" + row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "' ");
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 初始常用工具
|
||
/// </summary>
|
||
public void InitPrintMenu()
|
||
{
|
||
if (!string.IsNullOrEmpty(baseModuleFile))
|
||
{
|
||
String[] strs = baseModuleFile.Split('|');
|
||
for (int i = 0; i < strs.Length; i++)
|
||
{
|
||
BarButtonItem bbi = new BarButtonItem();
|
||
int index = i + 1;
|
||
bbi.Caption = strs[i].Replace(".rmf", "");
|
||
bbi.Tag = strs[i];
|
||
bbi.ItemClick += new ItemClickEventHandler(print_ItemClick);
|
||
pm_print.AddItem(bbi);
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 初始化常用功能
|
||
/// </summary>
|
||
public void InitOperMenu()
|
||
{
|
||
bbi_import = new BarButtonItem();
|
||
bbi_import.Caption = "数据导入";
|
||
bbi_import.ItemClick += new ItemClickEventHandler(btnImprt_Click);
|
||
|
||
bbi_export = new BarButtonItem();
|
||
bbi_export.Caption = "数据导出";
|
||
bbi_export.ItemClick += new ItemClickEventHandler(btnExport_Click);
|
||
|
||
bbi_print = new BarButtonItem();
|
||
bbi_print.Caption = "常规打印";
|
||
bbi_print.ItemClick += new ItemClickEventHandler(BtnPrint_Click);
|
||
|
||
bbi_word = new BarButtonItem();
|
||
bbi_word.Caption = "帮助文档";
|
||
bbi_word.ItemClick += new ItemClickEventHandler(btnHelp_Click);
|
||
|
||
pm_oper.AddItem(bbi_import);
|
||
pm_oper.AddItem(bbi_export);
|
||
pm_oper.AddItem(bbi_print);
|
||
pm_oper.AddItem(bbi_word);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:获取打印完成后进行数据库业务处理的参数</para>
|
||
/// <para>创建人:姜棚</para>
|
||
/// <para>创建日期:2018-07-19 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
private void GetPrintOtherParam()
|
||
{
|
||
string tmpSql = string.IsNullOrEmpty(basePrintSQL) ? beforeSearchSQL : basePrintSQL;
|
||
//取得打印完成后的参数
|
||
if (!string.IsNullOrEmpty(tmpSql) && tmpSql.Contains("<<"))
|
||
{
|
||
string[] strs = tmpSql.Split(new[] { ">>" }, 2, StringSplitOptions.None);
|
||
_mainPrintSql = strs[1];
|
||
_printModeCond = strs[0].Replace("<<", "");
|
||
}
|
||
if (!string.IsNullOrEmpty(_printModeCond) && _printModeCond.IndexOf(';') > 0)
|
||
{
|
||
string[] str = _printModeCond.Split(';');
|
||
string sql = string.Format("select * from v_systemdlltab where DllCoid='{0}'", str[0]);
|
||
DataTable dt = SqlHelper.ExecuteDataTable(sql);
|
||
if (dt == null || dt.Rows.Count == 0) return;
|
||
string tableName = dt.Rows[0]["TableName"] + "";
|
||
string modetype = dt.Rows[0]["modType"] + "";
|
||
string sql2 = string.Format("select column_prefix from p_systemtables where lower(table_name)='{0}'", tableName);
|
||
DataTable dt2 = SqlHelper.ExecuteDataTable(sql2);
|
||
if (dt2 == null || dt2.Rows.Count == 0) return;
|
||
string comprefix = dt2.Rows[0]["column_prefix"] + "";
|
||
string sql3 = string.Format("select top 1 fieldname from P_systemwordbooktab where tab='{0}' order by orderid", str[0]);
|
||
DataTable dt3 = SqlHelper.ExecuteDataTable(sql3);
|
||
|
||
string primaryKey = modetype == "1" ? dt3.Rows[0]["fieldname"] + "" : comprefix + "billdocument_id";
|
||
//表名,列前缀,主键字段,主键值,模块编号,主打印Sql
|
||
_printSaveParams = new List<string>() { tableName, comprefix, primaryKey, str[1], str[0], _mainPrintSql };
|
||
|
||
//判断是否直接打印 modetype 区别单据和基础档案模块
|
||
switch (modetype)
|
||
{
|
||
case "1":
|
||
string sql4 = string.Format("select * from P_systemdlltab where DllCoid='{0}'", str[0]);
|
||
DataTable dt4 = SqlHelper.ExecuteDataTable(sql4);
|
||
if (dt4 != null && dt4.Rows.Count > 0) _isExcPrint = dt4.Rows[0]["printType"] + "" == "3";
|
||
break;
|
||
case "2":
|
||
string sql5 = string.Format("select mastertable,overbacksql,overbackkey,overbackoper,overbackcond,prefix,formkey,billPrintType from p_systembilltype where typecode='{0}'", str[0]);
|
||
//BaseAccraditationModel model = new BaseAccraditationModel(BillAuditImpl.Instance.GetPubAuditProperty(str[0]));
|
||
DataTable dt5 = SqlHelper.ExecuteDataTable(sql5);
|
||
if (dt5 != null && dt5.Rows.Count > 0) _isExcPrint = dt5.Rows[0]["billPrintType"] + "" == "3";
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 打印
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void print_ItemClick(object sender, ItemClickEventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (e.Item != null && string.IsNullOrWhiteSpace(e.Item.Tag + "")) return;
|
||
|
||
string tmpSql = string.IsNullOrEmpty(basePrintSQL) ? beforeSearchSQL : basePrintSQL;
|
||
string tmpSql1 = basePrintSQL1;
|
||
string tmpSql2 = basePrintSQL2;
|
||
string path = PubUtil.AbsolutelyPath + "lib/P_PubPrint.lsp";
|
||
string printFile = e.Item.Tag + "";
|
||
|
||
if (string.IsNullOrEmpty(basePrintType))
|
||
{
|
||
basePrintType = "1";
|
||
}
|
||
//tmpSql = "select " + OperatorId + " as OperatorId,'" + OperatorName + "' OperatorName,getdate() as CreateTime";
|
||
|
||
//tmpSql1 = mcc.ActionSql;
|
||
//tmpSql2 = mcc.ActionSql;
|
||
DataRow row = gcMain.gridView.GetFocusedDataRow();
|
||
tmpSql = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql, OperatorId, OperatorName));
|
||
tmpSql1 = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql1, OperatorId, OperatorName));
|
||
tmpSql2 = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql2, OperatorId, OperatorName));
|
||
|
||
string mainSql = string.Empty;
|
||
List<string> tmpSqls = tmpSql2.Split(';').ToList();
|
||
if (_printSaveParams != null && _printSaveParams.Count > 0)
|
||
{
|
||
_printSaveParams[5] = mainSql = PubClass.ReqSql(row, _mainPrintSql);
|
||
//单据编号
|
||
_printSaveParams[3] = row.Table.Columns.Contains(_printSaveParams[2] + "") ? row[_printSaveParams[2]] + "" : row["billdocument_id"] + "";
|
||
tmpSqls.Add(tmpSql1);
|
||
tmpSqls.Add(mainSql);
|
||
}
|
||
if (printFile.Contains(PrintUtil.TemplateFlag))
|
||
{
|
||
PrintUtil.OnAfterPrint += new EventHandler(OnReportPrintAfter);
|
||
PrintUtil.TemplatePrint(tmpSqls, printFile, _isExcPrint);
|
||
}
|
||
else
|
||
{
|
||
PubUtil.LoadDelphiDll(path, path, printFile, tmpSql, tmpSql1, Convert.ToInt32(basePrintType), tmpSql2);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show("打印出错" + ex.Message);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:打印完成后回调</para>
|
||
/// <para>创建人:姜棚</para>
|
||
/// <para>创建日期:2018-07-05 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <param name="sender">The sender.</param>
|
||
/// <param name="e">The e.</param>
|
||
private void OnReportPrintAfter(object sender, EventArgs e)
|
||
{
|
||
//打印完成后添加数据库
|
||
int result = SavePrintRecord(_printSaveParams[0], _printSaveParams[1], _printSaveParams[2], _printSaveParams[3], _printSaveParams[4]);
|
||
}
|
||
/// <summary>
|
||
/// <para>说明:打印完成成功后数据业务处理</para>
|
||
/// <para>创建人:姜棚</para>
|
||
/// <para>创建日期:2018-07-05 </para>
|
||
/// <para>修改人:</para>
|
||
/// <para>修改日期:</para>
|
||
/// <para>修改备注:</para>
|
||
/// <para>版本:1.0</para>
|
||
/// </summary>
|
||
/// <returns>System.Int32.</returns>
|
||
public int SavePrintRecord(string tableName, string prefix, string primaryKey, string primaryValue, string modeCode)
|
||
{
|
||
string sqlValue = string.Format(@"update {0} set {1}printCount=isnull({1}printCount,0)+1,
|
||
{1}printLastTime=getdate(),{1}printLastOper='{4}'
|
||
where {2}='{3}'", tableName, prefix, primaryKey, primaryValue, ERPInfo.Instance.EmployeeId);
|
||
int i = SqlHelper.ExecuteNonQuery(sqlValue);
|
||
if (i < 0) return -1;
|
||
string sqlValue2 = string.Format(@"insert into p_systemPrintDetails (typeCode,sourcecode,OperatorId,operatedate,OperType)
|
||
values ('{0}','{1}','{2}','{3}','{4}')", modeCode, primaryValue, ERPInfo.Instance.EmployeeId, DateTime.Now, 3);
|
||
return SqlHelper.ExecuteNonQuery(sqlValue2);
|
||
}
|
||
/// <summary>
|
||
/// 执行右键菜单后刷新表格数据
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void gm_OnGridMenuClickRefreshData(object sender, EventArgs e)
|
||
{
|
||
//MessageBox.Show(beforeSearchSQL);
|
||
DataRow row = gridViewLeft.GetFocusedDataRow();
|
||
if (row != null)
|
||
beforeSearchSQL = PubClass.ReplaceWhereCond(MyNotBmpSql) + " and " + dtSystemwordbooktabTag3["fieldsqlid"] + " = '" + row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "' ";
|
||
if (string.IsNullOrEmpty(beforeSearchSQL))
|
||
{
|
||
if (mSeearchMode == 1)
|
||
{
|
||
string sqlValue = mccTop.SetSearchSqlValue();
|
||
if (!string.IsNullOrEmpty(sqlValue))
|
||
{
|
||
InitData(sqlValue);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
btnSearch_Click(null, null);
|
||
}
|
||
}
|
||
else
|
||
InitData(beforeSearchSQL);
|
||
}
|
||
public void Drag_EventHandler(object sender, DragEventArgs e)
|
||
{
|
||
MessageBox.Show("类别修改成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
/// <summary>
|
||
/// 处理图片
|
||
/// </summary>
|
||
/// <param name="sql"></param>
|
||
private void HandleBmp(string sql)
|
||
{
|
||
this.MyNotBmpSql = 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"] + "";
|
||
//MyNotBmpSql = MyNotBmpSql.Replace(" ", "-").Replace("-", "").Replace(", ", ",").Replace(" ,", ",");
|
||
MyNotBmpSql = MyNotBmpSql.Replace("," + fieldName + ",", ",").Replace("," + fieldName, " ");
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 表格拖动
|
||
/// <summary>
|
||
/// 拖动权限
|
||
/// </summary>
|
||
/// <param name="dr"></param>
|
||
/// <returns></returns>
|
||
private bool CanDragRowState(DataRow dr)
|
||
{
|
||
try
|
||
{
|
||
string tempCond = dragCond;
|
||
bool canDrag = string.IsNullOrEmpty(dragCond);
|
||
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 = dtSystemDlltab["SQLDT1"] + "";
|
||
string unionField = dtSystemwordbooktabTag3["fieldsqlid"] + "";
|
||
string parmaryKey = mParmaryKey;
|
||
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 (dtSystemDlltab["searchEnable"].ToString() == "1")
|
||
{
|
||
if (mSeearchMode == 1)
|
||
{
|
||
sqlValue = mccTop.SetSearchSqlValue();
|
||
if (!string.IsNullOrEmpty(sqlValue))
|
||
{
|
||
InitData(sqlValue);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
btnSearch_Click(null, null);
|
||
}
|
||
}
|
||
}
|
||
XtraMessageBox.Show("拖动成功 " + dragSuccess + " 条," + "失败 " + dragError + " 条", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 绑定数据
|
||
public void InitData(string sql)
|
||
{
|
||
|
||
int oldRowHandle = (gcMain.gridControl.MainView as GridView).FocusedRowHandle;
|
||
beforeSearchSQL = sql;
|
||
//这个绑定数据源
|
||
da = SqlHelper.ExecuteAdapter(CommandType.Text, sql);
|
||
if (ds != null && ds.Tables.Count > 0)
|
||
ds.Clear();
|
||
da.Fill(ds);
|
||
SqlCommandBuilder cb = new SqlCommandBuilder(da);
|
||
gcMain.gridControl.DataSource = ds.Tables[0];
|
||
(gcMain.gridControl.MainView as GridView).ClearSelection();
|
||
(gcMain.gridControl.MainView as GridView).FocusedRowHandle = oldRowHandle;
|
||
(gcMain.gridControl.MainView as GridView).SelectRow(oldRowHandle);
|
||
|
||
|
||
SetDetailData();
|
||
}
|
||
#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];
|
||
nullableFields = dtColumns.Rows.OfType<DataRow>().Where(x => x["tagid"] + "" == "1").ToArray();
|
||
gcMain.ModuleKey = DLLCoid;
|
||
gcMain.ModuleType = 1;
|
||
gcMain.FormKey = dtSystemDlltab["formkey"] + "";
|
||
gcMain.EnterOrder = mEnterOrder;
|
||
|
||
gcMain.SetColumns2(gcMain.ResetColumns(dtColumns));
|
||
|
||
gcMain.RowColorCondtion = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemwordbookcolor where isnull(useflag,0)=0 and tab ='{0}' order by orderid", DLLCoid)).Tables[0];
|
||
}
|
||
#endregion
|
||
|
||
#region 添加数据
|
||
/// <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(dtSystemDlltab["AddDllName"] + ""))
|
||
{
|
||
if (LeftType == 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.Name + "", 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 (LeftType == 2)
|
||
{
|
||
int[] rows = gridViewLeft.GetSelectedRows();
|
||
if (rows.Length == 0)
|
||
{
|
||
XtraMessageBox.Show("请选择类别", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
DataRow row = gridViewLeft.GetDataRow(rows[0]);
|
||
fieldsqlid = row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "";
|
||
fieldsqlname = row[dtSystemwordbooktabTag3["fieldsqlname"] + ""] + "";
|
||
|
||
DataTable dtGcHeader = gridLeft.gridControl.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,
|
||
"",
|
||
"0",
|
||
"",
|
||
fieldsqlid,
|
||
fieldsqlname,
|
||
strTag,
|
||
"",
|
||
"",
|
||
"",
|
||
jsonData
|
||
};
|
||
IForm form = PubUtil.LoadDllForm(dtSystemDlltab["AddDllName"] + "", args);
|
||
DialogResult result = form.SubForm.ShowDialog();
|
||
if (result == DialogResult.OK)
|
||
{
|
||
//string where = string.Empty;
|
||
//if (dtSystemwordbooktabTag3 != null) where = " and " + dtSystemwordbooktabTag3["fieldname"] + " like '" + fieldsqlid + "%'";
|
||
//if (string.IsNullOrEmpty(beforeSearchSQL))
|
||
//{
|
||
// InitData(PubClass.ReplaceWhereCond(MyNotBmpSql) + where);
|
||
//}
|
||
//else
|
||
//{
|
||
// InitData(PubClass.ReplaceWhereCond(beforeSearchSQL));
|
||
//}
|
||
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 (LeftType == 1)
|
||
{
|
||
TreeNode treeNode = tvLeft.GetTreeView.SelectedNode;
|
||
if (treeNode != null && treeNode.Nodes.Count > 0)
|
||
{
|
||
XtraMessageBox.Show("请选中末级节点!");
|
||
return;
|
||
}
|
||
}
|
||
AddRow(gcMain.gridView);
|
||
}
|
||
}
|
||
|
||
/// <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 (LeftType == 2)
|
||
{
|
||
int[] rows = gridViewLeft.GetSelectedRows();
|
||
if (rows.Length > 0)
|
||
{
|
||
DataRow row = gridViewLeft.GetDataRow(rows[0]);
|
||
GridColumn tmpcol = gcMain.gridView.Columns[dtSystemwordbooktabTag3["fieldname"] + ""];
|
||
view.SetRowCellValue(gcMain.gridView.FocusedRowHandle, tmpcol, row[dtSystemwordbooktabTag3["fieldsqlid"] + ""]);
|
||
view.UpdateCurrentRow();
|
||
view.ShowEditor();
|
||
}
|
||
}
|
||
if (LeftType == 1)
|
||
{
|
||
TreeNode tn = tvLeft.GetTreeView.SelectedNode;
|
||
GridColumn tmpcol = gcMain.gridView.Columns[dtSystemwordbooktabTag3["fieldname"] + ""];
|
||
view.SetRowCellValue(gcMain.gridView.FocusedRowHandle, tmpcol, tn.Name);
|
||
view.UpdateCurrentRow();
|
||
view.ShowEditor();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 删除数据
|
||
private void BtnDel_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(deleteCond);
|
||
string tempCond = deleteCond;
|
||
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[mParmaryKey];
|
||
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[mParmaryKey] + "',";
|
||
}
|
||
else
|
||
{
|
||
noDeleteIds += dr[mParmaryKey] + " >> " + msg + "\n";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
noDeleteIds += dr[mParmaryKey] + " >>不符删除合条件\n";
|
||
}
|
||
}
|
||
if (ids != string.Empty)
|
||
{
|
||
string sql = "delete from " + dtSystemDlltab["SQLDT1"] + " where " + mParmaryKey + " in(" + ids.Trim(',') + ")";
|
||
SqlHelper.ExecuteNonQuery(sql);
|
||
//InitData(MyNotBmpSql);
|
||
// 移除表格选中数据
|
||
gcMain.gridView.DeleteSelectedRows();
|
||
(gcMain.gridControl.DataSource as DataTable).AcceptChanges();
|
||
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 gridView_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
|
||
{
|
||
SetDetailData();
|
||
}
|
||
#endregion
|
||
|
||
#region 查询
|
||
/// <summary>
|
||
/// 查询
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnSearch_Click(object sender, EventArgs e)
|
||
{
|
||
isSearch = true; // 设置当前查询模式为全部数据查询
|
||
SearchData();
|
||
}
|
||
/// <summary>
|
||
/// 查询所有数据
|
||
/// </summary>
|
||
private void SearchData()
|
||
{
|
||
string field = cbField.SelectedValue + "";
|
||
string strWhere = " ";
|
||
treeTags = string.Empty;
|
||
if (LeftType == 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(treeTags))
|
||
strWhere += " and " + dtSystemwordbooktabTag3["fieldname"] + " in (" + treeTags.Trim(',') + ")";
|
||
InitData(PubClass.ReplaceWhereCond(MyNotBmpSql) + strWhere);
|
||
}
|
||
/// <summary>
|
||
/// 查询数据(按当前模式,树点击or表格点击or点击查询按钮)
|
||
/// </summary>
|
||
private void SearchCondData()
|
||
{
|
||
// 假如为树形结构,并且为点击树查询数据
|
||
if (LeftType == 1 && !isSearch)
|
||
{
|
||
TreeNode treeNode = tvLeft.GetTreeView.SelectedNode;
|
||
if (treeNode != null)
|
||
InitData(PubClass.ReplaceWhereCond(beforeSearchSQL) + " and " + dtSystemwordbooktabTag3["fieldname"] + " like '" + treeNode.Name + "%' ");
|
||
else
|
||
InitData(beforeSearchSQL);
|
||
}
|
||
// 假如左侧为表格数据,并且为点击表格查询数据
|
||
else if (LeftType == 2 && !isSearch)
|
||
{
|
||
int[] rows = gridViewLeft.GetSelectedRows();
|
||
if (rows.Length == 0)
|
||
return;
|
||
DataRow row = gridViewLeft.GetDataRow(rows[0]);
|
||
InitData(PubClass.ReplaceWhereCond(beforeSearchSQL) + " and " + dtSystemwordbooktabTag3["fieldname"] + " like '" + row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "%' ");
|
||
}
|
||
else
|
||
{
|
||
// 查询所有数据
|
||
InitData(beforeSearchSQL);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存
|
||
private void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
if (gridRequired())
|
||
{
|
||
try
|
||
{
|
||
//这个绑定数据源
|
||
if (da == null && this.beforeSearchSQL != null) {
|
||
da = SqlHelper.ExecuteAdapter(CommandType.Text, this.beforeSearchSQL);
|
||
}
|
||
da.Update(gcMain.gridControl.DataSource as DataTable);
|
||
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();
|
||
}
|
||
}
|
||
}
|
||
catch (InvalidOperationException ioe)
|
||
{
|
||
// 多表保存失败
|
||
gridSave();
|
||
return;
|
||
}
|
||
catch (DBConcurrencyException dce)
|
||
{
|
||
// 并发异常
|
||
XtraMessageBox.Show("数据已更新,请刷新后重试.");
|
||
return;
|
||
}
|
||
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>
|
||
/// <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 nullableFields)
|
||
{
|
||
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;
|
||
}
|
||
/// <summary>
|
||
/// 多表表格修改
|
||
/// </summary>
|
||
private void gridSave()
|
||
{
|
||
try
|
||
{
|
||
string tabName = dtSystemDlltab["SQLDT1"] + "";
|
||
if (string.IsNullOrEmpty(tabName))
|
||
{
|
||
XtraMessageBox.Show("检测到未设置表名");
|
||
return;
|
||
}
|
||
|
||
List<string> mList = new List<string>();
|
||
StringBuilder mBuilder = new StringBuilder();
|
||
List<string> keyValueList = new List<string>();
|
||
|
||
DataColumnCollection columns = SqlHelper.ExecuteDataTable(string.Format("select * from {0} where 1<>1", tabName)).Columns;
|
||
|
||
DataTable dtTable = gcMain.gridControl.DataSource as DataTable;
|
||
List<DataRow> modifiedRows = dtTable.Rows.Cast<DataRow>().Where(x => x.RowState == DataRowState.Modified || x.RowState == DataRowState.Added).ToList();
|
||
foreach (DataRow row in modifiedRows)
|
||
{
|
||
string updateSql = "update {0} set {1} where {2}='{3}';";
|
||
string insertSql = "insert into {0}({1}) values({2});";
|
||
string updateFields = string.Empty;
|
||
string insertFields = string.Empty;
|
||
string insertValues = string.Empty;
|
||
|
||
foreach (DataColumn col in columns)
|
||
{
|
||
DataRow hasContainRow = dtColumns.Rows.Cast<DataRow>().FirstOrDefault(x => x["fieldname"] + "" == col.ColumnName);
|
||
if (hasContainRow != null && col.ColumnName != mParmaryKey)
|
||
{
|
||
if (row.RowState == DataRowState.Modified)
|
||
{
|
||
updateFields += string.Format("{0}='{1}',", col.ColumnName, row[col.ColumnName]);
|
||
}
|
||
else if (row.RowState == DataRowState.Added)
|
||
{
|
||
insertFields += col.ColumnName + ",";
|
||
insertValues += "'" + row[col.ColumnName] + "',";
|
||
}
|
||
}
|
||
}
|
||
updateFields = updateFields.TrimEnd(',');
|
||
insertFields = insertFields.TrimEnd(',');
|
||
insertValues = insertValues.TrimEnd(',');
|
||
|
||
if (!string.IsNullOrEmpty(updateFields))
|
||
{
|
||
updateSql = string.Format(updateSql, tabName, updateFields, mParmaryKey, row[mParmaryKey]);
|
||
mList.Add(updateSql);
|
||
}
|
||
if (!string.IsNullOrEmpty(insertFields))
|
||
{
|
||
insertSql = string.Format(insertSql, tabName, insertFields, insertValues);
|
||
mList.Add(insertSql);
|
||
}
|
||
keyValueList.Add(row[mParmaryKey].ToString());
|
||
}
|
||
|
||
// 由于数据sql长度限制,每次只保存10条数据
|
||
int resultCount = 0; //成功记录数
|
||
List<string> failList = new List<string>();//失败记录关键值
|
||
for (int i = 0; i < mList.Count; i++)
|
||
{
|
||
if (i == mList.Count - 1 || (i != 0 && i % 10 == 0))
|
||
{
|
||
if (i == mList.Count - 1)
|
||
mBuilder.Append(mList[i]);
|
||
|
||
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("@baseSql",SqlDbType.VarChar,8000),
|
||
new SqlParameter("@saveType",SqlDbType.Int),
|
||
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
||
new SqlParameter("@tablename",SqlDbType.VarChar,50),
|
||
new SqlParameter("@keyfield",SqlDbType.VarChar,50),
|
||
new SqlParameter("@keyvalue",SqlDbType.VarChar,50),
|
||
new SqlParameter("@Operatorid",SqlDbType.Int),
|
||
new SqlParameter("@operatorname",SqlDbType.VarChar,50),
|
||
pMsg,
|
||
returnValue
|
||
};
|
||
param[0].Value = mBuilder.ToString();
|
||
param[1].Value = 8;// --8新增保存,9修改保存,10 删除条码
|
||
param[2].Value = DLLCoid;
|
||
param[3].Value = tabName;
|
||
param[4].Value = mParmaryKey;
|
||
param[5].Value = "";
|
||
param[6].Value = OperatorId;
|
||
param[7].Value = OperatorName;
|
||
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "P_BaseSave", "baseSave", param);
|
||
string rMsg = pMsg.Value.ToString();
|
||
//resultCount += Convert.ToInt32(returnValue.Value.ToString());
|
||
if (Convert.ToInt32(returnValue.Value.ToString()) > 0)
|
||
resultCount += Convert.ToInt32(returnValue.Value.ToString());
|
||
else
|
||
{
|
||
failList.Add(keyValueList[i] + ":" + rMsg.ToString());
|
||
}
|
||
|
||
mBuilder.Clear();
|
||
}
|
||
mBuilder.Append(mList[i]);
|
||
}
|
||
if (resultCount > 0)
|
||
{
|
||
if (resultCount == mList.Count)
|
||
{
|
||
(gcMain.gridControl.DataSource as DataTable).AcceptChanges();
|
||
SearchCondData();
|
||
//XtraMessageBox.Show("修改成功");
|
||
}
|
||
}
|
||
string lmsg = "保存操作完成,共" + (resultCount + failList.Count).ToString() + "条,成功" + resultCount.ToString() + "条";
|
||
if (failList.Count > 0)
|
||
{
|
||
lmsg = lmsg + ",失败" + failList.Count.ToString() + "条";
|
||
}
|
||
XtraMessageBox.Show(lmsg + "\n" + String.Join("\n", failList.ToArray()));
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
XtraMessageBox.Show(ex.Message);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 打印
|
||
private void BtnPrint_Click(object sender, EventArgs e)
|
||
{
|
||
PubClass.Preview(gcMain.gridControl);
|
||
}
|
||
#endregion
|
||
|
||
#region 树选中操作
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public string GetTreeCheck()
|
||
{
|
||
treeTags = string.Empty;
|
||
foreach (TreeNode item in tvLeft.GetTreeView.Nodes)
|
||
{
|
||
GetCheckedState(item);
|
||
}
|
||
return treeTags;
|
||
}
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
protected string treeTags = string.Empty;
|
||
/// <summary>
|
||
/// 选中节点之后,选中节点的所有子节点
|
||
/// </summary>
|
||
/// <param name="currNode"></param>
|
||
/// <param name="state"></param>
|
||
private void GetCheckedState(TreeNode currNode)
|
||
{
|
||
if (currNode.Checked)
|
||
treeTags += "" + currNode.Name + ",";
|
||
TreeNodeCollection nodes = currNode.Nodes;
|
||
if (nodes.Count > 0)
|
||
{
|
||
foreach (TreeNode tn in nodes)
|
||
{
|
||
if (tn.Checked)
|
||
treeTags += "'" + tn.Name + "',";
|
||
GetCheckedState(tn);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 修改
|
||
private void GridViewpub_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(dtSystemDlltab["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
|
||
{
|
||
btnSearch_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(modifyCond);
|
||
if (needModified == true)
|
||
{
|
||
string tempCond = modifyCond;
|
||
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[mParmaryKey].ToString();
|
||
string[] args = {
|
||
FormText,
|
||
OperatorId,
|
||
OperatorName,
|
||
Privilege,
|
||
DLLCoid,
|
||
"",
|
||
Convert.ToInt32( !canModify).ToString(),
|
||
productId,
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
"",
|
||
JsonUtil.ToJson(ToDataTable(dr))
|
||
};
|
||
IForm form = PubUtil.LoadDllForm(dtSystemDlltab["AddDllName"] + "", args);
|
||
DialogResult dialogResult = form.SubForm.ShowDialog();
|
||
}
|
||
return true;
|
||
}
|
||
public DataTable ToDataTable(DataRow row)
|
||
{
|
||
if (row == null) return null;
|
||
DataTable tmp = row.Table.Clone(); // 复制DataRow的表结构
|
||
tmp.Rows.Add(row.ItemArray); // 将DataRow添加到DataTable中
|
||
return tmp;
|
||
}
|
||
#endregion
|
||
|
||
#region 动态加载菜单
|
||
/// <summary>
|
||
///动态加载菜单
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void cmsGrid_Opening(object sender, CancelEventArgs e)
|
||
{
|
||
cmsGrid.Items.Clear();
|
||
List<ToolStripMenuItem> listQQ = new List<ToolStripMenuItem>();
|
||
List<ToolStripMenuItem> listWWW = new List<ToolStripMenuItem>();
|
||
|
||
int[] rowCount = gcMain.gridView.GetSelectedRows();
|
||
if (rowCount.Length > 0)
|
||
{
|
||
DataRow row = gcMain.gridView.GetDataRow(rowCount[0]);
|
||
GridColumnCollection columns = gcMain.gridView.Columns;
|
||
for (int i = 0; i < columns.Count; i++)
|
||
{
|
||
GridColumn gcItem = columns[i];
|
||
string tag = gcItem.Tag + "";
|
||
if (tag == "qq")
|
||
{
|
||
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
|
||
{
|
||
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.PubModuleDetail.Properties.Resources.qq);
|
||
item.Tag = row[gcItem.Name];
|
||
item.Click += new EventHandler(item_qq_Click);
|
||
listQQ.Add(item);
|
||
}
|
||
}
|
||
if (tag == "www")
|
||
{
|
||
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
|
||
{
|
||
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.PubModuleDetail.Properties.Resources.www);
|
||
item.Tag = row[gcItem.Name];
|
||
item.Click += new EventHandler(item_www_Click);
|
||
listWWW.Add(item);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
cmsGrid.Items.AddRange(tsmMenuList.ToArray());
|
||
cmsGrid.Items.AddRange(listQQ.ToArray());
|
||
cmsGrid.Items.AddRange(listWWW.ToArray());
|
||
}
|
||
#endregion
|
||
|
||
#region 打开QQ
|
||
protected void item_qq_Click(object sender, EventArgs e)
|
||
{
|
||
ToolStripMenuItem t = (ToolStripMenuItem)sender;
|
||
string text = t.Tag + "";
|
||
if (string.IsNullOrEmpty(text))
|
||
{
|
||
MessageBox.Show("请输入您的QQ号码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
Process p = new Process();
|
||
ProcessStartInfo ps = new ProcessStartInfo();
|
||
string Url = string.Format(@"tencent://message/?Menu=yes&uin={0}", text);
|
||
ps.FileName = @"iexplore.exe";
|
||
ps.Arguments = Url;
|
||
ps.UseShellExecute = true;
|
||
ps.RedirectStandardInput = false;
|
||
//ps.WindowStyle = ProcessWindowStyle.Hidden;
|
||
p.StartInfo = ps;
|
||
p.Start();
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 打开WWW
|
||
protected void item_www_Click(object sender, EventArgs e)
|
||
{
|
||
ToolStripMenuItem t = (ToolStripMenuItem)sender;
|
||
string url = t.Tag + "";
|
||
if (string.IsNullOrEmpty(url))
|
||
{
|
||
MessageBox.Show("请输入您要打开网址", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||
return;
|
||
}
|
||
System.Diagnostics.Process.Start("iexplore.exe", url);
|
||
}
|
||
#endregion
|
||
|
||
#region 左边树点击事件
|
||
private void gridViewLeft_RowCellClick(object sender, RowCellClickEventArgs e)
|
||
{
|
||
isSearch = false; // 设置当前查询模式为部分数据查询
|
||
DataRow row = gridViewLeft.GetDataRow(e.RowHandle);
|
||
string sql = PubClass.ReplaceWhereCond(MyNotBmpSql) + " and " + dtSystemwordbooktabTag3["fieldname"] + " = '" + row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "' ";
|
||
// 替换查询条件
|
||
List<string> list = PubClass.GetParamValue(sql);
|
||
|
||
foreach (string item in list)
|
||
{
|
||
string fileName = item.Replace("{", "").Replace("}", "");
|
||
Control[] ctrs = pl_search.Controls.Find("txt_" + fileName, true);
|
||
if (ctrs.Length > 0)
|
||
{
|
||
sql = MySearchCreateControl.SetReplaceSql(sql, item, ctrs);
|
||
}
|
||
}
|
||
InitData(sql);
|
||
}
|
||
#endregion
|
||
|
||
#region 窗体关闭事件
|
||
protected override void OnClosed(EventArgs e)
|
||
{
|
||
base.OnClosed(e);
|
||
if (PubUtil.ModuleForms.ContainsKey(ModuleId))
|
||
{
|
||
DllModule dm = PubUtil.ModuleForms[ModuleId];
|
||
if (dm != null)
|
||
{
|
||
dm.ModuleForm = null;
|
||
dm.ModuleInPtr = IntPtr.Zero;
|
||
PubUtil.ModuleForms.Remove(ModuleId);
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 帮助手册
|
||
private void btnHelp_Click(object sender, EventArgs e)
|
||
{
|
||
if (string.IsNullOrEmpty(DLLCoid))
|
||
{
|
||
MessageBox.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.ToString()
|
||
};
|
||
IForm form = PubUtil.LoadDllForm2("Lskj.Attachment.dll", args);
|
||
form.SubForm.ShowDialog();
|
||
}
|
||
#endregion
|
||
|
||
#region Execl 操作
|
||
/// <summary>
|
||
/// 导入操作
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnImprt_Click(object sender, EventArgs e)
|
||
{
|
||
string leftField = string.Empty;
|
||
string leftValue = string.Empty;
|
||
|
||
if (LeftType != 3)
|
||
{
|
||
leftField = dtSystemwordbooktabTag3["fieldname"] + "";
|
||
leftValue = tvLeft.GetSelectValue();
|
||
}
|
||
|
||
string columnPrefix = PubClass.GetColumnPrefix(dtSystemDlltab["SQLDT1"].ToString());
|
||
frmImport frm = new frmImport(gcMain, dtSystemDlltab["SQLDT1"].ToString(), "", "", OperatorId, OperatorName, columnPrefix, leftField, leftValue);
|
||
DialogResult result = frm.ShowDialog();
|
||
if (result == DialogResult.OK)
|
||
{
|
||
InitData(beforeSearchSQL);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 导出操作
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
private void btnExport_Click(object sender, EventArgs e)
|
||
{
|
||
PubClass.SaveXls(gcMain.gridControl);
|
||
}
|
||
#endregion
|
||
|
||
#region 添加、删除、修改按钮处理
|
||
/// <summary>
|
||
/// 处理删除按钮
|
||
/// </summary>
|
||
private void HandleDelButtonState(DataRow dr)
|
||
{
|
||
try
|
||
{
|
||
string tempCond = deleteCond;
|
||
bool canDel = string.IsNullOrEmpty(deleteCond);
|
||
if (!string.IsNullOrEmpty(tempCond))
|
||
{
|
||
tempCond = PubClass.ReqSqlWhere(dr, PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
||
canDel = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
||
}
|
||
BtnDel.Enabled = canDel && dtSystemDlltab["deleteEnable"].ToString() == "1";
|
||
}
|
||
catch (Exception)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
private void HandleAddButtonState()
|
||
{
|
||
try
|
||
{
|
||
string tempCond = addCond;
|
||
bool canDel = string.IsNullOrEmpty(addCond);
|
||
if (!string.IsNullOrEmpty(tempCond))
|
||
{
|
||
tempCond = PubClass.SqlToCode(PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
||
//MessageBox.Show(tempCond);
|
||
canDel = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
||
}
|
||
BtnAdd.Enabled = canDel && (dtSystemDlltab["addEnable"].ToString() == "1") && (ModulePriv == 1);
|
||
if (bbi_import != null)
|
||
{
|
||
bbi_import.Enabled = canDel && (dtSystemDlltab["importEnable"].ToString() == "1") && (ModulePriv == 1);
|
||
}
|
||
|
||
tempCond = printCond;
|
||
tempCond = PubClass.SqlToCode(PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
||
canDel = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
||
if (bbi_print != null) bbi_print.Enabled = canDel && (ModulePriv == 1); ;
|
||
|
||
tempCond = exportCond;
|
||
tempCond = PubClass.SqlToCode(PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
||
canDel = Convert.ToBoolean(Evaluator.Eval(tempCond)) && (dtSystemDlltab["exportEnable"].ToString() == "1") && (ModulePriv == 1);
|
||
if (bbi_export != null)
|
||
{
|
||
bbi_export.Enabled = canDel;
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 验证是否可以编辑行
|
||
/// </summary>
|
||
/// <param name="dr"></param>
|
||
private void HandleEditRowState(DataRow dr)
|
||
{
|
||
try
|
||
{
|
||
string tempCond = modifyCond;
|
||
bool canEdit = string.IsNullOrEmpty(modifyCond);
|
||
if (!string.IsNullOrEmpty(tempCond))
|
||
{
|
||
tempCond = PubClass.ReqSqlWhere(dr, PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName));
|
||
canEdit = Convert.ToBoolean(Evaluator.Eval(tempCond));
|
||
}
|
||
btnSave.Enabled = canEdit && dtSystemDlltab["modifyEnable"].ToString() == "1"; ;
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 行颜色
|
||
private void gvList_RowCellStyle(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 dtSysColorList.Rows)
|
||
{
|
||
List<string> condition = PubClass.GetParamValue(dr["condition"].ToString());
|
||
cond = dr["condition"].ToString();
|
||
foreach (string item in condition)
|
||
{
|
||
string filedName = item.Replace("{", "").Replace("}", "");
|
||
cond = cond.Replace(item, row[filedName].ToString());
|
||
}
|
||
cond = PubClass.SqlToCode(cond);
|
||
color = dr["backcolor"] + "";
|
||
forecolor = dr["forcecolor"].ToString() + "";
|
||
|
||
string obj = Evaluator.Eval(cond) + "";
|
||
if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1)
|
||
{
|
||
if (!string.IsNullOrEmpty(color))
|
||
{
|
||
System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(color);
|
||
e.Appearance.BackColor = color1;
|
||
}
|
||
if (!string.IsNullOrEmpty(forecolor))
|
||
{
|
||
System.Drawing.Color foreColor = System.Drawing.ColorTranslator.FromHtml(forecolor);
|
||
e.Appearance.ForeColor = foreColor;
|
||
|
||
}
|
||
FontStyle fst = new FontStyle();
|
||
if (dr["ifBold"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Bold;
|
||
}
|
||
if (dr["ifItalic"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Italic;
|
||
}
|
||
if (dr["ifStrickOut"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Strikeout;
|
||
}
|
||
if (dr["ifUnderLine"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Underline;
|
||
}
|
||
e.Appearance.Font = new Font(e.Appearance.Font, fst);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region GridViewpub_KeyDown事件
|
||
private void GridViewpub_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.Control & e.KeyCode == Keys.C)
|
||
{
|
||
Clipboard.SetDataObject((sender as GridView).GetFocusedRowCellValue((sender as GridView).FocusedColumn));
|
||
e.Handled = true;
|
||
}
|
||
// 向下复制整行
|
||
if (e.Control && e.Shift && e.KeyCode == Keys.C)
|
||
{
|
||
DataRow rt = (sender as GridView).GetFocusedDataRow();
|
||
DataTable dt = (DataTable)(sender as GridView).GridControl.DataSource;
|
||
dt.Rows.Add(rt.ItemArray);
|
||
(sender as GridView).GridControl.DataSource = dt;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 处理Grid计算
|
||
private void gridBillInfo_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
|
||
{
|
||
if (inSummary == true)
|
||
return;
|
||
inSummary = true;
|
||
try
|
||
{
|
||
DataRow gvRow = gcMain.gridView.GetDataRow(e.RowHandle);
|
||
foreach (DataRow row in dtSum.Rows)
|
||
{
|
||
string calcExpr = row["calcExpr"].ToString();
|
||
if (e.Column.FieldName != row["fieldName"].ToString())
|
||
{
|
||
List<string> listParam = PubClass.GetParamValue(calcExpr);
|
||
foreach (string str in listParam)
|
||
{
|
||
string filed = str.Replace("{", "").Replace("}", "");
|
||
string filedValue = gvRow[filed].ToString();
|
||
if (string.IsNullOrEmpty(filedValue))
|
||
filedValue = "0";
|
||
calcExpr = calcExpr.Replace(str, filedValue + "");
|
||
}
|
||
calcExpr = calcExpr.Replace("=", "==").Replace("<>", "!=").Replace("and", "&&").Replace("or", "|");
|
||
string result = Evaluator.Eval(calcExpr).ToString();
|
||
gcMain.gridView.SetRowCellValue(e.RowHandle, gcMain.gridView.Columns[row["fieldName"].ToString()], Math.Round(double.Parse(result), 2, MidpointRounding.AwayFromZero));
|
||
}
|
||
}
|
||
}
|
||
catch
|
||
{
|
||
|
||
}
|
||
inSummary = false;
|
||
}
|
||
#endregion
|
||
|
||
#region 基础档案、报表右侧明细表格
|
||
/// <summary>
|
||
/// 加载右侧多标签,添加在一个面板上,显示为上下结构的表格,只加载报表表格
|
||
/// </summary>
|
||
public void LoadDllDetailWithPanelPage()
|
||
{
|
||
tabMain.Visible = false;
|
||
mRightGridMode = 1;
|
||
mRightGridDataMode = 1;
|
||
// 获取配置明细列表
|
||
moduleDetailTable = SqlHelper.ExecuteDataSet("select distinct a.*,b.SQL from p_systemDlltabDetail a inner join p_systemdlltab b on a.UnionModule = b.DllCoid where a.tab='" + DLLCoid + "' and isnull(a.isVisible,0)=0 and a.rightVisible=1 and ISNULL(b.dllcoid,'')<>'' order by a.orderid").Tables[0];
|
||
// 明细列表没有数据,则获取报表明细配置,兼容旧版本
|
||
if (moduleDetailTable == null || moduleDetailTable.Rows.Count == 0)
|
||
{
|
||
moduleDetailTable = SqlHelper.ExecuteDataSet("select * from p_systemDlltabDetail where tab='" + DLLCoid + "' and isVisible=0 and rightVisible=1 order by orderid").Tables[0];
|
||
mRightGridDataMode = 2;
|
||
}
|
||
int count = moduleDetailTable.Rows.Count;
|
||
int currentHeight = 2;
|
||
foreach (DataRow row in moduleDetailTable.Rows)
|
||
{
|
||
Panel panel = new Panel();
|
||
GroupBox gb = new GroupBox();
|
||
gb.Text = row["detailName"] + "";
|
||
gb.Dock = DockStyle.Fill;
|
||
GridControlEx dgv = CreateDetailDgvWithTabPage(row);
|
||
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", dgv.gridControl);
|
||
gm.BindGridMenu(row["formKey"] + "");
|
||
dgv.Name = "grid";
|
||
dgv.Dock = DockStyle.Fill;
|
||
dgv.gridView.OptionsView.ShowFooter = true;
|
||
dgv.gridView.Tag = moduleDetailTable.Columns.Contains("SQL") ? row["SQL"] : row["detailSql"];
|
||
gb.Controls.Add(dgv);
|
||
panel.Controls.Add(gb);
|
||
panel.Tag = row;
|
||
panel.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
|
||
panel.Top = currentHeight;
|
||
panel.Width = plRightGrid.Width;
|
||
currentHeight += panel.Height = plRightGrid.Height / count;
|
||
plRightGrid.Controls.Add(panel);
|
||
}
|
||
if (moduleDetailTable.Rows.Count == 0)
|
||
{
|
||
tabMain.Visible = plRightGrid.Visible = splitterControl2.Visible = false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 加载右侧多标签,添加在多标签上,只加载报表表格
|
||
/// </summary>
|
||
public void LoadDllDeatilWithTabPage()
|
||
{
|
||
mRightGridMode = 2;
|
||
mRightGridDataMode = 1;
|
||
tabMain.TabPages.Clear();
|
||
// 获取配置明细列表
|
||
moduleDetailTable = SqlHelper.ExecuteDataSet(@"select a.*,b.SQL from p_systemDlltabDetail a
|
||
inner join p_systemdlltab b on a.UnionModule = b.DllCoid
|
||
where a.tab='" + DLLCoid + @"' and isnull(a.isVisible,0)=0
|
||
and isnull(a.rightVisible,0)=1 and ISNULL(b.dllcoid,'')<>'' order by a.orderid").Tables[0];
|
||
// 明细列表没有数据,则获取报表明细配置,兼容旧版本
|
||
if (moduleDetailTable == null || moduleDetailTable.Rows.Count == 0)
|
||
{
|
||
moduleDetailTable = SqlHelper.ExecuteDataSet("select * from p_systemDlltabDetail where tab='" + DLLCoid + "' and isVisible=0 and rightVisible=1 order by orderid").Tables[0];
|
||
mRightGridDataMode = 2;
|
||
}
|
||
foreach (DataRow row in moduleDetailTable.Rows)
|
||
{
|
||
XtraTabPage tabPage = new XtraTabPage();
|
||
tabPage.Text = row["detailName"] + "";
|
||
GridControlEx dgv = CreateDetailDgvWithTabPage(row);
|
||
dgv.Name = "grid" + row["id"];
|
||
///
|
||
dgv.ModuleType = 2;
|
||
dgv.ModuleKey = row["formKey"].ToString();
|
||
////
|
||
dgv.Tag = row;
|
||
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", dgv.gridControl);
|
||
gm.BindGridMenu(row["formKey"].ToString());
|
||
tabPage.Controls.Add(dgv);
|
||
dgv.gridView.Tag = moduleDetailTable.Columns.Contains("SQL") ? row["SQL"] : row["detailSql"];
|
||
dgv.gridView.OptionsView.ShowFooter = true;
|
||
dgv.Dock = DockStyle.Fill;
|
||
|
||
tabPage.Tag = dgv;
|
||
tabMain.TabPages.Add(tabPage);
|
||
}
|
||
if (moduleDetailTable.Rows.Count == 0)
|
||
{
|
||
tabMain.Visible = plRightGrid.Visible = splitterControl2.Visible = false;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 创建表格,为了兼容之前版本先取报表配置列,未配置则取报表明细列
|
||
/// </summary>
|
||
/// <param name="row"></param>
|
||
/// <returns></returns>
|
||
public GridControlEx CreateDetailDgvWithTabPage(DataRow row)
|
||
{
|
||
var detailId = Convert.ToInt32(row["Id"]);
|
||
var detailSql = Convert.ToString(row["detailSql"]);
|
||
var unionModule = row["UnionModule"] + "";
|
||
|
||
GridControlEx gcEx = new GridControlEx();
|
||
// 取报表配置列
|
||
SqlParameter[] p =
|
||
{
|
||
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
||
new SqlParameter("@operatorname",SqlDbType.VarChar,20)
|
||
};
|
||
p[0].Value = row["UnionModule"];
|
||
p[1].Value = OperatorName;
|
||
DataTable dtFileds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "[p_getBaseModuleField]", "temp", p).Tables[0];
|
||
|
||
if (dtFileds != null && dtFileds.Rows.Count == 0)
|
||
{
|
||
// 取报表明细列
|
||
SqlParameter[] p1 =
|
||
{
|
||
new SqlParameter("@modid",SqlDbType.VarChar,50),
|
||
new SqlParameter("@detailid",SqlDbType.Int,4),
|
||
new SqlParameter("@operatorname",SqlDbType.VarChar,50)
|
||
};
|
||
p1[0].Value = DLLCoid;
|
||
p1[1].Value = detailId;
|
||
p1[2].Value = OperatorName;
|
||
dtFileds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_getBaseModuleDetailField", "temp", p1).Tables[0];
|
||
gcEx.SetColumns(dtFileds);
|
||
gcEx.gridView.RowCellStyle += new RowCellStyleEventHandler(gridView_RowCellStyle);
|
||
}
|
||
else
|
||
{
|
||
gcEx.SetColumns2(dtFileds);
|
||
}
|
||
detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
gcEx.gridView.Tag = detailSql;
|
||
gcEx.RowColorCondtion = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemwordbookcolor where isnull(useflag,0)=0 and tab ='{0}' order by orderid", row["formkey"])).Tables[0];
|
||
return gcEx;
|
||
}
|
||
/// <summary>
|
||
/// 设置右侧表格数据
|
||
/// </summary>
|
||
private void SetRightGridData(DataRow drRow)
|
||
{
|
||
switch (mRightGridMode)
|
||
{
|
||
case 1: // 面板模式
|
||
SetRightPanelGridData(drRow);
|
||
break;
|
||
case 2:// 标签模式
|
||
SetRightTabGridData(drRow);
|
||
break;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 设置右侧面板表格数据
|
||
/// </summary>
|
||
private void SetRightPanelGridData(DataRow row)
|
||
{
|
||
foreach (Control item in plRightGrid.Controls)
|
||
{
|
||
if (item.Controls.Count > 0 && item.Controls[0].Controls.Count > 0)
|
||
{
|
||
GridControlEx gc = item.Controls[0].Controls[0] as GridControlEx;
|
||
gc.gridView.OptionsBehavior.Editable = false;
|
||
DataRow drRight = item.Tag as DataRow;
|
||
string sql = gc.gridView.Tag + "";
|
||
string fieldName = mParmaryKey;
|
||
string fieldValue = row[fieldName] + "";
|
||
|
||
string detailSql = sql;
|
||
string unionValue = (drRight["unionValue"] + "").Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
if (!string.IsNullOrEmpty(detailSql))
|
||
{
|
||
// sql模式
|
||
if (sql.IndexOf("select", StringComparison.OrdinalIgnoreCase) != -1)
|
||
{
|
||
detailSql = PubClass.ReplaceWhereCond(PubClass.ReqSql(row, sql));
|
||
detailSql += " and " + unionValue + " = '" + fieldValue + "'";
|
||
}
|
||
}
|
||
|
||
// 列表模式
|
||
//if (mRightGridDataMode == 1)
|
||
//{
|
||
// detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
//}
|
||
//else
|
||
//{ // 报表明细模式
|
||
detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
List<string> paramList = PubClass.GetParamValue(detailSql);
|
||
foreach (string param in paramList)
|
||
{
|
||
string fileName = param.Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
if (row.Table.Columns.Contains(fieldName))
|
||
{
|
||
detailSql = detailSql.Replace(param, row[fileName] + "");
|
||
}
|
||
}
|
||
//}
|
||
gc.SetDataSource(detailSql);
|
||
gc.gridView.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 设置右侧多标签数据
|
||
/// </summary>
|
||
/// <param name="row"></param>
|
||
private void SetRightTabGridData(DataRow row)
|
||
{
|
||
foreach (XtraTabPage tab in tabMain.TabPages)
|
||
{
|
||
GridControlEx gc = tab.Tag as GridControlEx;
|
||
DataRow drRight = gc.Tag as DataRow;
|
||
string sql = gc.gridView.Tag + "";
|
||
string fieldName = mParmaryKey;
|
||
string fieldValue = row[fieldName] + "";
|
||
string detailSql = sql;
|
||
string unionValue = (drRight["unionValue"] + "").Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
if (!string.IsNullOrEmpty(detailSql))
|
||
{
|
||
// sql模式
|
||
if (sql.IndexOf("select", StringComparison.OrdinalIgnoreCase) != -1)
|
||
{
|
||
detailSql = PubClass.ReplaceWhereCond(PubClass.ReqSql(row, sql));
|
||
detailSql += " and " + unionValue + " = '" + fieldValue + "'";
|
||
}
|
||
}
|
||
// 列表模式
|
||
//if (mRightGridDataMode == 1)
|
||
//{
|
||
// detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
//}
|
||
//else
|
||
//{ // 报表明细模式
|
||
detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
List<string> paramList = PubClass.GetParamValue(detailSql);
|
||
foreach (string param in paramList)
|
||
{
|
||
string fileName = param.Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
if (row.Table.Columns.Contains(fieldName))
|
||
{
|
||
detailSql = detailSql.Replace(param, row[fileName] + "");
|
||
}
|
||
}
|
||
//}
|
||
gc.SetDataSource(detailSql + " and " + unionValue + " = '" + fieldValue + "'");
|
||
gc.gridView.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 设置行颜色
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void gridView_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
||
{
|
||
if (e.RowHandle >= 0)
|
||
{
|
||
XtraTabPage tagpage = tabMain.SelectedTabPage;
|
||
if (tagpage == null) return;
|
||
GridControlEx gce = tagpage.Tag as GridControlEx;
|
||
DataRow row = gce.gridView.GetDataRow(e.RowHandle);
|
||
//颜色集合
|
||
DataTable dt = gce.RowColorCondtion as DataTable;
|
||
//选择列
|
||
string cond = string.Empty;
|
||
string color = string.Empty;
|
||
string forecolor = string.Empty;
|
||
|
||
if (dt != null && dt.Rows.Count > 0)
|
||
{
|
||
foreach (DataRow dr in dt.Rows)
|
||
{
|
||
List<string> condition = PubClass.GetParamValue(dr["condition"].ToString());
|
||
cond = dr["condition"].ToString();
|
||
foreach (string item in condition)
|
||
{
|
||
string filedName = item.Replace("{", "").Replace("}", "");
|
||
cond = cond.Replace(item, row[filedName].ToString());
|
||
}
|
||
cond = PubClass.SqlToCode(cond);
|
||
color = dr["backcolor"] + "";
|
||
forecolor = dr["forcecolor"].ToString() + "";
|
||
|
||
string obj = Evaluator.Eval(cond) + "";
|
||
if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1)
|
||
{
|
||
if (!string.IsNullOrEmpty(color))
|
||
{
|
||
System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(color);
|
||
e.Appearance.BackColor = color1;
|
||
}
|
||
if (!string.IsNullOrEmpty(forecolor))
|
||
{
|
||
System.Drawing.Color foreColor = System.Drawing.ColorTranslator.FromHtml(forecolor);
|
||
e.Appearance.ForeColor = foreColor;
|
||
|
||
}
|
||
FontStyle fst = new FontStyle();
|
||
if (dr["ifBold"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Bold;
|
||
}
|
||
if (dr["ifItalic"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Italic;
|
||
}
|
||
if (dr["ifStrickOut"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Strikeout;
|
||
}
|
||
if (dr["ifUnderLine"].ToString() == "1")
|
||
{
|
||
fst = fst | FontStyle.Underline;
|
||
}
|
||
e.Appearance.Font = new Font(e.Appearance.Font, fst);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载底部多标签
|
||
/// <summary>
|
||
/// 加载底部标签(可支持基础档案和报表)
|
||
/// </summary>
|
||
private void LoadDllDeatilWithBottomTabPage()
|
||
{
|
||
if (bottomHeight <= 100)
|
||
plBottomMain.Height = this.Height * bottomHeight / 100;
|
||
else
|
||
plBottomMain.Height = bottomHeight;
|
||
|
||
tabBottomMain.TabPages.Clear();
|
||
// 获取配置明细列表
|
||
moduleDetailBottomTable = SqlHelper.ExecuteDataSet("select a.*,b.SQL,isnull(b.isReport,0) isReport from p_systemDlltabDetail a inner join p_systemdlltab b on a.UnionModule = b.DllCoid where a.tab='" + DLLCoid + "' and a.isVisible=0 and isnull(a.rightVisible,0)=0 order by a.orderid").Tables[0];
|
||
// 明细列表没有数据,则获取报表明细配置,兼容旧版本
|
||
if (moduleDetailBottomTable == null || moduleDetailBottomTable.Rows.Count == 0)
|
||
{
|
||
moduleDetailBottomTable = SqlHelper.ExecuteDataSet("select * from p_systemDlltabDetail where tab='" + DLLCoid + "' and isVisible=0 and isnull(rightVisible,0)=0 order by orderid").Tables[0];
|
||
}
|
||
foreach (DataRow row in moduleDetailBottomTable.Rows)
|
||
{
|
||
var unionModule = row["UnionModule"] + "";
|
||
var unionValue = row["UnionValue"] + "";
|
||
var detailName = row["detailName"] + "";
|
||
var autoRefresh = row["autoRefresh"] + "";
|
||
|
||
var idFileName = unionValue.Replace("{", "").Replace("}", "");
|
||
SqlParameter[] p =
|
||
{
|
||
new SqlParameter("@modid",SqlDbType.VarChar,20),
|
||
new SqlParameter("@operatorname",SqlDbType.VarChar,20)
|
||
};
|
||
p[0].Value = unionModule;
|
||
p[1].Value = OperatorName;
|
||
DataTable dtCol = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "[p_getBaseModuleField]", "temp", p).Tables[0];
|
||
|
||
XtraTabPage tabPage = new XtraTabPage();
|
||
tabPage.Text = detailName;
|
||
DataTable dtMainTag3 = SqlHelper.ExecuteDataSet("select top 1 fieldname from p_systemwordbooktab where tab='" + unionModule + "' order by orderid asc").Tables[0];
|
||
if (dtMainTag3.Rows.Count > 0)
|
||
idFileName = dtMainTag3.Rows[0]["fieldname"] + "";
|
||
bool isTreeMode = !string.IsNullOrEmpty(row["detailType"] + "") && Convert.ToInt32(row["detailType"]) == 3;
|
||
DataTable dtMain = SqlHelper.ExecuteDataSet("select * from p_systemdlltab where dllcoid='" + unionModule + "'").Tables[0];
|
||
if (isTreeMode)
|
||
{
|
||
//树表创建
|
||
MouduleTreeGrid treeGrid = new MouduleTreeGrid();
|
||
treeGrid.FormText = detailName;
|
||
treeGrid.ParentPriv = ModulePriv;
|
||
treeGrid.ObjectId = idFileName;
|
||
treeGrid.OperatorName = OperatorName;
|
||
treeGrid.OperatorId = OperatorId;
|
||
treeGrid.DLLCoid = unionModule;
|
||
treeGrid.TreeColumnSource = dtCol;
|
||
treeGrid.Privilege = "0";
|
||
treeGrid.Tag = tabPage;
|
||
if (dtMain != null && dtMain.Rows.Count > 0)
|
||
{
|
||
treeGrid.TreeSourceSql = dtMain.Rows[0]["SQL"] + "";
|
||
}
|
||
treeGrid.Dock = DockStyle.Fill;
|
||
treeGrid.BringToFront();
|
||
tabPage.Controls.Add(treeGrid);
|
||
tabPage.Tag = treeGrid;
|
||
}
|
||
else
|
||
{
|
||
Panel_TabPage p_tabPage = new Panel_TabPage();
|
||
p_tabPage.pageText = detailName;
|
||
p_tabPage.parentPriv = ModulePriv;
|
||
tabPage.Controls.Add(p_tabPage);
|
||
p_tabPage.Dock = DockStyle.Fill;
|
||
p_tabPage.BringToFront();
|
||
//p_tabPage.TreeGridState = row["detailType"]+"".Trim() == "3";
|
||
|
||
p_tabPage.dtColumns = dtCol;
|
||
p_tabPage.gridList.EnterOrder = mEnterOrder;
|
||
p_tabPage.gridList.SetColumns2(dtCol);
|
||
|
||
//记录formKey
|
||
p_tabPage.gridList.FormKey = row["formKey"] + "";
|
||
p_tabPage.Name = "tab";
|
||
|
||
if (dtMain != null && dtMain.Rows.Count > 0)
|
||
{
|
||
p_tabPage.gridList.Sql = dtMain.Rows[0]["SQL"] + "";
|
||
p_tabPage.gridList.ModuleKey = unionModule;
|
||
p_tabPage.gridList.ModuleType = 1;
|
||
}
|
||
p_tabPage.DLLCoid = unionModule;
|
||
p_tabPage.FormText = detailName;
|
||
|
||
p_tabPage.objectId = idFileName; //关联字段Key
|
||
p_tabPage.OperatorId = OperatorId;
|
||
p_tabPage.OperatorName = OperatorName;
|
||
p_tabPage.Privilege = "0";
|
||
p_tabPage.objectValue = ""; // 关联字段值
|
||
p_tabPage.autoRefresh = "0"; // 初始化不刷新数据
|
||
p_tabPage.HasReport = moduleDetailBottomTable.Columns.Contains("isReport") ? Convert.ToBoolean(row["isReport"]) : true;
|
||
|
||
p_tabPage.gridList.gridView.Tag = moduleDetailBottomTable.Columns.Contains("SQL") ? row["SQL"] : row["detailSql"];
|
||
p_tabPage.gridList.Tag = row;
|
||
//if (p_tabPage.TreeGridState)
|
||
//p_tabPage.InitMenu();
|
||
tabPage.Tag = p_tabPage;
|
||
}
|
||
tabBottomMain.TabPages.Add(tabPage);
|
||
}
|
||
if (moduleDetailBottomTable.Rows.Count == 0)
|
||
{
|
||
splitContainerControl1.PanelVisibility = SplitPanelVisibility.Panel1;
|
||
//plBottomMain.Visible = false;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置底部表格数据
|
||
/// </summary>
|
||
/// <param name="row"></param>
|
||
private void SetBottomGridData(DataRow row)
|
||
{
|
||
//判断修改条件是否符合
|
||
bool canModify = false;
|
||
if (needModified)
|
||
{
|
||
string tempCond = modifyCond;
|
||
if (!canModify)
|
||
{
|
||
tempCond = PubClass.ReqSqlParam(tempCond, OperatorId, OperatorName);
|
||
tempCond = PubClass.ReqSqlWhere(row, tempCond);
|
||
canModify = string.IsNullOrEmpty(tempCond) ? true : Convert.ToBoolean(Evaluator.Eval(tempCond));
|
||
}
|
||
}
|
||
|
||
foreach (XtraTabPage tab in tabBottomMain.TabPages)
|
||
{
|
||
try
|
||
{
|
||
Panel_TabPage tabPage = tab.Tag as Panel_TabPage;
|
||
if (tabPage == null)
|
||
{
|
||
MouduleTreeGrid TreeGrid = tab.Tag as MouduleTreeGrid;
|
||
TreeGrid.RefreshData();
|
||
}
|
||
else
|
||
{
|
||
GridControlEx gc = tabPage.gridList;
|
||
DataRow drBottom = gc.Tag as DataRow;
|
||
string sql = gc.gridView.Tag + "";
|
||
string fieldName = drBottom.Table.Columns.Contains("unionParentField") && !string.IsNullOrEmpty(drBottom["unionParentField"] + "")
|
||
? drBottom["unionParentField"] + ""
|
||
: mParmaryKey;
|
||
string fieldValue = row[fieldName] + "";
|
||
string detailSql = PubClass.ReqSqlParam(sql, OperatorId, OperatorName);
|
||
//string unionValue = row[(drBottom["unionValue"] + "").Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "").ToString()]+"";
|
||
//string unionField = (drBottom["unionValue"] + "").Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
string unionValue = row[fieldName] + "";
|
||
string unionField = (drBottom["unionValue"] + "").Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
|
||
tabPage.objectId = unionField;
|
||
tabPage.objectValue = unionValue;
|
||
DataTable dtMainTag = SqlHelper.ExecuteDataSet("select top 1 fieldname from p_systemwordbooktab where tab='" + drBottom["UnionModule"] + "" + "' and lower(fieldname)='" + unionField.ToLower() + "'").Tables[0];
|
||
if (dtMainTag.Rows.Count < 1)
|
||
{
|
||
unionField = tabPage.objectId;
|
||
}
|
||
//string unionField = tabPage.objectId;
|
||
// 列表模式
|
||
//if (mRightGridDataMode == 1)
|
||
//{
|
||
// detailSql = PubClass.ReqSqlParam(detailSql, OperatorId, OperatorName);
|
||
//}
|
||
//else
|
||
//{ // 报表明细模式
|
||
if (sql.IndexOf("select", StringComparison.OrdinalIgnoreCase) >= 0)
|
||
{
|
||
detailSql = PubClass.ReplaceWhereCond(PubClass.ReqSql(row, detailSql));
|
||
detailSql = detailSql + " and " + unionField + " = '" + unionValue + "'";
|
||
}
|
||
List<string> paramList = PubClass.GetParamValue(detailSql);
|
||
foreach (string param in paramList)
|
||
{
|
||
string fileName = param.Replace("{", "").Replace("}", "").Replace("{", "").Replace("}", "");
|
||
if (row.Table.Columns.Contains(fieldName))
|
||
{
|
||
detailSql = detailSql.Replace(param, row[fileName] + "");
|
||
}
|
||
}
|
||
//}
|
||
gc.Sql = detailSql;
|
||
tabPage.InitData(gc.Sql);
|
||
tab.Text = tabPage.pageText + "(" + gc.gridView.DataRowCount.ToString() + ")";
|
||
|
||
if (gc.gridView.DataRowCount > 0)
|
||
{
|
||
tab.Appearance.Header.ForeColor = Color.Red;
|
||
}
|
||
else
|
||
{
|
||
tab.Appearance.Header.ForeColor = Color.FromArgb(0, 0, 0);
|
||
}
|
||
|
||
gc.gridView.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
|
||
}
|
||
}
|
||
catch (Exception)
|
||
{
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 设置明细数据
|
||
private void SetDetailData()
|
||
{
|
||
int[] rows = gcMain.gridView.GetSelectedRows();
|
||
if (rows != null && rows.Length > 0)
|
||
{
|
||
DataRow row = gcMain.gridView.GetDataRow(rows[0]);
|
||
this.HandleDelButtonState(row); // 验证删除按钮是否可以用
|
||
this.HandleEditRowState(row);
|
||
this.SetRightGridData(row); // 设置右侧表格数据
|
||
this.SetBottomGridData(row); // 设置底部表格数据
|
||
}
|
||
}
|
||
|
||
//表格编辑
|
||
private void gridView_ShowingEditor(object sender, CancelEventArgs e)
|
||
{
|
||
e.Cancel = !btnSave.Enabled;
|
||
}
|
||
|
||
#endregion
|
||
|
||
private void txtKey_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Return)
|
||
btnCondSearch_1.PerformClick();
|
||
}
|
||
|
||
private void pl_search_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void gridViewLeft_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
|
||
{
|
||
string dragState = gridViewLeft.Tag + "";
|
||
if ((dragState == "0") || (dragState == ""))
|
||
{
|
||
isSearch = false; // 设置当前查询模式为部分数据查询
|
||
DataRow row = gridViewLeft.GetDataRow(e.FocusedRowHandle);
|
||
string sqlValue = string.Empty;
|
||
if (row != null)
|
||
{
|
||
if (MyNotBmpSql.Contains("#"))
|
||
{
|
||
sqlValue = PubClass.ReqSql(row, MyNotBmpSql.Replace("#", ""));
|
||
}
|
||
else
|
||
{
|
||
sqlValue = MyNotBmpSql;
|
||
}
|
||
|
||
beforeSearchSQL = PubClass.ReplaceWhereCond(sqlValue) + " and " + dtSystemwordbooktabTag3["fieldsqlid"] + " = '" + row[dtSystemwordbooktabTag3["fieldsqlid"] + ""] + "' ";
|
||
InitData(beforeSearchSQL);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void panel1_Resize(object sender, EventArgs e)
|
||
{
|
||
if (mInitFinish)
|
||
{
|
||
Lskj.PubUtils.INIHelper.Write("base_width_" + DLLCoid, panel1.Width + "");
|
||
}
|
||
}
|
||
}
|
||
}
|