using SchedulingSystem.EntityClass;
using SchedulingSystemClient.EntityClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace SchedulingSystemClient.UpdateWindow
{
///
/// XGJSWindow.xaml 的交互逻辑
///
public partial class XGJSWindow : Window
{
public XGJSWindow(Cus_Role row )
{
InitializeComponent();
cusrole = row;
}
SurgerySchedulingEntities myModel = new SurgerySchedulingEntities();
Cus_Role cusrole = new Cus_Role();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List listsfqy = new List();
listsfqy.Add(new ComboBoxBinding() { ID = 0, Name = "是" });
listsfqy.Add(new ComboBoxBinding() { ID = 1, Name = "否" });
sfky.ItemsSource = listsfqy;
sfky.SelectedValuePath = "ID";
sfky.DisplayMemberPath = "Name";
if (cusrole.SFKY==true)
{
sfky.SelectedValue = 0;
}
else
{
sfky.SelectedValue = 1;
}
jsmc.Text = cusrole.Role;
}
private void btn_bc_Click(object sender, RoutedEventArgs e)
{
if (jsmc.Text == null || jsmc.Text == string.Empty)
{
MessageBox.Show("请输入角色名称");
return;
}
if (jsmc.Text!= cusrole.Role)
{
var listjs = (from tbjs in myModel.SYS_JSB where tbjs.JSMC == jsmc.Text select new { tbjs }).ToList();
if (listjs.Count > 0)
{
MessageBox.Show("请该角色已存在");
return;
}
}
bool ky = Convert.ToInt32(sfky.SelectedValue) == 0;
SYS_JSB role = new SYS_JSB();
role.ID = cusrole.ID;
role.JSMC = jsmc.Text;
role.SFQY = ky;
try
{
myModel.Entry(role).State = System.Data.Entity.EntityState.Modified;
myModel.SaveChanges();
MessageBox.Show("修改成功");
this.Close();
}
catch (Exception)
{
MessageBox.Show("修改失败");
}
}
}
}