feat: 更新业务及控件功能
This commit is contained in:
@@ -692,6 +692,9 @@ namespace Lskj.Control
|
||||
gridPanel.Dock = DockStyle.Right;
|
||||
gridPanel.BorderStyle = BorderStyles.NoBorder;
|
||||
GridControlEx grid = new GridControlEx();
|
||||
|
||||
grid.Model = this.SysModel;
|
||||
|
||||
if (dataCaches != null)
|
||||
{
|
||||
grid.GetDataCaches(dataCaches, modelkeyName + key);
|
||||
@@ -712,7 +715,7 @@ namespace Lskj.Control
|
||||
grid.SetGridRightMenus(dtGridRightMenus, SysModel);
|
||||
grid.GridView.Tag = accrModel;
|
||||
grid.GridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
||||
grid.Model = this.SysModel;
|
||||
//grid.Model = this.SysModel;
|
||||
// 追加复选框用于批量审批
|
||||
if (BaseAccraditModelObj.MuitlAuditFlag || BaseAccraditModelObj.MuitlAuditBackFlag)
|
||||
{
|
||||
|
||||
@@ -143,6 +143,10 @@ namespace Lskj.Control
|
||||
}
|
||||
bool isAdmin = ERPInfo.Instance.UserName.Equals("管理员");
|
||||
this.btnCover.Visible = SysModel == null ? isAdmin : isAdmin ? true : SysModel.OperPermissionsUser.Contains(ERPInfo.Instance.UserName);
|
||||
|
||||
//if (SysModel!=null&&!string.IsNullOrWhiteSpace(SysModel.OperPermissionsUser) && SysModel.OperPermissionsUser.Equals("无")) this.btnCover.Visible = false;
|
||||
|
||||
|
||||
this.SourceColumns = BaseImpl.GetDataTableResult(string.Format("select * from {0} where 1<>1", _tableName)).Columns;
|
||||
DataTable dtCalcFields = BaseImpl.GetDataTableResult(string.Format("select name from sys.columns where object_id=object_id('{0}') and is_computed=1", _tableName));
|
||||
if ((dtCalcFields != null) && (dtCalcFields.Rows.Count > 0))
|
||||
@@ -632,7 +636,11 @@ namespace Lskj.Control
|
||||
}
|
||||
|
||||
dt.AcceptChanges();
|
||||
XtraMessageBox.Show("数据导入完成,成功" + success.ToString() + "条,失败" + failed.ToString() + "条", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
if (failedData.Rows.Count > 0 || !SystemInfo.Instance.SuppressImportSuccessTip)
|
||||
{
|
||||
XtraMessageBox.Show("数据导入完成,成功" + success.ToString() + "条,失败" + failed.ToString() + "条", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
if (failedData.Rows.Count > 0)
|
||||
{
|
||||
MessageUtil.Show(failedData.Rows[0]["import_errormsg"].ToString());
|
||||
@@ -658,6 +666,9 @@ namespace Lskj.Control
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (failed == 0 && datatb.Rows.Count > 0) this._isImported = true;
|
||||
|
||||
datatb.Clear();
|
||||
dt.Clear();
|
||||
if (failed > 0)
|
||||
@@ -1026,7 +1037,7 @@ namespace Lskj.Control
|
||||
{
|
||||
if (MessageUtil.Show("如果导入数据量太多将花费较长时间,是否确认导入", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
return;
|
||||
this._isImported = true;
|
||||
|
||||
|
||||
if (!this.DetermineImportConditions())
|
||||
{
|
||||
@@ -1038,6 +1049,8 @@ namespace Lskj.Control
|
||||
|
||||
// 采用存储过程保存
|
||||
//this.SaveImportData(table);
|
||||
|
||||
if(this._isImported&& SystemInfo.Instance.SuppressImportSuccessTip) this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -5536,6 +5536,9 @@ namespace Lskj.Control
|
||||
modelLookUp.Tag = model;
|
||||
|
||||
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
||||
|
||||
btnEdit.ShowDropDown = ShowDropDown.Never;
|
||||
|
||||
btnEdit.NullText = "";
|
||||
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
||||
btnEdit.AllowNullInput = DefaultBoolean.False;
|
||||
@@ -5580,6 +5583,9 @@ namespace Lskj.Control
|
||||
}
|
||||
|
||||
RepositoryItemCheckedComboBoxEdit btnEdit = new RepositoryItemCheckedComboBoxEdit();
|
||||
|
||||
btnEdit.ShowDropDown = ShowDropDown.Never;
|
||||
|
||||
btnEdit.NullText = "";
|
||||
btnEdit.PopupBorderStyle = PopupBorderStyles.Flat;
|
||||
btnEdit.AllowNullInput = DefaultBoolean.False;
|
||||
|
||||
@@ -289,7 +289,6 @@ namespace Lskj.Control.Model
|
||||
DragHander.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:获取表格选中行数据</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
@@ -552,6 +551,7 @@ namespace Lskj.Control.Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 焦点行改变时
|
||||
/// </summary>
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Lskj.Control.Model
|
||||
public class GridViewMenuStrip : BaseRightMenu
|
||||
{
|
||||
private int[] _oldSelectRows;
|
||||
private HashSet<object> _oldSelectPrimaryValues;
|
||||
private DataRow _oldDataRow;
|
||||
private int _oldRowHandler;
|
||||
private GridView _gridView;
|
||||
@@ -231,41 +232,116 @@ namespace Lskj.Control.Model
|
||||
this._oldSelectRows = this._gridView.GetSelectedRows();
|
||||
this._oldDataRow = this._gridView.GetFocusedDataRow();
|
||||
this._oldRowHandler = this._gridView.FocusedRowHandle;
|
||||
|
||||
// 复选框模式下保存选中行的主键值,避免刷新后行号对应到其他数据。
|
||||
this._oldSelectPrimaryValues = null;
|
||||
string primaryKey = this.GridControlObj == null ? string.Empty : this.GridControlObj.MultiplePrimary;
|
||||
bool isCheckBoxRowSelect = this._gridView.OptionsSelection.MultiSelect == true
|
||||
&& this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false
|
||||
&& this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect;
|
||||
if (isCheckBoxRowSelect && !string.IsNullOrWhiteSpace(primaryKey) && this._oldSelectRows != null)
|
||||
{
|
||||
foreach (int rowHandle in this._oldSelectRows)
|
||||
{
|
||||
DataRow row = this._gridView.GetDataRow(rowHandle);
|
||||
if (row == null || !row.Table.Columns.Contains(primaryKey) || row.IsNull(primaryKey))
|
||||
continue;
|
||||
|
||||
object primaryValue = row[primaryKey];
|
||||
if (string.IsNullOrWhiteSpace(primaryValue + ""))
|
||||
continue;
|
||||
|
||||
if (this._oldSelectPrimaryValues == null)
|
||||
this._oldSelectPrimaryValues = new HashSet<object>();
|
||||
this._oldSelectPrimaryValues.Add(primaryValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void MenuStripClickAfter(ToolStripMenuItem item, GridRightMenuModel model)
|
||||
{
|
||||
DataTable dataTable = this.GridControlObj.GridView.GetGridViewFilteredAndSortedDataToDataTable() as DataTable;
|
||||
List<DataRow> rows = new List<DataRow>() { this._oldDataRow };
|
||||
IEnumerable<DataRow> QBJ = dataTable.Select().AsEnumerable().Intersect(rows.AsEnumerable(), DataRowComparer.Default);
|
||||
int NRowHandle = 0;
|
||||
try
|
||||
string ParmaryKey = string.Empty;
|
||||
if(this.GridControlObj!=null) ParmaryKey = GridControlObj.MultiplePrimary;
|
||||
bool isCheckBoxRowSelect = this._gridView.OptionsSelection.MultiSelect == true&& this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false && this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect;
|
||||
DataTable currentDataTable = this.GridControlObj == null ? null : this.GridControlObj.GridControl.DataSourceTable();
|
||||
|
||||
if (isCheckBoxRowSelect&& !string.IsNullOrWhiteSpace(ParmaryKey) && this._oldSelectPrimaryValues != null&& this._oldSelectPrimaryValues.Count > 0&& currentDataTable != null&& currentDataTable.Columns.Contains(ParmaryKey))
|
||||
{
|
||||
DataTable NDataTable = QBJ.CopyToDataTable();
|
||||
if (NDataTable.Rows.Count > 0)
|
||||
//2026-08-17添加,如果是复选框模式,并且有主键,右键后选中之前的行用主键值判断
|
||||
|
||||
// 只恢复刷新后仍存在的主键,已删除的数据不再按原行号选中。
|
||||
this._gridView.ClearSelection();
|
||||
if (!model.RefreshCheckState)
|
||||
{
|
||||
NRowHandle = dataTable.Rows.IndexOf(QBJ.First());
|
||||
this._oldRowHandler = NRowHandle >= 0 ? NRowHandle : this._oldRowHandler;
|
||||
}
|
||||
}
|
||||
catch (System.InvalidOperationException ex) //如果差集为null,就回进当前报错
|
||||
{
|
||||
}
|
||||
if (this._gridView.OptionsSelection.MultiSelect == true && this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false && this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect)
|
||||
{
|
||||
if (model.RefreshCheckState)
|
||||
this._gridView.ClearSelection();
|
||||
else if (!model.RefreshCheckState && this._oldSelectRows != null)
|
||||
{
|
||||
foreach (int index in this._oldSelectRows)
|
||||
DataColumn[] tablePrimaryKey = currentDataTable.PrimaryKey;
|
||||
bool canFindByPrimaryKey = this.GridControlObj.GridControl.DataSource is DataTable
|
||||
&& tablePrimaryKey != null
|
||||
&& tablePrimaryKey.Length == 1
|
||||
&& tablePrimaryKey[0].ColumnName.Equals(ParmaryKey, StringComparison.OrdinalIgnoreCase);
|
||||
if (canFindByPrimaryKey)
|
||||
{
|
||||
this._gridView.SelectRow(index);
|
||||
// DataTable设置了PrimaryKey时,使用其内部索引直接查找。
|
||||
foreach (object primaryValue in this._oldSelectPrimaryValues)
|
||||
{
|
||||
DataRow row = currentDataTable.Rows.Find(primaryValue);
|
||||
if (row == null)
|
||||
continue;
|
||||
|
||||
int rowHandle = this._gridView.GetRowHandle(currentDataTable.Rows.IndexOf(row));
|
||||
if (rowHandle >= 0)
|
||||
this._gridView.SelectRow(rowHandle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// MultiplePrimary只是字段配置时没有数据索引,单次扫描比逐个LocateByValue更稳定。
|
||||
HashSet<object> remainingPrimaryValues = new HashSet<object>(this._oldSelectPrimaryValues);
|
||||
for (int rowHandle = 0; rowHandle < this._gridView.DataRowCount && remainingPrimaryValues.Count > 0; rowHandle++)
|
||||
{
|
||||
DataRow row = this._gridView.GetDataRow(rowHandle);
|
||||
if (row == null || !row.Table.Columns.Contains(ParmaryKey) || row.IsNull(ParmaryKey))
|
||||
continue;
|
||||
|
||||
if (remainingPrimaryValues.Remove(row[ParmaryKey]))
|
||||
this._gridView.SelectRow(rowHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._gridView.ClearSelection();
|
||||
this._gridView.SelectRowHandler(this._oldRowHandler);
|
||||
DataTable dataTable = this.GridControlObj.GridView.GetGridViewFilteredAndSortedDataToDataTable() as DataTable;
|
||||
List<DataRow> rows = new List<DataRow>() { this._oldDataRow };
|
||||
IEnumerable<DataRow> QBJ = dataTable.Select().AsEnumerable().Intersect(rows.AsEnumerable(), DataRowComparer.Default);
|
||||
int NRowHandle = 0;
|
||||
try
|
||||
{
|
||||
DataTable NDataTable = QBJ.CopyToDataTable();
|
||||
if (NDataTable.Rows.Count > 0)
|
||||
{
|
||||
NRowHandle = dataTable.Rows.IndexOf(QBJ.First());
|
||||
this._oldRowHandler = NRowHandle >= 0 ? NRowHandle : this._oldRowHandler;
|
||||
}
|
||||
}
|
||||
catch (System.InvalidOperationException ex) //如果差集为null,就回进当前报错
|
||||
{
|
||||
}
|
||||
if (this._gridView.OptionsSelection.MultiSelect == true && this._gridView.OptionsSelection.EnableAppearanceFocusedCell == false && this._gridView.OptionsSelection.MultiSelectMode == GridMultiSelectMode.CheckBoxRowSelect)
|
||||
{
|
||||
if (model.RefreshCheckState)
|
||||
this._gridView.ClearSelection();
|
||||
else if (!model.RefreshCheckState && this._oldSelectRows != null)
|
||||
{
|
||||
foreach (int index in this._oldSelectRows)
|
||||
{
|
||||
this._gridView.SelectRow(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this._gridView.ClearSelection();
|
||||
this._gridView.SelectRowHandler(this._oldRowHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override List<string> HandleRightMenuParams(List<string> paramList, DataRow rowData, DataRow[] rowDatas = null, int actionType = 0)
|
||||
|
||||
@@ -1047,6 +1047,10 @@ namespace Lskj.Control
|
||||
this.gcMain.Model = this.Model;
|
||||
this.gcMain.SysModel = this.SysModel;
|
||||
this.gcMain.Dock = DockStyle.Fill;
|
||||
if (this.SysModel.GridObjIsCheck == 1)//主表加载复选框
|
||||
{
|
||||
GridDragGrid.GridAddCheckBox((this.gcMain as BandedGridControlEx).GridView);
|
||||
}
|
||||
this.panelControl1.Controls.Add(this.gcMain);
|
||||
if (this.SysModel.LoadFilter) (this.gcMain as BandedGridControlEx).GridView.OptionsView.ShowAutoFilterRow = true;
|
||||
(this.gcMain as BandedGridControlEx).gridControl.Tag = panel;
|
||||
@@ -3553,9 +3557,23 @@ namespace Lskj.Control
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
|
||||
{
|
||||
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
|
||||
string newResult = SqlHelper.ExecuteScalar(sql) + "";
|
||||
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
|
||||
try
|
||||
{
|
||||
WaitForm.ShowForm();
|
||||
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
|
||||
string newResult = SqlHelper.ExecuteScalar(sql) + "";
|
||||
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(e);
|
||||
MessageUtil.Show("基础档案导入后执行sql错误!" + Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
WaitForm.HideForm();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 刷新数据
|
||||
|
||||
@@ -786,6 +786,7 @@ namespace Lskj.Control
|
||||
{
|
||||
try
|
||||
{
|
||||
this.pl_main.Visible = false;
|
||||
if (sysModel != null && dyncModel != null)
|
||||
{
|
||||
this.SysModel = sysModel;
|
||||
@@ -1443,6 +1444,10 @@ namespace Lskj.Control
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.pl_main.Visible = true;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user