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 { /// /// XGHSWindow.xaml 的交互逻辑 /// public partial class XGHSWindow : Window { public XGHSWindow(Cus_HS row) { InitializeComponent(); hsrow = row; } Cus_HS hsrow = new Cus_HS(); SurgerySchedulingEntities myModel = new SurgerySchedulingEntities(); 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 = "否" }); sfqy.ItemsSource = listsfqy; sfqy.SelectedValuePath = "ID"; sfqy.DisplayMemberPath = "Name"; List listyszc = new List(); listyszc = (from tbssjb in myModel.SYS_HSZCB select new ComboBoxBinding { ID = tbssjb.ID, Name = tbssjb.Name, }).ToList(); yszc.ItemsSource = listyszc; yszc.SelectedValuePath = "ID"; yszc.DisplayMemberPath = "Name"; List listsss = new List(); listsss = (from tbssjb in myModel.SYS_SSSB select new ComboBoxBinding { ID = tbssjb.ID, Name = tbssjb.SSSMC, }).ToList(); sss.ItemsSource = listsss; sss.SelectedValuePath = "ID"; sss.DisplayMemberPath = "Name"; sfqy.SelectedValue = hsrow.strSFQY == "是" ? 0 : 1; yszc.SelectedValue = hsrow.HSZC; sss.SelectedValue = hsrow.SSSID; ysxm.Text = hsrow.HSXM; ysgh.Text = hsrow.HSGH; } private void btn_bc_Click(object sender, RoutedEventArgs e) { if (ysxm.Text == string.Empty) { MessageBox.Show("请填写护士姓名"); return; } if (ysgh.Text == string.Empty) { MessageBox.Show("请填护士生姓名"); return; } if (yszc.SelectedValue == null) { MessageBox.Show("请选择职称"); return; } if (sss.SelectedValue == null) { MessageBox.Show("请选择手术室"); return; } try { if (ysgh.Text != hsrow.HSGH || ysxm.Text != hsrow.HSXM) { var listmzys = (from ybmzys in myModel.SYS_HSB where ybmzys.HSBM == ysgh.Text && ybmzys.HSMC == ysxm.Text select new { ybmzys }).ToList(); if (listmzys.Count > 0) { MessageBox.Show("护士姓名和编码重复!"); return; } } SYS_HSB hsb = new SYS_HSB(); hsb.ID = hsrow.ID; hsb.SFQY = sfqy.SelectedValue.ToString() == "0" ? true : false; hsb.SSSID = Convert.ToInt32(sss.SelectedValue); hsb.HSBM = ysgh.Text; hsb.HSMC = ysxm.Text; hsb.ZCID = Convert.ToInt32(yszc.SelectedValue); myModel.Entry(hsb).State = System.Data.Entity.EntityState.Modified; myModel.SaveChanges(); MessageBox.Show("修改成功"); this.Close(); } catch (Exception ex) { MessageBox.Show("修改失败" + ex.ToString()); } } } }