using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Basics.DockPanel;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.Client.DataModels;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Dongke.IBOSS.PRD.Client.SystemModule
{
public partial class F_MST_1801 : DockPanelBase
{
#region 成员变量
private static F_MST_1801 _instance;
#endregion
#region 构造函数
public F_MST_1801()
{
InitializeComponent();
this.Text = "产品对应釉料";
this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
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_MST_1801 Instance
{
get
{
if (_instance == null)
{
_instance = new F_MST_1801();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 页面加载事件
///
///
///
private void F_MST_1801_Load(object sender, EventArgs e)
{
// 按钮权限控制
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1801";
cre.Name = "GetGlaze";
cre.Properties["GLAZE"] = "";
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
DataSet set = sre.Data;
DataTable dt = set.Tables[0];
DataRow dr = dt.NewRow();
dr["GLAZETYPEID"] = "0";
dr["GLAZE"] = "";
dt.Rows.Add(dr);
DataSet GlazeInfo = sre.Data;
if (GlazeInfo != null && GlazeInfo.Tables.Count > 0)
{
this.cmbGlaze.DataSource = dt;
this.cmbGlaze.DisplayMember = "GLAZE";
this.cmbGlaze.ValueMember = "GLAZETYPEID";
this.cmbGlaze.SelectedValue = "0";
}
}
///
/// 查询事件
///
///
///
private void btnSearch_Click(object sender, EventArgs e)
{
this.DataSource = this.GetSearchData();
if (this.DataSource != null)
{
if (this.DataSource.Tables[0] != null && this.DataSource.Tables[0].Rows.Count > 0)
{
this.dgvLayout.DataSource = this.DataSource.Tables[0];
}
else
{
// 清空明细中的数据
this.dgvLayout.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
// 清空明细中的数据
this.dgvLayout.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvLayout.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 退出
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 编辑
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
if (this.dgvLayout.SelectedRows.Count != 0)
{
string GlazeTypeID = this.dgvLayout.SelectedRows[0].Cells["GLAZETYPEID"].Value.ToString();
string goodscode= this.dgvLayout.SelectedRows[0].Cells["GOODSCODE"].Value.ToString();
string ValueFlag = this.dgvLayout.SelectedRows[0].Cells["ValueFlag"].Value.ToString();
F_MST_1802 frmFPC1802 = new F_MST_1802(Constant.FormMode.Edit, goodscode, GlazeTypeID, ValueFlag);
DialogResult dialogresult = frmFPC1802.ShowDialog();
btnSearch_Click(sender, null);
}
}
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_MST_1802 frmMST1802 = new F_MST_1802(Constant.FormMode.Add, "","","");
DialogResult dialogResult = frmMST1802.ShowDialog();
// 重新加载GridView
btnSearch_Click(sender, null);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 清空按钮
///
///
///
private void btnClearCondition_Click(object sender, EventArgs e)
{
this.txtGoodsCode.Clear();
this.cmbGlaze.SelectedValue = "0";
this.cbflagtrue.Checked = true;
this.cbflagfalse.Checked = true;
}
///
/// 窗体关闭事件
///
///
///
private void F_MST_1801_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
#region 私有方法
///
/// 根据界面查询条件获取数据集
///
private DataSet GetSearchData()
{
try
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1801";
cre.Name = "GetGoodsGlaze";
cre.Properties["GLAZETYPEID"] = cmbGlaze.SelectedValue.ToString();
cre.Properties["GLAZE"] = cmbGlaze.Text.ToString();
cre.Properties["GOODSCODE"] = txtGoodsCode.Text;
if (this.cbflagtrue.Checked == true && this.cbflagfalse.Checked == true)
{
cre.Properties["VALUEFLAG"] = "";
}
else if (this.cbflagtrue.Checked == true && this.cbflagfalse.Checked == false)
{
cre.Properties["VALUEFLAG"] = 1;
}
else if (this.cbflagtrue.Checked == false && this.cbflagfalse.Checked == true)
{
cre.Properties["VALUEFLAG"] = 0;
}
else if (this.cbflagtrue.Checked == false && this.cbflagfalse.Checked == false)
{
cre.Properties["VALUEFLAG"] = 2;
}
ServiceResultEntity sre = SystemModuleProxy.Service.DoRequest(cre);
if (sre.Status == Basics.BaseResources.Constant.ServiceResultStatus.Success)
{
return sre.Data;
}
return null;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
private void tsrOperate_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
{
}
}
}