using SchedulingSystem.EntityClass; using SchedulingSystemClient; 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 SchedulingSystem { /// /// ZXGZYSVIPWindow.xaml 的交互逻辑 /// public partial class XZGZYSVIPWindow : Window { public XZGZYSVIPWindow() { InitializeComponent(); } SurgerySchedulingEntities myModel = new SurgerySchedulingEntities(); private void btn_bc_Click(object sender, RoutedEventArgs e) { int intqz; if (ysxm == null || ysxm.Text == string.Empty) { MessageBox.Show("请填写医生姓名"); return; } if (ysbm == null || ysbm.Text == string.Empty) { MessageBox.Show("请填写医生编码"); return; } try { intqz = Convert.ToInt32(qz.Text); } catch (Exception) { MessageBox.Show("请输入正确的权重格式"); return; } var listysvip = (from tbysvip in myModel.SYS_YSVIPB where tbysvip.YSBM == ysbm.Text select new { tbysvip }).ToList(); if (listysvip.Count > 0) { MessageBox.Show("医生编码不能重复"); return; } SYS_YSVIPB ysvipqz = new SYS_YSVIPB(); ysvipqz.YSXM = ysxm.Text; ysvipqz.YSBM = ysbm.Text; ysvipqz.QZ = intqz; try { myModel.SYS_YSVIPB.Add(ysvipqz); myModel.SaveChanges(); MessageBox.Show("新增成功"); this.Close(); } catch (Exception ex) { MessageBox.Show("新增失败"+ex.ToString()); } } string strysxm = string.Empty; List listysbm = new List(); private void Window_Loaded(object sender, RoutedEventArgs e) { List listysxm = new List(); //listysxm = (from tbysb in myModel.SYS_YSVIPB // select new ComboBoxBinding // { // ID = tbysb.ID, // Name = tbysb.YSXM, // }).ToList(); //ysxm.ItemsSource = listysxm; //ysxm.SelectedValuePath = "ID"; //ysxm.DisplayMemberPath = "Name"; } private void ysxm_SelectionChanged(object sender, SelectionChangedEventArgs e) { //if (ysxm.SelectedValue !=null) //{ //int id =Convert.ToInt32(ysxm.SelectedValue); //string strysxm = (from tbysb in myModel.SYS_YSB where tbysb.ID == id select new { tbysb}).Single().tbysb.YSXM; //listysbm = new List(); //if (strysxm != null && strysxm != string.Empty) //{ // listysbm = (from tbysb in myModel.SYS_YSB // where tbysb.YSXM == strysxm // select new ComboBoxBinding // { // ID = tbysb.ID, // Name = tbysb.YSBM, // }).ToList(); //} //ysbm.ItemsSource = listysbm; //ysbm.SelectedValuePath = "ID"; //ysbm.DisplayMemberPath = "Name"; //ysbm.SelectedIndex = 0; //} } } }