using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.Controls;
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_0801 : DKDockPanelBase
{
#region 成员变量
// 单例模式
private static F_PC_0801 _instance;
// 正在查询
private bool _isSearching = false;
#endregion
#region 构造函数
public F_PC_0801()
{
InitializeComponent();
this.Text = "线边仓组件配置";
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PC_0801 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PC_0801();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 加载
///
///
///
private void F_PC_0801_Load(object sender, EventArgs e)
{
dgvLGORT.AutoGenerateColumns = false;
dgvIDNRKTYPE.AutoGenerateColumns = false;
}
///
/// 查询
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
this._isSearching = true;
this.dgvLGORT.DataSource = null;
this.dgvIDNRKTYPE.DataSource = null;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0801";
cre.Name = "GetLGORT";
cre.Properties["dictionaryvalue"] = this.txtLGORT.Text;
cre.Properties["DICTIONARYTYPE"] = "TPC011"; //线边仓数据字典类别
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
this.Tag = false;
if (sre.Data.Tables[0] != null && sre.Data.Tables[0].Rows.Count > 0)
{
this.dgvLGORT.DataSource = sre.Data.Tables[0];
this.Tag = true;
dgvLGORT_SelectionChanged(null, null);
}
else
{
// 清空明细中的数据
this.dgvLGORT.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
this.btnSearch.Enabled = true;
this.btnClearCondition.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvLGORT.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
this.dgvIDNRKTYPE.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 关闭
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 编辑
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
if (this.dgvLGORT.SelectedRows.Count != 0)
{
string dictionaryvalue = this.dgvLGORT.SelectedRows[0].Cells["dictionaryvalue"].Value + "";
F_PC_0802 frmFPC0802 = new F_PC_0802(dictionaryvalue);
DialogResult dialogresult = frmFPC0802.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
DataGridViewRow currentRow = this.dgvLGORT.CurrentRow;
if (currentRow != null)
{
string LGORT = currentRow.Cells["dictionaryvalue"].Value.ToString();
// 调用服务器端获取数据集
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0801";
cre.Name = "GetIDNRKTYPE";
cre.Properties["LGORT"] = LGORT;
ServiceResultEntity sre = DoAsync(() =>
{
return PCModuleProxyNew.Service.HandleRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
this.dgvIDNRKTYPE.DataSource = sre.Data.Tables[0];
}
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空条件
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtLGORT.Clear();
}
///
/// 组件库选中事件
///
///
///
private void dgvLGORT_SelectionChanged(object sender, EventArgs e)
{
try
{
// 在绑定总表时 不查询明细
if (!Convert.ToBoolean(this.Tag)
|| this.dgvLGORT.CurrentCell == null)
{
return;
}
else
{
DataGridViewRow currentRow = this.dgvLGORT.CurrentRow;
if (currentRow != null)
{
string LGORT = currentRow.Cells["dictionaryvalue"].Value.ToString();
// 调用服务器端获取数据集
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_PC_0801";
cre.Name = "GetIDNRKTYPE";
cre.Properties["LGORT"] = LGORT;
if (!this.txtLGORT.ReadOnly)
{
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)
{
this.dgvIDNRKTYPE.DataSource = sre.Data.Tables[0];
this.dgvIDNRKTYPE.Focus();
this.dgvIDNRKTYPE.CurrentCell = null;
}
}
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 释放窗体
///
///
///
private void F_PC_0801_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
}
}