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.
120 lines
3.9 KiB
120 lines
3.9 KiB
using SchedulingSystem.EntityClass; |
|
using System; |
|
using System.Collections.Generic; |
|
using System.Linq; |
|
using System.Windows; |
|
|
|
namespace SchedulingSystemClient.InsertWindow |
|
{ |
|
/// <summary> |
|
/// XZSBWindow.xaml 的交互逻辑 |
|
/// </summary> |
|
public partial class XZSBWindow : Window |
|
{ |
|
public XZSBWindow() |
|
{ |
|
InitializeComponent(); |
|
} |
|
SurgerySchedulingEntities myModel = new SurgerySchedulingEntities(); |
|
private void Window_Loaded(object sender, RoutedEventArgs e) |
|
{ |
|
List<ComboBoxBinding> listsblx = new List<ComboBoxBinding>(); |
|
listsblx = (from tbsblxb in myModel.SYS_SBLXB |
|
select new ComboBoxBinding |
|
{ |
|
ID = tbsblxb.ID, |
|
Name = tbsblxb.Name, |
|
}).ToList(); |
|
sblx.ItemsSource = listsblx; |
|
sblx.SelectedValuePath = "ID"; |
|
sblx.DisplayMemberPath = "Name"; |
|
List<ComboBoxBinding> listsss = new List<ComboBoxBinding>(); |
|
listsss = (from tbsssb in myModel.SYS_SSSB |
|
select new ComboBoxBinding |
|
{ |
|
ID = tbsssb.ID, |
|
Name = tbsssb.SSSMC, |
|
}).ToList(); |
|
sss.ItemsSource = listsss; |
|
sss.SelectedValuePath = "ID"; |
|
sss.DisplayMemberPath = "Name"; |
|
List<ComboBoxBinding> listsbdj = new List<ComboBoxBinding>(); |
|
listsbdj = (from tbsbdj in myModel.SYS_SBDJB |
|
select new ComboBoxBinding |
|
{ |
|
ID = tbsbdj.ID, |
|
Name = tbsbdj.Name, |
|
}).ToList(); |
|
sbdj.ItemsSource = listsbdj; |
|
sbdj.SelectedValuePath = "ID"; |
|
sbdj.DisplayMemberPath = "Name"; |
|
} |
|
|
|
private void btn_bc_Click(object sender, RoutedEventArgs e) |
|
{ |
|
if (sbbm.Text == string.Empty) |
|
{ |
|
MessageBox.Show("请填写设备编码"); |
|
return; |
|
} |
|
if (sbmc.Text == string.Empty) |
|
{ |
|
MessageBox.Show("请填写设备名称"); |
|
return; |
|
} |
|
if (sss.SelectedValue == null) |
|
{ |
|
MessageBox.Show("请选择手术室"); |
|
return; |
|
} |
|
if (sblx.SelectedValue == null) |
|
{ |
|
MessageBox.Show("请选择设备类型"); |
|
return; |
|
} |
|
if (sbdj.SelectedValue == null) |
|
{ |
|
MessageBox.Show("请选择设备等级"); |
|
return; |
|
} |
|
decimal jg; |
|
try |
|
{ |
|
if (sbjg.Text!=string.Empty) |
|
{ |
|
jg = Convert.ToDecimal(sbjg.Text); |
|
} |
|
else |
|
{ |
|
jg = 0; |
|
} |
|
} |
|
catch (Exception ) |
|
{ |
|
MessageBox.Show("设备价格格式不正确"); |
|
return; |
|
} |
|
int sssid = Convert.ToInt32(sss.SelectedValue); |
|
int sblxid = Convert.ToInt32(sblx.SelectedValue); |
|
int sbjdid = Convert.ToInt32(sbdj.SelectedValue); |
|
Bus_SBB sbb = new Bus_SBB(); |
|
sbb.SBBM = sbbm.Text.Trim(); |
|
sbb.SBDJ = sbjdid; |
|
sbb.SBJG = jg; |
|
sbb.SBLX = sblxid; |
|
sbb.SBMC = sbmc.Text.Trim(); |
|
sbb.SSSID = sssid; |
|
try |
|
{ |
|
myModel.Bus_SBB.Add(sbb); |
|
myModel.SaveChanges(); |
|
MessageBox.Show("新增成功"); |
|
this.Close(); |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageBox.Show(ex.ToString()); |
|
} |
|
} |
|
} |
|
}
|
|
|