public MmForm(XapDataList <EmsOrDrug> list, EmsDrugItemDO drugItemDO) : this() { IMaterialStockService stoctService = XapServiceMgr.find <IMaterialStockService>(); GetStockReqDTO[] reqDtos = new GetStockReqDTO[list.Count]; for (int i = 0; i < list.Count; i++) { GetStockReqDTO reqDTO = new GetStockReqDTO(); reqDTO.Id_mm = list[i].Id_mm; reqDTO.Id_dep = ""; reqDTO.Req_unit_id = list[i].Id_unit_sale; reqDtos[i] = reqDTO; } MaterialStockDTO[] stockdto = stoctService.getMaterialStocks(reqDtos); for (int i = list.Count - 1; i >= 0; i--) { MaterialStockDTO materialDo = stockdto.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (materialDo != null) { double mmcount = (double)materialDo.Quan_stock; if (mmcount <= 0) { list.RemoveAt(i); } else { list[i].Fact_count = Math.Round(mmcount); list[i].Price = materialDo.Price_act; } } } IEnumerable <EmsOrDrug> query = null; query = from items in list orderby items.Fact_count descending select items; int flag = 0; foreach (var item in query) { list[flag] = item; flag++; //Console.WriteLine(item.Id+":"+item.Name); } mm = new MmRefView(list); mm.DoubleClickEvent += new EventHandler(mm_DoubleClickEvent); this.Panel = mm; }
void gv_MouseClick(object sender, MouseEventArgs e) { drug = xapFormControl1.GetFocused <EmsOrDrug>("drug"); if (gv.GetFocusedRow().ClickCell.FieldName == "Name_mm") { string id_srv = (gv.GetFocusedRow().RowDataSource as EmsOrDrug).Id_srv; //拿到 点击的药品对应服务的id_srv //根据服务id 取到 服务关联的药品 , if (this.EmsHeadDO.Emsdrugs.EmsOrDrug.Count > 1) //如果只有一条 { MmForm mmref = new MmForm(this.EmsHeadDO.Emsdrugs.EmsOrDrug, this.EmsHeadDO.Emsdrugs); Point formPoint = Control.MousePosition; mmref.StartPosition = FormStartPosition.Manual; mmref.Location = gv.PointToScreen(new Point(gv.Location.X, gv.Location.Y + gv.Size.Height + 1)); mmref.TopMost = true; if (mmref.ShowDialog() == DialogResult.OK) { EmsOrDrug orDrug = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[gv.FocusedRowHandle]; string id_mm = mmref.drugmm.Id_mm; string id_dep_phy = this.EmsHeadDO.Emsdrugs.Id_dep; GetStockReqDTO reqDto = new GetStockReqDTO(); reqDto.Id_dep = id_dep_phy; reqDto.Id_mm = id_mm; reqDto.Req_unit_id = mmref.drugmm.Id_unit_med; GetStockReqDTO[] reqDtoArr = new GetStockReqDTO[1]; reqDtoArr[0] = reqDto; try { MaterialStockDTO[] materialArr = cof.getMaterialStocksCount(reqDtoArr); if (materialArr != null && materialArr.Length > 0) { MaterialStockDTO material = materialArr[0]; if (material != null && material.Quan_stock > 0) { cof.CopyTo(mmref.drugmm, orDrug, "Id_srv", "Name_srv"); } else { this.ShowInfo("该药品在" + this.EmsHeadDO.Emsdrugs.Name_dep + "库存为零,请重新选择药品或更改执行科室!"); return; } } } catch //(Exception ex) { } } } } }
void xapFormControl1_DataChanged(object sender, DataChangedEventArgs e) { switch (e.PropName)//计算结束日期 { case "Dt_begin_ui": DateTime adm = CommonExtentions.NowTime(this); //TODO: 入院时间 string info = cof.CompareWithAdmission(this.EmsHeadDO.PatInfo.Id_ent, this.EmsHeadDO.Emsdrugs.Dt_begin_ui); if (info != "") { this.ShowInfo(info); return; } DateTime dtb = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_begin_ui; int?useDay = cof.GetUseDays(dtb, this.EmsHeadDO.Emsdrugs.Dt_end_ui); if (this.EmsHeadDO.Emsdrugs.Use_days != useDay) { this.EmsHeadDO.Emsdrugs.Use_days = useDay; } if (this.EmsHeadDO.Emsdrugs.Dt_fail != null) { //失效时间 this.EmsHeadDO.Emsdrugs.Dt_fail = cof.GetSpareEndTime(this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value); dt_fail.MinDate = this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value.AddDays(-1); dt_fail.MaxDate = this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value.AddHours(this.Context.GetOrgParam <int>(ICiOrdNSysParamConst.SYS_PARAM_TemporaryPrnOrValidTime)); } if (this.EmsHeadDO.Emsdrugs.Dt_end_ui == null) { return; } DateTime dte = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_end_ui; if (dtb.CompareTo(dte) > 0) { // e.Cancel = true; this.EmsHeadDO.Emsdrugs.Dt_begin_ui = dte; this.ShowInfo(OrdParam.MESSAGE_TIEMCHECK); return; } break; case "Use_days": //医嘱天数 if (this.EmsHeadDO.Emsdrugs.Use_days == -1) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = null; this.EmsHeadDO.Emsdrugs.Use_days = null; } else if (this.EmsHeadDO.Emsdrugs.Use_days == 0) { if (this.EmsHeadDO.Emsdrugs.Dt_end_ui != this.EmsHeadDO.Emsdrugs.Dt_begin_ui) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = this.EmsHeadDO.Emsdrugs.Dt_begin_ui; } } else if (this.EmsHeadDO.Emsdrugs.Use_days != null) { DateTime?temDateTime = cof.GetEndTime(this.EmsHeadDO.Emsdrugs.Dt_begin_ui, this.EmsHeadDO.Emsdrugs.Use_days.Value); if (this.EmsHeadDO.Emsdrugs.Dt_end_ui != temDateTime) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = temDateTime; } } if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") { cof.GetDrugTotal(this.EmsHeadDO); } //取模 int?m = this.EmsHeadDO.Emsdrugs.Use_days % 7; if ((this.EmsHeadDO.Emsdrugs.Name_freq.IndexOf("周") > 0 || this.EmsHeadDO.Emsdrugs.Name_freq.IndexOf("星期") > 0) && m % 7 != 0) { if (m == 0 || m == 6) { //减的 int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = uu * 7; } else { int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = (uu + 1) * 7; } } break; case "Dt_end_ui": //计算医嘱天数 dtb = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_begin_ui; if (this.EmsHeadDO.Emsdrugs.Dt_end_ui == null) { return; } dte = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_end_ui; if (dtb.CompareTo(dte) > 0) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = dtb; this.ShowInfo(OrdParam.MESSAGE_TIEMCHECK); return; } useDay = cof.GetUseDays(dtb, this.EmsHeadDO.Emsdrugs.Dt_end_ui); if (this.EmsHeadDO.Emsdrugs.Use_days != useDay) { this.EmsHeadDO.Emsdrugs.Use_days = useDay; } if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") { drug.Quan_cur = cof.GetDrugUseTotalCount(this.EmsHeadDO); cof.GetDrugTotal(this.EmsHeadDO); } break; case "Name_freq": //计算执行时刻1 if (e.Input != null && e.Input.ToString().Contains("日")) { cof.getControlByName(xapFormControl1, "drugsUse", "quan_firday_mp").Enabled = true; cof.getControlByName(xapFormControl1, "drugsUse", "work_time").Enabled = false; } else if (e.Input != null && (e.Input.ToString().Contains("周") || e.Input.ToString().Contains("星期"))) { //取模 m = this.EmsHeadDO.Emsdrugs.Use_days % 7; if (m == 0 || m == 6) { //减的 int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = uu * 7; } else { int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = (uu + 1) * 7; } } else { cof.getControlByName(xapFormControl1, "drugsUse", "quan_firday_mp").Enabled = false; cof.getControlByName(xapFormControl1, "drugsUse", "work_time").Enabled = false; } GetMpTimes(this.EmsHeadDO.Emsdrugs.Id_freq); cof.setFreqctMaxMin(this.EmsHeadDO, xapFormControl1); // 先于 OnRefResult(object sender, RefResultEventArgs e)执行,会出现 这个地方获取的id 是上次的 而不是最新的 break; case "Id_freq": //计算执行时刻1 // 先于 OnRefResult(object sender, RefResultEventArgs e)执行,会出现 这个地方获取的id 是上次的 而不是最新的 break; case "Fg_long": if (e.Input.ToString() == "false") { cof.getControlByName(xapFormControl1, "drugsUse", "Use_days").Enabled = false; //临时 医嘱天数 不可输入 } else { cof.getControlByName(xapFormControl1, "drugsUse", "Use_days").Enabled = true; } break; case "Fg_self": if (this.EmsHeadDO.Emsdrugs.Fg_self == true) { this.EmsHeadDO.Emsdrugs.Fg_outp = !this.EmsHeadDO.Emsdrugs.Fg_self; } break; case "Fg_outp": if (this.EmsHeadDO.Emsdrugs.Fg_outp == true) { this.EmsHeadDO.Emsdrugs.Fg_self = !this.EmsHeadDO.Emsdrugs.Fg_outp; //ctlTotal.Enabled = true; gv.DataTable.Columns["Quan_cur"].ReadOnly = false; if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") { cof.GetDrugTotal(this.EmsHeadDO); } gv.DataTable.Columns["Quan_cur"].ReadOnly = false; gv.DataTable.Columns["Name_unit_sale"].ReadOnly = false; manageUnitName("out"); } else { gv.DataTable.Columns["Quan_cur"].ReadOnly = true; foreach (EmsOrDrug itemDrug in this.EmsHeadDO.Emsdrugs.EmsOrDrugList) { itemDrug.Quan_cur = null; } gv.DataTable.Columns["Quan_cur"].ReadOnly = true; gv.DataTable.Columns["Name_unit_sale"].ReadOnly = true; manageUnitName("in"); //ctlTotal.Enabled = false; } break; case "Fg_treat": this.EmsHeadDO.Emsdrugs.Fg_propc = !this.EmsHeadDO.Emsdrugs.Fg_treat; break; case "Fg_propc": this.EmsHeadDO.Emsdrugs.Fg_treat = !this.EmsHeadDO.Emsdrugs.Fg_propc; break; case "Quan_med": if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") { cof.GetDrugTotal(this.EmsHeadDO); } break; case "Quan_firday_mp": cof.getWorkTime(this.xapFormControl1, exctimes); if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") { cof.GetDrugTotal(this.EmsHeadDO); } break; case "Name_unit_sale": this.manageUnitName(""); //保存所有单位名称到缓存 break; case "Quan_cur": GetStockReqDTO reqDto = new GetStockReqDTO(); if (gv.GetFocusedRow <EmsOrDrug>() != null) { string id_mm = gv.GetFocusedRow <EmsOrDrug>().Id_mm; string id_dep_phy = this.EmsHeadDO.Emsdrugs.Id_dep; reqDto.Id_dep = id_dep_phy; reqDto.Id_mm = id_mm; reqDto.Req_unit_id = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Id_unit_sale; GetStockReqDTO[] reqDtoArr = new GetStockReqDTO[1]; reqDtoArr[0] = reqDto; try { MaterialStockDTO[] materialArr = cof.getMaterialStocksCount(reqDtoArr); if (materialArr != null && materialArr.Length > 0) { MaterialStockDTO material = materialArr[0]; if (material == null || material.Quan_stock < gv.GetFocusedRow <EmsOrDrug>().Quan_cur) { this.ShowInfo(this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Name_mm + "数量已超过库存量,无法开立!"); return; } } } catch //(Exception ex) { } } break; default: break; } }
void gv_MouseClick(object sender, MouseEventArgs e) { //if (gv.FocusedRowHandle < 0) return; emsOrDrug = gv.GetFocusedRow().RowDataSource as EmsOrDrug; // 待修改 if (gv.GetFocusedRow().ClickCell.FieldName == "Name_mm") { string id_srv = emsOrDrug.Id_srv; //拿到 点击的药品对应服务的id_srv if (this.EmsHeadDO.Emsdrugs.EmsOrDrug.Count > 1) //如果只有一条 { List <EmsOrDrug> list = this.EmsHeadDO.Emsdrugs.EmsOrDrug.ToList().Where <EmsOrDrug>(p => p.Id_srv == id_srv).ToList(); MmForm mmref = new MmForm(cof.ConvertDataSouse <EmsOrDrug>(list), this.EmsHeadDO.Emsdrugs); Point formPoint = Control.MousePosition; mmref.Local = formPoint; mmref.TopMost = true; mmref.ShowDialog(); if (mmref.DialogResult == DialogResult.OK) { string id_mm = mmref.drugmm.Id_mm; string id_dep_phy = this.EmsHeadDO.Emsdrugs.Id_dep; GetStockReqDTO reqDto = new GetStockReqDTO(); reqDto.Id_dep = id_dep_phy; reqDto.Id_mm = id_mm; reqDto.Req_unit_id = mmref.drugmm.Id_unit_med; GetStockReqDTO[] reqDtoArr = new GetStockReqDTO[1]; reqDtoArr[0] = reqDto; try { MaterialStockDTO[] materialArr = cof.getMaterialStocksCount(reqDtoArr); if (materialArr != null && materialArr.Length > 0) { MaterialStockDTO material = materialArr[0]; if (material != null && material.Quan_stock > 0) { //下面是正确的做法 只对 关键值进行替换 EmsOrDrug orDrug = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[gv.FocusedRowHandle]; orDrug.Name_mm = mmref.drugmm.Name_mm; //药品名称 orDrug.Spec_mm = mmref.drugmm.Spec_mm; //规格 orDrug.Name_hp = mmref.drugmm.Name_hp; //医保类型 orDrug.Limit = mmref.drugmm.Limit; //限制报销条件 orDrug.Price = mmref.drugmm.Price; //参考价格 } else { this.ShowInfo("该药品在" + this.EmsHeadDO.Emsdrugs.Name_dep + "库存为零,请重新选择药品或更改执行科室!"); return; } } } catch //(Exception ex) { } } } } //} }
public void setEmsOrDrugList(XapDataList <EmsOrDrug> list) { lock (this) { IMaterialStockService stoctService = XapServiceMgr.find <IMaterialStockService>(); List <GetStockReqDTO> reqDtos = new List <GetStockReqDTO>(); if (emsOrDrugList == null) { emsOrDrugList = new XapDataList <EmsOrDrug>(); } for (int i = 0; i < list.Count; i++) { if (list[i].Fg_mm == true) { GetStockReqDTO reqDTO = new GetStockReqDTO(); reqDTO.Id_mm = list[i].Id_mm; reqDTO.Id_dep = list[i].Id_dep_wh; reqDTO.Req_unit_id = list[i].Id_unit_sale; reqDtos.Add(reqDTO); } } if (reqDtos.Count > 0) { MaterialStockDTO[] stockdto = null; try { stockdto = stoctService.getMaterialStocks(reqDtos.ToArray()); } catch (Exception ex) { ex.Publish(); //this.ShowInfo(ex.Message); } if (stockdto == null) { return; } for (int i = list.Count - 1; i >= 0; i--) { MaterialStockDTO materialDo = stockdto.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (materialDo != null) { FDouble mmcount = materialDo.Quan_stock; int? mmStatus = materialDo.Mmstatus; //药房无此药的移除 if (mmStatus != null && mmStatus == (int)MaterialStatus.NORELATION) { list.RemoveAt(i); } else { list[i].Fact_count = mmcount; list[i].Price = materialDo.Price_act; list[i].Mmstatus = materialDo.Mmstatus; EmsOrDrug ems = emsOrDrugList.FirstOrDefault(p => p.Id_mm == list[i].Id_mm); if (ems != null) { emsOrDrugList.Remove(ems); } emsOrDrugList.Add(list[i]); } } } List <EmsOrDrug> sortList = null; try { sortList = emsOrDrugList.OrderByDescending(p => p.Fact_count).OrderBy(p => p.Mmstatus).ToList(); } catch //(Exception e) { // e.Message; } if (emsOrDrugList == null) { emsOrDrugList = new XapDataList <EmsOrDrug>(); } else { emsOrDrugList.Clear(); } sortList.ForEach(p => emsOrDrugList.Add(p)); } } }
void xapFormControl1_DataChanged(object sender, DataChangedEventArgs e) { switch (e.PropName) //计算结束日期 { case "Use_days": //医嘱天数 if (EmsHeadDO.Emsdrugs.Use_days == null) { EmsHeadDO.Emsdrugs.Dt_end_ui = null; return; } //EmsHeadDO.Emsdrugs.Dt_end_ui = cof.GetEndTime(EmsHeadDO.Emsdrugs.Dt_begin_ui, EmsHeadDO.Emsdrugs.Use_days.Value); //cof.GetDrugUseTotalCount(EmsHeadDO);//住院的也将该代码注释了,不知原因 //if (getControlByName("drugsUse", "fg_outp").ValueText == "true") //{ //取模 int?m = EmsHeadDO.Emsdrugs.Use_days % 7; //判断周期类型错误 //if (EmsHeadDO.Emsdrugs.Name_freq.IndexOf("周") > 0 && m % 7 != 0) if ((EmsHeadDO.Emsdrugs.Name_freq.IndexOf("周") > 0 || EmsHeadDO.Emsdrugs.Name_freq.IndexOf("星期") > 0) && m % 7 != 0) { if (m == 0 || m == 6) { //减的 int?uu = EmsHeadDO.Emsdrugs.Use_days / 7; EmsHeadDO.Emsdrugs.Use_days = uu * 7; } else { int?uu = EmsHeadDO.Emsdrugs.Use_days / 7; EmsHeadDO.Emsdrugs.Use_days = (uu + 1) * 7; } } this.setTime_cur(); setQauntum(this.EmsHeadDO.Emsdrugs.Times_cur); //设置结束时间和停止标志 setEndTime(); //} break; //界面上没有相关字段 //case "Dt_begin_ui": // if (EmsHeadDO.Emsdrugs.Dt_begin_ui != null) // { // UserRender us = xapFormControl1.GetUserRender("drugsUse", "dt_end_ui"); // xap.cli.sdk.render.Items.XCalendarTimerComboBox dt_begin = us.Renders[0] as xap.cli.sdk.render.Items.XCalendarTimerComboBox; // dt_begin.MinDate = EmsHeadDO.Emsdrugs.Dt_begin_ui.Value; // } // break; //case "Dt_end_ui"://计算医嘱天数 // EmsHeadDO.Emsdrugs.Use_days = cof.GetUseDays(EmsHeadDO.Emsdrugs.Dt_begin_ui, EmsHeadDO.Emsdrugs.Dt_end_ui); // //获取总量 // // EmsOrDrug drug = EmsHeadDO.Emsdrugs.EmsOrDrugList[0]; // //drug.Quan_cur= cof.GetDrugUseTotalCount(EmsHeadDO); // int useDay = cof.GetUseDays(EmsHeadDO.Emsdrugs.Dt_begin_ui, EmsHeadDO.Emsdrugs.Dt_end_ui); // if (EmsHeadDO.Emsdrugs.Use_days != useDay) { // EmsHeadDO.Emsdrugs.Use_days = useDay; // } // EmsOrDrug drug = EmsHeadDO.Emsdrugs.EmsOrDrugList[0]; // if (getControlByName("drugsUse", "fg_outp").ValueText == "true") // { // //drug.Quan_cur = cof.GetDrugUseTotalCount(EmsHeadDO); // cof.GetDrugTotal(EmsHeadDO); // } // break; //case "Name_freq"://计算执行时刻1 // if (e.Input != null && e.Input.ToString().Contains("日")) // { // getControlByName("drugsUse", "quan_firday_mp").Enabled = true; // getControlByName("drugsUse", "work_time").Enabled = true; // } // else // { // getControlByName("drugsUse", "quan_firday_mp").Enabled = false; // getControlByName("drugsUse", "work_time").Enabled = false; // } // // 先于 OnRefResult(object sender, RefResultEventArgs e)执行,会出现 这个地方获取的id 是上次的 而不是最新的 // break; case "Fg_long": if (e.Input == null || e.Input.ToString().ToLower() == "false") { getControlByName("drugsUse", "use_days").Enabled = false; //临时 医嘱天数 不可输入 EmsHeadDO.Emsdrugs.Use_days = 1; } else { getControlByName("drugsUse", "use_days").Enabled = true; } break; case "Fg_self": if (EmsHeadDO.Emsdrugs.Fg_self == true) { EmsHeadDO.Emsdrugs.Fg_outp = !EmsHeadDO.Emsdrugs.Fg_self; } break; case "Fg_outp": if (EmsHeadDO.Emsdrugs.Fg_outp == true) { EmsHeadDO.Emsdrugs.Fg_self = !EmsHeadDO.Emsdrugs.Fg_outp; //ctlTotal.Enabled = true; gv.DataTable.Columns["Quan_cur"].ReadOnly = false; } else { gv.DataTable.Columns["Quan_cur"].ReadOnly = true; EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Quan_cur = null; //ctlTotal.Enabled = false; } break; case "Fg_treat": EmsHeadDO.Emsdrugs.Fg_propc = !EmsHeadDO.Emsdrugs.Fg_treat; break; case "Fg_propc": EmsHeadDO.Emsdrugs.Fg_treat = !EmsHeadDO.Emsdrugs.Fg_propc; break; case "Quan_cur": GetStockReqDTO reqDto = new GetStockReqDTO(); string id_mm = EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Id_mm; string id_dep_phy = EmsHeadDO.Emsdrugs.Id_dep; //reqDto.Id_dep = id_dep_phy; reqDto.Id_mm = id_mm; reqDto.Req_unit_id = EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Id_unit_sale; GetStockReqDTO[] reqDtoArr = new GetStockReqDTO[1]; reqDtoArr[0] = reqDto; MaterialStockDTO[] materialArr = cof.getMaterialStocksCount(reqDtoArr); if (materialArr != null && materialArr.Length > 0) { MaterialStockDTO material = materialArr[0]; if (material == null || material.Quan_stock == 0) { this.ShowInfo(EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Name_mm + "数量已超过库存量,无法开立!"); return; } } break; case "customercolumn_menu": this.setTime_cur(); setQauntum(this.EmsHeadDO.Emsdrugs.Times_cur); break; case "Name_routedes": if (!bEdit_Note_or) { cof.SetNoteOr(this.EmsHeadDO); } break; default: break; } updateTableCustomerComtrol(); }
void xapFormControl1_DataChanged(object sender, DataChangedEventArgs e) { switch (e.PropName) //计算结束日期 { case "Use_days": //医嘱天数 if (uday == "-1") { uday = ""; this.EmsHeadDO.Emsdrugs.Use_days = null; return; } if (this.EmsHeadDO.Emsdrugs.Use_days == null) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = null; return; } if (this.EmsHeadDO.Emsdrugs.Use_days == 0) { if (this.EmsHeadDO.Emsdrugs.Dt_end_ui != this.EmsHeadDO.Emsdrugs.Dt_begin_ui) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = this.EmsHeadDO.Emsdrugs.Dt_begin_ui; } return; } else if (this.EmsHeadDO.Emsdrugs.Use_days == -1 && this.EmsHeadDO.Emsdrugs.Dt_end_ui == null) { XLabelBaseUserRender tmpUserRender2 = sender as XLabelBaseUserRender; uday = "-1"; tmpUserRender2.ValueText = ""; //this.EmsHeadDO.Emsdrugs.Use_days = null; return; } else if (this.EmsHeadDO.Emsdrugs.Use_days == -1) { this.EmsHeadDO.Emsdrugs.Use_days = null; this.EmsHeadDO.Emsdrugs.Dt_end_ui = null; return; } else if (this.EmsHeadDO.Emsdrugs.Use_days > 0) { DateTime?endDateTime = cof.GetEndTime(this.EmsHeadDO.Emsdrugs.Dt_begin_ui, this.EmsHeadDO.Emsdrugs.Use_days.Value); if (this.EmsHeadDO.Emsdrugs.Dt_end_ui != endDateTime) { this.EmsHeadDO.Emsdrugs.Dt_end_ui = endDateTime; } } //取模 int?m = this.EmsHeadDO.Emsdrugs.Use_days % 7; //判断周期类型错误 //if (this.EmsHeadDO.Emsdrugs.Name_freq.IndexOf("周") > 0 && m % 7 != 0) if ((this.EmsHeadDO.Emsdrugs.Name_freq.IndexOf("周") > 0 || this.EmsHeadDO.Emsdrugs.Name_freq.IndexOf("星期") > 0) && m % 7 != 0) { if (m == 6 || m == 0) { //减的 int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = uu * 7; } else { int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = (uu + 1) * 7; } } uday = ""; break; case "Dt_end_ui": //计算医嘱天数 DateTime dtb = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_begin_ui; if (this.EmsHeadDO.Emsdrugs.Dt_end_ui == null) { return; } DateTime dte = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_end_ui; if (dtb.CompareTo(dte) > 0) { // e.Cancel = true; this.EmsHeadDO.Emsdrugs.Dt_end_ui = dtb; this.ShowInfo(OrdParam.MESSAGE_TIEMCHECK); return; } int?useDay = cof.GetUseDays(dtb, this.EmsHeadDO.Emsdrugs.Dt_end_ui); if (this.EmsHeadDO.Emsdrugs.Use_days != useDay) { this.EmsHeadDO.Emsdrugs.Use_days = useDay; } EmsOrDrug drug = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0]; break; case "Name_freq": //计算执行时刻1 if (e.Input != null && e.Input.ToString().Contains("日")) { cof.getControlByName(xapFormControl1, "drugsUse", "quan_firday_mp").Enabled = true; cof.getControlByName(xapFormControl1, "drugsUse", "work_time").Enabled = false; GetMpTimes(this.EmsHeadDO.Emsdrugs.Id_freq); } else if (e.Input != null && (e.Input.ToString().Contains("周") || e.Input.ToString().Contains("星期"))) { //取模 m = this.EmsHeadDO.Emsdrugs.Use_days % 7; if (m == 0 || m == 6) { //减的 int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = uu * 7; } else { int?uu = this.EmsHeadDO.Emsdrugs.Use_days / 7; this.EmsHeadDO.Emsdrugs.Use_days = (uu + 1) * 7; } } else { cof.getControlByName(xapFormControl1, "drugsUse", "quan_firday_mp").Enabled = false; cof.getControlByName(xapFormControl1, "drugsUse", "work_time").Enabled = false; } // 先于 OnRefResult(object sender, RefResultEventArgs e)执行,会出现 这个地方获取的id 是上次的 而不是最新的 break; case "Fg_long": if (e.Input.ToString() == "False") { cof.getControlByName(xapFormControl1, "drugsUse", "Use_days").Enabled = false; //临时 医嘱天数 不可输入 this.EmsHeadDO.Emsdrugs.Use_days = 1; } else { if (cof.getControlByName(xapFormControl1, "drugsUse", "Use_days") != null) { cof.getControlByName(xapFormControl1, "drugsUse", "Use_days").Enabled = true; } } break; case "Fg_self": break; //case "Fg_outp": // if (this.EmsHeadDO.Emsdrugs.Fg_outp == true) // { // //drug = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0]; // cof.GetDrugTotal(this.EmsHeadDO,true); // this.EmsHeadDO.Emsdrugs.Fg_self = !this.EmsHeadDO.Emsdrugs.Fg_outp; // //ctlTotal.Enabled = true; // gv.DataTable.Columns["Quan_cur"].ReadOnly = false; // gv.DataTable.Columns["Name_unit_sale"].ReadOnly = false; // manageUnitName("out"); // } // else // { // gv.DataTable.Columns["Quan_cur"].ReadOnly = true; // gv.DataTable.Columns["Name_unit_sale"].ReadOnly = true; // this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Quan_cur = null; // manageUnitName(""); // //ctlTotal.Enabled = false; // } //break; case "Fg_treat": this.EmsHeadDO.Emsdrugs.Fg_propc = !this.EmsHeadDO.Emsdrugs.Fg_treat; break; case "Fg_propc": this.EmsHeadDO.Emsdrugs.Fg_treat = !this.EmsHeadDO.Emsdrugs.Fg_propc; break; case "Quan_firday_mp": getWorkTime(); //if (cof.getControlByName(xapFormControl1,"drugsUse", "fg_outp").ValueText == "true") //{ // cof.GetDrugTotal(this.EmsHeadDO, true); //} break; case "Dt_begin_ui": //开始时间变化备用时间也发生变化 dtb = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_begin_ui; if (this.EmsHeadDO.Emsdrugs.Dt_end_ui != null) { dte = (DateTime)this.EmsHeadDO.Emsdrugs.Dt_end_ui; if (dte != null && dtb.CompareTo(dte) > 0) { // e.Cancel = true; this.EmsHeadDO.Emsdrugs.Dt_begin_ui = dte; this.ShowInfo(OrdParam.MESSAGE_TIEMCHECK); return; } } useDay = cof.GetUseDays(dtb, this.EmsHeadDO.Emsdrugs.Dt_end_ui); if (this.EmsHeadDO.Emsdrugs.Use_days != useDay) { this.EmsHeadDO.Emsdrugs.Use_days = useDay; } drug = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0]; //if (cof.getControlByName(xapFormControl1,"drugsUse", "fg_outp").ValueText == "true") //{ // drug.Quan_cur = cof.GetDrugUseTotalCount(this.EmsHeadDO); // cof.GetDrugTotal(this.EmsHeadDO,true); //} if (this.EmsHeadDO.Emsdrugs.Dt_fail != null) { //备用药结束时间 this.EmsHeadDO.Emsdrugs.Dt_fail = cof.GetSpareEndTime(this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value); dt_fail.MinDate = this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value.AddDays(-1); dt_fail.MaxDate = this.EmsHeadDO.Emsdrugs.Dt_begin_ui.Value.AddHours(this.Context.GetOrgParam <int>(ICiOrdNSysParamConst.SYS_PARAM_TemporaryPrnOrValidTime)); } break; case "Quan_cur": GetStockReqDTO reqDto = new GetStockReqDTO(); string id_mm = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Id_mm; string id_dep_phy = this.EmsHeadDO.Emsdrugs.Id_dep; reqDto.Id_dep = id_dep_phy; reqDto.Id_mm = id_mm; reqDto.Req_unit_id = this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Id_unit_sale; GetStockReqDTO[] reqDtoArr = new GetStockReqDTO[1]; reqDtoArr[0] = reqDto; try { MaterialStockDTO[] materialArr = cof.getMaterialStocksCount(reqDtoArr); if (materialArr != null && materialArr.Length > 0) { MaterialStockDTO material = materialArr[0]; if (material == null || material.Quan_stock < this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Quan_cur) { this.ShowInfo(this.EmsHeadDO.Emsdrugs.EmsOrDrugList[0].Name_mm + "数量已超过库存量,无法开立!"); return; } } } catch //(Exception ex) { } break; case "Quan_med": //if (cof.getControlByName(xapFormControl1, "drugsUse", "fg_outp").ValueText == "true") //{ // cof.GetDrugTotal(this.EmsHeadDO, true); //} break; default: break; } }