SVN r247
SVN-Revision: r247
This commit is contained in:
@@ -18,14 +18,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
public partial class FrmModelLookUp : BaseForm
|
||||
{
|
||||
#region 私有字段
|
||||
/// <summary>
|
||||
/// 复选框字段名称
|
||||
/// </summary>
|
||||
private string _checkFieldName = "_check";
|
||||
/// <summary>
|
||||
/// The _id
|
||||
/// </summary>
|
||||
private string _id = "_id";
|
||||
|
||||
#endregion
|
||||
#region 公有字段
|
||||
/// <summary>
|
||||
@@ -65,7 +58,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// </summary>
|
||||
public string RemarkField = "remark";
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// 数据源(初始)
|
||||
/// </summary>
|
||||
/// <value>The source SQL.</value>
|
||||
public string SourceSQL { get; set; }
|
||||
@@ -143,6 +136,12 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// 左侧树结构、表格主键
|
||||
/// </summary>
|
||||
public string ParentKeyField;
|
||||
/// <summary>
|
||||
/// 数据源(替换参数后)
|
||||
/// </summary>
|
||||
/// <value>The source SQL.</value>
|
||||
public string NewSourceSQL;
|
||||
|
||||
|
||||
#endregion
|
||||
public FrmModelLookUp(string ModuleCodel)
|
||||
@@ -182,29 +181,23 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
//设置关联模块
|
||||
bool result = SetAssociatedModules();
|
||||
|
||||
|
||||
|
||||
//单选模式,不显示明细表,主表双击选中后退出选择界面
|
||||
if (SingleChoiceMode)
|
||||
{
|
||||
this.splitMain_Right.PanelVisibility = SplitPanelVisibility.Panel1;
|
||||
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClickRadio);
|
||||
//设置上方条件
|
||||
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段
|
||||
this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx);
|
||||
this.SearchObj.ParentUnionField = this.ParentUnionField;
|
||||
this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top);
|
||||
this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack;
|
||||
this.SourceSQL = this.SysModel.MenuSql;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gcMain.GridView.DoubleClick += new EventHandler(OnRowCellClick);
|
||||
this.gcDetail.GridView.DoubleClick += new EventHandler(OnDoubleClick);
|
||||
this.pl_top.Height = 0;
|
||||
this.Resize += new System.EventHandler(maximization);
|
||||
this.splitMain_Right.SplitterMoved += new EventHandler(PositionChange);
|
||||
}
|
||||
|
||||
|
||||
this.SourceSQL = this.SysModel.MenuSql;
|
||||
this.gcDetail.GridView.OptionsSelection.EnableAppearanceFocusedCell = false;
|
||||
|
||||
this.gcDetail.GridView.OptionsView.ColumnAutoWidth = true;
|
||||
@@ -278,7 +271,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
{
|
||||
success = this.gcMain.GridView.UpdateCustomColumnToDatabase(this.CurrentOperColumnKey);
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
//this.SetDetailDataSource();
|
||||
MessageUtil.Show(success ? ResourceKeys.SaveSuccess : ResourceKeys.SaveFault);
|
||||
}
|
||||
catch (SqlException sex)
|
||||
@@ -311,16 +304,17 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// </summary>
|
||||
private void SetDetailDataSource()
|
||||
{
|
||||
DataTable table = this.DataSource.Copy();
|
||||
DataRow[] rows = table.Select(_checkFieldName + "=True");
|
||||
//return;
|
||||
//DataTable table = this.DataSource.Copy();
|
||||
//DataRow[] rows = table.Select(_checkFieldName + "=True");
|
||||
|
||||
if (rows != null && rows.Length > 0)
|
||||
this.gcDetail.GridControl.DataSource = rows.CopyToDataTable();
|
||||
else
|
||||
{
|
||||
this.gcDetail.GridControl.DataSource = table;
|
||||
this.gcDetail.GridControl.DataSourceTable().Clear();
|
||||
}
|
||||
//if (rows != null && rows.Length > 0)
|
||||
// this.gcDetail.GridControl.DataSource = rows.CopyToDataTable();
|
||||
//else
|
||||
//{
|
||||
// this.gcDetail.GridControl.DataSource = table;
|
||||
// this.gcDetail.GridControl.DataSourceTable().Clear();
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -362,22 +356,17 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// </summary>
|
||||
private void SetReadOnlyColumns()
|
||||
{
|
||||
if (this.ConfigureColumnMode && SingleChoiceMode)
|
||||
if (this.ConfigureColumnMode)//&& SingleChoiceMode
|
||||
{
|
||||
DataTable _gridColumns = BaseModuleImpl.GetBaseGridColumns(this.UnionModuleCodel);
|
||||
this.gcMain.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);
|
||||
this.gcDetail.SetReadOnlyColumns(_gridColumns, GridCustomColumnStruct.BaseMainGridView + this.SysModel.FormKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.gcMain.GridView.Columns.Clear();
|
||||
this.gcDetail.GridView.Columns.Clear();
|
||||
|
||||
GridColumn checkColumn = new GridColumn();
|
||||
checkColumn.Name = checkColumn.FieldName = this._checkFieldName;
|
||||
checkColumn.Caption = "选";
|
||||
checkColumn.Width = 30;
|
||||
checkColumn.Visible = true;
|
||||
checkColumn.OptionsColumn.AllowEdit = false;
|
||||
|
||||
GridColumn valueColumn = new GridColumn();
|
||||
valueColumn.FieldName = valueColumn.Name = ValueField;
|
||||
@@ -397,8 +386,8 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
|
||||
|
||||
|
||||
this.gcMain.GridView.Columns.AddRange(new GridColumn[] { checkColumn, valueColumn, textColumn });
|
||||
this.gcDetail.GridView.Columns.AddRange(new GridColumn[] { checkColumn, valueColumn, textColumn });
|
||||
this.gcMain.GridView.Columns.AddRange(new GridColumn[] { valueColumn, textColumn });
|
||||
this.gcDetail.GridView.Columns.AddRange(new GridColumn[] {valueColumn, textColumn });
|
||||
|
||||
if (DataSource.Columns.IndexOf("remark") != -1)
|
||||
{
|
||||
@@ -625,11 +614,17 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
/// <param name="menuCode">The menu code.</param>
|
||||
public void InitControls(string UnionModuleCodel)
|
||||
{
|
||||
//单选模式以模块sql为为准
|
||||
if (SingleChoiceMode)
|
||||
{
|
||||
this.SourceSQL = this.SysModel.MenuSql;
|
||||
}
|
||||
|
||||
this.SysModel.MenuSql = this.NewSourceSQL;
|
||||
//设置上方条件
|
||||
this.pl_top.Controls.Clear();
|
||||
DataTable queryTable = BaseModuleImpl.GetCustomQueryFields(this.SysModel.CondKey);//加载自定义配置字段
|
||||
this.SearchObj = new MyControl(this.SysModel.MenuSql, this.gcMain, LeftTreeViewEx, LeftGridEx);
|
||||
this.SearchObj.ParentUnionField = this.ParentUnionField;
|
||||
this.pl_top.Height = 0;
|
||||
this.pl_top.Height = this.SearchObj.InitSearchControl(queryTable, this.pl_top);
|
||||
this.SearchObj.OnSearchAfterCallBack += SearchObj_OnSearchAfterCallBack;
|
||||
|
||||
if (LeftTreeViewEx != null && LeftTreeViewEx.TreeView.Nodes.Count > 0)
|
||||
{
|
||||
LeftTreeViewEx.TreeView.SelectedNode = LeftTreeViewEx.TreeView.Nodes[0];//重新打开时默认选中第一条
|
||||
@@ -640,7 +635,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
LeftGridEx.GridView.SelectRow(0);
|
||||
}
|
||||
|
||||
this.DataSource = BaseImpl.GetDataTableResult(this.SourceSQL);
|
||||
this.DataSource = BaseImpl.GetDataTableResult(this.NewSourceSQL);
|
||||
this.SetSelectionBox();
|
||||
//创建表格列
|
||||
if (isFirst)
|
||||
@@ -658,7 +653,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
|
||||
private void SearchObj_OnSearchAfterCallBack(object sender, EventArgs e)
|
||||
{
|
||||
this.SetSelectionBox();
|
||||
//this.SetSelectionBox();
|
||||
//this.SetReadOnlyColumns();
|
||||
}
|
||||
|
||||
@@ -712,8 +707,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
DataRow rowItem = rowItem = this.DataSource.Rows.Cast<DataRow>().FirstOrDefault(x => x[isValue ? ValueMember : TextField] + "" == spilts[i].Trim());
|
||||
if (rowItem != null)
|
||||
{
|
||||
rowItem[_checkFieldName] = check;
|
||||
rowItem.AcceptChanges();
|
||||
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray);
|
||||
}
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
@@ -796,11 +790,10 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
DataRow rowItem = this.gcMain.GridView.GetFocusedDataRow();
|
||||
if (rowItem != null)
|
||||
{
|
||||
rowItem[_checkFieldName] = "True".Equals(rowItem[_checkFieldName] + "") ? 0 : 1;
|
||||
//rowItem[_checkFieldName] = rowItem.Table.Columns.Contains(_checkFieldName) : "True".Equals(rowItem[_checkFieldName] + "") ? 0 : 1 ? 0;
|
||||
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(rowItem.ItemArray);
|
||||
rowItem.AcceptChanges();
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -818,8 +811,6 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
{
|
||||
|
||||
DataRow dr = this.gcMain.GridView.GetFocusedDataRow();
|
||||
//DataRow[] rowItems = this.DataSource.Select(_checkFieldName + "=True");
|
||||
|
||||
if (dr != null)
|
||||
{
|
||||
this.EditValue = dr[ValueMember] + "";
|
||||
@@ -849,13 +840,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
{
|
||||
if (this.gcDetail.GridView.RowCount == 0) return;
|
||||
DataRow rowItem = this.gcDetail.GridView.GetFocusedDataRow();
|
||||
DataRow[] sourceRowItems = this.DataSource.Select(_id + "=" + rowItem[_id] + "");
|
||||
if (rowItem != null && sourceRowItems != null && sourceRowItems.Length > 0)
|
||||
{
|
||||
sourceRowItems[0][_checkFieldName] = 0;
|
||||
sourceRowItems[0].AcceptChanges();
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Remove(rowItem);
|
||||
}
|
||||
#endregion
|
||||
#region 关闭时清空唯一键
|
||||
@@ -894,16 +879,13 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
this.EditValue = string.Empty;
|
||||
this.EditText = string.Empty;
|
||||
|
||||
DataRow[] rowItems = this.DataSource.Select(_checkFieldName + "=True");
|
||||
|
||||
foreach (DataRow item in rowItems)
|
||||
foreach (DataRow item in (this.gcDetail.GridControl.DataSource as DataTable).Rows)
|
||||
{
|
||||
this.EditValue += item[ValueMember] + ",";
|
||||
this.EditText += item[TextField] + ",";
|
||||
}
|
||||
|
||||
//this.EditValue = this.EditValue.Trim(',');
|
||||
//this.EditText = this.EditText.Trim(',');
|
||||
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
@@ -939,9 +921,8 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
DataTable DataSource = this.gcMain.GridView.GetGridViewFilteredAndSortedDataToDataTable();
|
||||
foreach (DataRow item in DataSource.Rows)
|
||||
{
|
||||
DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + ""));
|
||||
rowItem[_checkFieldName] = 1;
|
||||
rowItem.AcceptChanges();
|
||||
//DataRow rowItem = this.DataSource.Select("1=1").FirstOrDefault(x => (item[_id] + "").Equals(x[_id] + ""));
|
||||
(this.gcDetail.GridControl.DataSource as DataTable).Rows.Add(item.ItemArray);
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
}
|
||||
@@ -956,16 +937,7 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
private void btn_cancelAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
DataTable dt = this.DataSource.Clone();
|
||||
foreach (DataRow item in this.DataSource.Rows)
|
||||
{
|
||||
if ("True".Equals(item[_checkFieldName] + ""))
|
||||
{
|
||||
|
||||
item[_checkFieldName] = 0;
|
||||
}
|
||||
}
|
||||
this.SetDetailDataSource();
|
||||
(this.gcDetail.GridControl.DataSource as DataTable).Clear();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1026,17 +998,4 @@ namespace Lskj.Control.MultiModelLookUp
|
||||
case 2: // 左侧为表格
|
||||
this.gridLeft.Visible = true;
|
||||
this.treeLeft.Visible = false;
|
||||
this.InitlizeSpiltLocation();
|
||||
this.SetLeftGridView();
|
||||
//this.ModuleGridObj.SaveEvent += new Lskj.Control.ModuleGridEx.SaveEventHander(SetDetailGridView);
|
||||
this.LeftGridEx = this.gridLeft;
|
||||
break;
|
||||
case 3: // 左侧为空
|
||||
default:
|
||||
this.splitMain.PanelVisibility = SplitPanelVisibility.Panel2;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
|
||||
this.InitlizeSpiltLocation();
|
||||
Reference in New Issue
Block a user