using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
namespace Dongke.IBOSS.PRD.Client.PCModule
{
public partial class F_PC_0802 : DKDockPanelBase
{
#region 成员变量
// 单例模式
private static F_PC_0802 _instance;
// 正在查询
private bool _isSearching = false;
// 选中的名称
private string _dictionaryvalue;
#endregion
#region 构造函数
public F_PC_0802()
{
InitializeComponent();
}
public F_PC_0802( string dictionaryvalue)
{
InitializeComponent();
this.Text = "编辑线边仓组件配置";
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
this._dictionaryvalue = dictionaryvalue;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PC_0802 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PC_0802();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 页面加载
///
///
///
private void F_PC_0802_Load(object sender, EventArgs e)
{
// 按钮权限控制
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
if(!string.IsNullOrEmpty(_dictionaryvalue))
{
// 调用服务器端获取数据集
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0801";
cre.Name = "GetIDNRKTYPE";
cre.Properties["LGORT"] = _dictionaryvalue;
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
if(sre.Data.Tables[0]!=null && sre.Data.Tables[0].Rows.Count>0)
{
string filter = " check1 = 1";
sre.Data.Tables[0].DefaultView.RowFilter= filter;
DataTable CheckedDt = sre.Data.Tables[0].DefaultView.ToTable();
this.dgvChecked.DataSource = CheckedDt;
}
}
}
}
///
/// 查询
///
///
///
private void tsbtnSearch_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(_dictionaryvalue))
{
// 调用服务器端获取数据集
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0801";
cre.Name = "GetIDNRKTYPE";
cre.Properties["LGORT"] = _dictionaryvalue;
cre.Properties["ModuleName"] = this.txtDICTIONARYTYPE.Text.Trim();
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
{
string filter = " check1 = 0";
sre.Data.Tables[0].DefaultView.RowFilter = filter;
DataTable CheckedDt = sre.Data.Tables[0].DefaultView.ToTable();
this.dgvCheck.DataSource = CheckedDt;
}
}
}
}
///
/// 保存
///
///
///
private void btnSave_Click(object sender, EventArgs e)
{
try
{
DataTable checkDt = (DataTable)this.dgvCheck.DataSource;
DataTable checkedDt = (DataTable)this.dgvChecked.DataSource;
DataTable paramDt = new DataTable();
paramDt.Columns.Add("IDNRKTYPE", typeof(string));
if (checkDt != null && checkDt.Rows.Count > 0)
{
foreach (DataRow item in checkDt.Rows)
{
if ("1".Equals(item["check1"].ToString()))
{
DataRow dr = paramDt.NewRow();
dr["IDNRKTYPE"] = item["ModuleName"].ToString();
paramDt.Rows.Add(dr);
}
}
}
if (checkedDt != null && checkedDt.Rows.Count > 0)
{
foreach (DataRow item in checkedDt.Rows)
{
if ("1".Equals(item["check1"].ToString()))
{
DataRow dr = paramDt.NewRow();
dr["IDNRKTYPE"] = item["ModuleName"].ToString();
paramDt.Rows.Add(dr);
}
}
}
// 调用服务器端获取数据集
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0802";
cre.Name = "SaveLgortIdnrktype";
cre.Properties["LGORT"] = this._dictionaryvalue;
paramDt.TableName = "SaveTable";
DataSet ds = new DataSet();
ds.Tables.Add(paramDt.Copy());
cre.Data = ds;
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "线边仓组件配置", "保存"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.DialogResult = DialogResult.OK;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空条件
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtDICTIONARYTYPE.Clear();
}
///
/// 自适应列宽
///
///
///
private void toolStripButton3_Click(object sender, EventArgs e)
{
this.dgvCheck.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
this.dgvChecked.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 关闭
///
///
///
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 释放窗体
///
///
///
private void F_PC_0802_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
}
}