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.
85 lines
2.5 KiB
85 lines
2.5 KiB
using SchedulingSystem.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.InsertWindow |
|
{ |
|
/// <summary> |
|
/// XZRYWindow.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class XZRYWindow : Window |
|
{ |
|
public XZRYWindow() |
|
{ |
|
InitializeComponent(); |
|
} |
|
SurgerySchedulingEntities myModel = new SurgerySchedulingEntities(); |
|
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; |
|
} |
|
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.GH = gh.Text; |
|
yh.YHM = xm.Text; |
|
yh.MM = "123"; |
|
yh.JSID =Convert.ToInt32(js.SelectedValue); |
|
try |
|
{ |
|
myModel.SYS_YHB.Add(yh); |
|
myModel.SaveChanges(); |
|
MessageBox.Show("新增成功"); |
|
this.Close(); |
|
} |
|
catch (Exception) |
|
{ |
|
MessageBox.Show("新增失败"); |
|
} |
|
} |
|
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e) |
|
{ |
|
List<ComboBoxBinding> listjs = new List<ComboBoxBinding>(); |
|
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"; |
|
} |
|
} |
|
}
|
|
|