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