Exemple #1
0
        public JsonResult GetApplySubList(int userID, int applyMainID = 0)
        {
            Thread.Sleep(500);
            LycJsonResult lycResult = new LycJsonResult();

            try
            {
                using (FDB = new FamilyCaiWuDBEntities())
                {
                    //查询出用户的银行信息
                    List <UserBank> ubList = FDB.UserBanks.Where(c => c.UserID == userID).ToList();

                    var result = (from s in FDB.Apply_Sub
                                  join sc in FDB.Apply_Sub_CashChange on s.ID equals sc.Apply_Sub_ID into ssc
                                  from left1 in ssc.DefaultIfEmpty()
                                  where s.ApplyMain_BillCode == applyMainID
                                  select new
                    {
                        ApplySubID = s.ID,
                        ApplyMainID = s.ApplyMain_BillCode,
                        CashOrBank = s.CashOrBank,
                        FlowTypeID = s.FlowTypeID,
                        FlowTypeName = s.FlowTypeName,
                        InoutType = s.InOutType,
                        FeeItemID = s.FeeItemID == null ? 0 : s.FeeItemID.Value,
                        FeeItemName = s.FeeItemName,
                        iMoney = s.iMoney,
                        UserBankID = s.UserBankID == null ? 0 : s.UserBankID.Value,
                        BChange = s.BChange,
                        InUserBankID = left1.InUserBankID == null ? 0 : left1.InUserBankID.Value,
                        OutUserBankID = left1.OutUserBankID == null ? 0 : left1.OutUserBankID.Value,
                        CAdd = s.CAdd,
                        CreateDate_date = s.CreateDate.Value
                    }).ToList();
                    List <QueryApplySubModel> list = new List <QueryApplySubModel>();
                    foreach (var s in result)
                    {
                        QueryApplySubModel asm = new QueryApplySubModel();
                        asm.CreateDate      = s.CreateDate_date.ToString("yyyy-MM-dd");
                        asm.ApplySubID      = s.ApplySubID;
                        asm.ApplyMainID     = s.ApplyMainID;
                        asm.CashOrBank      = s.CashOrBank;
                        asm.FlowTypeID      = s.FlowTypeID;
                        asm.FlowTypeName    = s.FlowTypeName;
                        asm.InoutType       = s.InoutType;
                        asm.FeeItemID       = s.FeeItemID;
                        asm.FeeItemName     = s.FeeItemName;
                        asm.iMoney          = s.iMoney.ToString();
                        asm.UserBankID      = s.UserBankID;
                        asm.UserBankName    = "";
                        asm.BChange         = s.BChange;
                        asm.InUserBankID    = s.InUserBankID;
                        asm.InUserBankName  = "";
                        asm.OutUserBankID   = s.OutUserBankID;
                        asm.OutUserBankName = "";
                        asm.CAdd            = s.CAdd;
                        foreach (var bank in ubList)
                        {
                            if (asm.UserBankID == bank.ID)
                            {
                                asm.UserBankName = bank.BankName;
                            }
                            if (asm.InUserBankID == bank.ID)
                            {
                                asm.InUserBankName = bank.BankName;
                            }
                            if (asm.OutUserBankID == bank.ID)
                            {
                                asm.OutUserBankName = bank.BankName;
                            }
                        }
                        list.Add(asm);
                    }
                    lycResult.Data = new JsonResultModel(true, "账单明细成功!", list);
                }
            }
            catch
            {
                lycResult.Data = new JsonResultModel(false, "账单查询失败!", new object { });
            }
            return(lycResult);
        }
        public JsonResult GetApplySubList(int userID, int applyMainID = 0)
        {
            Thread.Sleep(500);
            LycJsonResult lycResult = new LycJsonResult();
            try
            {
                using (FDB = new FamilyCaiWuDBEntities())
                {
                    //查询出用户的银行信息
                    List<UserBank> ubList = FDB.UserBanks.Where(c => c.UserID == userID).ToList();

                    var result = (from s in FDB.Apply_Sub
                                    join sc in FDB.Apply_Sub_CashChange on s.ID equals sc.Apply_Sub_ID into ssc
                                    from left1 in ssc.DefaultIfEmpty()
                                    where s.ApplyMain_BillCode == applyMainID
                                    select new
                                    {
                                        ApplySubID = s.ID,
                                        ApplyMainID = s.ApplyMain_BillCode,
                                        CashOrBank = s.CashOrBank,
                                        FlowTypeID = s.FlowTypeID,
                                        FlowTypeName = s.FlowTypeName,
                                        InoutType = s.InOutType,
                                        FeeItemID = s.FeeItemID == null ? 0 : s.FeeItemID.Value,
                                        FeeItemName = s.FeeItemName,
                                        iMoney = s.iMoney,
                                        UserBankID = s.UserBankID == null ? 0 : s.UserBankID.Value,
                                        BChange = s.BChange,
                                        InUserBankID = left1.InUserBankID == null ? 0 : left1.InUserBankID.Value,
                                        OutUserBankID = left1.OutUserBankID == null ? 0 : left1.OutUserBankID.Value,
                                        CAdd = s.CAdd,
                                        CreateDate_date = s.CreateDate.Value
                                    }).ToList();
                    List<QueryApplySubModel> list = new List<QueryApplySubModel>();
                    foreach (var s in result)
                    {
                        QueryApplySubModel asm = new QueryApplySubModel();
                        asm.CreateDate = s.CreateDate_date.ToString("yyyy-MM-dd");
                        asm.ApplySubID = s.ApplySubID;
                        asm.ApplyMainID = s.ApplyMainID;
                        asm.CashOrBank = s.CashOrBank;
                        asm.FlowTypeID = s.FlowTypeID;
                        asm.FlowTypeName = s.FlowTypeName;
                        asm.InoutType = s.InoutType;
                        asm.FeeItemID = s.FeeItemID;
                        asm.FeeItemName = s.FeeItemName;
                        asm.iMoney = s.iMoney.ToString();
                        asm.UserBankID = s.UserBankID;
                        asm.UserBankName = "";
                        asm.BChange = s.BChange;
                        asm.InUserBankID = s.InUserBankID;
                        asm.InUserBankName = "";
                        asm.OutUserBankID = s.OutUserBankID;
                        asm.OutUserBankName = "";
                        asm.CAdd = s.CAdd;
                        foreach (var bank in ubList)
                        {
                            if (asm.UserBankID == bank.ID)
                            {
                                asm.UserBankName = bank.BankName;
                            }
                            if (asm.InUserBankID == bank.ID)
                            {
                                asm.InUserBankName = bank.BankName;
                            }
                            if (asm.OutUserBankID == bank.ID)
                            {
                                asm.OutUserBankName = bank.BankName;
                            }
                        }
                        list.Add(asm);
                    }
                    lycResult.Data = new JsonResultModel(true, "账单明细成功!", list);
                }
            }
            catch
            {
                lycResult.Data = new JsonResultModel(false, "账单查询失败!", new object { });
            }
            return lycResult;
        }