/// <summary>
        /// 根据交款ID得到结算交款表对象
        /// </summary>
        /// <param name="rpt">结算交款表对象</param>
        /// <param name="Accountid">交款ID</param>
        public void GetAccountRptInfo(AbstractCostAccountRpt rpt, int Accountid)
        {
            ZY_Account zyAccount = new ZY_Account();

            zyAccount = zyAccount.GetAccount(Accountid);
            rpt.医院名称  = HIS.SYSTEM.BussinessLogicLayer.Classes.BaseData.WorkName + "住院每日缴款清单";
            rpt.交款人   = zyAccount.AccountName;
            rpt.交款时间  = zyAccount.AccountDate.ToString();

            #region 发票项目
            DataTable dt       = zyAccount.GetTicketTotle(Accountid);
            decimal   AllKMFee = 0;
            //dt = null;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                AllKMFee += Convert.ToDecimal(dt.Rows[i]["Tolal_Fee"]);
            }


            #endregion
            rpt.发票项目   = dt;
            rpt.发票科目合计 = AllKMFee.ToString();
            List <ZY_CostMaster> zy_CML = zyAccount.GetCostData(Accountid);
            if (zy_CML != null && zy_CML.Count > 0)
            {
                #region 收费票据

                rpt.收费发票开始号 = zy_CML[0].TicketCode;
                rpt.收费发票结束号 = zy_CML[zy_CML.Count - 1].TicketCode;
                rpt.收费发票张数  = zy_CML.Count.ToString();
                List <ZY_CostMaster> zy_CMLx = zy_CML.FindAll(delegate(ZY_CostMaster x) { return(x.Record_Flag == 2); });
                rpt.收费退费张数 = zy_CMLx.Count.ToString();
                rpt.收费退费金额 = zy_CMLx.Sum(x => x.Total_Fee).ToString();
                rpt.废票张数   = zyAccount.GetBadTicketCount(Accountid).ToString();
                #endregion

                #region 记账部分
                DataTable             dt1  = BaseDataFactory.GetData(baseDataType.病人类型);
                List <AccountPatType> apts = new List <AccountPatType>();
                AccountPatType        apt;
                int AllNum = 0;
                for (int i = 0; i < dt1.Rows.Count; i++)
                {
                    List <ZY_CostMaster> zy_CMLy = zy_CML.FindAll(delegate(ZY_CostMaster y) { return(y.PatType.Trim() == dt1.Rows[i]["code"].ToString()); });
                    apt          = new AccountPatType();
                    apt.TypeName = dt1.Rows[i]["name"].ToString();
                    apt.CostNum  = zy_CMLy.Count.ToString();
                    apt.CostFee  = zy_CMLy.Sum(x => x.NotWorkUnit_Fee).ToString();
                    apts.Add(apt);
                    AllNum += zy_CMLy.Count;
                }

                apt = new AccountPatType();
                //单位
                List <ZY_CostMaster> zy_CMLy5 = zy_CML.FindAll(delegate(ZY_CostMaster y) { return(y.WorkUnit_Fee != 0); });
                apt.TypeName = "单位";
                apt.CostNum  = zy_CMLy5.Count.ToString();
                apt.CostFee  = zy_CMLy5.Sum(y => y.WorkUnit_Fee).ToString();
                apts.Add(apt);
                //合计
                apt          = new AccountPatType();
                apt.TypeName = "合计";
                apt.CostNum  = (AllNum + zy_CMLy5.Count).ToString();
                apt.CostFee  = zy_CML.Sum(y => y.Village_Fee).ToString();
                apts.Add(apt);

                rpt.记账内容 = apts.ToArray();

                #endregion

                #region 收现金

                rpt.优惠金额 = zy_CML.Sum(z => z.Favor_Fee).ToString();
                rpt.应收金额 = zy_CML.Sum(z => z.Self_Fee).ToString();
                rpt.预收金额 = zy_CML.Sum(z => z.Deptosit_Fee).ToString();
                decimal decR = zy_CML.Sum(z => z.Reality_Fee);
                //补收
                List <ZY_CostMaster> zy_CML11 = zy_CML.FindAll(delegate(ZY_CostMaster y) { return(y.Reality_Fee > 0); });
                //补退
                List <ZY_CostMaster> zy_CML22 = zy_CML.FindAll(delegate(ZY_CostMaster y) { return(y.Reality_Fee < 0); });
                //欠费
                List <ZY_CostMaster> zy_CML33 = zy_CML.FindAll(delegate(ZY_CostMaster y) { return(y.Ntype == 3); });

                rpt.补收金额 = zy_CML11.Sum(x => x.Reality_Fee).ToString("0.00");
                rpt.补退金额 = (0 - zy_CML22.Sum(x => x.Reality_Fee)).ToString("0.00");
                rpt.实收金额 = decR.ToString();
                rpt.小写合计 = decR.ToString();
                rpt.大写合计 = decR.ToString();

                List <ZY_ChargeList> zy_cl = zyAccount.GetChargeListData(Accountid);
                //现金
                List <ZY_ChargeList> zy_cl0 = zy_cl.FindAll(x => x.FeeType == 0);
                //POS
                List <ZY_ChargeList> zy_cl1 = zy_cl.FindAll(x => x.FeeType == 1);
                rpt.预交金现金   = zy_cl0.Sum(x => x.Total_Fee).ToString();
                rpt.预交金POS  = zy_cl1.Sum(x => x.Total_Fee).ToString();
                rpt.补收金额现金  = zy_CML11.Sum(x => x.Money_Fee).ToString();
                rpt.补收金额POS = zy_CML11.Sum(x => x.Pos_Fee).ToString();
                rpt.费金额     = zy_CML33.Sum(x => (x.Self_Fee - x.Deptosit_Fee)).ToString();
                #endregion
            }
        }
Ejemplo n.º 2
0
        private void GetCostData()
        {
            #region 第四步:结算的DataGrid数据
            costAllData.CostData = HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjToDataTable(zyAccountSonlistCost);

            List <ZY_CostMaster> zyCostlistW      = AccountIDCost.Count > 0 ? zyAccount.GetCostData(AccountIDCost.ToArray(), 0) : (new List <ZY_CostMaster>());
            List <ZY_CostMaster> zyCostlistB      = AccountIDCost.Count > 0 ? zyAccount.GetCostData(AccountIDCost.ToArray(), 1) : (new List <ZY_CostMaster>());
            List <ZY_ChargeList> zyChargelistCost = AccountIDCost.Count > 0 ? zyAccount.GetChargeData(AccountIDCost.ToArray(), 2) : (new List <ZY_ChargeList>());
            if (AccountIDCost.Count > 0)
            {
                DataTable TypeCostData = zyAccount.GetBIGItemData(AccountIDCost.ToArray());
                DataRow   dr           = TypeCostData.NewRow();
                dr["itemname"] = "合计";
                decimal dec = 0;
                for (int i = 0; i < TypeCostData.Rows.Count; i++)
                {
                    dec += Convert.ToDecimal(TypeCostData.Rows[i]["total_fee"]);
                }
                dr["total_fee"] = dec;
                TypeCostData.Rows.Add(dr);//汇总
                costAllData.TypeCostData = TypeCostData;
            }
            else
            {
                costAllData.TypeCostData = null;
            }
            List <ZY_CostMaster> zyCostlistSonW  = new List <ZY_CostMaster>();
            List <ZY_CostMaster> zyCostlistSonB  = new List <ZY_CostMaster>();
            List <ZY_ChargeList> zyChargeSonCost = new List <ZY_ChargeList>();
            for (int i = 0; i < zyCostlistW.Count; i++)
            {
                ZY_CostMaster zyCostlistson = zyCostlistW[i];
                zyCostlistson.UserName = BaseNameFactory.GetName(baseNameType.用户名称, zyCostlistson.ChargeCode);
                zyCostlistSonW.Add(zyCostlistson);
            }
            //汇总
            ZY_CostMaster zyCostlistSonW1 = new ZY_CostMaster();
            zyCostlistSonW1.TicketNum   = "合计";
            zyCostlistSonW1.Total_Fee   = zyCostlistSonW.Sum(x => x.Total_Fee);
            zyCostlistSonW1.Reality_Fee = zyCostlistSonW.Sum(x => x.Reality_Fee);
            zyCostlistSonW1.Village_Fee = zyCostlistSonW.Sum(x => x.Village_Fee);
            zyCostlistSonW1.Favor_Fee   = zyCostlistSonW.Sum(x => x.Favor_Fee);
            zyCostlistSonW.Add(zyCostlistSonW1);

            costAllData.GoodCostList = HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjToDataTable(zyCostlistSonW);

            for (int i = 0; i < zyCostlistB.Count; i++)
            {
                ZY_CostMaster zyCostlistson = zyCostlistB[i];
                zyCostlistson.UserName = BaseNameFactory.GetName(baseNameType.用户名称, zyCostlistson.ChargeCode);
                zyCostlistSonB.Add(zyCostlistson);
            }
            //汇总
            ZY_CostMaster zyCostlistSonB1 = new ZY_CostMaster();
            zyCostlistSonB1.TicketNum   = "合计";
            zyCostlistSonB1.Total_Fee   = zyCostlistSonB.Sum(x => x.Total_Fee);
            zyCostlistSonB1.Reality_Fee = zyCostlistSonB.Sum(x => x.Reality_Fee);
            zyCostlistSonB1.Village_Fee = zyCostlistSonB.Sum(x => x.Village_Fee);
            zyCostlistSonB1.Favor_Fee   = zyCostlistSonB.Sum(x => x.Favor_Fee);
            zyCostlistSonB.Add(zyCostlistSonB1);

            costAllData.BadCostList = HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjToDataTable(zyCostlistSonB);

            for (int i = 0; i < zyChargelistCost.Count; i++)
            {
                ZY_ChargeList zyChargelistson = zyChargelistCost[i];
                zyChargelistson.ChargeUserName = BaseNameFactory.GetName(baseNameType.用户名称, zyChargelistson.ChargeCode);
                zyChargeSonCost.Add(zyChargelistson);
            }
            //汇总
            ZY_ChargeList zyChargeSonCost1 = new ZY_ChargeList();
            zyChargeSonCost1.BillNo    = "合计";
            zyChargeSonCost1.Total_Fee = zyChargeSonCost.Sum(x => x.Total_Fee);
            zyChargeSonCost.Add(zyChargeSonCost1);

            costAllData.ChargeList = HIS.SYSTEM.PubicBaseClasses.ApiFunction.ObjToDataTable(zyChargeSonCost);

            costAllText.deptosit_fee = Convert.ToString(zyCostlistW.Sum(x => x.Deptosit_Fee) + zyCostlistB.Sum(x => x.Deptosit_Fee));
            costAllText.lbRoundFee   = Convert.ToString(Convert.ToDecimal(CostAllText.lbAllFee) - Convert.ToDecimal(CostAllText.deptosit_fee) - Convert.ToDecimal(CostAllText.AllFee));



            #endregion
        }