/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_MST_GoodsImage.cs
* 2.功能描述:产品线性图
* 编辑履历:
* 作者 日期 版本 修改内容
* 冯林勇 2024-04-15 1.00 一览
*******************************************************************************/
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.WinForm.Controls;
using System;
using System.Reflection;
using System.Windows.Forms;
namespace Dongke.IBOSS.PRD.Client.Controls
{
public partial class F_MST_GoodsImage : DKDockPanelBase
{
#region 静态变量
#endregion
#region 成员变量
// 窗体单例模式
private static F_MST_GoodsImage _instance = null;
private string _materialcode = null;
#endregion
#region 构造函数
public F_MST_GoodsImage()
{
InitializeComponent();
// 工具栏按钮文本赋值
this.tsbtnAddInvoice.Text = ButtonText.TSBTN_ADD;
this.tsbtnDelete.Text = ButtonText.TSBTN_DELETE;
this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
// 查询、清空条件按钮文本赋值
this.tsbtnSearch.Text = ButtonText.BTN_SEARCH;
this.tsbtnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
// 设置表格不自动创建列
this.dgvGoodsImage.AutoGenerateColumns = false;
// 删除
this.tsbtnDelete.Enabled = false;
}
#endregion
#region 单例模式
///
/// 单例模式,防止重复创建窗体
///
public static F_MST_GoodsImage Instance
{
get
{
if (_instance == null)
{
_instance = new F_MST_GoodsImage();
}
return _instance;
}
}
#endregion
#region 控件事件
///
/// 画面打开
///
///
///
private void F_MST_GoodsImage_Load(object sender, EventArgs e)
{
try
{
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 画面关闭
///
///
///
private void F_MST_GoodsImage_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
///
/// 查询
///
///
///
private void tsbtnSearch_Click(object sender, EventArgs e)
{
try
{
this.QueryDataFromOther();
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空查询条件
///
///
///
private void tsbtnClearCondition_Click(object sender, EventArgs e)
{
try
{
this.txtMATNR.Text = "";
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 点击新建线性图按钮
///
///
///
private void tsbtnAddInvoice_Click(object sender, System.EventArgs e)
{
try
{
F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd(String.Empty, String.Empty);
DialogResult dialogresult = frmGoodAdd.ShowDialog();
if (DialogResult.OK == dialogresult)
{
QueryDataFromOther();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#region 编辑(目前不考虑,删除重新上传)
///
/// 点击编辑按钮,编辑现有票据基本信息
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
// 获取活动行
DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
string winStatus = "Edit";
string matnr = currentRow.Cells["MATERIALCODE"].Value.ToString();
F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd(winStatus, matnr);
DialogResult dialogresult = frmGoodAdd.ShowDialog();
if (DialogResult.OK == dialogresult)
{
QueryDataFromOther();
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 预览后期添加 本期预留
///
/// 预览票据按钮按下
///
///
///
private void tsbtnPreviewInvoice_Click(object sender, EventArgs e)
{
try
{
//// 获取活动行
//DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
//if (currentRow != null)
//{
// // 给票据预览画面赋值,并打开
// F_MST_012005 frm012005 = new F_MST_012005();
// frm012005.LayoutID = Convert.ToInt32(currentRow.Cells["InvoiceLayoutID"].Value);
// frm012005.ShowDialog();
//}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
///
/// 点击删除按钮
///
///
///
private void tsbtnDelete_Click(object sender, EventArgs e)
{
try
{
// 获取活动行
DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
if (currentRow != null)
{
DialogResult dr = MessageBox.Show("是否删除当前选择数据。", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr != System.Windows.Forms.DialogResult.Yes)
{
return;
}
string materialcode = currentRow.Cells["materialcode"].Value.ToString();
ServiceResultEntity sre = DoAsync(() =>
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_GoodsImage";
cre.Name = "DeleteGoodsImage";
cre.Properties["MATERIALCODE"] = materialcode;
return SystemModuleProxy.Service.DoRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
MessageBox.Show(string.Format("{0}的{1}操作成功完成了。", "产品线性图", "删除"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
QueryDataFromOther();
}
}
else
{
MessageBox.Show("没有选择任何数据。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 单击自适应列宽,将所有的列宽都自动去适应内容
///
///
///
private void tsbtnAdaptive_Click(object sender, System.EventArgs e)
{
this.dgvGoodsImage.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 关闭页面
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 所选数据发生改变时
///
///
///
private void dgvInvoice_SelectionChanged(object sender, EventArgs e)
{
try
{
if (this.dgvGoodsImage.CurrentCell == null
|| this.dgvGoodsImage.SelectedRows.Count == 0)
{
this.tsbtnDelete.Enabled = false;
}
else
{
this.tsbtnDelete.Enabled = true;
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 双击查看
///
///
///
private void dgvGoodsImage_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
try
{
// 获取活动行
DataGridViewRow currentRow = this.dgvGoodsImage.CurrentRow;
if (currentRow != null)
{
this._materialcode = currentRow.Cells["MATERIALCODE"].Value.ToString();
F_MST_GoodsImageAdd frmGoodAdd = new F_MST_GoodsImageAdd("Edit", _materialcode);
DialogResult dialogresult = frmGoodAdd.ShowDialog();
if (DialogResult.OK == dialogresult)
{
QueryDataFromOther();
}
}
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion
#region 重写方法
///
/// 查询数据
///
/// 验证通过true,其他false
private void QueryDataFromOther()
{
try
{
this.dgvGoodsImage.DataSource = null;
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_GoodsImage";
cre.Name = "getGoodsImage";
cre.Properties["MATNR"] = this.txtMATNR.TextValue;
ServiceResultEntity sre = DoAsync(() =>
{
return SystemModuleProxy.Service.DoRequest(cre);
});
if (sre.Status == Constant.ServiceResultStatus.Success)
{
// 查询成功
this.dgvGoodsImage.DataSource = sre.Data.Tables[0];
if (sre.Data.Tables[0].Rows.Count > 0)
{
this.dgvGoodsImage.Rows[0].Selected = true;
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 私有方法
#endregion
}
}