/*******************************************************************************
* Copyright(c) 2016 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_RPT_030116.cs
* 2.功能描述:成型存坯汇总表
* 编辑履历:
* 作者 日期 版本 修改内容
* 陈晓野 2018/04/01 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.PMModuleService;
using Dongke.IBOSS.PRD.WCF.DataModels.PMModule;
using Dongke.IBOSS.PRD.Client.Controls;
using System.Collections.Generic;
namespace Dongke.IBOSS.PRD.Client.ReportModule
{
///
/// 成型存坯汇总表
///
public partial class F_RPT_030116 : DKDockPanelBase
{
#region 成员变量
//单例模式
private static F_RPT_030116 _instance;
ClientRequestEntity _cre1 = null;
ClientRequestEntity _cre2 = null;
#endregion
#region 构造函数
///
/// 废弃一览构造
///
public F_RPT_030116()
{
InitializeComponent();
this.Text = "成型存坯汇总表";
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_RPT_030116 Instance
{
get
{
if (_instance == null)
{
_instance = new F_RPT_030116();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 查询事件
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
// 汇总表
if (this.tabControl1.SelectedIndex == 0)
{
this.dgvG1.DataSource = null;
this._cre1 = new ClientRequestEntity();
this._cre1.NameSpace = "R03";
this._cre1.Name = "R030116Goods";
this._cre1.Properties["LineCode"] = this.txtLinCode.Text.Trim();
this._cre1.Properties["UserCode"] = this.txtUserCode.Text.Trim();
this._cre1.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
this._cre1.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
if (this.chkGDate.Checked)
{
this._cre1.Properties["DateBegin"] = this.txtTimeStart.Value;
this._cre1.Properties["DateEnd"] = this.txtTimeEnd.Value;
}
ServiceResultEntity resultEntity = DoAsync(() =>
{
return ReportModuleProxy.Service.DoRequest(_cre1);
});
if (resultEntity == null || resultEntity.Data == null ||
resultEntity.Data.Tables.Count == 0 ||
resultEntity.Data.Tables[0].Rows.Count == 0)
{
this.dgvG1.AutoResizeColumns();
return;
}
else
{
this.dgvG1.DataSource = resultEntity.Data.Tables[0];
this.dgvG1.ReadOnly = true;
this.dgvG1.Rows[0].Selected = true;
this.dgvG1.AutoResizeColumns();
}
}
else if (this.tabControl1.SelectedIndex == 1)
{
this.dgvG2.DataSource = null;
this._cre2 = new ClientRequestEntity();
this._cre2.NameSpace = "R03";
this._cre2.Name = "R030116User";
this._cre2.Properties["LineCode"] = this.txtLinCode.Text.Trim();
this._cre2.Properties["UserCode"] = this.txtUserCode.Text.Trim();
this._cre2.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
this._cre2.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
if (this.chkGDate.Checked)
{
this._cre2.Properties["DateBegin"] = this.txtTimeStart.Value;
this._cre2.Properties["DateEnd"] = this.txtTimeEnd.Value;
}
ServiceResultEntity resultEntity = DoAsync(() =>
{
return ReportModuleProxy.Service.DoRequest(_cre2);
});
if (resultEntity == null || resultEntity.Data == null ||
resultEntity.Data.Tables.Count == 0 ||
resultEntity.Data.Tables[0].Rows.Count == 0)
{
this.dgvG2.AutoResizeColumns();
return;
}
else
{
this.dgvG2.DataSource = resultEntity.Data.Tables[0];
this.dgvG2.ReadOnly = true;
this.dgvG2.Rows[0].Selected = true;
this.dgvG2.AutoResizeColumns();
}
}
// 明细表
else
{
this.dgvG3.DataSource = null;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "R03";
cre.Name = "R030116D";
cre.Properties["LineCode"] = this.txtLinCode.Text.Trim();
cre.Properties["UserCode"] = this.txtUserCode.Text.Trim();
cre.Properties["GoodsTypeCode"] = scbGoodsType.SearchedValue + "";
cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
if (this.chkGDate.Checked)
{
cre.Properties["DateBegin"] = this.txtTimeStart.Value;
cre.Properties["DateEnd"] = this.txtTimeEnd.Value;
}
ServiceResultEntity resultEntity = DoAsync(() =>
{
return ReportModuleProxy.Service.DoRequest(cre);
});
if (resultEntity == null || resultEntity.Data == null ||
resultEntity.Data.Tables.Count == 0 ||
resultEntity.Data.Tables[0].Rows.Count == 0)
{
this.dgvG3.AutoResizeColumns();
return;
}
else
{
this.dgvG3.DataSource = resultEntity.Data.Tables[0];
this.dgvG3.ReadOnly = true;
this.dgvG3.Rows[0].Selected = true;
this.dgvG3.AutoResizeColumns();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空条件
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtLinCode.Clear();
this.txtUserCode.Clear();
this.scbGoodsType.ClearValue();
this.txtGoodsCode.Text = string.Empty;
this.chkGDate.Checked = false;
}
///
/// 关闭一览窗体
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 窗体关闭事件
///
///
///
private void F_RPT_030110_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 自动列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvG1.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
this.dgvG2.AutoResizeColumns();
this.dgvG3.AutoResizeColumns();
}
///
/// 窗体加载
///
///
///
private void F_RPT_030110_Load(object sender, EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
this.dgvG1.AutoGenerateColumns = false;
// 设置日期控件默认值
DateTime date = DateTime.Now;
this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void chkGDate_CheckedChanged(object sender, EventArgs e)
{
this.txtTimeStart.Enabled = this.chkGDate.Checked;
this.txtTimeEnd.Enabled = this.chkGDate.Checked;
if (!this.chkGDate.Checked)
{
DateTime date = DateTime.Now;
this.txtTimeStart.Value = new DateTime(date.Year, date.Month, 1);
this.txtTimeEnd.Value = this.txtTimeStart.Value.AddMonths(1).AddSeconds(-1);
}
}
private void dgvG1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0 || this.dgvG1.CurrentRow == null)
{
return;
}
try
{
this.dgvG3.DataSource = null;
this._cre1.NameSpace = "R03";
this._cre1.Name = "R030116D";
this._cre1.Properties["GoodsID"] = this.dgvG1.CurrentRow.Cells["g1GOODSID"].Value;
this.tabControl1.SelectedIndex = 2;
ServiceResultEntity resultEntity = DoAsync(() =>
{
return ReportModuleProxy.Service.DoRequest(this._cre1);
});
if (resultEntity == null || resultEntity.Data == null ||
resultEntity.Data.Tables.Count == 0 ||
resultEntity.Data.Tables[0].Rows.Count == 0)
{
this.dgvG3.AutoResizeColumns();
return;
}
else
{
this.dgvG3.DataSource = resultEntity.Data.Tables[0];
this.dgvG3.ReadOnly = true;
this.dgvG3.Rows[0].Selected = true;
this.dgvG3.AutoResizeColumns();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
private void dgvG2_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0 || this.dgvG2.CurrentRow == null)
{
return;
}
try
{
this.dgvG3.DataSource = null;
this._cre2.NameSpace = "R03";
this._cre2.Name = "R030116D";
this._cre2.Properties["LineID"] = this.dgvG2.CurrentRow.Cells["g2groutinglineid"].Value;
this._cre2.Properties["UserID"] = this.dgvG2.CurrentRow.Cells["g2userid"].Value;
this._cre2.Properties["GoodsID"] = this.dgvG2.CurrentRow.Cells["g2GOODSID"].Value;
this.tabControl1.SelectedIndex = 2;
ServiceResultEntity resultEntity = DoAsync(() =>
{
return ReportModuleProxy.Service.DoRequest(this._cre2);
});
if (resultEntity == null || resultEntity.Data == null ||
resultEntity.Data.Tables.Count == 0 ||
resultEntity.Data.Tables[0].Rows.Count == 0)
{
this.dgvG3.AutoResizeColumns();
return;
}
else
{
this.dgvG3.DataSource = resultEntity.Data.Tables[0];
this.dgvG3.ReadOnly = true;
this.dgvG3.Rows[0].Selected = true;
this.dgvG3.AutoResizeColumns();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 根据界面查询条件获取数据集
///
private DataTable GetData(ClientRequestEntity cre)
{
try
{
ServiceResultEntity resultEntity = ReportModuleProxy.Service.DoRequest(cre);
if (resultEntity == null || resultEntity.Data == null || resultEntity.Data.Tables.Count == 0)
{
return null;
}
return resultEntity.Data.Tables[0];
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}