442 lines
13 KiB
C#
442 lines
13 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.Model.SystemManage;
|
|||
|
|
using WMS.Common;
|
|||
|
|
using WMS.Ctrl;
|
|||
|
|
using WMS.Model.Base;
|
|||
|
|
using DevExpress.XtraGrid.Columns;
|
|||
|
|
using DevExpress.XtraEditors.Repository;
|
|||
|
|
using WMS.Frm;
|
|||
|
|
using WMS.Business;
|
|||
|
|
using WMS.Business.Base;
|
|||
|
|
using WMS.Business.SystemManage;
|
|||
|
|
|
|||
|
|
namespace WMS.FrmSystems
|
|||
|
|
{
|
|||
|
|
public partial class FrmTeam : FormBase
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 班组MODEL
|
|||
|
|
/// </summary>
|
|||
|
|
TeamModel teamModel = new TeamModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 班组集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<TeamModel> teamList = new List<TeamModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 班组人员Model
|
|||
|
|
/// </summary>
|
|||
|
|
TeamUserModel teamUserModel = new TeamUserModel();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 班组人员集合
|
|||
|
|
/// </summary>
|
|||
|
|
List<TeamUserModel> infoList = new List<TeamUserModel>();
|
|||
|
|
|
|||
|
|
|
|||
|
|
List<TeamUserModel> tml = new List<TeamUserModel>();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 业务类型
|
|||
|
|
/// </summary>
|
|||
|
|
int workflag = 3;//0 增加 1 修改 2 删除 ;
|
|||
|
|
|
|||
|
|
public FrmTeam()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void FrmTeam_Load(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
BindTeam();
|
|||
|
|
panelControl1.Visible = true;
|
|||
|
|
FrmSelectModle = new TeamModel();
|
|||
|
|
BSTeamTab.DataSource = new TeamModel();
|
|||
|
|
|
|||
|
|
//this.txtTeamID.Enabled = false;
|
|||
|
|
//this.txtTeamName.Enabled = false;
|
|||
|
|
//this.txtPYName.Enabled = false;
|
|||
|
|
//this.DicMaster.Enabled = false;
|
|||
|
|
//this.DicTeam.Enabled = false;
|
|||
|
|
panelControl1.Enabled = false;
|
|||
|
|
bindlookupEdit();
|
|||
|
|
if (teamList.Count > 0)
|
|||
|
|
{
|
|||
|
|
GVTeam_Click(null, null);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定下拉框
|
|||
|
|
/// </summary>
|
|||
|
|
private void bindlookupEdit()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
TLEP_DEP.Properties.DataSource = IBussFactory<BussCompany>.Instance().getCompanytDataSet("", "");
|
|||
|
|
TLEP_DEP.Properties.DisplayMember = "COM_NAME";
|
|||
|
|
TLEP_DEP.Properties.ValueMember = "COM_ID";
|
|||
|
|
}
|
|||
|
|
catch(Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载失败,请检查网络是否正常!"+e.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定班组数据信息
|
|||
|
|
/// </summary>
|
|||
|
|
private void BindTeam()
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
teamList = IBussFactory<BussTeam>.Instance().GetList(new TeamModel());
|
|||
|
|
GCTeam.DataSource = teamList;
|
|||
|
|
GVTeam.RefreshData();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox(e.Message);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (teamList.Count > 0)
|
|||
|
|
{
|
|||
|
|
BindTeamUser(teamList[0]);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
infoList.Clear();
|
|||
|
|
GCTeamUser.DataSource = infoList;
|
|||
|
|
GVTeamUser.RefreshData();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 绑定班组人员明细数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="model"></param>
|
|||
|
|
private void BindTeamUser(TeamModel model)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
infoList = IBussFactory<BussTeamUser>.Instance().GetList(new TeamUserModel() { TEAM_ID = model.TEAM_ID });
|
|||
|
|
GCTeamUser.DataSource = infoList;
|
|||
|
|
GVTeamUser.RefreshData();
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("加载失败,请检查网络是否正常!" + e.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 通用查询
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="table"></param>
|
|||
|
|
public override void LoadListData(DataTable table)
|
|||
|
|
{
|
|||
|
|
teamList = ConvertHelper<TeamModel>.ConvertToList(table);
|
|||
|
|
GCTeam.DataSource = teamList;
|
|||
|
|
GVTeam.RefreshData();
|
|||
|
|
if (teamList.Count > 0)
|
|||
|
|
{
|
|||
|
|
BindTeamUser(teamList[0]);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region 以下是继承的按钮事件
|
|||
|
|
/// <summary>
|
|||
|
|
/// 新增按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Add()
|
|||
|
|
{
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
panelControl1.Visible = true;
|
|||
|
|
panelControl1.Enabled = true;
|
|||
|
|
workflag = 0;
|
|||
|
|
BSTeamTab.DataSource = new TeamModel();
|
|||
|
|
txtTeamID.Select();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 保存按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Save()
|
|||
|
|
{
|
|||
|
|
FrmOperator(workflag);
|
|||
|
|
panelControl1.Enabled = false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 删除按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Del()
|
|||
|
|
{
|
|||
|
|
workflag = 2;
|
|||
|
|
if (SystemCommon.ShowMessageBoxResult("确定此班组及班组人员:" + GVTeam.GetFocusedRowCellValue("TEAM_ID").ToString()) == System.Windows.Forms.DialogResult.Yes)
|
|||
|
|
{
|
|||
|
|
Save();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 修改按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Edit()
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(teamModel.TEAM_ID))
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
frmButtonItem["Save"].Enabled = true;
|
|||
|
|
workflag = 1;
|
|||
|
|
panelControl1.Visible = true;
|
|||
|
|
panelControl1.Enabled = true;
|
|||
|
|
BSTeamTab.DataSource = teamModel;
|
|||
|
|
DicMaster.TextBoxFlag = teamModel.TEAM_MASTER;
|
|||
|
|
DicMaster.TextBoxValue = teamModel.TEAM_MASTER_NAME;
|
|||
|
|
|
|||
|
|
txtTeamID.Enabled = false;
|
|||
|
|
txtTeamName.Select();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 刷新按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Refresh()
|
|||
|
|
{
|
|||
|
|
BindTeam();
|
|||
|
|
panelControl1.Visible = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 确定按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void ConfrimDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 查询按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void Search()
|
|||
|
|
{
|
|||
|
|
FrmSelect frm = new FrmSelect(this.FrmSelectModle);
|
|||
|
|
if (frm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|||
|
|
{
|
|||
|
|
this.LoadListData(frm.SelectData);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 导出按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void ExportDataButton() { }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 打印按钮
|
|||
|
|
/// </summary>
|
|||
|
|
public void PrintDataButton()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 备注
|
|||
|
|
/// </summary>
|
|||
|
|
public void Remark()
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
//FrmSelectRemark frmSelectRemark = new FrmSelectRemark();
|
|||
|
|
//frmSelectRemark.remarkType = "班组管理";
|
|||
|
|
//frmSelectRemark.ShowDialog();
|
|||
|
|
//if (frmSelectRemark.remarkType != "selected") { return; }
|
|||
|
|
//teamModel.REMARK = frmSelectRemark.baseRemarkDictionaryModel.CONTENT;
|
|||
|
|
//txtRemark.Text = frmSelectRemark.baseRemarkDictionaryModel.CONTENT;
|
|||
|
|
//txtRemark.ForeColor = System.Drawing.ColorTranslator.FromHtml(frmSelectRemark.baseRemarkDictionaryModel.COLOR_ID);
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <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)
|
|||
|
|
{
|
|||
|
|
BSTeamTab.EndEdit();
|
|||
|
|
string errtxt = string.Empty;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
teamModel = BSTeamTab.DataSource as TeamModel;
|
|||
|
|
if (string.IsNullOrEmpty(teamModel.TEAM_ID))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("请填写班组编号!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(teamModel.TEAM_NAME))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("请填写班组名称!");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
teamModel.TEAM_MASTER = DicMaster.TextBoxFlag;
|
|||
|
|
infoList.Clear();
|
|||
|
|
if (DicTeam.SelectTable.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (DataRow row in DicTeam.SelectTable.Rows)
|
|||
|
|
{
|
|||
|
|
infoList.Add(new TeamUserModel() { TEAM_ID = teamModel.TEAM_ID, USER_ID = row["user_id"].ToString() });
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (flag == 0)
|
|||
|
|
{
|
|||
|
|
if (infoList.Count == 0)
|
|||
|
|
{
|
|||
|
|
if (SystemCommon.ShowMessageBoxResult("您还未给班组分配人员,是否继续?") == System.Windows.Forms.DialogResult.No)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
errtxt = IBussFactory<BussTeam>.Instance().AddAndList(teamModel, infoList);
|
|||
|
|
}
|
|||
|
|
else if (flag == 1)
|
|||
|
|
{
|
|||
|
|
if (infoList.Count == 0)
|
|||
|
|
{
|
|||
|
|
errtxt = IBussFactory<BussTeam>.Instance().Update(teamModel);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
errtxt = IBussFactory<BussTeam>.Instance().UpdateAndList(teamModel, infoList);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else if (flag == 2)
|
|||
|
|
{
|
|||
|
|
errtxt = IBussFactory<BussTeam>.Instance().DeleteAndList(teamModel);
|
|||
|
|
}
|
|||
|
|
if (!string.IsNullOrEmpty(errtxt))
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox(errtxt);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("操作成功!");
|
|||
|
|
frmButtonItem["Save"].Enabled = false;
|
|||
|
|
Refresh();
|
|||
|
|
GCTeam.Focus();
|
|||
|
|
workflag = 3;
|
|||
|
|
txtTeamID.Enabled = true;
|
|||
|
|
GVTeam_Click(null, null);
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch (Exception e)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowInfoMessageBox("您的操作失败!" + Environment.NewLine + e.Message);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
private void GVTeam_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (GVTeam.FocusedRowHandle > -1)
|
|||
|
|
{
|
|||
|
|
teamModel = GVTeam.GetFocusedRow() as TeamModel;
|
|||
|
|
|
|||
|
|
BSTeamTab.DataSource = teamModel;
|
|||
|
|
DicMaster.TextBoxFlag = teamModel.TEAM_MASTER;
|
|||
|
|
DicMaster.TextBoxValue = teamModel.TEAM_MASTER_NAME;
|
|||
|
|
|
|||
|
|
|
|||
|
|
BindTeamUser(teamModel);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtTeamID_Leave(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (workflag == 0)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
BSTeamTab.EndEdit();
|
|||
|
|
teamModel = BSTeamTab.DataSource as TeamModel;
|
|||
|
|
if (!string.IsNullOrEmpty(teamModel.TEAM_ID))
|
|||
|
|
{
|
|||
|
|
teamList = IBussFactory<BussTeam>.Instance().GetList(teamModel);
|
|||
|
|
|
|||
|
|
if (teamList.Count > 0)
|
|||
|
|
{
|
|||
|
|
SystemCommon.ShowErrorMessageBox("该班组编号已存在!");
|
|||
|
|
teamModel.TEAM_ID = "";
|
|||
|
|
BSTeamTab.ResetBindings(true);
|
|||
|
|
txtTeamID.Select();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void DicTeam_Button_Click(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
if (this.DicTeam.SelectTable.Rows.Count > 0)
|
|||
|
|
{
|
|||
|
|
tml.Clear();
|
|||
|
|
string errText = string.Empty;
|
|||
|
|
UserDataModel um = new UserDataModel();
|
|||
|
|
List<UserDataModel> teamuserlis = ConvertHelper<UserDataModel>.ConvertToList(DicTeam.SelectTable);
|
|||
|
|
foreach (UserDataModel tm in teamuserlis)
|
|||
|
|
{
|
|||
|
|
teamUserModel = new TeamUserModel();
|
|||
|
|
|
|||
|
|
teamUserModel.USER_ID = tm.USER_ID;
|
|||
|
|
teamUserModel.USER_NAME = tm.NAME;
|
|||
|
|
teamUserModel.TEAM_ID = this.txtTeamID.Text;
|
|||
|
|
tml.Add(teamUserModel);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
GCTeamUser.DataSource = tml;
|
|||
|
|
GVTeamUser.RefreshData();
|
|||
|
|
infoList = tml;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void txtRemark_TextChanged(object sender, EventArgs e)
|
|||
|
|
{
|
|||
|
|
//if (this.GVTeam.FocusedRowHandle < 0)
|
|||
|
|
//{
|
|||
|
|
// return;
|
|||
|
|
//}
|
|||
|
|
//else
|
|||
|
|
//{
|
|||
|
|
// teamModel.REMARK = this.txtRemark.Text;
|
|||
|
|
//}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|