452 lines
14 KiB
C#
452 lines
14 KiB
C#
|
|
/***************************************
|
|||
|
|
*基础资料:供应商分类
|
|||
|
|
**************************************/
|
|||
|
|
|
|||
|
|
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;
|
|||
|
|
using WMS.Frm.Base;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmBaseData
|
|||
|
|
{
|
|||
|
|
public partial class FrmProviderType : FormBase
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 供应商类别对象
|
|||
|
|
/// </summary>
|
|||
|
|
ProviderTypeModel providerTypeModel;
|
|||
|
|
/// <summary>
|
|||
|
|
/// 供应商类别对象集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<ProviderTypeModel> Sourcelist = new List<ProviderTypeModel>();
|
|||
|
|
|
|||
|
|
List<ProviderTypeModel> addlist = new List<ProviderTypeModel>();
|
|||
|
|
List<ProviderTypeModel> updatelist = new List<ProviderTypeModel>();
|
|||
|
|
List<ProviderTypeModel> dellist = new List<ProviderTypeModel>();
|
|||
|
|
|
|||
|
|
int workflag;//0 增加 1 修改 2 删除 ;
|
|||
|
|
|
|||
|
|
public FrmProviderType()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmProviderType_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
FrmSelectModle = new ProviderTypeModel();
|
|||
|
|
BSPriType.DataSource = new ProviderTypeModel();
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
bindgrid();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
Sourcelist = ConvertHelper<ProviderTypeModel>.ConvertToList(table);
|
|||
|
|
GCProviderType.DataSource = Sourcelist;
|
|||
|
|
GVProviderType.RefreshData();
|
|||
|
|
GVProviderType.ExpandAllGroups();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定GRIDVIEW信息
|
|||
|
|
/// </summary>
|
|||
|
|
private void bindgrid()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
providerTypeModel = new ProviderTypeModel();
|
|||
|
|
DataTable ds = IBussFactory<BussProviderType>.Instance().GetProviderTypeDS(providerTypeModel);
|
|||
|
|
if (ds.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
Sourcelist = ConvertHelper<ProviderTypeModel>.ConvertToList(ds);
|
|||
|
|
}
|
|||
|
|
GCProviderType.DataSource = Sourcelist;
|
|||
|
|
GCProviderType.Refresh();
|
|||
|
|
GVProviderType.ExpandAllGroups();
|
|||
|
|
panelControl2.Enabled = false;
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox(ex.Message.ToString());
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#region 选取供应商类型
|
|||
|
|
/// <summary>
|
|||
|
|
/// 双击GRID改变绑定信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void GCProviderType_DoubleClick(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (GVProviderType.FocusedRowHandle < 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
providerTypeModel = GVProviderType.GetRow(GVProviderType.FocusedRowHandle) as ProviderTypeModel;
|
|||
|
|
BSPriType.DataSource = providerTypeModel;
|
|||
|
|
if (providerTypeModel.STATUS.Trim() == "正常")
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateIN.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 单击GRID改变绑定信息
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void GCProviderType_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (GVProviderType.FocusedRowHandle < 0)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
providerTypeModel = GVProviderType.GetRow(GVProviderType.FocusedRowHandle) as ProviderTypeModel;
|
|||
|
|
BSPriType.DataSource = providerTypeModel;
|
|||
|
|
if (providerTypeModel.STATUS.Trim() == "正常")
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateIN.Checked = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
#region 以下是继承的按钮事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Add()
|
|||
|
|
{
|
|||
|
|
if (addlist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
if (updatelist.Count > 0 || dellist.Count > 0)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("是否保存刚才的操作?"))
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
updatelist.Clear();
|
|||
|
|
dellist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
//调用实例化窗体
|
|||
|
|
panelControl2.Enabled = true;
|
|||
|
|
workflag = 0;
|
|||
|
|
BSPriType.DataSource = new ProviderTypeModel();
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Save()
|
|||
|
|
{
|
|||
|
|
string strError = "";
|
|||
|
|
FrmOperator(workflag);
|
|||
|
|
if (workflag == 0)
|
|||
|
|
{
|
|||
|
|
if (addlist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("无需要保存的数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
strError = IBussFactory<BussProviderType>.Instance().execTypeWorkAdd(addlist);
|
|||
|
|
if (string.IsNullOrEmpty(strError))
|
|||
|
|
{
|
|||
|
|
addlist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (workflag == 1)
|
|||
|
|
{
|
|||
|
|
if (updatelist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("无需要保存的数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
strError = IBussFactory<BussProviderType>.Instance().execTypeWorkUpdate(updatelist);
|
|||
|
|
if (string.IsNullOrEmpty(strError))
|
|||
|
|
{
|
|||
|
|
updatelist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (workflag == 2)
|
|||
|
|
{
|
|||
|
|
if (dellist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("无需要保存的数据!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("确定删除这些供应商类别?"))
|
|||
|
|
{
|
|||
|
|
strError = IBussFactory<BussProviderType>.Instance().execTypeWorkDel(dellist);
|
|||
|
|
if (string.IsNullOrEmpty(strError))
|
|||
|
|
{
|
|||
|
|
dellist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(strError))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox(strError);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
bindgrid();
|
|||
|
|
txtProviderTypeID.Focus();
|
|||
|
|
frmButtonItem["Save"].Enabled = false;
|
|||
|
|
panelControl2.Enabled = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Del()
|
|||
|
|
{
|
|||
|
|
if (dellist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
if (updatelist.Count > 0 || addlist.Count > 0)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("是否保存刚才的操作?"))
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
updatelist.Clear();
|
|||
|
|
addlist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
workflag = 2;
|
|||
|
|
if (GVProviderType.FocusedRowHandle > -1)
|
|||
|
|
{
|
|||
|
|
Sourcelist.RemoveAt(GVProviderType.FocusedRowHandle);
|
|||
|
|
}
|
|||
|
|
GCProviderType.DataSource = Sourcelist;
|
|||
|
|
GVProviderType.RefreshData();
|
|||
|
|
BSPriType.DataSource = new ProviderTypeModel();
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Edit()
|
|||
|
|
{
|
|||
|
|
if (updatelist.Count <= 0)
|
|||
|
|
{
|
|||
|
|
if (addlist.Count > 0 || dellist.Count > 0)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("是否保存刚才的操作?"))
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
addlist.Clear();
|
|||
|
|
dellist.Clear();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
workflag = 1;
|
|||
|
|
panelControl2.Enabled = true;
|
|||
|
|
GCProviderType_Click(null, null);
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 停用
|
|||
|
|
/// </summary>
|
|||
|
|
public void UnableButton()
|
|||
|
|
{
|
|||
|
|
FrmOperator(3);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 启用
|
|||
|
|
/// </summary>
|
|||
|
|
public void EnableButton()
|
|||
|
|
{
|
|||
|
|
FrmOperator(4);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void RefreshDataButton()
|
|||
|
|
{
|
|||
|
|
bindgrid();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确定按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void ConfrimDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void SeachDataButton()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void ExportDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 打印按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void PrintDataButton()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 备注
|
|||
|
|
/// </summary>
|
|||
|
|
protected new void NoteDataButton(FormBase fBase) { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 审核
|
|||
|
|
/// </summary>
|
|||
|
|
public void AuditDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 反审核
|
|||
|
|
/// </summary>
|
|||
|
|
public void ReturnAuditDataButton() { }
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region 操作(增、改、删)
|
|||
|
|
/// <summary>
|
|||
|
|
/// 操作(增、改、删)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="flag">0 新增 1修改 2删除 3停用 4启用/param>
|
|||
|
|
private void FrmOperator(int flag)
|
|||
|
|
{
|
|||
|
|
GVProviderType.Focus();
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
ProviderTypeModel temProviderTypeModel = BSPriType.DataSource as ProviderTypeModel;
|
|||
|
|
if (temProviderTypeModel.PRO_TYPE_ID == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
temProviderTypeModel.STATUS = txtProviderTypeStateOff.Checked ? "正常" : "停用";
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
if (Sourcelist.Find(r => r.PRO_TYPE_ID == temProviderTypeModel.PRO_TYPE_ID) != null)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("供应商类型已存在!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
workflag = 0;
|
|||
|
|
addlist.Add(temProviderTypeModel);
|
|||
|
|
}
|
|||
|
|
else if (flag == 1)
|
|||
|
|
{
|
|||
|
|
workflag = 1;
|
|||
|
|
updatelist.Add(temProviderTypeModel);
|
|||
|
|
}
|
|||
|
|
else if (flag == 2)
|
|||
|
|
{
|
|||
|
|
workflag = 2;
|
|||
|
|
dellist.Add(temProviderTypeModel);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("请规范操作!" + Environment.NewLine + e.Message);
|
|||
|
|
}
|
|||
|
|
finally
|
|||
|
|
{
|
|||
|
|
BSPriType.DataSource = new ProviderTypeModel();
|
|||
|
|
txtProviderTypeStateIN.Checked = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 不是增加操作,不能修改类型编号
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void txtProviderTypeID_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (BSPriType.DataSource != null)
|
|||
|
|
{
|
|||
|
|
if (Sourcelist.Find(r => r.PRO_TYPE_ID == (BSPriType.DataSource as ProviderTypeModel).PRO_TYPE_ID) != null)
|
|||
|
|
{
|
|||
|
|
txtProviderTypeID.Text = (BSPriType.DataSource as ProviderTypeModel).PRO_TYPE_ID;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 停用启用切换
|
|||
|
|
private void txtProviderTypeStateIN_CheckedChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateOff.Checked = !txtProviderTypeStateIN.Checked;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtProviderTypeStateOff_CheckedChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
txtProviderTypeStateIN.Checked = !txtProviderTypeStateOff.Checked;
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
#region 窗体关闭时处理未完成的操作
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void FrmProviderType_FormClosing(object sender, FormClosingEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (updatelist.Count > 0 || addlist.Count > 0 || dellist.Count > 0)
|
|||
|
|
{
|
|||
|
|
if (DialogResult.Yes == SystemCommon.ShowMessageBoxResult("是否保存刚才的操作?"))
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|