1322 lines
60 KiB
C#
1322 lines
60 KiB
C#
/******************************
|
|
* 说明:PubSpec分类模块
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-01-02
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Control;
|
|
using Lskj.Model;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Data;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Business;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using Lskj.Core;
|
|
using DevExpress.XtraGrid.Columns;
|
|
|
|
namespace Lskj.PubSpec
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
private readonly AltButtonShortcutManager mAltButtonShortcuts =
|
|
new AltButtonShortcutManager();
|
|
|
|
private bool _existsPid = false;
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
private string _parmaryKey;
|
|
/// <summary>
|
|
/// 左侧树
|
|
/// </summary>
|
|
private DataRow _leftTreeRow;
|
|
/// <summary>
|
|
/// 表格列
|
|
/// </summary>
|
|
private DataTable _gridColumns;
|
|
/// <summary>
|
|
/// 当前是否为显示所有分类
|
|
/// </summary>
|
|
private bool _isShowAllNode = true;
|
|
/// <summary>
|
|
/// 模块对象
|
|
/// </summary>
|
|
public DynamicModel Model;
|
|
/// <summary>
|
|
/// 系统对象
|
|
/// </summary>
|
|
public ModuleModel SysModel;
|
|
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
InitializeAltButtonShortcuts();
|
|
}
|
|
|
|
private void InitializeAltButtonShortcuts()
|
|
{
|
|
mAltButtonShortcuts.Register(btnExport, Keys.E);
|
|
mAltButtonShortcuts.Register(btnSave, Keys.S);
|
|
mAltButtonShortcuts.Register(btnDelete, Keys.D);
|
|
mAltButtonShortcuts.Register(btnAdd, Keys.A);
|
|
mAltButtonShortcuts.Register(btnRefresh, Keys.R);
|
|
}
|
|
|
|
protected override bool ProcessCmdKey(
|
|
ref System.Windows.Forms.Message msg, Keys keyData)
|
|
{
|
|
return mAltButtonShortcuts.ProcessKey(keyData) ||
|
|
base.ProcessCmdKey(ref msg, keyData);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
WaitForm.ShowForm();
|
|
|
|
try
|
|
{
|
|
this.Model.Privilege = this.Model.Privilege.Equals("3") ? "1" : Model.ModuleId > 0 ? BaseImpl.GetUserPurviewsByMenuId(Model.ModuleId + "") + "" : BaseImpl.GetUserPurviewsByMenuCode(Model.ModuleCode) + "";
|
|
if (!this.Model.HasPrivilege())
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnPurview);
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
this._parmaryKey = BaseModuleImpl.GetBasePrimaryKey(this.Model.ModuleCode);//获取主键
|
|
this.SysModel = new ModuleModel(MainImpl.GetSystemdllTab(this.Model.ModuleCode));//获取单个模块信息
|
|
|
|
this.treeLeft.TreeInhibitSort = this.SysModel.TreeInhibitSort;//树节点 禁用默认排序
|
|
|
|
this.btnAdd.Enabled = this.SysModel.AddEnable;
|
|
this.btnDelete.Enabled = this.SysModel.DeleteEnable;
|
|
this.btnSave.Enabled = this.SysModel.ModifyEnable;
|
|
this.gcMain.GridView.OptionsBehavior.Editable = this.SysModel.ModifyEnable;
|
|
if (Model.HasReadPrivilege())
|
|
{
|
|
this.btnAdd.Enabled = this.btnDelete.Enabled = this.btnSave.Enabled = false;
|
|
this.gcMain.GridView.OptionsBehavior.Editable = false;
|
|
}
|
|
this.InitializeTreeView();
|
|
this.InitializeGridView();
|
|
//if (this.SysModel.GridObjIsCheck == 1)
|
|
//{
|
|
// this.gcMain.GridView.ClearSelection();//清除第一行选中
|
|
//}
|
|
}
|
|
|
|
if (SystemInfo.Instance.HideHelpDocument)
|
|
{
|
|
//隐藏帮助文档按钮
|
|
this.simpleButton1.Visible = false;
|
|
this.btnShowAll.Location = new Point(this.btnShowAll.Location.X + simpleButton1.Width, this.btnShowAll.Location.Y);
|
|
|
|
}
|
|
this.InitlizeSpiltLocation();
|
|
this.scc_container.SplitterMoved += new System.EventHandler(this.OnSplitterMoved);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show(ex.StackTrace);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
|
|
WaitForm.HideForm();
|
|
this.scc_container.Visible = true;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化树</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeTreeView()
|
|
{
|
|
if (this.Model.ModuleCode != "A006101")
|
|
{
|
|
this._leftTreeRow = BaseModuleImpl.GetBaseLeftTreeField(this.Model.ModuleCode);
|
|
string specialId = string.Empty;
|
|
if (this._leftTreeRow != null)
|
|
{
|
|
//if (BaseImpl.HasExistsTable("p_systemTreeNodeSetTab"))
|
|
//{
|
|
// DataRow treeNodedr = BaseImpl.TreeNodeSetTab(this.SysModel.MenuTable);
|
|
// if (treeNodedr != null)
|
|
// {
|
|
// specialId = treeNodedr["treeIdField"] + "";
|
|
// }
|
|
//}
|
|
if (this._leftTreeRow.Table.Columns.Contains("TreeNodeSearch") && "1".Equals(this._leftTreeRow["TreeNodeSearch"] + "")) this.treeLeft.pl_top.Visible = true;
|
|
this.treeLeft.TreeView.CheckBoxes = false;
|
|
this.treeLeft.TreeNodeKeyField = this._leftTreeRow["fieldsqlid"] + "";
|
|
this.treeLeft.TreeNodeTextField = this._leftTreeRow["fieldsqlname"] + "";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter);
|
|
//if (string.IsNullOrEmpty(specialId))
|
|
//{
|
|
DataTable treeSourceTab = BaseImpl.GetDataTableResult(this._leftTreeRow["fieldsql"] + "");
|
|
if (treeSourceTab.Rows.Count == 0)
|
|
{
|
|
string fieldValue = string.Empty;
|
|
string tableName = this.SysModel.MenuTable;
|
|
if (string.IsNullOrEmpty(tableName))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.MenuTableNameIsNull);
|
|
return;
|
|
}
|
|
string insertSql = "insert into {0}({1}) values({2});";
|
|
string insertFields = string.Empty;//插入字段
|
|
string insertValues = string.Empty;//插入的值
|
|
string Autogrowcolumn = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", tableName)) + "";//自动增长列
|
|
DataColumnCollection columns = BaseImpl.GetTableColumns(tableName).Columns;
|
|
foreach (DataColumn col in columns)
|
|
{
|
|
DataTable gridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);
|
|
// 区分大小写匹配列
|
|
DataRow hasContainRow = gridColumns.Rows.Cast<DataRow>().FirstOrDefault(x => x["fieldname"] + "" == col.ColumnName);
|
|
if (hasContainRow != null)
|
|
{
|
|
string defaultValue = BaseImpl.GetDefaultValue(hasContainRow["defaultdate"] + ""); //默认值
|
|
//if (col.ColumnName != _parmaryKey)
|
|
// fieldValue = defaultValue;
|
|
if (col.ColumnName == _parmaryKey)
|
|
fieldValue = defaultValue;
|
|
if (Autogrowcolumn.ToLower() == col.ColumnName.ToLower())
|
|
continue;
|
|
insertFields += col.ColumnName + ",";
|
|
if (col.ColumnName.Equals(treeLeft.TreeNodeKeyField))
|
|
insertValues += "'01',";
|
|
else if (col.ColumnName.Equals(treeLeft.TreeNodeTextField))
|
|
insertValues += "'公司',";
|
|
else
|
|
insertValues += string.IsNullOrWhiteSpace(defaultValue) ? "NULL," : "'" + defaultValue + "',";
|
|
}
|
|
}
|
|
insertFields = insertFields.TrimEnd(',');
|
|
insertValues = insertValues.TrimEnd(',');
|
|
BaseSaveModel model = new BaseSaveModel()
|
|
{
|
|
MenuCode = this.Model.ModuleCode,
|
|
TableName = tableName,
|
|
KeyField = _parmaryKey,
|
|
BaseSaveType = SaveType.Add,
|
|
FieldValue = fieldValue,
|
|
BaseSql = string.Format(insertSql, tableName, insertFields, insertValues)
|
|
};
|
|
List<BaseSaveModel> mList = new List<BaseSaveModel>();
|
|
mList.Add(model);
|
|
try
|
|
{
|
|
string retuenMsg = "";
|
|
// 批量保存数据
|
|
if (BaseModuleImpl.SaveBaseGridData(mList, out retuenMsg))
|
|
{
|
|
treeSourceTab = BaseImpl.GetDataTableResult(this._leftTreeRow["fieldsql"] + "");
|
|
}
|
|
else
|
|
{
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ResourceKeys.SaveFault);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
this.treeLeft.BindTreeView(treeSourceTab);
|
|
//}
|
|
//else
|
|
//{
|
|
// _existsPid = true;
|
|
// this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this._leftTreeRow["fieldsql"] + ""), specialId);
|
|
//}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception(string.Format("未查询到左侧树数据,模块编号:{0}", this.Model.ModuleCode));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (SysModel != null)
|
|
{
|
|
string sql = SysModel.MenuSql;
|
|
sql = sql + " order by speciesNo";
|
|
this.treeLeft.TreeView.CheckBoxes = false;
|
|
this.treeLeft.TreeNodeKeyField = "SpeciesNo";
|
|
this.treeLeft.TreeNodeTextField = "SpeciesName";
|
|
this.treeLeft.TreeNodeSelectAfter += new TreeViewEventHandler(OnTreeNodeSelectAfter);
|
|
this.treeLeft.BindSpecialTreeView(BaseImpl.GetDataTableResult(sql));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 通过列属性判断是否可以编辑
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void OnGridViewShowingEditor(object sender, CancelEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridView gridView = (GridView)sender;
|
|
GridColumn gridColumn = gridView.FocusedColumn;
|
|
GridColumnModel gridColumnModel = null;
|
|
if (gridColumn.Tag != null)
|
|
{
|
|
gridColumnModel = (GridColumnModel)gridColumn.Tag;
|
|
}
|
|
DataRow focusedRow = gridView.GetFocusedDataRow();
|
|
if (!gridView.FocusedColumn.FieldName.Equals("RightMenuBtnEdit"))//操作列可点击
|
|
{
|
|
e.Cancel = !btnSave.Enabled;
|
|
}
|
|
if (!string.IsNullOrEmpty(this.SysModel.RowAllowEditCond) && focusedRow != null)
|
|
{
|
|
//e.Cancel = ReplaceHelper.EvalCond(ReplaceHelper.ReplaceRowParam(focusedRow, this.SysModel.RowAllowEditCond));
|
|
e.Cancel = !ValidateCond(this.SysModel.RowAllowEditCond, focusedRow, "P_SystemDllTab", "rowAllowEditCond");
|
|
}
|
|
else if (gridColumnModel != null && !string.IsNullOrEmpty(gridColumnModel.DisableCond))
|
|
{
|
|
//e.Cancel = !ReplaceHelper.EvalCond(ReplaceHelper.ReplaceRowParam(focusedRow, gridColumnModel.DisableCond));
|
|
e.Cancel = !ValidateCond(gridColumnModel.DisableCond, focusedRow);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:初始化表格</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void InitializeGridView()
|
|
{
|
|
if (this.SysModel.GridObjIsCheck == 1)
|
|
{
|
|
GridDragGrid.GridAddCheckBox(this.gcMain.GridView);
|
|
}
|
|
this.gcMain.GridView.ShowingEditor += new CancelEventHandler(OnGridViewShowingEditor);
|
|
this.gcMain.Model = this.Model;
|
|
this._gridColumns = BaseModuleImpl.GetBaseGridColumns(this.Model.ModuleCode);
|
|
//GridDragTree dragTree = new GridDragTree(this.gcMain.GridView, this.treeLeft.TreeView);
|
|
//dragTree.OnDragComplete += new GridDragTreeCompleteEventHandler(OnDragCompleted);
|
|
this.gcMain.IsSpecModel = true;
|
|
this.gcMain.SetEditColumns(this._gridColumns, GridCustomColumnStruct.PubSpecMainGridView + this.SysModel.FormKey);
|
|
this.gcMain.SetGridRowColors(BaseModuleImpl.GetBaseGridRowColors(this.Model.ModuleCode));
|
|
this.gcMain.SetGridRightMenus(BaseModuleImpl.GetBaseGridRightMenus(this.Model.ModuleCode), this.Model, OnGridViewRightCallBack, null);
|
|
this.gcMain.GridView.FocusedRowObjectChanged += new DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventHandler(OnGridViewFocusedRowObjectChanged);
|
|
this.SearchLastGridView();
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:行选中发生变化,判断是否是否可用</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-10 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs"/> instance containing the event data.</param>
|
|
void OnGridViewFocusedRowObjectChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowObjectChangedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GridView gridView = sender as GridView;
|
|
DataRow rowItem = gridView.GetFocusedDataRow();
|
|
|
|
this.ValidateButtonState(rowItem);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查按钮是否可用</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-21 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void ValidateButtonState(DataRow rowItem)
|
|
{
|
|
if (rowItem == null) return;
|
|
try
|
|
{
|
|
if (!Model.HasOperPrivilege())
|
|
{
|
|
this.btnAdd.Enabled = this.btnDelete.Enabled = this.btnSave.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
|
|
if (this.treeLeft.TreeView.SelectedNode != null)
|
|
{
|
|
this.btnAdd.Enabled = this.SysModel.AddEnable && this.ValidateCond(this.SysModel.AddCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), rowItem, "P_SystemDllTab", "addEnable"); // 判断添加权限
|
|
this.btnDelete.Enabled = this.SysModel.DeleteEnable && this.ValidateCond(this.SysModel.DeleteCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), rowItem, "P_SystemDllTab", "deleteCond"); // 判断删除权限
|
|
this.btnSave.Enabled = this.SysModel.ModifyEnable && this.ValidateCond(this.SysModel.ModifyCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), rowItem, "P_SystemDllTab", "modifyCond"); // 判断修改权限
|
|
}
|
|
else
|
|
{
|
|
this.btnAdd.Enabled = this.SysModel.AddEnable && this.ValidateCond(this.SysModel.AddCond, rowItem, "P_SystemDllTab", "addEnable"); // 判断添加权限
|
|
this.btnDelete.Enabled = this.SysModel.DeleteEnable && this.ValidateCond(this.SysModel.DeleteCond, rowItem, "P_SystemDllTab", "deleteCond"); // 判断删除权限
|
|
this.btnSave.Enabled = this.SysModel.ModifyEnable && this.ValidateCond(this.SysModel.ModifyCond, rowItem, "P_SystemDllTab", "modifyCond"); // 判断修改权限
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:检查可用条件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="cond">The cond.</param>
|
|
/// <param name="dataRow">The data row.</param>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
private bool ValidateCond(string cond, DataRow dataRow, string TableName = null, string ColumnName = null)
|
|
{
|
|
bool result = false;
|
|
string condition = cond;
|
|
try
|
|
{
|
|
cond = ReplaceHelper.ReplaceRowParam(dataRow, cond);
|
|
if (cond.StartsWith("@") || cond.StartsWith("!"))
|
|
{
|
|
result = "1".Equals(BaseImpl.GetDefaultValue(cond));
|
|
}
|
|
else
|
|
{
|
|
result = ReplaceHelper.ReplaceRowParamCond(dataRow, cond);
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
string Tips = string.Empty;
|
|
if (!string.IsNullOrWhiteSpace(TableName) && !string.IsNullOrWhiteSpace(ColumnName))
|
|
{
|
|
Tips = string.Format("{0}表中{1}字段{2},判断条件失败\r\n", TableName, ColumnName, condition);
|
|
}
|
|
else
|
|
{
|
|
Tips = string.Format("条件为:{0}\r\n", condition);
|
|
}
|
|
//MessageUtil.Show("条件判断错误:\r\n" + Tips);
|
|
Tips = "条件判断错误:\r\n" + Tips;
|
|
string Message = ErrorMessage.PromptErrorMessage(ex, "", Tips);
|
|
}
|
|
return result;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:查询GridView数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SearchLastGridView(string parentValue = "")
|
|
{
|
|
try
|
|
{
|
|
string sqlValue = string.Empty;
|
|
WaitForm.ShowForm();
|
|
int firstNum = this.treeLeft.TreeView.Nodes[0].Name.Length;
|
|
int focusRowHandle = this.gcMain.GridView.FocusedRowHandle;
|
|
string maxdivision = string.Empty;
|
|
for (int i = 0; i < firstNum; i++)
|
|
{
|
|
maxdivision += "_";
|
|
}
|
|
if (this.Model.ModuleCode != "A006101")
|
|
{
|
|
if (_existsPid)
|
|
{
|
|
sqlValue = string.IsNullOrWhiteSpace(parentValue)
|
|
? this.SysModel.MenuSql
|
|
: this.SysModel.MenuSql + string.Format(" and pid='{1}' order by {0}", "orderid", parentValue);
|
|
}
|
|
else
|
|
{
|
|
string sortField = _leftTreeRow["fieldsqlid"] + "";
|
|
//配置了树节点不排序,主sql排序默认添加orderid
|
|
if (this.SysModel.TreeInhibitSort)
|
|
{
|
|
sortField = " orderid," + _leftTreeRow["fieldsqlid"];
|
|
if (!Lskj.Business.Impl.BaseImpl.HasExistsColumn(this.SysModel.MenuTable, "orderid"))
|
|
{
|
|
MessageUtil.Show(string.Format("配置了树节点禁用默认排序的情况下,请在主表{0}中,添加orderid字段", this.SysModel.MenuTable));
|
|
return;
|
|
}
|
|
}
|
|
|
|
sqlValue = string.IsNullOrWhiteSpace(parentValue)
|
|
? this.SysModel.MenuSql
|
|
: this.SysModel.MenuSql + string.Format(" and {0} like '{1}{2}' order by {3}", _leftTreeRow["fieldsqlid"] + "", parentValue, maxdivision, sortField);
|
|
|
|
if (!string.IsNullOrWhiteSpace(this.SysModel.SortField))
|
|
{
|
|
sqlValue = string.IsNullOrWhiteSpace(parentValue)
|
|
? this.SysModel.MenuSql
|
|
: this.SysModel.MenuSql + string.Format(" and {0} like '{1}{2}' order by {3}", _leftTreeRow["fieldsqlid"] + "", parentValue, maxdivision, this.SysModel.SortField);
|
|
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
sqlValue = string.IsNullOrWhiteSpace(parentValue)
|
|
? this.SysModel.MenuSql
|
|
: this.SysModel.MenuSql + string.Format(" and {0} like '{1}{2}' order by {0}", "SpeciesNo", parentValue, maxdivision);
|
|
}
|
|
DataTable table=BaseImpl.GetDataTableResult(sqlValue);
|
|
this.gcMain.SetGridViewDataSource(table);
|
|
this.gcMain.GridView.SelectRowHandler(focusRowHandle);
|
|
if (table != null && table.Rows.Count == 0&& this.treeLeft.TreeView.SelectedNode!=null)
|
|
{
|
|
//DataRow RowItem = gcMain.GridControl.DataSourceTable().NewRow();
|
|
//this.ValidateButtonState(RowItem);
|
|
if (!Model.HasOperPrivilege())
|
|
{
|
|
this.btnAdd.Enabled = this.btnDelete.Enabled = this.btnSave.Enabled = false;
|
|
}
|
|
else
|
|
{
|
|
//this.SysModel.ModifyCond.Replace("{SpeciesNo}", parentValue).Replace("{SpeciesName}", this.treeLeft.TreeView.SelectedNode.Text)
|
|
this.btnAdd.Enabled = this.SysModel.AddEnable && this.ValidateCond(this.SysModel.AddCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), null, "P_SystemDllTab", "addEnable"); // 判断添加权限
|
|
this.btnDelete.Enabled = this.SysModel.DeleteEnable && this.ValidateCond(this.SysModel.DeleteCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), null, "P_SystemDllTab", "deleteCond"); // 判断删除权限
|
|
this.btnSave.Enabled = this.SysModel.ModifyEnable && this.ValidateCond(this.SysModel.ModifyCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), null, "P_SystemDllTab", "modifyCond"); // 判断修改权限
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
finally
|
|
{
|
|
WaitForm.HideForm();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:保存Grid数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
|
private void AddGridData(string parentValue)
|
|
{
|
|
string parentText = "新增分类";
|
|
string fieldValue = string.Empty;
|
|
string tableName = this.SysModel.MenuTable;
|
|
|
|
if (string.IsNullOrEmpty(tableName))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.MenuTableNameIsNull);
|
|
return;
|
|
}
|
|
|
|
string insertSql = "insert into {0}({1}) values({2});";
|
|
string insertFields = string.Empty;//插入字段
|
|
string insertValues = string.Empty;//插入的值
|
|
string Autogrowcolumn = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", tableName)) + "";//自动增长列
|
|
DataColumnCollection columns = BaseImpl.GetTableColumns(tableName).Columns;
|
|
foreach (DataColumn col in columns)
|
|
{
|
|
// 区分大小写匹配列
|
|
DataRow hasContainRow = _gridColumns.Rows.Cast<DataRow>().FirstOrDefault(x => x["fieldname"] + "" == col.ColumnName);
|
|
if (hasContainRow != null)
|
|
{
|
|
string defaultValue = BaseImpl.GetDefaultValue(hasContainRow["defaultdate"] + ""); //默认值
|
|
//if (col.ColumnName != _parmaryKey)
|
|
// fieldValue = defaultValue;
|
|
if (col.ColumnName == _parmaryKey)
|
|
fieldValue = defaultValue;
|
|
if (Autogrowcolumn.ToLower() == col.ColumnName.ToLower())
|
|
continue;
|
|
insertFields += col.ColumnName + ",";
|
|
if (col.ColumnName.Equals(treeLeft.TreeNodeKeyField))
|
|
insertValues += "'" + parentValue + "',";
|
|
else if (col.ColumnName.Equals(treeLeft.TreeNodeTextField))
|
|
insertValues += "'" + parentText + "',";
|
|
else
|
|
insertValues += string.IsNullOrWhiteSpace(defaultValue) ? "NULL," : "'" + defaultValue + "',";
|
|
}
|
|
}
|
|
|
|
|
|
insertFields = insertFields.TrimEnd(',');
|
|
insertValues = insertValues.TrimEnd(',');
|
|
|
|
BaseSaveModel model = new BaseSaveModel()
|
|
{
|
|
MenuCode = this.Model.ModuleCode,
|
|
TableName = tableName,
|
|
KeyField = _parmaryKey,
|
|
BaseSaveType = SaveType.Add,
|
|
FieldValue = fieldValue,
|
|
BaseSql = string.Format(insertSql, tableName, insertFields, insertValues)
|
|
};
|
|
|
|
List<BaseSaveModel> mList = new List<BaseSaveModel>();
|
|
mList.Add(model);
|
|
|
|
try
|
|
{
|
|
string retuenMsg = "";
|
|
// 批量保存数据
|
|
if (BaseModuleImpl.SaveBaseGridData(mList, out retuenMsg))
|
|
{
|
|
//MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
|
|
TreeNode selectedNode = this.treeLeft.TreeView.SelectedNode;
|
|
TreeNode treeNode = selectedNode.Nodes.Add(parentValue, parentText);
|
|
treeNode.Tag = parentValue;
|
|
selectedNode.Expand();
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
}
|
|
else
|
|
{
|
|
if (mList != null && mList.Count > 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + mList[0].FaultMsg);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ResourceKeys.SaveFault);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:更新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-04 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void UpdateGridData()
|
|
{
|
|
string tableName = this.SysModel.MenuTable;
|
|
|
|
if (string.IsNullOrEmpty(tableName))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.MenuTableNameIsNull);
|
|
return;
|
|
}
|
|
List<BaseSaveModel> mList = new List<BaseSaveModel>();
|
|
DataRow[] modifiedRows = (gcMain.GridControl.DataSource as DataTable)
|
|
.Rows
|
|
.Cast<DataRow>()
|
|
.Where(x => x.RowState == DataRowState.Modified || x.RowState == DataRowState.Added)
|
|
.ToArray();
|
|
|
|
if (modifiedRows == null || modifiedRows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnUpdateData);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
string Autogrowcolumn = BaseImpl.GetResult(string.Format("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME='{0}' AND COLUMNPROPERTY(OBJECT_ID('{0}'),COLUMN_NAME,'IsIdentity')=1", tableName)) + "";
|
|
DataColumnCollection columns = BaseImpl.GetTableColumns(tableName).Columns;
|
|
|
|
foreach (DataRow row in modifiedRows)
|
|
{
|
|
string updateSql = "update {0} set {1} where {2}='{3}';";
|
|
string updateFields = string.Empty;
|
|
|
|
BaseSaveModel model = new BaseSaveModel()
|
|
{
|
|
MenuCode = this.Model.ModuleCode,
|
|
TableName = tableName,
|
|
NewVer = this.SysModel.NewVer,
|
|
KeyField = _parmaryKey
|
|
};
|
|
|
|
foreach (DataColumn col in columns)
|
|
{
|
|
// 忽略大小写匹配列
|
|
DataRow hasContainRow = _gridColumns.Rows.Cast<DataRow>().FirstOrDefault(x => (x["fieldname"] + "").Equals(col.ColumnName, StringComparison.CurrentCultureIgnoreCase));
|
|
if (Autogrowcolumn.ToLower() == col.ColumnName.ToLower())
|
|
continue;
|
|
if (hasContainRow != null && col.ColumnName != _parmaryKey)
|
|
{
|
|
if (row.RowState == DataRowState.Modified)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(row[col.ColumnName] + ""))
|
|
{
|
|
updateFields += string.Format("{0}=N'{1}',", col.ColumnName, col.DataType == typeof(DateTime) ? Convert.ToDateTime(row[col.ColumnName] + "").ToString("yyyy-MM-dd HH:mm:ss") : row[col.ColumnName] + "");
|
|
}
|
|
else
|
|
{
|
|
if (col.DataType == typeof(Decimal) ||
|
|
col.DataType == typeof(Double) ||
|
|
col.DataType == typeof(Int16) ||
|
|
col.DataType == typeof(Int32) ||
|
|
col.DataType == typeof(Int64))
|
|
updateFields += string.Format("{0}='{1}',", col.ColumnName, 0);
|
|
else if (col.DataType == typeof(DateTime))
|
|
updateFields += string.Format("{0}='{1}',", col.ColumnName, null);
|
|
else
|
|
updateFields += string.Format("{0}='{1}',", col.ColumnName, row[col.ColumnName]);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
updateFields = updateFields.TrimEnd(',');
|
|
|
|
if (!string.IsNullOrEmpty(updateFields))
|
|
{
|
|
model.FieldValue = row[_parmaryKey] + "";
|
|
model.BaseSaveType = SaveType.Update;
|
|
model.BaseSql = string.Format(updateSql, tableName, updateFields, _parmaryKey, row[_parmaryKey]);
|
|
}
|
|
mList.Add(model);
|
|
}
|
|
|
|
try
|
|
{
|
|
string retuenMsg = "";
|
|
string apiMsg = "";
|
|
// 批量保存数据
|
|
if (BaseModuleImpl.SaveBaseGridData(mList, out retuenMsg, out apiMsg))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
if (this._isShowAllNode)//显示所有节点
|
|
this.SearchLastGridView();
|
|
else
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
}
|
|
else
|
|
{
|
|
string FaultMsg = string.Empty;
|
|
foreach (BaseSaveModel baseSaveModel in mList)
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(baseSaveModel.FaultMsg))
|
|
{
|
|
FaultMsg += baseSaveModel.FaultMsg + "\r\n";
|
|
}
|
|
}
|
|
if (retuenMsg == "9")
|
|
{
|
|
if (MessageUtil.Show(ResourceKeys.SaveFault + FaultMsg, MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
if (BaseModuleImpl.SaveBaseGridData(mList, "1"))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveSuccess);
|
|
if (this._isShowAllNode)//显示所有节点
|
|
this.SearchLastGridView();
|
|
else
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault);
|
|
}
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SaveFault + FaultMsg);
|
|
}
|
|
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ResourceKeys.SaveFault);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:右键菜单执行后刷新数据,刷新规则按照上一次查询条件刷新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
|
protected void OnGridViewRightCallBack(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:表格拖动到树结构</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The e.</param>
|
|
protected void OnDragCompleted(object sender, GridDragTreeArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.GridViewSelectRows == null || e.GridViewSelectRows.Length == 0 || e.SelectTreeNode == null) return;
|
|
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.DragSelectNode, e.SelectTreeNode.Text), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
int[] records = new int[e.GridViewSelectRows.Length];
|
|
string fieldName = this._leftTreeRow["fieldName"] + "";
|
|
|
|
for (int i = 0; i < e.GridViewSelectRows.Length; i++)
|
|
{
|
|
DataRow item = e.GridViewSelectRows[i];
|
|
try
|
|
{
|
|
records[i] = BaseModuleImpl.UpdateRecord(this.SysModel.MenuTable, fieldName, e.SelectTreeNode.Tag + "", this._parmaryKey, item[this._parmaryKey] + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
}
|
|
}
|
|
|
|
int successCount = records.Contains(1) ? records.Where(x => x == 1).Count() : 0;
|
|
int faultCount = records.Contains(0) ? records.Where(x => x == 0).Count() : 0;
|
|
|
|
MessageUtil.Show(string.Format(ResourceKeys.DragSuccessCount, successCount) + "\r\n" + string.Format(ResourceKeys.DragFaultCount, faultCount));
|
|
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:树结构选中后</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-03 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="TreeViewEventArgs"/> instance containing the event data.</param>
|
|
private void OnTreeNodeSelectAfter(object sender, TreeViewEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.lblSpeciesName.Text = e.Node.Text;
|
|
this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
this._isShowAllNode = false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:显示所有分类</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnShowAllButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.SearchLastGridView();
|
|
this._isShowAllNode = true;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:刷新数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnRefreshButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.Model.ModuleCode != "A006101")
|
|
{
|
|
this.treeLeft.BindTreeView(BaseImpl.GetDataTableResult(this._leftTreeRow["fieldsql"] + ""));
|
|
}
|
|
else
|
|
{
|
|
string sql = SysModel.MenuSql;
|
|
sql = sql + " order by speciesNo";
|
|
this.treeLeft.BindSpecialTreeView(BaseImpl.GetDataTableResult(sql));
|
|
}
|
|
this.treeLeft.TreeView.SelectedNode = this.treeLeft.TreeView.TopNode;
|
|
this.SearchLastGridView(this.treeLeft.TreeView.TopNode.Tag + "");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:添加数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnAddButtonClick(object sender, EventArgs e)
|
|
{
|
|
string maxSpeciesNo = "01";
|
|
TreeNode treeNode = null;
|
|
|
|
try
|
|
{
|
|
bool canAdd = string.IsNullOrEmpty(this.SysModel.AddCond);
|
|
if (!canAdd)
|
|
{
|
|
DataRow dr = gcMain.GridView.GetFocusedDataRow();
|
|
if (this.treeLeft.TreeView.SelectedNode != null)
|
|
{
|
|
canAdd = this.ValidateCond(this.SysModel.AddCond.Replace("{leftSpeciesNo}", this.treeLeft.TreeView.SelectedNode.Name).Replace("{leftSpeciesName}", this.treeLeft.TreeView.SelectedNode.Text), null, "P_SystemDllTab", "addEnable"); // 判断添加权限
|
|
}
|
|
else
|
|
{
|
|
canAdd = this.ValidateCond(this.SysModel.AddCond, dr, "P_SystemDllTab", "addCond");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (canAdd)
|
|
{
|
|
if (this.treeLeft.TreeView.Nodes.Count > 0)
|
|
{
|
|
treeNode = this.treeLeft.TreeView.SelectedNode;
|
|
if (treeNode == null)
|
|
{
|
|
|
|
MessageUtil.Show(ResourceKeys.SelectTreeNodeIsNull);
|
|
return;
|
|
}
|
|
maxSpeciesNo = BaseSpecImpl.GetMaxSpeciesNo(this.SysModel.MenuTable, this.treeLeft.TreeNodeKeyField, treeNode.Name, this.treeLeft.TreeView.Nodes[0].Name);
|
|
}
|
|
|
|
if ("99".Equals(maxSpeciesNo))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ChildTreeNodeFlowOver);
|
|
return;
|
|
}
|
|
if ("999".Equals(maxSpeciesNo))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ChildMaxTreeNodeFlowOver);
|
|
return;
|
|
}
|
|
|
|
this.AddGridData(maxSpeciesNo);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisAddCond);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:删除数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnDeleteButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
// 检查是否可以删除
|
|
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
|
if (rowItem == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectDeleteRows);
|
|
return;
|
|
}
|
|
if (MessageUtil.Show(string.Format(ResourceKeys.DeleteRows, 1), MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
string parmaryValue = rowItem[this._parmaryKey] + "";
|
|
|
|
string nodeValue = rowItem[this.treeLeft.TreeNodeKeyField] + "";
|
|
if ("01".Equals(nodeValue))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnableToDeleteFirstNode);
|
|
return;
|
|
}
|
|
// 检查当前选中节点是否还存在子节点
|
|
if (BaseSpecImpl.GetNodeChildCount(this.SysModel.MenuTable, this.treeLeft.TreeNodeKeyField, nodeValue) > 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UnableToDeleteContainerChildsNode);
|
|
return;
|
|
}
|
|
string deleteCond = this.SysModel.DeleteCond;
|
|
List<BaseSaveModel> mList = new List<BaseSaveModel>();
|
|
bool canDelete = string.IsNullOrEmpty(deleteCond);
|
|
|
|
if (!canDelete)
|
|
{
|
|
// 验证删除条件
|
|
//deleteCond = ReplaceHelper.ReplaceRowParam(rowItem, deleteCond);
|
|
// canDelete = BaseImpl.GetDefaultValue(deleteCond) == "1";
|
|
canDelete = ValidateCond(deleteCond, rowItem, "P_SystemDllTab", "deleteCond");
|
|
}
|
|
if (canDelete)
|
|
{
|
|
// 验证删除存储过程
|
|
string tipMsg = string.Empty;
|
|
string fieldValue = rowItem[this._parmaryKey] + "";
|
|
string sqlValue = string.Format("delete from {0} where {1} = '{2}'", this.SysModel.MenuTable, this._parmaryKey, rowItem[this._parmaryKey] + "");
|
|
BaseSaveModel model = new BaseSaveModel
|
|
{
|
|
BaseSaveType = SaveType.Delete,
|
|
BaseSql = sqlValue,
|
|
KeyField = _parmaryKey,
|
|
FieldValue = fieldValue,
|
|
NewVer = this.SysModel.NewVer,
|
|
MenuCode = this.Model.ModuleCode,
|
|
TableName = this.SysModel.MenuTable
|
|
};
|
|
int result = BaseImpl.VerifyCanDelete(this.Model.ModuleCode, parmaryValue, out tipMsg);
|
|
if (result != 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisDeleteCond + "\r\n" + tipMsg);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
mList.Add(model);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DisDeleteCond);
|
|
return;
|
|
}
|
|
ApiHelper apiHelper = null;
|
|
Interface.Api.ActionType actionType = Interface.Api.ActionType.Delete;
|
|
if (ApiHelper.IsExecEventApi(Interface.Api.OperateEvent.AfterModuleDataDelete, this.Model.ModuleCode, 0))
|
|
{
|
|
apiHelper = new ApiHelper(this.Model.ModuleCode, parmaryValue, this._parmaryKey, this.SysModel.MenuTable, 0, rowItem);
|
|
actionType = Interface.Api.ActionType.Delete;
|
|
//请求删除数据时先等待返回结果后再进行删除
|
|
apiHelper.OnEvent(Interface.Api.OperateEvent.AfterModuleDataDelete, actionType, false);
|
|
}
|
|
// 删除记录
|
|
//int execResult = BaseSpecImpl.DeleteNode(this.SysModel.MenuTable, this._parmaryKey, parmaryValue);
|
|
if (this.SysModel.NewVer == 1)
|
|
{
|
|
string apiReturnMsg = "";
|
|
bool success = BaseModuleImpl.SaveBaseGridData(mList, out apiReturnMsg);
|
|
if (success)
|
|
{
|
|
if (apiHelper != null) apiHelper.OnEvent();
|
|
TreeNode[] nodes = this.treeLeft.TreeView.Nodes.Find(nodeValue, true);
|
|
if (nodes.Length > 0)
|
|
this.treeLeft.TreeView.Nodes.Remove(nodes[0]);
|
|
//this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
int rowHandle = this.gcMain.GridView.FocusedRowHandle;
|
|
this.gcMain.GridView.DeleteRow(rowHandle);
|
|
MessageUtil.Show(ResourceKeys.DeleteSuccess);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(mList[0].FaultMsg);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int execResult = BaseSpecImpl.DeleteNode(this.SysModel.MenuTable, this._parmaryKey, parmaryValue);
|
|
if (execResult == 1)
|
|
{
|
|
if (apiHelper != null) apiHelper.OnEvent();
|
|
TreeNode[] nodes = this.treeLeft.TreeView.Nodes.Find(nodeValue, true);
|
|
if (nodes.Length > 0)
|
|
this.treeLeft.TreeView.Nodes.Remove(nodes[0]);
|
|
//this.SearchLastGridView(this.treeLeft.GetSelectNodeValue());
|
|
int rowHandle = this.gcMain.GridView.FocusedRowHandle;
|
|
this.gcMain.GridView.DeleteRow(rowHandle);
|
|
MessageUtil.Show(ResourceKeys.DeleteSuccess);
|
|
}
|
|
else
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DataNotFount);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
LogUtil.WriteError(ResourceKeys.BaseModule, ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:保存数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-01-02 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnSaveButtonClick(object sender, EventArgs e)
|
|
{
|
|
for (int i = 0; i < (this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable() as DataTable).Rows.Count; i++)
|
|
{
|
|
if (this.gcMain.GridView.GetDataRow(i).GetColumnsInError().Count() > 0)
|
|
{
|
|
MessageUtil.Show("表格中数据不符合要求,保存失败!");
|
|
return;
|
|
}
|
|
}
|
|
try
|
|
{
|
|
DataRow[] nullFields = this._gridColumns.Select("nullable=1");
|
|
if (this.gcMain.GridView.ValidateNullRequired(nullFields))
|
|
{
|
|
this.UpdateGridData();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:导出Excel</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-06-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnExportClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.gcMain.GridControl.ToExcel(this.Model.FormText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
WebBrowserUtil.StartWebBrowser(this.Model.ModuleCode, this.SysModel.MenuText);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
protected void InitlizeSpiltLocation()
|
|
{
|
|
try
|
|
{
|
|
string htight = IniHelper.Read(string.Format("PubSpec_Wide_{0}", this.Model.ModuleCode));
|
|
if (!string.IsNullOrEmpty(htight))
|
|
{
|
|
|
|
this.scc_container.SplitterPosition = Convert.ToInt32(htight);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:设置分割条位置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-01 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
protected void OnSplitterMoved(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (this.Model != null)
|
|
{
|
|
|
|
IniHelper.Write(string.Format("PubSpec_Wide_{0}", this.Model.ModuleCode), this.scc_container.SplitterPosition + "");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|