/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PM_2701.cs
* 2.功能描述:成型报损信息一览
* 编辑履历:
* 作者 日期 版本 修改内容
* 周兴 2018/03/27 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;
namespace Dongke.IBOSS.PRD.Client.PMModule
{
///
/// 废弃产品信息一览
///
public partial class F_PM_2701 : DockPanelBase
{
#region 成员变量
//单例模式
private static F_PM_2701 _instance;
//产品分级类别ID
private int _goodsLevelTypeID = Convert.ToInt32(Constant.GoodsLevelType.Damage);
//页面审核状态值
private int? _AuditStatus;
#endregion
#region 构造函数
///
/// 废弃一览构造
///
public F_PM_2701()
{
InitializeComponent();
this.Text = FormTitles.F_PM_2701;
this.cbSelectTime.Checked = true;
this.txtScrapDateStart.Enabled = true;
this.txtScrapDateEnd.Enabled = true;
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
this.tsbtnApprover.Text = ButtonText.TSBTN_AUDIT;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
this.tsbtnReverse.Text = ButtonText.TSBTN_FINISHEDCANCELHANDOVER;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_PM_2701 Instance
{
get
{
if (_instance == null)
{
_instance = new F_PM_2701();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 窗体加载
///
///
///
private void F_PM_2701_Load(object sender, EventArgs e)
{
try
{
this.dgvScrapProduct.AutoGenerateColumns = false;
// 加载权限
FormPermissionManager.FormPermissionControl(this.Name, this,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
Dongke.IBOSS.PRD.Client.DataModels.LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
DataSet dsStatus = SystemModuleProxy.Service.GetAuditStatus();
this.cbAuditStatus.DataSource = dsStatus.Tables[0];
this.cbAuditStatus.ValueMember = "AuditStatusID";
this.cbAuditStatus.DisplayMember = "AuditStatusName";
this.cbAuditStatus.Text = "";
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 打开新建窗体事件
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
F_PM_2702 f_PM_2702 = new F_PM_2702(Constant.FormMode.Add, "", 0,this.tsbtnApprover.Visible);
DialogResult dialogresult = f_PM_2702.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvScrapProduct.DataSource = null;
DataSet dsScrap = (DataSet)DoAsync(new AsyncMethod(() =>
{
return this.GetScrapProduct();
}));
if (dsScrap != null)
{
if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvScrapProduct.DataSource = ((DataSet)dsScrap).Tables[Constant.INT_IS_ZERO];
this.dgvScrapProduct.ReadOnly = true;
}
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 查询事件
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
try
{
if (this.cbAuditStatus.Text != string.Empty)
{
this._AuditStatus = Convert.ToInt32(this.cbAuditStatus.SelectedValue);
}
else
{
this._AuditStatus = null;
}
DataSet dsScrapProduct = (DataSet)DoAsync(new AsyncMethod(() =>
{
return this.GetScrapProduct();
}));
if (dsScrapProduct != null)
{
if (dsScrapProduct.Tables[0].Rows.Count != Constant.INT_IS_ZERO)
{
this.dgvScrapProduct.DataSource = ((DataSet)dsScrapProduct).Tables[Constant.INT_IS_ZERO];
this.dgvScrapProduct.ReadOnly = true;
}
else
{
this.dgvScrapProduct.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
this.dgvScrapProduct.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 时间有效性切换
///
///
///
private void cbSelectTime_CheckedChanged(object sender, EventArgs e)
{
this.txtScrapDateStart.Enabled = this.cbSelectTime.Checked;
this.txtScrapDateEnd.Enabled = this.cbSelectTime.Checked;
}
///
/// 清空条件
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtBarCode.Text = "";
this.txtUserCode.Text = "";
this.cbSelectTime.Checked = true;
this.txtGoodsCode.Text = "";
this.txtGoodsName.Text = "";
this.txtRemarks.Text = "";
this.txtRreason.Text = "";
this.txtGroutingUserCode.Text = "";
}
///
/// 编辑窗体打开
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
if (currentRow != null)
{
string barCode = currentRow.Cells["BarCode"].Value.ToString();
int sPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString());
F_PM_2702 frmFPM2702 = new F_PM_2702(Constant.FormMode.Edit, barCode, sPId, this.tsbtnApprover.Visible);
DialogResult dialogresult = frmFPM2702.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvScrapProduct.DataSource = null;
object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
if (obScrapResult != null)
{
DataSet dsScrap = (DataSet)obScrapResult;
if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
this.dgvScrapProduct.ReadOnly = true;
}
}
}
}
else
{
MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑窗体打开
///
///
///
private void dgvScrapProduct_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
if (currentRow != null)
{
string barCode = currentRow.Cells["BarCode"].Value.ToString();
int SPId = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value.ToString());
F_PM_2702 frmFPM2702 = new F_PM_2702(Constant.FormMode.Edit, barCode, SPId,this.tsbtnApprover.Visible);
DialogResult dialogresult = frmFPM2702.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvScrapProduct.DataSource = null;
object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
if (obScrapResult != null)
{
DataSet dsScrap = (DataSet)obScrapResult;
if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
this.dgvScrapProduct.ReadOnly = true;
}
}
}
}
else
{
MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
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_PM_2701_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 自动列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvScrapProduct.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 审批按钮事件
///
///
///
private void tsbtnApprover_Click(object sender, EventArgs e)
{
try
{
DataGridViewRow currentRow = this.dgvScrapProduct.CurrentRow;
if (currentRow != null)
{
string barCode = currentRow.Cells["BarCode"].Value.ToString();
int ScrapProductID = Convert.ToInt32(currentRow.Cells["ScrapProductID"].Value);
F_PM_2703 frmFPM2703 = new F_PM_2703(barCode, 0, ScrapProductID);
DialogResult dialogresult = frmFPM2703.ShowDialog();
if (dialogresult.Equals(DialogResult.OK))
{
this.dgvScrapProduct.DataSource = null;
object obScrapResult = DoAsync(new AsyncMethod(GetScrapProduct));
if (obScrapResult != null)
{
DataSet dsScrap = (DataSet)obScrapResult;
if (dsScrap.Tables.Count != Constant.INT_IS_ZERO)
{
this.dgvScrapProduct.DataSource = dsScrap.Tables[Constant.INT_IS_ZERO];
this.dgvScrapProduct.ReadOnly = true;
}
}
}
}
else
{
MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 撤销
///
///
///
private void tsbtnReverse_Click(object sender, EventArgs e)
{
try
{
if (this.dgvScrapProduct.CurrentRow != null)
{
F_PM_2801 frmFPM2801 = new F_PM_2801();
frmFPM2801.CurrentBarCode = this.dgvScrapProduct.CurrentRow.Cells["BarCode"].Value + "";
frmFPM2801.ShowDialog();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 私有方法
///
/// 根据界面查询条件获取数据集
///
private DataSet GetScrapProduct()
{
try
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "GroutingScrapProduct";
cre.Name = "GetGroutingScrapProduct";
cre.Properties["GroutingUserCode"] = this.txtGroutingUserCode.Text.Trim();
cre.Properties["BarCode"] = this.txtBarCode.Text.Trim();
cre.Properties["ResponUserCode"] = this.txtUserCode.Text.Trim();
cre.Properties["GoodsCode"] = this.txtGoodsCode.Text.Trim();
cre.Properties["GoodsName"] = this.txtGoodsName.Text.Trim();
cre.Properties["Remarks"] = this.txtRemarks.Text.Trim();
cre.Properties["Rreason"] = this.txtRreason.Text.Trim();
if (this.cbSelectTime.Checked)
{
cre.Properties["ScrapDateStart"] = this.txtScrapDateStart.Text.Trim();
cre.Properties["ScrapDateEnd"] = this.txtScrapDateEnd.Text.Trim();
}
if (this._AuditStatus != null)
{
cre.Properties["AuditStatus"] = this._AuditStatus;
}
ServiceResultEntity result = PMModuleProxyNew.Service.HandleRequest(cre);
return result.Data;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}