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_1401 : DockPanelBase
{
#region 成员变量
private static F_MST_1401 _instance;
#endregion
#region 构造函数
public F_MST_1401()
{
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_1401 Instance
{
get
{
if (_instance == null)
{
_instance = new F_MST_1401();
}
return _instance;
}
}
#endregion
#region 事件
///
/// 页面加载事件
///
///
///
private void F_MST_1401_Load(object sender, EventArgs e)
{
// 按钮权限控制
FormPermissionManager.FormPermissionControl(this.Name, this,
LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData,
LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
//设置表格不自动创建列
this.dgvCustomer.AutoGenerateColumns = false;
}
///
/// 查询事件
///
///
///
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.dgvCustomer.DataSource = this.DataSource.Tables[0];
}
else
{
// 清空明细中的数据
this.dgvCustomer.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
// 清空明细中的数据
this.dgvCustomer.DataSource = null;
// 提示未查找到数据
MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
///
/// 自适应列宽
///
///
///
private void tsbtnAdaptive_Click(object sender, EventArgs e)
{
this.dgvCustomer.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
}
///
/// 退出
///
///
///
private void tsbtnClose_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 新建
///
///
///
private void tsbtnAdd_Click(object sender, EventArgs e)
{
try
{
F_MST_1402 frmMST1402 = new F_MST_1402(Constant.FormMode.Add,"");
DialogResult dialogResult = frmMST1402.ShowDialog();
// 重新加载GridView
btnSearch_Click(sender, null);
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
///
/// 编辑
///
///
///
private void tsbtnEdit_Click(object sender, EventArgs e)
{
try
{
if (this.dgvCustomer.SelectedRows.Count != 0)
{
string Customerid = this.dgvCustomer.SelectedRows[0].Cells["CUSTOMERID"].Value.ToString();
F_MST_1402 frmFPC1302 = new F_MST_1402(Constant.FormMode.Edit, Customerid);
DialogResult dialogresult = frmFPC1302.ShowDialog();
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.txtCustomerCode.Clear();
this.txtCustomerName.Clear();
this.txtGoodsCode.Clear();
this.txtGoodsName.Clear();
this.cbflagtrue.Checked = true;
this.cbflagfalse.Checked = true;
}
///
/// 窗体关闭事件
///
///
///
private void F_MST_1401_FormClosed(object sender, FormClosedEventArgs e)
{
_instance = null;
}
#endregion
#region 私有方法
///
/// 根据界面查询条件获取数据集
///
private DataSet GetSearchData()
{
try
{
ClientRequestEntity cre = new ClientRequestEntity();
cre.NameSpace = "F_MST_1401";
cre.Name = "GetCustomer";
cre.Properties["Customerid"] = "";
cre.Properties["CustomerCode"] = this.txtCustomerCode.Text;
cre.Properties["CustomerName"] = this.txtCustomerName.Text;
cre.Properties["GOODSCODE"] = this.txtGoodsCode.Text;
cre.Properties["GOODSNAME"] = this.txtGoodsName.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
}
}