public EditMedicineView(CommContracts.Medicine medicine = null) { InitializeComponent(); MedicineTypeEnumCombo.ItemsSource = Enum.GetValues(typeof(CommContracts.MedicineTypeEnum)); DosageFormEnumCombo.ItemsSource = Enum.GetValues(typeof(CommContracts.DosageFormEnum)); YiBaoEnum.ItemsSource = Enum.GetValues(typeof(CommContracts.YiBaoEnum)); bIsEdit = false; if (medicine != null) { this.Medicine = medicine; this.NameEdit.Text = medicine.Name; this.MedicineTypeEnumCombo.SelectedItem = medicine.MedicineTypeEnum; this.Abbr1Edit.Text = medicine.Abbr1; this.Abbr2Edit.Text = medicine.Abbr2; this.Abbr3Edit.Text = medicine.Abbr3; this.DosageFormEnumCombo.SelectedItem = medicine.DosageFormEnum; this.Unit.Text = medicine.Unit; this.AdministrationRoute.Text = medicine.AdministrationRoute; this.Specifications.Text = medicine.Specifications; this.Manufacturer.Text = medicine.Manufacturer; this.PoisonousHemp.IsChecked = medicine.PoisonousHemp; this.Valuable.IsChecked = medicine.Valuable; this.EssentialDrugs.IsChecked = medicine.EssentialDrugs; this.YiBaoEnum.Text = medicine.YiBaoEnum.ToString(); this.MaxNum.Text = medicine.MaxNum.ToString(); this.MinNum.Text = medicine.MinNum.ToString(); this.SellPrice.Text = medicine.SellPrice.ToString(); bIsEdit = true; } }
private void InsertIntoMedicine(CommContracts.Medicine medicine) { if (medicine == null) { return; } if (CheckRepeat(medicine.ID)) { MessageBox.Show(medicine.Name + "已经存在!"); return; } MyDetail item = new MyDetail(); item.ID = medicine.ID; item.Name = medicine.Name; item.Usage = CommContracts.UsageEnum.口服; item.Specifications = medicine.Specifications; item.Manufacturer = medicine.Manufacturer; item.SingleDoseUnit = medicine.Unit; item.SellPrice = medicine.SellPrice; m_contentItems.Add(item); // 跳转到单次剂量 if (m_skipList.Count > 0) { GridSkipTo(m_contentItems.Count - 1, m_skipList.ElementAt(0)); } }
public bool SaveMedicine(CommContracts.Medicine Medicine) { using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.Medicine, DAL.Medicine>(); }); var mapper = config.CreateMapper(); DAL.Medicine temp = new DAL.Medicine(); temp = mapper.Map <DAL.Medicine>(Medicine); ctx.Medicines.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
public bool UpdateMedicine(CommContracts.Medicine Medicine) { using (DAL.HisContext ctx = new DAL.HisContext()) { var temp = ctx.Medicines.FirstOrDefault(m => m.ID == Medicine.ID); if (temp != null) { temp.MedicineTypeEnum = (DAL.MedicineTypeEnum)Medicine.MedicineTypeEnum; temp.Name = Medicine.Name; temp.Abbr1 = Medicine.Abbr1; temp.Abbr2 = Medicine.Abbr2; temp.Abbr3 = Medicine.Abbr3; temp.DosageFormEnum = (DAL.DosageFormEnum)Medicine.DosageFormEnum; temp.Unit = Medicine.Unit; temp.AdministrationRoute = Medicine.AdministrationRoute; temp.Specifications = Medicine.Specifications; temp.Manufacturer = Medicine.Manufacturer; temp.PoisonousHemp = Medicine.PoisonousHemp; temp.Valuable = Medicine.Valuable; temp.EssentialDrugs = Medicine.EssentialDrugs; temp.YiBaoEnum = (DAL.YiBaoEnum)Medicine.YiBaoEnum; temp.MaxNum = Medicine.MaxNum; temp.MinNum = Medicine.MinNum; temp.SellPrice = Medicine.SellPrice; } else { return(false); } try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
private void ShowDetails(CommContracts.MedicineDoctorAdvice doctorAdvice, CommContracts.DoctorAdviceContentEnum doctorAdviceContentEnum) { if (doctorAdvice == null) { return; } CommClient.Medicine myd = new CommClient.Medicine(); CommContracts.Medicine medicine = new CommContracts.Medicine(); List <MyDetail> list = new List <MyDetail>(); foreach (var tem in doctorAdvice.MedicineDoctorAdviceDetails) { MyDetail doctorAdviceDetail = new MyDetail(); //doctorAdviceDetail.GroupNum = tem.GroupNum; doctorAdviceDetail.ID = tem.MedicineID; medicine = myd.GetMedicine(tem.MedicineID); doctorAdviceDetail.Name = medicine.Name; doctorAdviceDetail.Specifications = medicine.Specifications; doctorAdviceDetail.SingleDose = tem.AllNum; //doctorAdviceDetail.SingleDose = tem.SingleDose; //doctorAdviceDetail.Usage = tem.Usage; //doctorAdviceDetail.DDDS = tem.DDDS; //doctorAdviceDetail.DaysNum = tem.DaysNum; //doctorAdviceDetail.IntegralDose = tem.IntegralDose; //doctorAdviceDetail.Illustration = tem.Illustration; list.Add(doctorAdviceDetail); } if (doctorAdviceContentEnum == CommContracts.DoctorAdviceContentEnum.西药成药) { this.XiChengDoctorAdviceMsg.Text = doctorAdvice.ToString(); myXiChengTableEdit.SetAllDetails(list); myXiChengTableEdit.IsEnabled = false; } else if (doctorAdviceContentEnum == CommContracts.DoctorAdviceContentEnum.中药) { this.ZhongDoctorAdviceMsg.Text = doctorAdvice.ToString(); myZhongTableEdit.SetAllDetails(list); myZhongTableEdit.IsEnabled = false; } }
//public List<CommContracts.Medicine> getAllMedicine() //{ // List<CommContracts.Medicine> list = new List<CommContracts.Medicine>(); // using (DAL.HisContext ctx = new DAL.HisContext()) // { // var query = from m in ctx.Medicines // select m; // var config = new MapperConfiguration(cfg => // { // cfg.CreateMap<DAL.Medicine, CommContracts.Medicine>(); // }); // var mapper = config.CreateMapper(); // foreach (DAL.Medicine tem in query) // { // var dto = mapper.Map<CommContracts.Medicine>(tem); // list.Add(dto); // } // } // return list; //} public CommContracts.Medicine GetMedicine(int id) { CommContracts.Medicine medicine = new CommContracts.Medicine(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from m in ctx.Medicines where m.ID == id select m; var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.Medicine, CommContracts.Medicine>(); }); var mapper = config.CreateMapper(); foreach (DAL.Medicine tem in query) { medicine = mapper.Map <CommContracts.Medicine>(tem); break; } } return(medicine); }
public List <CommContracts.Medicine> GetAllMedicine(string strName = "") { List <CommContracts.Medicine> list = new List <CommContracts.Medicine>(); using (DAL.HisContext ctx = new DAL.HisContext()) { var query = from a in ctx.Medicines where a.Name.StartsWith(strName) select a; foreach (DAL.Medicine ass in query) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <DAL.Medicine, CommContracts.Medicine>(); }); var mapper = config.CreateMapper(); CommContracts.Medicine temp = mapper.Map <CommContracts.Medicine>(ass); list.Add(temp); } } return(list); }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.NameEdit.Text.Trim())) { return; } if (this.MedicineTypeEnumCombo.SelectedItem == null) { return; } if (bIsEdit) { Medicine.Name = this.NameEdit.Text.Trim(); Medicine.MedicineTypeEnum = (CommContracts.MedicineTypeEnum) this.MedicineTypeEnumCombo.SelectedItem; Medicine.Abbr1 = this.Abbr1Edit.Text; Medicine.Abbr2 = this.Abbr2Edit.Text; Medicine.Abbr3 = this.Abbr3Edit.Text; Medicine.DosageFormEnum = (CommContracts.DosageFormEnum) this.DosageFormEnumCombo.SelectedItem; Medicine.Unit = this.Unit.Text; Medicine.AdministrationRoute = this.AdministrationRoute.Text; Medicine.Specifications = this.Specifications.Text; Medicine.Manufacturer = this.Manufacturer.Text; Medicine.PoisonousHemp = this.PoisonousHemp.IsChecked.Value; Medicine.Valuable = this.Valuable.IsChecked.Value; Medicine.EssentialDrugs = this.EssentialDrugs.IsChecked.Value; Medicine.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem; Medicine.MaxNum = int.Parse(this.MaxNum.Text); Medicine.MinNum = int.Parse(this.MinNum.Text); Medicine.SellPrice = decimal.Parse(this.SellPrice.Text); CommClient.Medicine myd = new CommClient.Medicine(); if (myd.UpdateMedicine(Medicine)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } else { CommContracts.Medicine medicine = new CommContracts.Medicine(); medicine.Name = this.NameEdit.Text.Trim(); medicine.MedicineTypeEnum = (CommContracts.MedicineTypeEnum) this.MedicineTypeEnumCombo.SelectedItem; medicine.Abbr1 = this.Abbr1Edit.Text; medicine.Abbr2 = this.Abbr2Edit.Text; medicine.Abbr3 = this.Abbr3Edit.Text; medicine.DosageFormEnum = (CommContracts.DosageFormEnum) this.DosageFormEnumCombo.SelectedItem; medicine.Unit = this.Unit.Text; medicine.AdministrationRoute = this.AdministrationRoute.Text; medicine.Specifications = this.Specifications.Text; medicine.Manufacturer = this.Manufacturer.Text; medicine.PoisonousHemp = this.PoisonousHemp.IsChecked.Value; medicine.Valuable = this.Valuable.IsChecked.Value; medicine.EssentialDrugs = this.EssentialDrugs.IsChecked.Value; medicine.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem; if (!string.IsNullOrEmpty(this.MaxNum.Text.Trim())) { medicine.MaxNum = int.Parse(this.MaxNum.Text); } if (!string.IsNullOrEmpty(this.MinNum.Text.Trim())) { medicine.MinNum = int.Parse(this.MinNum.Text); } if (!string.IsNullOrEmpty(this.SellPrice.Text.Trim())) { medicine.SellPrice = decimal.Parse(this.SellPrice.Text); } CommClient.Medicine myd = new CommClient.Medicine(); if (myd.SaveMedicine(medicine)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } }
private void Grid1_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter || e.Key == Key.Return) { if (editEnum == MyTableEditEnum.xichengyao || editEnum == MyTableEditEnum.zhongyao || editEnum == MyTableEditEnum.medicineInStock) { CommContracts.Medicine medicine = this.Grid1.SelectedItem as CommContracts.Medicine; CurrentMedicine = medicine; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.zhiliao) { CommContracts.TherapyItem therapyItem = this.Grid1.SelectedItem as CommContracts.TherapyItem; CurrentTherapyItem = therapyItem; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.jianyan) { CommContracts.AssayItem therapyItem = this.Grid1.SelectedItem as CommContracts.AssayItem; CurrentAssayItem = therapyItem; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.jiancha) { CommContracts.InspectItem therapyItem = this.Grid1.SelectedItem as CommContracts.InspectItem; CurrentInspectItem = therapyItem; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.cailiao || editEnum == MyTableEditEnum.materialInStock) { CommContracts.MaterialItem materialItem = this.Grid1.SelectedItem as CommContracts.MaterialItem; CurrentMaterialItem = materialItem; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.qita) { CommContracts.OtherServiceItem otherServiceItem = this.Grid1.SelectedItem as CommContracts.OtherServiceItem; CurrentOtherServiceItem = otherServiceItem; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.medicineOutStock) { CommContracts.StoreRoomMedicineNum storeRoomMedicineNum = this.Grid1.SelectedItem as CommContracts.StoreRoomMedicineNum; CurrentStoreRoomMedicineNum = storeRoomMedicineNum; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } else if (editEnum == MyTableEditEnum.materialOutStock) { CommContracts.StoreRoomMaterialNum storeRoomMaterialNum = this.Grid1.SelectedItem as CommContracts.StoreRoomMaterialNum; CurrentStoreRoomMaterialNum = storeRoomMaterialNum; (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } }