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.

262 lines
9.5 KiB

using SchedulingSystem.EntityClass;
using SchedulingSystemClient.EntityClass;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace SchedulingSystemClient
{
/// <summary>
/// RYPBWindow.xaml 的交互逻辑
/// </summary>
public partial class RYPBWindow : Window
{
public RYPBWindow(Cus_SSPB selectedRow )
{
InitializeComponent();
Row = selectedRow;
}
SurgerySchedulingEntities myModel = new SurgerySchedulingEntities();
Cus_SSPB Row = new Cus_SSPB();
private void Window_Loaded(object sender, RoutedEventArgs e)
{
int sssid = 0;
if (Row.SSSID !=null)
{
sssid = Convert.ToInt32(Row.SSSID);
}
sssmc.Content = Row.SSSMC;
ssmc.Content = Row.SSMC;
ssdj.Content = Row.SSDJ;
qklx.Content = Row.QKLX;
zdys.Content = Row.ZDYS;
hzxm.Content = Row.HZXM;
List<ComboBoxBinding> listzs1 = new List<ComboBoxBinding>();
listzs1 = (from tbsss in myModel.SYS_SSYSB
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.YSXM
}).ToList();
zs1.ItemsSource = listzs1;
zs1.SelectedValuePath = "ID";
zs1.DisplayMemberPath = "Name";
if (Row.ZS1ID!=null && Row.ZS1ID != 0)
{
zs1.SelectedValue = Row.ZS1ID;
}
List<ComboBoxBinding> listzs2 = new List<ComboBoxBinding>();
listzs2 = (from tbsss in myModel.SYS_SSYSB
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.YSXM
}).ToList();
zs2.ItemsSource = listzs2;
zs2.SelectedValuePath = "ID";
zs2.DisplayMemberPath = "Name";
if (Row.ZS2ID != null && Row.ZS2ID != 0)
{
zs2.SelectedValue = Row.ZS2ID;
}
List<ComboBoxBinding> listmz1 = new List<ComboBoxBinding>();
listmz1 = (from tbsss in myModel.SYS_MZYSB
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.YSMC
}).ToList();
mz1.ItemsSource = listmz1;
mz1.SelectedValuePath = "ID";
mz1.DisplayMemberPath = "Name";
if (Row.MZYS1ID != null && Row.MZYS1ID != 0)
{
mz1.SelectedValue = Row.MZYS1ID;
}
List<ComboBoxBinding> listmz2 = new List<ComboBoxBinding>();
listmz2 = (from tbsss in myModel.SYS_MZYSB
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.YSMC
}).ToList();
mz2.ItemsSource = listmz2;
mz2.SelectedValuePath = "ID";
mz2.DisplayMemberPath = "Name";
if (Row.MZYS2ID != null && Row.MZYS2ID != 0)
{
mz2.SelectedValue = Row.MZYS2ID;
}
List<ComboBoxBinding> listxs1 = new List<ComboBoxBinding>();
listxs1= (from tbsss in myModel.SYS_HSB
where tbsss.SSSID == sssid
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.HSMC
}).ToList();
xs1.ItemsSource = listxs1;
xs1.SelectedValuePath = "ID";
xs1.DisplayMemberPath = "Name";
if (Row.XSHS1ID != null && Row.XSHS1ID != 0)
{
xs1.SelectedValue = Row.XSHS1ID;
}
List<ComboBoxBinding> listxs2 = new List<ComboBoxBinding>();
listxs2 = (from tbsss in myModel.SYS_HSB
where tbsss.SSSID == sssid
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.HSMC
}).ToList();
xs2.ItemsSource = listxs2;
xs2.SelectedValuePath = "ID";
xs2.DisplayMemberPath = "Name";
if (Row.XSHS2ID != null && Row.XSHS2ID != 0)
{
xs2.SelectedValue = Row.XSHS2ID;
}
List<ComboBoxBinding> listxh1 = new List<ComboBoxBinding>();
listxh1 = (from tbsss in myModel.SYS_HSB
where tbsss.SSSID == sssid
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.HSMC
}).ToList();
xh1.ItemsSource = listxh1;
xh1.SelectedValuePath = "ID";
xh1.DisplayMemberPath = "Name";
if (Row.XHHS1ID != null && Row.XHHS1ID != 0)
{
xh1.SelectedValue = Row.XHHS1ID;
}
List<ComboBoxBinding> listxh2 = new List<ComboBoxBinding>();
listxh2 = (from tbsss in myModel.SYS_HSB
where tbsss.SSSID == sssid
select new ComboBoxBinding
{
ID = tbsss.ID,
Name = tbsss.HSMC
}).ToList();
xh2.ItemsSource = listxh2;
xh2.SelectedValuePath = "ID";
xh2.DisplayMemberPath = "Name";
if (Row.XHHS2ID != null && Row.XHHS2ID != 0)
{
xh2.SelectedValue = Row.XHHS2ID;
}
}
private void btn_bc_Click(object sender, RoutedEventArgs e)
{
try
{
int Intzs1 =0;
int Intzs2 =0;
int Intmz1 =0;
int Intmz2 =0;
int Intxs1 =0;
int Intxs2 =0;
int Intxh1 =0;
int Intxh2 =0;
if (mz1.SelectedValue != null)
{
Intmz1 = Convert.ToInt32(mz1.SelectedValue);
}
else
{
MessageBox.Show("请选择麻醉医生");
return;
}
if (mz2.SelectedValue != null)
{
Intmz2 = Convert.ToInt32(mz2.SelectedValue);
}
if (zs1.SelectedValue != null)
{
Intzs1 = Convert.ToInt32(zs1.SelectedValue);
}
if (zs2.SelectedValue != null)
{
Intzs2 = Convert.ToInt32(zs2.SelectedValue);
}
if (xh1.SelectedValue != null)
{
Intxh1 = Convert.ToInt32(xh1.SelectedValue);
}
if (xh2.SelectedValue != null)
{
Intxh2 = Convert.ToInt32(xh2.SelectedValue);
}
if (xs1.SelectedValue != null)
{
Intxs1 = Convert.ToInt32(xs1.SelectedValue);
}
if (xs2.SelectedValue != null)
{
Intxs2 = Convert.ToInt32(xs2.SelectedValue);
}
if (Intzs1== Intzs2)
{
MessageBox.Show("助手重复");
return;
}
if (Intmz1 == Intmz2)
{
MessageBox.Show("麻醉医生重复");
return;
}
if (Intxs1 == Intxs2|| Intxs1 == Intxh1|| Intxs1 == Intxh2 || Intxs2== Intxh1 || Intxs2 == Intxh2 || Intxh1 == Intxh2)
{
MessageBox.Show("护士重复");
return;
}
Bus_SSPBB sspb = new Bus_SSPBB();
sspb.ID = Row.ID;
sspb.BZ = Row.BZ;
sspb.HZXM = Row.HZXM;
sspb.KSID = Row.KSID;
sspb.MZYS1 = Intmz1;
sspb.MZYS2 = Intmz2;
//sspb.MZYS3 = Row.ID;
sspb.PBZT = Row.PBZTID;
sspb.QJSC = Row.QJSC;
sspb.QZ = Row.QZ;
sspb.SFJZ = Row.SFJZ;
sspb.SQDH = Row.SQDH;
sspb.SQSJ = Row.SQSJ;
sspb.SQZD = Row.SQZD;
sspb.SSID = Row.SSID;
sspb.SSJSSJ = Row.SSJSSJ;
sspb.SSKSSJ = Row.SSKSSJ;
sspb.SSRQ = Row.SSRQ;
sspb.SSSC = Row.SSSC;
sspb.SSSID = Row.SSSID;
sspb.SSZSC = Row.SSZSC;
sspb.XHHS1 = Intxh1;
sspb.XHHS2 = Intxh2;
sspb.XSHS1 = Intxs1;
sspb.XSHS2 = Intxs2;
sspb.ZDYS = Row.ZDYSID;
sspb.ZLKH = Row.ZLKH;
sspb.ZS1 = Intzs1;
sspb.ZS2 = Intzs2;
//sspb.ZS3 = Row.ZS3ID;
sspb.ZYH = Row.ZYH;
myModel.Entry(sspb).State = System.Data.Entity.EntityState.Modified;
myModel.SaveChanges();
MessageBox.Show("保存成功");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}