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 { /// /// XGRYWindow.xaml 的交互逻辑 /// public partial class XGRYWindow : Window { public XGRYWindow(Cus_User row) { InitializeComponent(); ryrow = row; } Cus_User ryrow = new Cus_User(); SurgerySchedulingEntities myModel = new SurgerySchedulingEntities(); private void Window_Loaded(object sender, RoutedEventArgs e) { List listjs = new List(); listjs = (from tbjs in myModel.SYS_JSB where tbjs.SFQY == true select new ComboBoxBinding { ID = tbjs.ID, Name = tbjs.JSMC, }).ToList(); js.ItemsSource = listjs; js.SelectedValuePath = "ID"; js.DisplayMemberPath = "Name"; js.SelectedValue = ryrow.JSID; xm.Text = ryrow.Name; gh.Text = ryrow.GH; } private void btn_bc_Click(object sender, RoutedEventArgs e) { if (xm.Text == null || xm.Text == string.Empty) { MessageBox.Show("请填写姓名"); return; } if (gh.Text == null || gh.Text == string.Empty) { MessageBox.Show("请填写工号"); return; } if (js.SelectedValue == null) { MessageBox.Show("请选择角色"); return; } if (gh.Text!=ryrow.GH) { var listyh = (from tbyh in myModel.SYS_YHB where tbyh.GH == gh.Text select new { tbyh }).ToList(); if (listyh.Count > 0) { MessageBox.Show("工号不能重复"); return; } } SYS_YHB yh = new SYS_YHB(); yh.ID = ryrow.ID; yh.GH = gh.Text; yh.YHM = xm.Text; yh.MM = "123"; yh.JSID = Convert.ToInt32(js.SelectedValue); try { myModel.Entry(yh).State = System.Data.Entity.EntityState.Modified; myModel.SaveChanges(); MessageBox.Show("修改成功"); this.Close(); } catch (Exception) { MessageBox.Show("修改失败"); } } } }