ab56a9bcf7
SVN-Revision: r240
260 lines
8.7 KiB
C#
260 lines
8.7 KiB
C#
/******************************
|
|
* 说明:Bom选择
|
|
* 创建人:龚宇超
|
|
* 创建日期:2018-02-06
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本: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.Control.Model;
|
|
using Lskj.PubBillNewDrag.Model;
|
|
using Lskj.Business.Impl;
|
|
using DevExpress.XtraGrid.Columns;
|
|
using DevExpress.XtraGrid;
|
|
using Lskj.Data;
|
|
|
|
namespace Lskj.PubBillNewDrag
|
|
{
|
|
/// <summary>
|
|
/// Bom选择
|
|
/// </summary>
|
|
public partial class FrmBomSelect : BaseForm
|
|
{
|
|
/// <summary>
|
|
/// 是否记住操作,后续不在弹出界面
|
|
/// </summary>
|
|
public bool OnlyPopup;
|
|
/// <summary>
|
|
/// 标题
|
|
/// </summary>
|
|
public string Caption;
|
|
/// <summary>
|
|
/// 选中的bom数据
|
|
/// </summary>
|
|
public DataRow[] SelectBomRows;
|
|
/// <summary>
|
|
/// The bom data table
|
|
/// </summary>
|
|
public DataTable BomDataTable;
|
|
/// <summary>
|
|
/// 单据明细表格列
|
|
/// </summary>
|
|
public GridColumnCollection GridColumns;
|
|
|
|
public FrmBomSelect()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:窗口加载</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-06 </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)
|
|
{
|
|
try
|
|
{
|
|
base.OnLoad(e);
|
|
if (BomDataTable != null)
|
|
{
|
|
this.Text = string.IsNullOrEmpty(Caption) ? this.Text : this.Caption;
|
|
|
|
DataColumn dataColumn = new DataColumn("Id", typeof(bool));
|
|
dataColumn.DefaultValue = true;
|
|
|
|
this.BomDataTable.Columns.Add(dataColumn);
|
|
this.InitGridView();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:初始化表格控件</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="table">The table.</param>
|
|
private void InitGridView()
|
|
{
|
|
// 增加选择列
|
|
GridColumn gridColumn = new GridColumn();
|
|
gridColumn.FieldName = gridColumn.Name = "Id";
|
|
gridColumn.Caption = "选择";
|
|
gridColumn.Width = 50;
|
|
gridColumn.VisibleIndex = 1;
|
|
gridColumn.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
|
|
gridColumn.Visible = true;
|
|
|
|
gcMain.GridView.Columns.Add(gridColumn);
|
|
|
|
// 添加其他列
|
|
foreach (GridColumn item in GridColumns)
|
|
{
|
|
GridColumn column = new GridColumn();
|
|
column.Caption = item.Caption;
|
|
column.FieldName = item.FieldName;
|
|
column.OptionsColumn.AllowEdit = false;
|
|
column.OptionsColumn.ReadOnly = true;
|
|
column.Width = item.Width;
|
|
column.VisibleIndex = item.VisibleIndex;
|
|
column.Visible = item.Visible;
|
|
gcMain.GridView.Columns.Add(column);
|
|
}
|
|
|
|
gcMain.SetGridViewDataSource(BomDataTable);
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:获取选中数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <returns>DataRow[].</returns>
|
|
private DataRow[] GetSelectRows()
|
|
{
|
|
DataTable table = gcMain.GridControl.DataSourceTable();
|
|
|
|
return table.Select("Id = true").ToArray();
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:全选</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </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>
|
|
void OnSelectAllClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataTable table = gcMain.GridControl.DataSourceTable();
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
item["Id"] = true;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:反选</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </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>
|
|
void OnClearSelectAllClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataTable table = gcMain.GridControl.DataSourceTable();
|
|
foreach (DataRow item in table.Rows)
|
|
{
|
|
item["Id"] = false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:确定</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </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>
|
|
void OnOkButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DataRow[] rows = GetSelectRows();
|
|
if (rows == null || rows.Length == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.SelectRowIsNull);
|
|
return;
|
|
}
|
|
|
|
this.SelectBomRows = rows;
|
|
this.OnlyPopup = chkOperate.Checked;
|
|
this.DialogResult = DialogResult.OK;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show("确定事件出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:取消</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-07 </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>
|
|
void OnCancelButtonClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message,ex.Message);
|
|
}
|
|
}
|
|
}
|
|
} |