Exemple #1
0
        public void Save()
        {
            if (!this.Valid())
            {
                return;
            }

            Neusoft.HISFC.BizLogic.Pharmacy.Constant phaConsManager = new Neusoft.HISFC.BizLogic.Pharmacy.Constant();
            bool isManagerStore = phaConsManager.IsManageStore(this.phaOutManager.TargetDept.ID);

            if (!isManagerStore)
            {
                MessageBox.Show(Language.Msg(this.phaOutManager.TargetDept.Name + " 不管理库存,不能通过出库审批进行出库"), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DialogResult rs = MessageBox.Show(Language.Msg("确认向" + this.phaOutManager.TargetDept.Name + "进行出库操作吗?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (rs == DialogResult.No)
            {
                return;
            }

            this.dt.DefaultView.RowFilter = "1=1";
            for (int i = 0; i < this.dt.DefaultView.Count; i++)
            {
                this.dt.DefaultView[i].EndEdit();
            }

            DataTable dtAddMofity = this.dt.GetChanges(DataRowState.Added | DataRowState.Modified);

            if (dtAddMofity == null || dtAddMofity.Rows.Count <= 0)
            {
                return;
            }

            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在进行保存操作..请稍候");
            System.Windows.Forms.Application.DoEvents();

            #region 事务定义

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            Neusoft.HISFC.BizLogic.Pharmacy.Constant    phaCons      = new Neusoft.HISFC.BizLogic.Pharmacy.Constant();
            Neusoft.HISFC.BizProcess.Integrate.Pharmacy phaIntegrate = new Neusoft.HISFC.BizProcess.Integrate.Pharmacy();

            this.itemManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);

            #endregion

            DateTime sysTime = this.itemManager.GetDateTimeFromSysDateTime();

            string outListNO = "";

            this.alPrintData = new ArrayList();

            foreach (DataRow dr in dtAddMofity.Rows)
            {
                string key = dr["药品编码"].ToString() + dr["批号"].ToString();
                Neusoft.HISFC.Models.Pharmacy.Output output = this.hsOutData[key] as Neusoft.HISFC.Models.Pharmacy.Output;

                if (this.isUseMinUnit)                                                      //使用最小单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["实发数量"]);                       //实发数量
                }
                else                                                                        //使用包装单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["实发数量"]) * output.Item.PackQty; //实发数量
                }
                output.StoreQty     = output.StoreQty - output.Quantity;
                output.StoreCost    = output.StoreQty * output.Item.PriceCollection.RetailPrice / output.Item.PackQty;
                output.Memo         = dr["备注"].ToString();
                output.DrugedBillNO = "0";                                           //摆药单号 不能为空

                output.Operation.ExamOper.ID       = this.phaOutManager.OperInfo.ID; //审核人
                output.Operation.ExamOper.OperTime = sysTime;                        //审核日期
                output.Operation.ExamQty           = output.Quantity;                //审核数量
                output.Operation.Oper = output.Operation.ExamOper;                   //操作信息
                output.GetPerson      = this.phaOutManager.TargetPerson.ID;          //领药人

                output.State = "1";                                                  //状态 审批

                #region 对数据来源为申请的数据进行更新 对本次新添加的数据生成申请信息记录

                if (dr["数据来源"].ToString() == "1")
                {
                    Neusoft.HISFC.Models.Pharmacy.ApplyOut applyOut = this.hsApplyData[output.User02] as Neusoft.HISFC.Models.Pharmacy.ApplyOut;

                    if (outListNO == "")
                    {
                        outListNO = applyOut.BillNO;
                    }

                    decimal tempApproveQty = applyOut.Operation.ApproveQty;
                    applyOut.Operation = output.Operation;              //操作信息
                    //未选择审批标记 只记录本次待发送的数量 不扣库存处理
                    if (!NConvert.ToBoolean(dr["审批"]))
                    {
                        //数量累计
                        applyOut.Operation.ApproveQty = tempApproveQty + output.Quantity;
                        applyOut.State = "0";
                    }
                    else
                    {
                        applyOut.Operation.ApproveOper = output.Operation.Oper;
                        applyOut.State = "2";
                    }

                    // {EE05DA01-8969-404d-9A6B-EE8AD0BC1CD0}处理出库审批并发的问题
                    int resultApplyOut = this.itemManager.UpdateApplyOut(applyOut, true);
                    if (resultApplyOut == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("更新" + output.Item.Name + "出库申请信息时出错");
                        return;
                    }
                    if (resultApplyOut == 0)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("该" + output.Item.Name + "申请信息已改变,请重新获取申请信息");
                        return;
                    }
                }
                else
                {
                    #region 无申请记录 此时只需更改申请人 到底需不需要添加申请信息呢? 不需要

                    output.Operation.ApplyOper = output.Operation.Oper;     //申请人
                    output.Operation.ApplyQty  = output.Quantity;           //申请数量

                    #endregion
                }

                #endregion

                #region 获取单据号

                if (outListNO == "")
                {
                    // //{59C9BD46-05E6-43f6-82F3-C0E3B53155CB} 更改入库单号获取方式
                    outListNO = phaIntegrate.GetInOutListNO(this.phaOutManager.DeptInfo.ID, false);
                    if (outListNO == null)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("获取新出库单号出错" + phaIntegrate.Err);
                        return;
                    }
                }

                output.OutListNO = outListNO;

                #endregion

                #region 以下信息在每次添加新数据时自动生成

                output.PrivType   = this.phaOutManager.PrivType.ID;             //出库类型
                output.SystemType = this.phaOutManager.PrivType.Memo;           //系统类型
                output.StockDept  = this.phaOutManager.DeptInfo;                //当前科室
                output.TargetDept = this.phaOutManager.TargetDept;              //目标科室

                #endregion

                //非药柜科室向药柜出库 进行特殊处理
                if (!this.phaOutManager.IsStockArk && this.phaOutManager.IsTargetArk)
                {
                    if (this.itemManager.ArkOutput(output, this.phaOutManager.IsStockArk, this.phaOutManager.IsTargetArk, false, true) == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("出库保存发生错误" + this.itemManager.Err);
                        return;
                    }
                }
                else
                {
                    if (this.itemManager.Output(output, null, false) == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("出库保存发生错误" + this.itemManager.Err);
                        return;
                    }
                }

                this.alPrintData.Add(output);
            }

            Neusoft.FrameWork.Management.PublicTrans.Commit();

            Function.ShowMsg("保存成功");

            DialogResult rsPrint = MessageBox.Show(Language.Msg("是否打印出库单?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (rsPrint == DialogResult.Yes)
            {
                this.Print();
            }

            this.Clear();
        }
Exemple #2
0
        public void Save()
        {
            this.phaOutManager.Fp.StopCellEditing();

            if (!this.Valid())
            {
                return;
            }

            DialogResult rs = MessageBox.Show(Language.Msg("确认向" + this.phaOutManager.TargetDept.Name + "进行出库操作吗?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (rs == DialogResult.No)
            {
                return;
            }

            this.dt.DefaultView.RowFilter = "1=1";
            for (int i = 0; i < this.dt.DefaultView.Count; i++)
            {
                this.dt.DefaultView[i].EndEdit();
            }

            DataTable dtAddMofity = this.dt.GetChanges(DataRowState.Added | DataRowState.Modified);

            if (dtAddMofity == null || dtAddMofity.Rows.Count <= 0)
            {
                return;
            }

            this.phaOutManager.Fp.StopCellEditing();

            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在进行保存操作..请稍候");
            System.Windows.Forms.Application.DoEvents();

            #region 事务定义

            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            Neusoft.HISFC.BizLogic.Pharmacy.Constant    phaCons      = new Neusoft.HISFC.BizLogic.Pharmacy.Constant();
            Neusoft.HISFC.BizProcess.Integrate.Pharmacy phaIntegrate = new Neusoft.HISFC.BizProcess.Integrate.Pharmacy();

            //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance);
            //t.BeginTransaction();
            this.itemManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            //phaIntegrate.SetTrans(t.Trans);
            //phaCons.SetTrans(t.Trans);

            #endregion

            DateTime sysTime   = this.itemManager.GetDateTimeFromSysDateTime();
            string   outListNO = "";
            string   inListNO  = "";
            //判断领用科室是否管理库存
            bool isManagerStore = phaCons.IsManageStore(this.phaOutManager.TargetDept.ID);
            //如管理库存 则提示是否确认保存出库
            if (isManagerStore)
            {
                Neusoft.FrameWork.WinForms.Classes.Function.HideWaitForm();

                DialogResult rsResult = MessageBox.Show(Language.Msg(this.phaOutManager.TargetDept.Name + "管理库存。确认进行出库操作吗?\n出库时将直接更新对方库存"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (rsResult == DialogResult.No)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    return;
                }

                Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在进行保存操作..请稍候");
                System.Windows.Forms.Application.DoEvents();
            }

            //一般出库对应的入库记录
            Neusoft.HISFC.Models.Pharmacy.Input input = null;

            //-------原程序处理方式
            //    //如领用科室管理库存 则只处理出库记录、更新本科室库存 不处理入库记录和领药科室库存 待领药科室入库核准后才处理库存
            //    //如领药科室不管理库存 则处理出库记录、更新本科室库存,试用期间处理入库记录、更新领药科室库存
            //    //						正式使用后不处理入库记录和领药科室库存
            //    //只需对isManagerStore赋值改变 对下边入库记录处理的判断做下修改即可
            //    //更新领药科室库存的操作封装于入库函数内 和入库记录一同处理 可通过传入参数判断是否处理库存
            //-------新程序处理方式
            //      一般出库时,不管目标科室是不是管理库存,都直接设置出库记录状态为已核准。
            //                  目标科室管理库存时,对目标科室产生入库记录,状态为已核准
            //                  目标科室不管理库存时,对目标科室不产生入库记录

            this.alPrintData = new ArrayList();

            foreach (DataRow dr in dtAddMofity.Rows)
            {
                string key = dr["药品编码"].ToString() + dr["批号"].ToString();
                Neusoft.HISFC.Models.Pharmacy.Output output = this.hsOutData[key] as Neusoft.HISFC.Models.Pharmacy.Output;

                output.Operation.ExamOper.ID       = this.phaOutManager.OperInfo.ID; //审核人
                output.Operation.ExamOper.OperTime = sysTime;                        //审核日期
                output.Operation.Oper = output.Operation.ExamOper;                   //操作信息

                #region 对数据来源为申请的数据进行处理

                if (dr["数据来源"].ToString() == "1")
                {
                    Neusoft.HISFC.Models.Pharmacy.ApplyOut applyOut = this.hsApplyData[output.User02] as Neusoft.HISFC.Models.Pharmacy.ApplyOut;

                    applyOut.State     = "1";                   //状态 审批
                    applyOut.Operation = output.Operation;      //操作信息

                    if (this.itemManager.UpdateApplyOut(applyOut) == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("更新" + output.Item.Name + "出库申请信息时出错");
                        return;
                    }

                    if (outListNO == "")
                    {
                        outListNO = applyOut.BillNO;
                    }
                }

                #endregion

                #region 获取单据号

                if (outListNO == "")
                {
                    // //{59C9BD46-05E6-43f6-82F3-C0E3B53155CB} 更改入库单号获取方式
                    outListNO = phaIntegrate.GetInOutListNO(this.phaOutManager.DeptInfo.ID, false);
                    if (outListNO == null)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("获取新出库单号出错" + phaIntegrate.Err);
                        return;
                    }
                }

                output.OutListNO = outListNO;

                #endregion

                #region Output实体必要信息赋值

                if (this.isUseMinUnit)                                                      //使用最小单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["出库数量"]);                       //出库数量
                }
                else                                                                        //使用包装单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["出库数量"]) * output.Item.PackQty; //出库数量
                }
                output.StoreQty  = output.StoreQty - output.Quantity;
                output.StoreCost = output.StoreQty * output.Item.PriceCollection.RetailPrice / output.Item.PackQty;

                output.Operation.ExamQty = output.Quantity;                     //审核数量
                output.Memo         = dr["备注"].ToString();
                output.DrugedBillNO = "0";                                      //摆药单号 不能为空

                output.GetPerson = this.phaOutManager.TargetPerson.ID;          //领药人

                //----原数据处理方式
                //if (isManagerStore)             //目标(领用)科室管理库存
                //    output.State = "1";         //审核
                //else
                //    output.State = "2";         //核准
                //----现处理方式 对于一般出库 直接设置出库状态为2
                output.State = "2";

                if (this.isSpecialOut)          //特殊出库 直接更新状态为核准
                {
                    output.SpecialFlag = "1";
                    output.State       = "2";
                }

                if (output.State == "2")
                {
                    output.Operation.ApproveOper = output.Operation.Oper;
                }

                #endregion

                #region 以下信息在每次添加新数据时自动生成

                output.PrivType   = this.phaOutManager.PrivType.ID;             //出库类型
                output.SystemType = this.phaOutManager.PrivType.Memo;           //系统类型
                output.StockDept  = this.phaOutManager.DeptInfo;                //当前科室
                output.TargetDept = this.phaOutManager.TargetDept;              //目标科室

                #endregion

                #region 形成目标科室的入库记录

                #region 根据领药科室是否管理库存   在不管理库存的情况下才处理入库记录
                if (!this.isSpecialOut)
                {
                    input = new Neusoft.HISFC.Models.Pharmacy.Input();
                    //设置入库单号
                    if (inListNO == "")
                    {
                        // //{59C9BD46-05E6-43f6-82F3-C0E3B53155CB} 更改入库单号获取方式
                        inListNO = phaIntegrate.GetInOutListNO(this.phaOutManager.TargetDept.ID, false);
                        if (inListNO == null)
                        {
                            Neusoft.FrameWork.Management.PublicTrans.RollBack();
                            MessageBox.Show(Language.Msg("对目标库存科室插入入库记录时获取入库单号出错") + this.itemManager.Err);
                            return;
                        }
                    }

                    //获取关联权限类型 关联权限类型不存在时 设置为默认值
                    if (this.privJoinClass3 != null)
                    {
                        input.PrivType   = this.privJoinClass3.Class3Code;
                        input.SystemType = this.privJoinClass3.Class3MeaningCode;
                    }
                    else
                    {
                        input.PrivType   = "01";                                                                                //一般入库对应的用户类型
                        input.SystemType = "11";                                                                                //一般入库
                    }

                    input.State     = "2";                                              //已审批
                    input.StockDept = this.phaOutManager.TargetDept;                    //库存部门

                    input.TargetDept = this.phaOutManager.DeptInfo;                     //目标科室 供货单位

                    input.InListNO                    = inListNO;                       //入库单据号
                    input.OutListNO                   = outListNO;                      //出库单据号
                    input.Operation.ExamOper.ID       = this.phaOutManager.OperInfo.ID; //审批人
                    input.Operation.ExamOper.OperTime = sysTime;                        //审批日期

                    input.Operation.ApproveOper = input.Operation.ExamOper;
                    input.Operation.ApplyOper   = input.Operation.ExamOper;

                    decimal storeQty = 0;
                    if (this.itemManager.GetStorageNum(this.phaOutManager.TargetDept.ID, output.Item.ID, out storeQty) == -1)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        MessageBox.Show(Language.Msg("获取" + output.Item.Name + "库存数量时发生错误" + this.itemManager.Err));
                        return;
                    }
                    input.StoreQty = storeQty + output.Quantity;

                    //设置出库记录中对应的入库单据号
                    output.InListNO = inListNO;
                }
                else
                {
                    input = null;
                }
                #endregion

                #endregion


                //原处理方式 第三个参数始终传入False
                if (this.itemManager.Output(output, input, isManagerStore) == -1)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    Function.ShowMsg("出库保存发生错误" + this.itemManager.Err);
                    return;
                }

                this.alPrintData.Add(output);
            }

            Neusoft.FrameWork.Management.PublicTrans.Commit();

            //for (int i = 0; i < this.dt.DefaultView.Count; i++)
            //{
            //    this.dt.DefaultView[i].BeginEdit();
            //}

            Function.ShowMsg("保存成功");

            DialogResult rsPrint = MessageBox.Show(Language.Msg("是否打印出库单?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (rsPrint == DialogResult.Yes)
            {
                this.Print();
            }


            this.Clear();
        }
        public void Save()
        {
            if (!this.Valid())
            {
                return;
            }

            DialogResult rs = MessageBox.Show(Language.Msg("确认向" + this.phaOutManager.TargetDept.Name + "进行出库操作吗?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);

            if (rs == DialogResult.No)
            {
                return;
            }

            this.dt.DefaultView.RowFilter = "1=1";
            for (int i = 0; i < this.dt.DefaultView.Count; i++)
            {
                this.dt.DefaultView[i].EndEdit();
            }

            DataTable dtAddMofity = this.dt.GetChanges(DataRowState.Added | DataRowState.Modified);

            if (dtAddMofity == null || dtAddMofity.Rows.Count <= 0)
            {
                return;
            }

            Neusoft.FrameWork.WinForms.Classes.Function.ShowWaitForm("正在进行保存操作..请稍候");
            System.Windows.Forms.Application.DoEvents();

            #region 事务定义
            Neusoft.FrameWork.Management.PublicTrans.BeginTransaction();

            Neusoft.HISFC.BizLogic.Pharmacy.Constant    phaCons      = new Neusoft.HISFC.BizLogic.Pharmacy.Constant();
            Neusoft.HISFC.BizProcess.Integrate.Pharmacy phaIntegrate = new Neusoft.HISFC.BizProcess.Integrate.Pharmacy();

            //Neusoft.FrameWork.Management.Transaction t = new Neusoft.FrameWork.Management.Transaction(Neusoft.FrameWork.Management.Connection.Instance);
            //t.BeginTransaction();
            this.itemManager.SetTrans(Neusoft.FrameWork.Management.PublicTrans.Trans);
            //phaIntegrate.SetTrans(t.Trans);
            //phaCons.SetTrans(t.Trans);

            #endregion

            DateTime sysTime = this.itemManager.GetDateTimeFromSysDateTime();
            //判断领用科室是否管理库存
            string outListNO      = "";
            bool   isManagerStore = phaCons.IsManageStore(this.phaOutManager.TargetDept.ID);

            this.alPrintData = new ArrayList();

            //均价出库 只扣减本科室库存 以购入价乘以百分比做为均价出库
            foreach (DataRow dr in dtAddMofity.Rows)
            {
                string key = dr["药品编码"].ToString() + dr["批号"].ToString();
                Neusoft.HISFC.Models.Pharmacy.Output output = this.hsOutData[key] as Neusoft.HISFC.Models.Pharmacy.Output;

                output.Operation.ExamOper.ID       = this.phaOutManager.OperInfo.ID; //审核人
                output.Operation.ExamOper.OperTime = sysTime;                        //审核日期
                output.Operation.Oper = output.Operation.ExamOper;                   //操作信息

                #region 获取单据号

                if (outListNO == "")
                {
                    // //{59C9BD46-05E6-43f6-82F3-C0E3B53155CB} 更改入库单号获取方式
                    outListNO = phaIntegrate.GetInOutListNO(this.phaOutManager.DeptInfo.ID, false);
                    if (outListNO == null)
                    {
                        Neusoft.FrameWork.Management.PublicTrans.RollBack();
                        Function.ShowMsg("获取新出库单号出错" + phaIntegrate.Err);
                        return;
                    }
                }

                output.OutListNO = outListNO;

                #endregion

                #region Output实体必要信息赋值

                if (this.isUseMinUnit)                                                      //使用最小单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["出库数量"]);                       //出库数量
                }
                else                                                                        //使用包装单位
                {
                    output.Quantity = NConvert.ToDecimal(dr["出库数量"]) * output.Item.PackQty; //出库数量
                }
                output.StoreQty  = output.StoreQty - output.Quantity;
                output.StoreCost = output.StoreQty * output.Item.PriceCollection.RetailPrice / output.Item.PackQty;

                output.Operation.ExamQty = output.Quantity;                     //审核数量
                output.Memo         = dr["备注"].ToString();
                output.DrugedBillNO = "0";                                      //摆药单号 不能为空

                output.GetPerson = this.phaOutManager.TargetPerson.ID;          //领药人

                //状态固定赋值为2
                output.State = "2";         //核准
                output.Operation.ApproveOper = output.Operation.Oper;

                #endregion

                #region 以下信息在每次添加新数据时自动生成

                output.PrivType   = this.phaOutManager.PrivType.ID;             //出库类型
                output.SystemType = this.phaOutManager.PrivType.Memo;           //系统类型
                output.StockDept  = this.phaOutManager.DeptInfo;                //当前科室
                output.TargetDept = this.phaOutManager.TargetDept;              //目标科室

                #endregion

                if (this.itemManager.Output(output, null, false) == -1)
                {
                    Neusoft.FrameWork.Management.PublicTrans.RollBack();
                    Function.ShowMsg("出库保存发生错误" + this.itemManager.Err);
                    return;
                }

                this.alPrintData.Add(output);
            }

            Neusoft.FrameWork.Management.PublicTrans.Commit();

            Function.ShowMsg("保存成功");

            DialogResult rsPrint = MessageBox.Show(Language.Msg("是否打印出库单?"), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (rsPrint == DialogResult.Yes)
            {
                this.Print();
            }

            this.Clear();
        }