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

290 lines
9.8 KiB
C#
Raw Permalink 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.Frm.Base;
using WMS.Model.Base;
using WMS.Ctrl;
using WMS.Common;
using WMS.Business;
using WMS.Business.Base;
namespace WMS.FrmSystems
{
public partial class FrmSystemMenu : FormBase
{
#region
/// <summary>
/// 菜单对象
/// </summary>
BaseMenuModel menuModel = new BaseMenuModel();
/// <summary>
/// 功能集合
/// </summary>
List<MenuFuctionModel> SouerceList;
/// <summary>
/// 原菜单功能
/// </summary>
List<MenuFuctionModel> copyList;
/// <summary>
/// 菜单update数组
/// </summary>
List<BaseMenuModel> upmenu = new List<BaseMenuModel>();
/// <summary>
/// 功能update数组
/// </summary>
List<MenuFuctionModel> upmunufuc = new List<MenuFuctionModel>();
/// <summary>
/// 功能delete数组
/// </summary>
List<MenuFuctionModel> delmunufuc = new List<MenuFuctionModel>();
/// <summary>
/// 功能insert数组
/// </summary>
List<MenuFuctionModel> addmunufuc = new List<MenuFuctionModel>();
/// <summary>
/// 菜单是否更新标志
/// </summary>
bool upmenuflag;
/// <summary>
/// 业务类型 0 添加窗体 1 修改窗体,功能。
/// </summary>
int workflag;
#endregion
/// <summary>
/// 窗体初始化
/// </summary>
/// <param name="menuSelectModel">窗体对象</param>
/// <param name="ListMunuFuc">功能列表</param>
public FrmSystemMenu(BaseMenuModel menuSelectModel, List<MenuFuctionModel> ListMunuFuc, int flag)
{
InitializeComponent();
menuModel = menuSelectModel;
SouerceList = ListMunuFuc;
copyList = ListMunuFuc.ToList();
workflag = flag;
txtEdit();
if (menuModel != null)
{
FuntionBinding.DataSource = SouerceList;
bgsMenu.DataSource = menuModel;
cbx_Tanc.Checked = menuModel.FRM_TYPE == "1";
if (menuModel.MENU_LEVEL == "1")
{
rbt_Lev1.Checked = true;
}
else
{
rbt_Lev2.Checked = true;
}
}
}
private void txtEdit()
{
if (workflag == 0)
{
txt_MenuID.Enabled = true;
}
else
{
txt_MenuID.Enabled = false;
}
}
/// <summary>
/// 窗体加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmSystemMenu_Load(object sender, EventArgs e)
{
upmenuflag = false;
}
/// <summary>
/// 添加功能按钮按下添加grid新行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons3_Click(object sender, EventArgs e)
{
//ctrlDictonary1.CtrlDictonary_KeyDown(null, null);
//gridView1.AddNewRow();
// FuntionBinding.DataSource = ListMunuFuc;
//SouerceList = (grdView.DataSource as List<MenuFuctionModel>);
SouerceList.Add(new MenuFuctionModel() { MENU_ID = txt_MenuID.Text, MENU_NAME = txt_MenuName.Text });
FuntionBinding.DataSource = SouerceList;
grdView.RefreshData();
//gdFution.Refresh();
}
/// <summary>
/// 确定按钮按下,更新启动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons1_Click(object sender, EventArgs e)
{
bgsMenu.EndEdit();
grdView.CloseEditor();
grdView.UpdateCurrentRow();
menuModel = bgsMenu.DataSource as BaseMenuModel;
menuModel.FRM_TYPE = cbx_Tanc.Checked ? "1" : "0";
if (rbt_Lev1.Checked)
{
menuModel.MENU_LEVEL = "1";
}
else if (rbt_Lev2.Checked)
{
menuModel.MENU_LEVEL = "2";
}
if (workflag == 0)
{
string errtex = IBussFactory<BussSystemMenu>.Instance().AddMenuData(menuModel, addmunufuc);
if (!string.IsNullOrEmpty(errtex))
{
SystemCommon.ShowErrorMessageBox("菜单添加失败"+errtex);
return;
}
else
{
SystemCommon.ShowInfoMessageBox("菜单添加成功");
}
workflag = 1;
txtEdit();
}
else
{
upmenu.Add(menuModel);
bool flag = IBussFactory<WMS.Business.Base.BussSystemMenuFuc>.Instance().NewMenuDataFuc(upmenu, upmunufuc, addmunufuc, delmunufuc);
if (flag)
{
MessageBox.Show("更新功能成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
upmenu.Clear();
upmunufuc.Clear();
addmunufuc.Clear();
delmunufuc.Clear();
}
else
{
MessageBox.Show("更新功能失败,请重试!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
/// <summary>
/// 退出按钮按下,确认退出页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons2_Click(object sender, EventArgs e)
{
if (DialogResult.Yes == MessageBox.Show("确定退出本窗口", "退出", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk))
{
this.Close();
}
}
/// <summary>
/// 删除功能按钮按下,删除当前行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ctrlButtons4_Click(object sender, EventArgs e)
{
if (grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID") != null &&
!string.IsNullOrEmpty((grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID").ToString())))
{
if (delmunufuc.Count(r => r.FUN_ID == grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID").ToString()) == 0)
{
delmunufuc.Add(SouerceList.Find(r => r.FUN_ID == grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID").ToString()));
}
if (addmunufuc.Find(r => r.FUN_ID == grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID").ToString()) != null)
{
addmunufuc.Remove(addmunufuc.Find(r => r.FUN_ID == grdView.GetRowCellValue(grdView.GetSelectedRows()[0], "FUN_ID").ToString()));
}
}
grdView.DeleteRow(grdView.GetSelectedRows()[0]);
}
#region
private void txt_MenuID_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void txt_MenuName_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void icbe_MenuImg_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void txt_FormPro_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void txt_FormClassName_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void rbt_Lev1_CheckedChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void rbt_Lev2_CheckedChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void cbx_Tanc_CheckedChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
private void MEtxtREMARK_TextChanged(object sender, EventArgs e)
{
upmenuflag = true;
}
#endregion
/// <summary>
/// Grid列值变化添加增加或更新语句
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
if (!addmunufuc.Contains((grdView.GetRow(e.RowHandle) as MenuFuctionModel)) && !copyList.Contains((grdView.GetRow(e.RowHandle) as MenuFuctionModel)))
{
addmunufuc.Add(grdView.GetRow(e.RowHandle) as MenuFuctionModel);
}
if (!upmunufuc.Contains((grdView.GetRow(e.RowHandle) as MenuFuctionModel)) && copyList.Contains((grdView.GetRow(e.RowHandle) as MenuFuctionModel)))
{
upmunufuc.Add(grdView.GetRow(e.RowHandle) as MenuFuctionModel);
}
}
private void repositoryItemImageComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
object d = grdView.GetFocusedRowCellValue(colFUN_ID);
string a = d.ToString();
SouerceList.Find(r => r.FUN_ID == a).FUN_IMAGE = ((DevExpress.XtraEditors.ImageComboBoxEdit)sender).EditValue.ToString();
}
}
}