public bool UpdateTherapyItem(CommContracts.TherapyItem TherapyItem) { using (DAL.HisContext ctx = new DAL.HisContext()) { var temp = ctx.TherapyItems.FirstOrDefault(m => m.ID == TherapyItem.ID); if (temp != null) { temp.Name = TherapyItem.Name; temp.AbbrPY = TherapyItem.AbbrPY; temp.AbbrWB = TherapyItem.AbbrWB; temp.Unit = TherapyItem.Unit; temp.YiBaoEnum = (DAL.YiBaoEnum)TherapyItem.YiBaoEnum; temp.Price = TherapyItem.Price; } else { return(false); } try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
public bool SaveTherapyItem(CommContracts.TherapyItem TherapyItem) { using (DAL.HisContext ctx = new DAL.HisContext()) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <CommContracts.TherapyItem, DAL.TherapyItem>(); }); var mapper = config.CreateMapper(); DAL.TherapyItem temp = new DAL.TherapyItem(); temp = mapper.Map <DAL.TherapyItem>(TherapyItem); ctx.TherapyItems.Add(temp); try { ctx.SaveChanges(); } #pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过 catch (Exception ex) #pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过 { return(false); } } return(true); }
private void InsertIntoTherapyItem(CommContracts.TherapyItem therapyItem) { if (therapyItem == null) { return; } if (CheckRepeat(therapyItem.ID)) { MessageBox.Show(therapyItem.Name + "已经存在!"); return; } MyDetail item = new MyDetail(); item.ID = therapyItem.ID; item.Name = therapyItem.Name; item.SingleDoseUnit = therapyItem.Unit; m_contentItems.Add(item); // 跳转到单次剂量 if (m_skipList.Count > 0) { GridSkipTo(m_contentItems.Count - 1, m_skipList.ElementAt(0)); } }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.NameEdit.Text.Trim())) { return; } if (this.YiBaoEnum.SelectedItem == null) { return; } if (bIsEdit) { TherapyItem.Name = this.NameEdit.Text.Trim(); TherapyItem.AbbrPY = this.AbbrPY.Text; TherapyItem.AbbrWB = this.AbbrWB.Text; TherapyItem.Unit = this.Unit.Text; TherapyItem.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem; TherapyItem.Price = decimal.Parse(this.Price.Text); CommClient.TherapyItem myd = new CommClient.TherapyItem(); if (myd.UpdateTherapyItem(TherapyItem)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } else { CommContracts.TherapyItem therapyItem = new CommContracts.TherapyItem(); therapyItem.Name = this.NameEdit.Text.Trim(); therapyItem.AbbrPY = this.AbbrPY.Text.Trim(); therapyItem.AbbrWB = this.AbbrWB.Text.Trim(); therapyItem.Unit = this.Unit.Text.Trim(); therapyItem.YiBaoEnum = (CommContracts.YiBaoEnum) this.YiBaoEnum.SelectedItem; if (!string.IsNullOrEmpty(this.Price.Text)) { therapyItem.Price = decimal.Parse(this.Price.Text.Trim()); } CommClient.TherapyItem myd = new CommClient.TherapyItem(); if (myd.SaveTherapyItem(therapyItem)) { (this.Parent as Window).DialogResult = true; (this.Parent as Window).Close(); } } }
public EditTherapyItemView(CommContracts.TherapyItem therapyItem = null) { InitializeComponent(); YiBaoEnum.ItemsSource = Enum.GetValues(typeof(CommContracts.YiBaoEnum)); bIsEdit = false; if (therapyItem != null) { this.TherapyItem = therapyItem; this.NameEdit.Text = therapyItem.Name; this.AbbrPY.Text = therapyItem.AbbrPY; this.AbbrWB.Text = therapyItem.AbbrWB; this.Unit.Text = therapyItem.Unit; this.YiBaoEnum.Text = therapyItem.YiBaoEnum.ToString(); this.Price.Text = therapyItem.Price.ToString(); bIsEdit = true; } }
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(); } } }