BaoKai_202508-Wms-Jingwang..../WMS.FrmSystems/FrmRoleDictionary.cs
2025-08-24 09:35:55 +08:00

299 lines
9.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.Model.SystemManage;
using WMS.Frm.Base;
using WMS.Common;
using WMS.Business.SystemManage;
using WMS.Business;
namespace WMS.FrmSystems
{
public partial class FrmRoleDictionary : FormBase
{
RoleDictionaryModel model = new RoleDictionaryModel();
List<RoleDictionaryModel> rolelist = new List<RoleDictionaryModel>();
int flag = 0;
public FrmRoleDictionary()
{
InitializeComponent();
}
private void FrmRoleDictionary_Load(object sender, EventArgs e)
{
FrmSelectModle = new RoleDictionaryModel();
BindRoleDictionaryData();
this.splitContainerControl1.Panel2.Enabled = false;
}
#region
// 新增按钮
public void Add()
{
flag = 0;
txtID.Focus();
this.splitContainerControl1.Panel2.Enabled = true;
bgsSelect.DataSource = new RoleDictionaryModel();
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = false; }
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = false; }
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = true; }
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = true; }
}
// 更新编辑修改按钮
public void Edit()
{
GCustomRoleDictionary_DoubleClick(null, null);
}
// 删除按钮
public void Del()
{
List<RoleDictionaryModel> dellist = new List<RoleDictionaryModel>();
int[] selectRows = this.gridViewRoleDictionary.GetSelectedRows();
this.labelControl1.Focus();
foreach (int j in selectRows)
{
model = new RoleDictionaryModel();
model = this.gridViewRoleDictionary.GetRow(j) as RoleDictionaryModel;
dellist.Add(model);
}
if (dellist.Count == 0)
{
return;
}
try
{
string errText = IBussFactory<BussRoleDictionary>.Instance().UpdateRoleDictionaryList(dellist);
if (errText == "")
{
SystemCommon.ShowInfoMessageBox("删除成功!");
}
else
{
SystemCommon.ShowInfoMessageBox("删除失败!");
}
}
catch (Exception ex)
{
SystemCommon.ShowErrorMessageBox("网络连接错误!请检查当前网络环境是否可用!");
}
this.splitContainerControl1.Panel2.Enabled = true;
BindRoleDictionaryData();
}
/// <summary>
/// 保存
/// </summary>
public void Save()
{
if (dataCheck())
//if (1 == 1)
{
bgsSelect.EndEdit();
string strRoleDictionary = Newtonsoft.Json.JsonConvert.SerializeObject(bgsSelect.DataSource);
string errText = string.Empty;
try
{
//新增
if (flag == 0)
{
errText = IBussFactory<BussRoleDictionary>.Instance().AddRoleDictionary(bgsSelect.DataSource as RoleDictionaryModel);
}
//修改
else if (flag == 1)
{
errText = IBussFactory<BussRoleDictionary>.Instance().UpdateRoleDictionary(bgsSelect.DataSource as RoleDictionaryModel);
}
}
catch (Exception ex)
{
SystemCommon.ShowErrorMessageBox("网络连接错误!请检查当前网络环境是否可用!");
return;
}
if (string.IsNullOrEmpty(errText))
{
SystemCommon.ShowInfoMessageBox("操作成功!");
}
else
{
SystemCommon.ShowInfoMessageBox("操作失败!");
}
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = true; }
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = false; }
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = true; }
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = true; }
this.txtID.Enabled = true;
this.splitContainerControl1.Panel2.Enabled = false;
BindRoleDictionaryData();
}
}
// 刷新按钮
public void Refresh()
{
// splitContainerControl1.Panel2.Enabled = false;
if (frmButtonItem.ContainsKey("Add"))
{
frmButtonItem["Add"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Edit"))
{
frmButtonItem["Edit"].Enabled = true;
}
if (frmButtonItem.ContainsKey("Save"))
{
frmButtonItem["Save"].Enabled = false;
}
if (frmButtonItem.ContainsKey("Del"))
{
frmButtonItem["Del"].Enabled = true;
}
BindRoleDictionaryData();
}
//数据导出到Excel
public void Export()
{
}
//打印
public void Print()
{
}
/// <summary>
/// 数据导入
/// </summary>
public void Import()
{
}
public void SaveImport()
{
}
#region
/// <summary>
/// 通用查询 方法
/// </summary>
/// <param name="table"></param>
public override void LoadListData(DataTable table)
{
rolelist = ConvertHelper<RoleDictionaryModel>.ConvertToList(table);
GCustomRoleDictionary.DataSource = rolelist;
bgsRoleDictionary.DataSource = GCustomRoleDictionary.DataSource;
this.gridViewRoleDictionary.RefreshData();
}
#endregion
#endregion
/// <summary>
/// 绑定角色信息
/// </summary>
private void BindRoleDictionaryData()
{
model = new RoleDictionaryModel();
rolelist = IBussFactory<BussRoleDictionary>.Instance().GetRoleDictionaryListData(model);
if (rolelist.Count > 0)
{
GCustomRoleDictionary.DataSource = rolelist;
bgsRoleDictionary.DataSource = GCustomRoleDictionary.DataSource;
this.gridViewRoleDictionary.RefreshData();
bgsSelect.DataSource = this.gridViewRoleDictionary.GetRow(0);
}
}
/// <summary>
/// 验证编号是否存在
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtID_Leave(object sender, EventArgs e)
{
//str_result 0不存在 1已存在
string str_result = IBussFactory<BussRoleDictionary>.Instance().ExistsRoleDictionary(this.txtID.Text.Trim());
if (str_result != "0")
{
SystemCommon.ShowInfoMessageBox("角色编号已经存在!请重新输入!");
txtID.Focus();
txtID.SelectAll();
return;
}
}
private bool dataCheck()
{
if (string.IsNullOrEmpty(txtID.Text.Trim()))
{
SystemCommon.ShowInfoMessageBox("角色编号不能为空!");
txtID.Focus();
return false;
}
if (string.IsNullOrEmpty(txtName.Text.Trim()))
{
SystemCommon.ShowInfoMessageBox("角色名称不能为空!");
txtName.Focus();
return false;
}
if (txtDIsc.Text.Length > 300)
{
SystemCommon.ShowInfoMessageBox("角色描述信息过长,请重新输入");
txtDIsc.Text = string.Empty;
return false;
}
return true;
}
//显示数据
private void GCustomRoleDictionary_Click(object sender, EventArgs e)
{
this.splitContainerControl1.Panel2.Enabled = false;
bgsSelect.DataSource = this.gridViewRoleDictionary.GetRow(this.gridViewRoleDictionary.FocusedRowHandle) as RoleDictionaryModel;
}
//修改数据
private void GCustomRoleDictionary_DoubleClick(object sender, EventArgs e)
{
flag = 1;
this.splitContainerControl1.Panel2.Enabled = true;
this.txtID.Enabled = false;
if (frmButtonItem.ContainsKey("Edit")) { frmButtonItem["Edit"].Enabled = false; }
if (frmButtonItem.ContainsKey("Del")) { frmButtonItem["Del"].Enabled = false; }
if (frmButtonItem.ContainsKey("Add")) { frmButtonItem["Add"].Enabled = false; }
if (frmButtonItem.ContainsKey("Save")) { frmButtonItem["Save"].Enabled = true; }
}
}
}