/*******************************************************************************
* Copyright(c) 2015 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_RPT_010202.cs
* 2.功能描述:产品损坯明细表
* 编辑履历:
* 作者 日期 版本 修改内容
* 袁新成 2015/4/14 1.00 新建
*******************************************************************************/
using System;
using System.Data;
using System.Text;
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.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_010202 : DKDockPanelBase
{
#region 成员变量
// 窗体的单例模式
private static F_RPT_010202 _instance;
//实体类
private RPT030102_SE _rptse = null;
private RPT030102_SE _rptse1 = null;
//默认清空工序,重置回用户当前权限工序
private string _currentUserPurview = null;
//默认清空生产线,重置回用户当前权限生产线
private string _currentUserLinePuview = null;
#endregion
#region 构造函数
public F_RPT_010202()
{
InitializeComponent();
// 窗体显示的Title
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;
this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_RPT_010202 Instance
{
get
{
if (_instance == null || _instance.IsDisposed)
{
_instance = new F_RPT_010202();
}
return _instance;
}
}
#endregion
#region 事件处理
///
/// 窗体加载事件
///
///
///
private void F_RPT_010202_Load(object sender, EventArgs e)
{
try
{
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
// 设置表格不自动创建列
//this.dgvScrapTotalModule.AutoGenerateColumns = false;
this.dgvScrapTotalModuleDetail.AutoGenerateColumns = false;
//this.dkproductionLineSearchBox.IsEnablePurview = true;
//this.dkProcedureSearchBox.IsEnablePurview = true;
// 初始化时间控件为当前日期
this.dtpScrapDateStart.Value = DateTime.Now.Date;
this.dtpScrapDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
//getPurview();
//getPurviewLine()
// wangx 2016-06-21
// 完成时间
this.dtpCDateStart.Value = DateTime.Now.Date;
this.dtpCDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpCDateStart.Enabled = false;
this.dtpCDateEnd.Enabled = false;
// 交坯时间
this.dtpDDateStart.Value = DateTime.Now.Date;
this.dtpDDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpDDateStart.Enabled = false;
this.dtpDDateEnd.Enabled = false;
// 注浆时间
this.dtpGDateStart.Value = DateTime.Now.Date;
this.dtpGDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpGDateStart.Enabled = false;
this.dtpGDateEnd.Enabled = false;
// wangx 2016-06-21 end
// 审核时间
this.dtpAuditDateStart.Value = DateTime.Now.Date;
this.dtpAuditDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpAuditDateStart.Enabled = false;
this.dtpAuditDateEnd.Enabled = false;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 窗体关闭事件
///
///
///
private void F_RPT_010202_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 关闭按钮
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 自动适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvScrapTotalModuleDetail.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 查询按钮事件
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
CreateSearchCondition();
this.dgvScrapTotalModuleDetail.DataSource = null;
this.dgvScrapTotalModuleDetail.DataSource = this.GetSearchDetailData();
}
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.dkproductionLineSearchBox.ClearControl();
this.scbGoodsType.ClearValue();
this.txtGoodCode.Clear();
this.dkProcedureSearchBox.ClearControl();
this.dtpScrapDateStart.Value = DateTime.Now.Date;
this.dtpScrapDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.chkScrapDateStart.Checked = true;
this.dkResponProcedureSearchBox.ClearControl();
this.dkResponUserInfoSearchBox.ClearControl();
//this.dkResponProcedureSearchBox.ProcedureIDS = this._currentUserPurview;
//this.dkproductionLineSearchBox.ProductionLineIDS = this._currentUserLinePuview;
this.txtAuditUser.Clear();
this.txtCreatUser.Clear();
this.chkSpecialRepairFlag.Checked = true;
this.chkReFireFlag.Checked = false;
// 完成时间
this.dtpCDateStart.Value = DateTime.Now.Date;
this.dtpCDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpCDateStart.Enabled = false;
this.dtpCDateEnd.Enabled = false;
this.chkPDate.Checked = false;
// 交坯时间
this.dtpDDateStart.Value = DateTime.Now.Date;
this.dtpDDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpDDateStart.Enabled = false;
this.dtpDDateEnd.Enabled = false;
this.chkDDate.Checked = false;
// 注浆时间
this.dtpGDateStart.Value = DateTime.Now.Date;
this.dtpGDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpGDateStart.Enabled = false;
this.dtpGDateEnd.Enabled = false;
this.chkGDate.Checked = false;
// 审核时间
this.dtpAuditDateStart.Value = DateTime.Now.Date;
this.dtpAuditDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
this.dtpAuditDateStart.Enabled = false;
this.dtpAuditDateEnd.Enabled = false;
this.chkAuditDate.Checked = false;
}
///
/// 报损日期选中改变事件
///
///
///
private void chkScrapDateStart_CheckedChanged(object sender, EventArgs e)
{
if (this.chkScrapDateStart.Checked)
{
this.dtpScrapDateStart.Enabled = true;
this.dtpScrapDateEnd.Enabled = true;
}
else
{
this.dtpScrapDateStart.Enabled = false;
this.dtpScrapDateEnd.Enabled = false;
this.dtpScrapDateStart.Value = DateTime.Now.Date;
this.dtpScrapDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
}
///
/// 完成时间选中改变事件
///
///
///
private void chkPDate_CheckedChanged(object sender, EventArgs e)
{
if (this.chkPDate.Checked)
{
this.dtpCDateStart.Enabled = true;
this.dtpCDateEnd.Enabled = true;
}
else
{
this.dtpCDateStart.Enabled = false;
this.dtpCDateEnd.Enabled = false;
this.dtpCDateStart.Value = DateTime.Now.Date;
this.dtpCDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
}
///
/// 交坯时间选中改变事件
///
///
///
private void chkDDate_CheckedChanged(object sender, EventArgs e)
{
if (this.chkDDate.Checked)
{
this.dtpDDateStart.Enabled = true;
this.dtpDDateEnd.Enabled = true;
}
else
{
this.dtpDDateStart.Enabled = false;
this.dtpDDateEnd.Enabled = false;
this.dtpDDateStart.Value = DateTime.Now.Date;
this.dtpDDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
}
///
/// 注浆时间选中改变事件
///
///
///
private void chkGDate_CheckedChanged(object sender, EventArgs e)
{
if (this.chkGDate.Checked)
{
this.dtpGDateStart.Enabled = true;
this.dtpGDateEnd.Enabled = true;
}
else
{
this.dtpGDateStart.Enabled = false;
this.dtpGDateEnd.Enabled = false;
this.dtpGDateStart.Value = DateTime.Now.Date;
this.dtpGDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
}
///
/// 审核日期
///
///
///
private void chkAuditDate_CheckedChanged(object sender, EventArgs e)
{
if (this.chkAuditDate.Checked)
{
this.dtpAuditDateStart.Enabled = true;
this.dtpAuditDateEnd.Enabled = true;
}
else
{
this.dtpAuditDateStart.Enabled = false;
this.dtpAuditDateEnd.Enabled = false;
this.dtpAuditDateStart.Value = DateTime.Now.Date;
this.dtpAuditDateEnd.Value = DateTime.Now.Date.AddDays(1).AddSeconds(-1);
}
}
#endregion
#region 私有方法
///
/// 搜索条件
///
///
private void CreateSearchCondition()
{
_rptse = new RPT030102_SE();
_rptse.ProductionLineID = this.dkproductionLineSearchBox.ProductionLineID;
_rptse.GoodsTypeCode = scbGoodsType.SearchedValue + "";
_rptse.GoodsCode = this.txtGoodCode.Text.Trim();
_rptse.ProcedureIDS = this.dkProcedureSearchBox.ProcedureIDS;
if (this.chkScrapDateStart.Checked)
{
_rptse.ScrapDateStart = DateTime.Parse(this.dtpScrapDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
_rptse.ScrapDateEnd = DateTime.Parse(this.dtpScrapDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
}
if (this.chkPDate.Checked)
{
_rptse.CTimeStart = DateTime.Parse(this.dtpCDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
_rptse.CTimeEnd = DateTime.Parse(this.dtpCDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
}
if (this.chkDDate.Checked)
{
_rptse.DTimeStart = DateTime.Parse(this.dtpDDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
_rptse.DTimeEnd = DateTime.Parse(this.dtpDDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
}
if (this.chkGDate.Checked)
{
_rptse.GTimeStart = DateTime.Parse(this.dtpGDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
_rptse.GTimeEnd = DateTime.Parse(this.dtpGDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
}
if (this.chkAuditDate.Checked)
{
_rptse.AuditTimeStart = DateTime.Parse(this.dtpAuditDateStart.Value.ToString("yyyy-MM-dd HH:mm") + ":00");
_rptse.AuditTimeEnd = DateTime.Parse(this.dtpAuditDateEnd.Value.ToString("yyyy-MM-dd HH:mm") + ":59");
}
_rptse.ResponProcedureIDS = this.dkResponProcedureSearchBox.ProcedureIDS;
_rptse.ResponUserIDS = this.dkResponUserInfoSearchBox.UserIDS;
_rptse.CreatUser = this.txtCreatUser.Text.Trim();
_rptse.AuditUser = this.txtAuditUser.Text.Trim();
_rptse.SpecialRepairFlag = this.chkSpecialRepairFlag.Checked;
_rptse.ReFireFlag = this.chkReFireFlag.Checked;
}
///
/// 查询损坏明细表
///
private DataTable GetSearchDetailData()
{
try
{
// 调用服务器端获取数据集
ServiceResultEntity sre = DoAsync(() =>
{
return ReportModuleProxy.Service.GetRPT030102IData(this._rptse);
}
);
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;
}
}
///
/// 获取权限
///
protected void getPurview()
{
try
{
StringBuilder sbProcedurePurview = new StringBuilder();
//得到工序查看权限
DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
{
return SystemModuleProxy.Service.GetUserPurview(9, LogInUserInfo.CurrentUser.UserID);
}));
if (dsProcedurePurview != null)
{
foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
{
sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
}
if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
{
this.dkResponProcedureSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
//this.dkResponProcedureSearchBox.ProcedureIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
this._currentUserPurview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 获取权限(生产线)
///
protected void getPurviewLine()
{
try
{
StringBuilder sbProcedurePurview = new StringBuilder();
//得到工序查看权限
DataSet dsProcedurePurview = (DataSet)DoAsync(new AsyncMethod(() =>
{
return SystemModuleProxy.Service.GetUserPurview(7, LogInUserInfo.CurrentUser.UserID);
}));
if (dsProcedurePurview != null)
{
foreach (DataRow dr in dsProcedurePurview.Tables[Constant.INT_IS_ZERO].Rows)
{
sbProcedurePurview.Append(dr[Constant.INT_IS_ZERO].ToString() + ",");
}
if (sbProcedurePurview.Length != Constant.INT_IS_ZERO)
{
this.dkproductionLineSearchBox.Purview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
//this.dkproductionLineSearchBox.ProductionLineIDS = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
this._currentUserLinePuview = sbProcedurePurview.ToString().Substring(Constant.INT_IS_ZERO, sbProcedurePurview.Length - 1);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}