/*******************************************************************************
* Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_RPT_010102_1.cs
* 2.功能描述:半检明细表
* 编辑履历:
* 作者 日期 版本 修改内容
* 袁新成 2015/4/10 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Windows.Forms;
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;
namespace Dongke.IBOSS.PRD.Client.ReportModule
{
///
/// 半检明细表
///
public partial class F_RPT_010102_1 : DKDockPanelBase
{
#region 成员变量
// 窗体的单例模式
private static F_RPT_010102_1 _instance;
#endregion
#region 构造函数
public F_RPT_010102_1()
{
InitializeComponent();
// 窗体显示的Title
this.Text = FormTitles.F_RPT_010102;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.btnSearch.Text = ButtonText.BTN_SEARCH;
this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_RPT_010102_1 Instance
{
get
{
if (_instance == null || _instance.IsDisposed)
{
_instance = new F_RPT_010102_1();
}
return _instance;
}
}
#endregion
#region 事件处理
///
/// 窗体加载事件
///
///
///
private void F_RPT_010102_1_Load(object sender, EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
// 设置表格不自动创建列
this.dgvSemiTestDetail.AutoGenerateColumns = false;
this.dgvSemiTestDetail.ColumnHeadersHeight = 46;
this.scbGoods.Focus();
// 获取半检类别
ServiceResultEntity sreType = DoAsync(() =>
{
return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC007");
}
);
if (sreType.Data == null)
{
return;
}
if (sreType.Data != null && sreType.Data.Tables[0].Rows.Count > Constant.INT_IS_ZERO)
{
// 设置空选项
DataRow dataRow = sreType.Data.Tables[0].NewRow();
dataRow["DictionaryID"] = DBNull.Value;
dataRow["DictionaryValue"] = Constant.CBO_SELECT_EMPTY_NAME;
dataRow["DisplayNo"] = 0;
sreType.Data.Tables[0].Rows.InsertAt(dataRow, 0);
this.dropSemiTestType.DisplayMember = "DictionaryValue";
this.dropSemiTestType.ValueMember = "DictionaryID";
this.dropSemiTestType.DataSource = sreType.Data.Tables[0];
}
// 获取缺陷 GetRptDictionaryData
ServiceResultEntity sreDefect = DoAsync(() =>
{
return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC005");
}
);
if (sreDefect.Data == null)
{
return;
}
// 获取缺陷位置
ServiceResultEntity sreDefectPosition = DoAsync(() =>
{
return ReportModuleProxy.Service.GetRptDictionaryData(0, "TPC006");
}
);
if (sreDefectPosition.Data == null)
{
return;
}
string strDefectId = string.Empty;
string strDefect = string.Empty;
string strDefectPositionId = string.Empty;
string strDefectPosition = string.Empty;
//绑定表头
for (int i = 0; i < sreDefect.Data.Tables[0].Rows.Count; i++)
{
strDefectId = "Col" + sreDefect.Data.Tables[0].Rows[i]["DICTIONARYID"].ToString();
strDefect = sreDefect.Data.Tables[0].Rows[i]["DICTIONARYVALUE"].ToString();
//添加根节点
TreeNode tn = this.dgvSemiTestDetail.ColumnTreeViewNode.Nodes.Add(strDefectId, strDefect);
for (int j = 0; j < sreDefectPosition.Data.Tables[0].Rows.Count; j++)
{
strDefectPositionId = strDefectId + sreDefectPosition.Data.Tables[0].Rows[j]["DICTIONARYID"].ToString();
strDefectPosition = sreDefectPosition.Data.Tables[0].Rows[j]["DICTIONARYVALUE"].ToString();
this.dgvSemiTestDetail.Columns.Add(strDefectPositionId, strDefectPosition);
this.dgvSemiTestDetail.Columns[strDefectPositionId].DataPropertyName = strDefectPositionId;
//添加子节点
tn.Nodes.Add(strDefectPositionId, strDefectPosition);
}
}
this.btnClearCondition_Click(null, null);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 关闭按钮
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 窗体关闭事件
///
///
///
private void F_RPT_010102_1_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 自动适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvSemiTestDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 查询按钮事件
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(this.dropSemiTestType.Text))
{
this.dropSemiTestType.Focus();
MessageBox.Show("半检类型是必选项,请选择半检类型!", this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
this.dgvSemiTestDetail.DataSource = null;
this.dgvSemiTestDetail.DataSource = this.GetSearchData();
//调整适应列宽
//this.dgvSemiTestDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
catch (Exception ex)
{
this.btnSearch.Enabled = true;
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空条件按钮事件
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.scbGoods.ClearValue();
this.dkTestUserInfoSearchBox.ClearControl();
this.dkUserInfoSearchBox.ClearControl();
this.scbGoodsType.ClearValue();
this.txtRemarks.Text = string.Empty;
this.dtpSemiTestDateStart.Value = DateTime.Now.Date;
this.dtpSemiTestDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
#endregion
#region 私有方法
///
/// 根据界面查询条件获取数据集
///
private DataTable GetSearchData()
{
try
{
RPT010102_SE se = new RPT010102_SE();
se.GoodsIDS = this.scbGoods.CheckedPKMember;
se.TestUserIDS = this.dkTestUserInfoSearchBox.UserIDS;
se.GroutingUserIDS = this.dkUserInfoSearchBox.UserIDS;
se.Remarks = this.txtRemarks.Text;
se.SemiTestDateStart = this.dtpSemiTestDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00";
se.SemiTestDateEnd = this.dtpSemiTestDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + " :59";
se.GoodsTypeIDS = scbGoodsType.SearchedValue + "";
if (!string.IsNullOrEmpty(dropSemiTestType.Text.Trim()))
{
se.semiTestTypeID = this.dropSemiTestType.SelectedValue.ToString();
}
// 调用服务器端获取数据集
ServiceResultEntity sre = DoAsync(() =>
{
return ReportModuleProxy.Service.GetRPT010102SData(se);
}
);
if (sre.Status == Constant.ServiceResultStatus.Success)
{
if (sre.Data.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
{
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
//清空数据
return null;
}
return sre.Data.Tables[0];
}
return null;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}