Пример #1
0
        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();
        }