Example #1
0
        /// <summary>
        /// 确费
        /// </summary>
        /// <param name="presorders"></param>
        /// <param name="ConfirDoc"></param>
        /// <returns></returns>
        public override bool SaveConfir(List <int> presorders, int ConfirDoc, int ConfirDept)
        {
            try
            {
                if (presorders.Count == 0)
                {
                    return(false);
                }
                object obj = GetConfig();
                oleDb.BeginTransaction();
                for (int i = 0; i < presorders.Count; i++)
                {
                    HIS.Model.ZY_PresOrder presorder = BindEntity <HIS.Model.ZY_PresOrder> .CreateInstanceDAL(oleDb).GetModel(presorders[i]);

                    HIS.Model.Medical_Confir Confir = new HIS.Model.Medical_Confir();
                    Confir.Cancel_Flag = 0;
                    Confir.ConfirDate  = XcDate.ServerDateTime;
                    Confir.ConfirDept  = ConfirDept;
                    Confir.ConfirDoc   = ConfirDoc;
                    Confir.Mark_Flag   = 1;
                    Confir.PatListId   = presorder.PatListID;
                    Confir.PresOrderId = presorder.PresOrderID;
                    string strWhere = Tables.medical_confir.PRESORDERID + oleDb.EuqalTo() + presorder.PresOrderID + oleDb.And() + Tables.medical_confir.CANCEL_FLAG +
                                      oleDb.EuqalTo() + 0 + oleDb.And() + Tables.medical_confir.MARK_FLAG + oleDb.EuqalTo() + 1;
                    if (BindEntity <HIS.Model.Medical_Confir> .CreateInstanceDAL(oleDb).Exists(strWhere) || presorder.Record_Flag != 0)
                    {
                        continue;
                    }
                    BindEntity <HIS.Model.Medical_Confir> .CreateInstanceDAL(oleDb).Add(Confir);

                    if (obj == null || obj.ToString().Trim() == "1")    //2010.9.19 update by heyan
                    {
                        presorder.ExecDeptCode = ConfirDept.ToString(); //修改执行科室
                        BindEntity <HIS.Model.ZY_PresOrder> .CreateInstanceDAL(oleDb).Update(presorder);
                    }
                }
                oleDb.CommitTransaction();
                return(true);
            }
            catch (System.Exception e)
            {
                oleDb.RollbackTransaction();
                throw new Exception(e.Message);
            }
        }
Example #2
0
        public bool GetSendNumAndFee(DataTable drugMsgOrder)
        {
            //try
            //{
            //    if (drugMsgOrder == null) return false;
            //    for (int i = 0; i < drugMsgOrder.Rows.Count; i++)
            //    {
            //        int orderid = Convert.ToInt32(drugMsgOrder.Rows[i]["ORDERRECIPEID"]);
            //        decimal num = Convert.ToDecimal(drugMsgOrder.Rows[i]["DRUGNUM"]);
            //        if (num >= 0)
            //        {
            //            List<HIS.Model.ZY_PresOrder> zyPlist = BindEntity<HIS.Model.ZY_PresOrder>.CreateInstanceDAL(oleDb).GetListArray("CHARGE_FLAG=1 and DRUG_FLAG=0 and RECORD_FLAG in(0,1) and (PRESORDERID=" + orderid + " or oldid=" + orderid + ")");

            //            HIS.Model.ZY_PresOrder zyPL1 = zyPlist.Find(delegate(HIS.Model.ZY_PresOrder y) { return (y.OldID == 0 && y.Record_Flag == 0); });
            //            List<HIS.Model.ZY_PresOrder> zyPL2 = zyPlist.FindAll(delegate(HIS.Model.ZY_PresOrder y) { return (y.OldID != 0 && y.Record_Flag == 1); });
            //            if (zyPlist != null && zyPL1 != null && zyPL2 != null)
            //            {
            //                decimal amount = zyPL2.Sum(y => y.Amount);
            //                int presamount = zyPL2.Sum(y => y.PresAmount);
            //                decimal total_fee = zyPL2.Sum(y => y.Tolal_Fee);

            //                zyPL1.Amount += amount;
            //                zyPL1.PresAmount += presamount;
            //                //zyPL1.Tolal_Fee += total_fee;

            //                int SmallNum = Convert.ToInt32(zyPL1.Amount) % Convert.ToInt32(zyPL1.RelationNum);
            //                int BigNum = Convert.ToInt32((zyPL1.Amount - SmallNum) / zyPL1.RelationNum);
            //                decimal fee = BigNum * zyPL1.Sell_Price + SmallNum * zyPL1.Sell_Price / zyPL1.RelationNum;
            //                drugMsgOrder.Rows[i]["DRUGNUM"] = zyPL1.Amount;
            //                drugMsgOrder.Rows[i]["RECIPENUM"] = zyPL1.PresAmount;
            //                drugMsgOrder.Rows[i]["RETAILFEE"] = fee;
            //            }
            //        }
            //        else
            //        {
            //            bool b = BindEntity<HIS.Model.ZY_PresOrder>.CreateInstanceDAL(oleDb).Exists("CHARGE_FLAG=1 and DRUG_FLAG=1 and RECORD_FLAG =2 and  oldid=" + orderid + "");
            //            if (b)
            //            {
            //                drugMsgOrder.Rows[i]["DRUGNUM"] = 0;
            //                drugMsgOrder.Rows[i]["RECIPENUM"] = 1;
            //                drugMsgOrder.Rows[i]["RETAILFEE"] = 0;
            //            }
            //            else
            //            {
            //                int RelationNum = Convert.ToInt32(drugMsgOrder.Rows[i]["UNITNUM"]);
            //                decimal Sell_Price = Convert.ToDecimal(drugMsgOrder.Rows[i]["RETAILPRICE"]);
            //                int SmallNum = Convert.ToInt32(num) % Convert.ToInt32(RelationNum);
            //                int BigNum = Convert.ToInt32((num - SmallNum) / RelationNum);
            //                decimal fee = BigNum * Sell_Price + SmallNum * Sell_Price / RelationNum;
            //                drugMsgOrder.Rows[i]["DRUGNUM"] = num;
            //                drugMsgOrder.Rows[i]["RECIPENUM"] = 1;
            //                drugMsgOrder.Rows[i]["RETAILFEE"] = fee;
            //            }
            //        }
            //    }
            //    return true;
            //}
            //catch (Exception e)
            //{
            //    throw e;
            //}
            try
            {
                if (drugMsgOrder == null)
                {
                    return(false);
                }
                for (int i = 0; i < drugMsgOrder.Rows.Count; i++)
                {
                    int     orderid = Convert.ToInt32(drugMsgOrder.Rows[i]["ORDERRECIPEID"]);
                    decimal num     = Convert.ToDecimal(drugMsgOrder.Rows[i]["DRUGNUM"]);
                    if (num >= 0)
                    {
                        List <HIS.Model.ZY_PresOrder> zyPlist = BindEntity <HIS.Model.ZY_PresOrder> .CreateInstanceDAL(oleDb).GetListArray("CHARGE_FLAG=1 and DRUG_FLAG=0 and RECORD_FLAG in(0,1) and (PRESORDERID=" + orderid + " or oldid=" + orderid + ")");

                        HIS.Model.ZY_PresOrder        zyPL1 = zyPlist.Find(delegate(HIS.Model.ZY_PresOrder y) { return(y.OldID == 0 && y.Record_Flag == 0); });
                        List <HIS.Model.ZY_PresOrder> zyPL2 = zyPlist.FindAll(delegate(HIS.Model.ZY_PresOrder y) { return(y.OldID != 0 && y.Record_Flag == 1); });

                        //已经发药(控制并发问题)
                        if (zyPlist.Count == 0)
                        {
                            drugMsgOrder.Rows[i]["DRUGNUM"]   = 0;
                            drugMsgOrder.Rows[i]["RECIPENUM"] = 0;
                            drugMsgOrder.Rows[i]["RETAILFEE"] = 0;
                        }
                        else if (zyPL1 != null && zyPL2 != null)
                        {
                            decimal amount     = zyPL2.Sum(y => y.Amount);
                            int     presamount = zyPL2.Sum(y => y.PresAmount);
                            decimal total_fee  = zyPL2.Sum(y => y.Tolal_Fee);

                            zyPL1.Amount     += amount;
                            zyPL1.PresAmount += presamount;
                            //zyPL1.Tolal_Fee += total_fee;

                            int     SmallNum = Convert.ToInt32(zyPL1.Amount) % Convert.ToInt32(zyPL1.RelationNum);
                            int     BigNum   = Convert.ToInt32((zyPL1.Amount - SmallNum) / zyPL1.RelationNum);
                            decimal fee      = BigNum * zyPL1.Sell_Price + SmallNum * zyPL1.Sell_Price / zyPL1.RelationNum;
                            drugMsgOrder.Rows[i]["DRUGNUM"]   = zyPL1.Amount;
                            drugMsgOrder.Rows[i]["RECIPENUM"] = zyPL1.PresAmount;
                            drugMsgOrder.Rows[i]["RETAILFEE"] = fee;
                        }
                    }
                    else
                    {
                        bool b = BindEntity <HIS.Model.ZY_PresOrder> .CreateInstanceDAL(oleDb).Exists("CHARGE_FLAG=1 and DRUG_FLAG=1 and RECORD_FLAG =1 and  PRESORDERID=" + orderid + "");

                        if (b == false)//已经退药(并发问题)
                        {
                            drugMsgOrder.Rows[i]["DRUGNUM"]   = 0;
                            drugMsgOrder.Rows[i]["RECIPENUM"] = 1;
                            drugMsgOrder.Rows[i]["RETAILFEE"] = 0;
                        }
                        else
                        {
                            b = BindEntity <HIS.Model.ZY_PresOrder> .CreateInstanceDAL(oleDb).Exists("CHARGE_FLAG=1 and DRUG_FLAG=1 and RECORD_FLAG =2 and  oldid=" + orderid + "");

                            if (b)//已经取消退药
                            {
                                drugMsgOrder.Rows[i]["DRUGNUM"]   = 0;
                                drugMsgOrder.Rows[i]["RECIPENUM"] = 1;
                                drugMsgOrder.Rows[i]["RETAILFEE"] = 0;
                            }
                            else
                            {
                                int     RelationNum = Convert.ToInt32(drugMsgOrder.Rows[i]["UNITNUM"]);
                                decimal Sell_Price  = Convert.ToDecimal(drugMsgOrder.Rows[i]["RETAILPRICE"]);
                                int     SmallNum    = Convert.ToInt32(num) % Convert.ToInt32(RelationNum);
                                int     BigNum      = Convert.ToInt32((num - SmallNum) / RelationNum);
                                decimal fee         = BigNum * Sell_Price + SmallNum * Sell_Price / RelationNum;
                                drugMsgOrder.Rows[i]["DRUGNUM"]   = num;
                                drugMsgOrder.Rows[i]["RECIPENUM"] = 1;
                                drugMsgOrder.Rows[i]["RETAILFEE"] = fee;
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                throw e;
            }
        }