You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
233 lines
8.8 KiB
233 lines
8.8 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media.Imaging;
|
|
using SSWMS.Common;
|
|
|
|
namespace SSWMS.Client
|
|
{
|
|
public partial class RelationEdit : AvalonDock.DocumentContent
|
|
{
|
|
private string RelationType = string.Empty;
|
|
private string RelationHeader = string.Empty;
|
|
private string RelationTable = string.Empty;
|
|
private string RelationID2 = string.Empty;
|
|
private string RelationName = string.Empty;
|
|
private string RelationWhere = string.Empty;
|
|
private string RelationOrder = string.Empty;
|
|
|
|
public RelationEdit(string sRelationCode)
|
|
{
|
|
InitializeComponent();
|
|
this.RelationType = sRelationCode;
|
|
switch (sRelationCode)
|
|
{
|
|
case SystemCode.RELATION_TYPE.User:
|
|
this.RelationHeader = "用户";
|
|
this.RelationTable = "SYS_USER";
|
|
this.RelationID2 = "USER_ID";
|
|
this.RelationName = "USER_NAME";
|
|
this.RelationWhere = "USER_ID>1 and USER_FLAG='1'";
|
|
this.RelationOrder = "USER_ID";
|
|
break;
|
|
case SystemCode.RELATION_TYPE.Menu:
|
|
this.RelationHeader = "菜单";
|
|
this.RelationTable = "SYS_MENU";
|
|
this.RelationID2 = "MENU_ID";
|
|
this.RelationName = "MENU_NAME";
|
|
this.RelationWhere = "MENU_IS_PARENT='0' and MENU_PARENT_ID>2 and MENU_FLAG='1'";
|
|
this.RelationOrder = "MENU_ORDER";
|
|
break;
|
|
case SystemCode.RELATION_TYPE.Flow:
|
|
this.RelationHeader = "流程";
|
|
this.RelationTable = "SYS_FLOW";
|
|
this.RelationID2 = "FLOW_ID";
|
|
this.RelationName = "FLOW_NAME";
|
|
this.RelationWhere = "FLOW_FLAG='1'";
|
|
this.RelationOrder = "FLOW_ORDER";
|
|
break;
|
|
case SystemCode.RELATION_TYPE.Warehouse:
|
|
this.RelationHeader = "仓库";
|
|
this.RelationID2 = "value";
|
|
this.RelationName = "name";
|
|
break;
|
|
}
|
|
DocumentContent_Loaded(null, null);
|
|
}
|
|
|
|
private void DocumentContent_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
this.gbUnSelected.Header = string.Format("未选{0}", this.RelationHeader);
|
|
this.gbSelected.Header = string.Format("已选{0}", this.RelationHeader);
|
|
|
|
this.dgRoles.U_SelectedChanged += () =>
|
|
{
|
|
this.LoadRelation();
|
|
};
|
|
this.dgRoles.U_WindowName = "COMMON";
|
|
this.dgRoles.U_TableName = "SYS_ROLE";
|
|
this.dgRoles.U_Where = "ROLE_ID>0";
|
|
this.dgRoles.U_OrderField = "ROLE_ID";
|
|
this.dgRoles.U_AllowOperatData = false;
|
|
this.dgRoles.U_InitControl();
|
|
}
|
|
|
|
private void LoadRelation()
|
|
{
|
|
DataRowView rowView = this.dgRoles.gridApp.SelectedItem as DataRowView;
|
|
if (rowView == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
try
|
|
{
|
|
this.lbSelected.Items.Clear();
|
|
this.lbUnSelected.Items.Clear();
|
|
int iRoleID = Convert.ToInt32(rowView["ROLE_ID"]);
|
|
DataTable dt = null;
|
|
if (this.RelationType == SystemCode.RELATION_TYPE.Warehouse)
|
|
{
|
|
dt = SystemCodeData.DicDataTable["WAREHOUSE_CODE"];
|
|
}
|
|
else
|
|
{
|
|
dt = WCFChannel._I_BaseService.GetDataTable(
|
|
string.Format("select {0},{1} from {2} where {3} order by {4}",
|
|
this.RelationID2, this.RelationName, this.RelationTable, this.RelationWhere, this.RelationOrder));
|
|
}
|
|
IList<SYS_RELATION> lRelation = WCFChannel._I_SystemService.GetRoleRelation(this.RelationType, iRoleID);
|
|
|
|
foreach (DataRow row in dt.Rows)
|
|
{
|
|
int iRelationID = Convert.ToInt32(row[this.RelationID2]);
|
|
string sRelationName = row[this.RelationName].ToString();
|
|
|
|
ListBoxItem lbi = new ListBoxItem
|
|
{
|
|
Margin = new Thickness(3),
|
|
Tag = iRelationID,
|
|
};
|
|
lbi.MouseDoubleClick += new MouseButtonEventHandler((sender, e) =>
|
|
{
|
|
if (this.lbUnSelected.Items.Contains(lbi))
|
|
{
|
|
this.lbUnSelected.Items.Remove(lbi);
|
|
this.lbSelected.Items.Add(lbi);
|
|
}
|
|
else
|
|
{
|
|
this.lbSelected.Items.Remove(lbi);
|
|
this.lbUnSelected.Items.Add(lbi);
|
|
}
|
|
});
|
|
StackPanel sp = new StackPanel
|
|
{
|
|
Orientation = Orientation.Horizontal
|
|
};
|
|
Image image = new Image
|
|
{
|
|
Margin = new Thickness(5, 2, 10, 2),
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
Source = new BitmapImage(new Uri("/@Images/report.png", UriKind.RelativeOrAbsolute))
|
|
};
|
|
TextBlock tb = new TextBlock
|
|
{
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
Text = sRelationName
|
|
};
|
|
sp.Children.Add(image);
|
|
sp.Children.Add(tb);
|
|
lbi.Content = sp;
|
|
|
|
if (lRelation.Count(r => r.RELATION_ID2 == iRelationID) > 0)
|
|
{
|
|
lbSelected.Items.Add(lbi);
|
|
}
|
|
else
|
|
{
|
|
lbUnSelected.Items.Add(lbi);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
|
|
private void bSelected_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach (ListBoxItem lbi in this.lbUnSelected.SelectedItems.Cast<ListBoxItem>().ToArray())
|
|
{
|
|
this.lbUnSelected.Items.Remove(lbi);
|
|
this.lbSelected.Items.Add(lbi);
|
|
}
|
|
}
|
|
|
|
private void bUnSelected_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach (ListBoxItem lbi in this.lbSelected.SelectedItems.Cast<ListBoxItem>().ToArray())
|
|
{
|
|
this.lbSelected.Items.Remove(lbi);
|
|
this.lbUnSelected.Items.Add(lbi);
|
|
}
|
|
}
|
|
|
|
private void bAllSelected_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach (ListBoxItem lbi in this.lbUnSelected.Items.Cast<ListBoxItem>().ToArray())
|
|
{
|
|
this.lbUnSelected.Items.Remove(lbi);
|
|
this.lbSelected.Items.Add(lbi);
|
|
}
|
|
}
|
|
|
|
private void bAllUnSelected_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
foreach (ListBoxItem lbi in this.lbSelected.Items.Cast<ListBoxItem>().ToArray())
|
|
{
|
|
this.lbSelected.Items.Remove(lbi);
|
|
this.lbUnSelected.Items.Add(lbi);
|
|
}
|
|
}
|
|
|
|
private void bSave_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DataRowView rowView = this.dgRoles.gridApp.SelectedItem as DataRowView;
|
|
if (rowView == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (MessageDialog.ShowDialog("确认执行保存操作"))
|
|
{
|
|
try
|
|
{
|
|
List<int> lRelationID2 = new List<int>();
|
|
foreach (ListBoxItem lbi in this.lbSelected.Items)
|
|
{
|
|
lRelationID2.Add(Convert.ToInt32(lbi.Tag));
|
|
}
|
|
string sResult = string.Empty;
|
|
bool bResult = WCFChannel._I_SystemService.UpdateRoleRelation(this.RelationType,
|
|
Convert.ToInt32(rowView["ROLE_ID"]), lRelationID2, out sResult);
|
|
MessageDialog.ShowResult(bResult, sResult);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageDialog.ShowException(ex);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void bRefresh_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.LoadRelation();
|
|
}
|
|
}
|
|
}
|