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.

108 lines
3.7 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>
/// XZHSWindow.xaml 的交互逻辑
/// </summary>
public partial class XZHSWindow : Window
{
public XZHSWindow()
{
InitializeComponent();
}
SurgerySchedulingEntities myModel = new SurgerySchedulingEntities();
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
{
var listmzys = (from ybmzys in myModel.SYS_MZYSB
where ybmzys.YSBM == ysgh.Text && ybmzys.YSMC == ysxm.Text
select new { ybmzys }).ToList();
if (listmzys.Count > 0)
{
MessageBox.Show("护士姓名和编码重复!");
return;
}
SYS_HSB hsb = new SYS_HSB();
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.SYS_HSB.Add(hsb);
myModel.SaveChanges();
MessageBox.Show("新增成功");
this.Close();
}
catch (Exception)
{
MessageBox.Show("新增失败");
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
List<ComboBoxBinding> listsfqy = new List<ComboBoxBinding>();
listsfqy.Add(new ComboBoxBinding() { ID = 0, Name = "是" });
listsfqy.Add(new ComboBoxBinding() { ID = 1, Name = "否" });
sfqy.ItemsSource = listsfqy;
sfqy.SelectedValuePath = "ID";
sfqy.DisplayMemberPath = "Name";
sfqy.SelectedIndex = 0;
List<ComboBoxBinding> listhszc = new List<ComboBoxBinding>();
listhszc = (from tbssjb in myModel.SYS_HSZCB
select new ComboBoxBinding
{
ID = tbssjb.ID,
Name = tbssjb.Name,
}).ToList();
yszc.ItemsSource = listhszc;
yszc.SelectedValuePath = "ID";
yszc.DisplayMemberPath = "Name";
List<ComboBoxBinding> listsss = new List<ComboBoxBinding>();
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";
}
}
}