public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            Sys_FunctionMaster_fum_Info info = null;
            try
            {
                info = KeyObject as Sys_FunctionMaster_fum_Info;
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    Sys_FunctionMaster_fum fum = db.Sys_FunctionMaster_fum.Single<Sys_FunctionMaster_fum>(i => i.fum_iRecordID == info.fum_iRecordID);

                    //for (int i = 0; i < fum.Sys_FormPurview_frps.Count; i++)
                    //{
                    //    Sys_FormPurview_frp sta = fum.Sys_FormPurview_frps[i];
                    //    db.Sys_FormPurview_frps.DeleteOnSubmit(sta);
                    //}

                    db.Sys_FunctionMaster_fum.DeleteOnSubmit(fum);
                    db.SubmitChanges();
                    return true;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            DepartmentMaster_dpm_Info searchInfo = KeyObject as DepartmentMaster_dpm_Info;
            if (searchInfo == null)
            {
                rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                rvInfo.isError = true;
                return rvInfo;
            }
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    List<DepartmentMaster_dpm> listDept = db.DepartmentMaster_dpm.Where(x => x.dpm_RecordID == searchInfo.dpm_RecordID).ToList();

                    if (listDept != null)
                    {
                        db.DepartmentMaster_dpm.DeleteAllOnSubmit(listDept);
                        db.SubmitChanges();
                        rvInfo.boolValue = true;
                    }
                }
            }
            catch (Exception ex)
            {
                rvInfo.messageText = ex.Message;
                rvInfo.isError = true;
            }
            return rvInfo;
        }
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);

            PaymentUDMealState_pms_Info deleteInfo = KeyObject as PaymentUDMealState_pms_Info;

            if (deleteInfo != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        PaymentUDMealState_pms deleteData = db.PaymentUDMealState_pms.FirstOrDefault(t => t.pms_cRecordID == deleteInfo.pms_cRecordID);

                        if (deleteData != null)
                        {
                            db.PaymentUDMealState_pms.DeleteOnSubmit(deleteData);

                            db.SubmitChanges();

                            returnInfo.boolValue = true;
                        }
                    }
                }
                catch (Exception Ex)
                {

                    returnInfo.messageText = Ex.Message;
                }
            }

            return returnInfo;
        }
        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            Sys_RoleMaster_rlm_Info info = null;
            try
            {
                info = KeyObject as Sys_RoleMaster_rlm_Info;
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    Sys_RoleMaster_rlm rlm = db.Sys_RoleMaster_rlm.Single<Sys_RoleMaster_rlm>(i => i.rlm_iRecordID == info.rlm_iRecordID);

                    for (int i = 0; i < rlm.Sys_UserRoles_usr.Count; i++)
                    {
                        Sys_UserRoles_usr sta = rlm.Sys_UserRoles_usr[i];
                        db.Sys_UserRoles_usr.DeleteOnSubmit(sta);
                    }

                    db.Sys_RoleMaster_rlm.DeleteOnSubmit(rlm);
                    db.SubmitChanges();
                    return true;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
        public ReturnValueInfo BatchDeleteRecords(PaymentUDGeneralSetting_pus_Info searchInfo)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();

            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    List<PaymentUDGeneralSetting_pus> searchData = db.PaymentUDGeneralSetting_pus.Where(x => 1 == 1).ToList();
                    PaymentUDGeneralSetting_pus_Info query = searchInfo as PaymentUDGeneralSetting_pus_Info;

                    if (query != null)
                    {
                        if (query.pus_cCardUserID != null)
                        {
                            searchData = searchData.Where(t => t.pus_cCardUserID == query.pus_cCardUserID).ToList();
                        }
                        if (query.pus_cClassID != null)
                        {
                            searchData = searchData.Where(t => t.pus_cClassID == query.pus_cClassID).ToList();
                        }
                        if (query.pus_cGradeID != null)
                        {
                            searchData = searchData.Where(t => t.pus_cGradeID == query.pus_cGradeID).ToList();
                        }
                        if (query.pus_iWeek != null && query.pus_iWeek != -1)
                        {
                            searchData = searchData.Where(t => t.pus_iWeek == query.pus_iWeek).ToList();
                        }
                    }
                    else
                    {
                        rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                        return rvInfo;
                    }

                    db.PaymentUDGeneralSetting_pus.DeleteAllOnSubmit(searchData);
                    db.SubmitChanges();
                    rvInfo.boolValue = true;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
Exemple #6
0
 public bool SaveRecord(Sys_UserMaster_usm_Info infoObj)
 {
     try
     {
         using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
         {
             LinqToSQLModel.Sys_UserMaster_usm newTab = Common.General.CopyObjectValue<Sys_UserMaster_usm_Info, LinqToSQLModel.Sys_UserMaster_usm>(infoObj);
             db.Sys_UserMaster_usm.InsertOnSubmit(newTab);
             db.SubmitChanges();
         }
         return true;
     }
     catch
     {
         throw;
     }
 }
        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            Sys_FormMaster_fom_Info info = null;
            try
            {
                info = KeyObject as Sys_FormMaster_fom_Info;
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    Sys_FormMaster_fom frm = db.Sys_FormMaster_fom.Single<Sys_FormMaster_fom>(i => i.fom_iRecordID == info.fom_iRecordID);

                    for (int i = 0; i < frm.Sys_FormPurview_frp.Count; i++)
                    {
                        Sys_FormPurview_frp sta = frm.Sys_FormPurview_frp[i];
                        db.Sys_FormPurview_frp.DeleteOnSubmit(sta);
                    }

                    if (frm != null)
                    {
                        frm.fom_lVaild = false;

                        IEnumerable<Sys_FormMaster_fom> subMenu = from t in db.Sys_FormMaster_fom
                                                                  where t.fom_iParentID == frm.fom_iRecordID
                                                                  select t;

                        if (subMenu != null && subMenu.Count() > 0)
                        {
                            foreach (Sys_FormMaster_fom item in subMenu)
                            {
                                item.fom_lVaild = false;
                            }
                        }
                    }
                    //db.Sys_FormMaster_fom.DeleteOnSubmit(frm);
                    db.SubmitChanges();
                    return true;
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
        }
Exemple #8
0
        public bool DeleteRecord(int id)
        {
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    var ret_usm = from usm in db.Sys_UserMaster_usm where usm.usm_iRecordID == id select usm;

                    if (ret_usm.Count() > 0)
                    {
                        db.Sys_UserMaster_usm.DeleteAllOnSubmit(ret_usm);
                        db.SubmitChanges();
                    }
                }
                return true;
            }
            catch
            {
                throw;
            }
        }
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                MealBookingHistory_mbh_Info infoObject = KeyObject as MealBookingHistory_mbh_Info;
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        MealBookingHistory_mbh history = db.MealBookingHistory_mbh.Where(x => x.mbh_cRecordID == infoObject.mbh_cRecordID).FirstOrDefault();

                        if (history != null)
                        {
                            db.MealBookingHistory_mbh.DeleteOnSubmit(history);

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                            rvInfo.ValueObject = infoObject;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
Exemple #10
0
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                UserCardPair_ucp_Info infoObject = KeyObject as UserCardPair_ucp_Info;
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        UserCardPair_ucp pair = db.UserCardPair_ucp.Where(x => x.ucp_cRecordID == infoObject.ucp_cRecordID).FirstOrDefault();

                        if (pair != null)
                        {
                            pair.ucp_lIsActive = false;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                            rvInfo.ValueObject = infoObject;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                CardUserAccountDetail_cuad_Info infoObject = KeyObject as CardUserAccountDetail_cuad_Info;
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        CardUserAccountDetail_cuad record = db.CardUserAccountDetail_cuad.Where(x => x.cuad_cRecordID == infoObject.cuad_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            db.CardUserAccountDetail_cuad.DeleteOnSubmit(record);

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                            rvInfo.ValueObject = infoObject;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
Exemple #12
0
 public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
 {
     bool isSuccess = false;
     CodeMaster_cmt_Info info = new CodeMaster_cmt_Info();
     info = KeyObject as CodeMaster_cmt_Info;
     try
     {
         using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
         {
             CodeMaster_cmt delTab = db.CodeMaster_cmt.SingleOrDefault(t => t.cmt_iRecordID == info.cmt_iRecordID);
             if (delTab != null)
             {
                 db.CodeMaster_cmt.DeleteOnSubmit(delTab);
                 db.SubmitChanges();
                 isSuccess = true;
             }
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     return isSuccess;
 }
        public ReturnValueInfo UpdateRecord(CardUserAccount_cua_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        CardUserAccount_cua record = db.CardUserAccount_cua.Where(x => x.cua_cRecordID == infoObject.cua_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.cua_cCUSID = infoObject.cua_cCUSID;
                            record.cua_dLastSyncTime = infoObject.cua_dLastSyncTime;
                            record.cua_fCurrentBalance = infoObject.cua_fCurrentBalance;
                            record.cua_fOriginalBalance = infoObject.cua_fOriginalBalance;
                            record.cua_lIsActive = infoObject.cua_lIsActive;
                            record.cua_cAdd = infoObject.cua_cAdd;
                            record.cua_dAddDate = infoObject.cua_dAddDate;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
 public ReturnValueInfo InsertRecord(CardUserAccountDetail_cuad_Info infoObject)
 {
     ReturnValueInfo rvInfo = new ReturnValueInfo();
     try
     {
         if (infoObject != null)
         {
             using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
             {
                 CardUserAccountDetail_cuad record = Common.General.CopyObjectValue<CardUserAccountDetail_cuad_Info, CardUserAccountDetail_cuad>(infoObject);
                 if (record != null)
                 {
                     db.CardUserAccountDetail_cuad.InsertOnSubmit(record);
                     db.SubmitChanges();
                     rvInfo.boolValue = true;
                     rvInfo.ValueObject = infoObject;
                 }
                 else
                 {
                     rvInfo.messageText = "TransEntity is null";
                 }
             }
         }
         else
         {
             rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
         }
     }
     catch (Exception ex)
     {
         rvInfo.isError = true;
         rvInfo.messageText = ex.Message;
     }
     return rvInfo;
 }
        public ReturnValueInfo UpdateRecord(CardUserAccountDetail_cuad_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        CardUserAccountDetail_cuad record = db.CardUserAccountDetail_cuad.Where(x => x.cuad_cRecordID == infoObject.cuad_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.cuad_cCUAID = infoObject.cuad_cCUAID;
                            record.cuad_fFlowMoney = infoObject.cuad_fFlowMoney;
                            record.cuad_cFlowType = infoObject.cuad_cFlowType;
                            if (infoObject.cuad_cConsumeID != null)
                            {
                                record.cuad_cConsumeID = infoObject.cuad_cConsumeID.Value;
                            }
                            record.cuad_cOpt = infoObject.cuad_cOpt;
                            record.cuad_dOptTime = infoObject.cuad_dOptTime;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public ReturnValueInfo UpdateRecord(PreConsumeRecord_pcs_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        PreConsumeRecord_pcs record = db.PreConsumeRecord_pcs.Where(x => x.pcs_cRecordID == infoObject.pcs_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.pcs_cConsumeType = infoObject.pcs_cConsumeType;
                            record.pcs_cAdd = infoObject.pcs_cAdd;
                            record.pcs_cAccountID = infoObject.pcs_cAccountID;
                            record.pcs_dAddDate = infoObject.pcs_dAddDate;
                            record.pcs_dConsumeDate = infoObject.pcs_dConsumeDate;
                            record.pcs_fCost = infoObject.pcs_fCost;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public ReturnValueInfo BatchSolveUncertainRecord(List<PreConsumeRecord_pcs_Info> listRecords, bool isSettled)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            if (listRecords == null || (listRecords != null && listRecords.Count < 1))
            {
                rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                return rvInfo;
            }

            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    db.Connection.Open();
                    db.Transaction = db.Connection.BeginTransaction();
                    try
                    {
                        List<SystemAccountDetail_sad> listSysAccountDetails = new List<SystemAccountDetail_sad>();
                        List<CardUserAccountDetail_cuad> listUserAccountDetails = new List<CardUserAccountDetail_cuad>();
                        foreach (PreConsumeRecord_pcs_Info preCostItem in listRecords)
                        {
                            PreConsumeRecord_pcs preCost = db.PreConsumeRecord_pcs.Where(x => x.pcs_cRecordID == preCostItem.pcs_cRecordID).FirstOrDefault();
                            if (preCost == null)
                            {
                                throw new Exception("部分记录已被删除  " + preCostItem.pcs_cRecordID.ToString());
                            }

                            preCost.pcs_lIsSettled = isSettled;
                            preCost.pcs_cConsumeType = preCostItem.pcs_cConsumeType;
                            preCost.pcs_cSourceID = preCostItem.pcs_cSourceID;
                            preCost.pcs_dConsumeDate = DateTime.Now;
                            if (isSettled)
                            {
                                preCost.pcs_dSettleTime = DateTime.Now;

                                CardUserAccountDetail_cuad userDetail = new CardUserAccountDetail_cuad();
                                userDetail.cuad_cOpt = preCostItem.pcs_cAdd;
                                userDetail.cuad_cConsumeID = preCostItem.pcs_cRecordID;
                                userDetail.cuad_cCUAID = preCostItem.pcs_cAccountID;
                                userDetail.cuad_cFlowType = preCostItem.pcs_cConsumeType;
                                userDetail.cuad_cRecordID = Guid.NewGuid();
                                userDetail.cuad_dOptTime = DateTime.Now;
                                userDetail.cuad_fFlowMoney = Math.Abs(preCostItem.pcs_fCost);
                                listUserAccountDetails.Add(userDetail);

                                SystemAccountDetail_sad sysDetail = new SystemAccountDetail_sad();
                                sysDetail.sad_cConsumeID = preCostItem.pcs_cRecordID;
                                sysDetail.sad_cDesc = Common.DefineConstantValue.GetMoneyFlowDesc(preCostItem.pcs_cConsumeType);
                                sysDetail.sad_cFLowMoney = Math.Abs(preCostItem.pcs_fCost);
                                sysDetail.sad_cFlowType = preCostItem.pcs_cConsumeType;
                                sysDetail.sad_cOpt = preCostItem.pcs_cAdd;
                                sysDetail.sad_cRecordID = Guid.NewGuid();
                                sysDetail.sad_dOptTime = DateTime.Now;
                                listSysAccountDetails.Add(sysDetail);
                            }
                        }

                        if (listUserAccountDetails.Count > 0)
                        {
                            db.CardUserAccountDetail_cuad.InsertAllOnSubmit(listUserAccountDetails);
                            db.SystemAccountDetail_sad.InsertAllOnSubmit(listSysAccountDetails);
                        }
                        db.SubmitChanges();
                        db.Transaction.Commit();
                        db.Connection.Close();
                        rvInfo.boolValue = true;
                    }
                    catch (Exception exx)
                    {
                        db.Transaction.Rollback();
                        db.Connection.Close();
                        throw exx;
                    }
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public ReturnValueInfo ResetAccountOverdraft(RechargeRecord_rcr_Info OverdraftInfo)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            if (OverdraftInfo == null)
            {
                rvInfo.isError = true;
                rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                return rvInfo;
            }
            try
            {
                //获取已发卡用户列表
                ICardUserMasterDA userDA = MasterDAFactory.GetDAL<ICardUserMasterDA>(MasterDAFactory.CardUserMaster);
                CardUserMaster_cus_Info userSearch = new CardUserMaster_cus_Info();
                userSearch.cus_cIdentityNum = Common.DefineConstantValue.CodeMasterDefine.KEY2_SIOT_CardUserIdentity_Student;
                List<CardUserMaster_cus_Info> listUsers = userDA.SearchRecordsWithCardInfo(userSearch);
                if (listUsers != null)
                {
                    listUsers = listUsers.Where(x => x.cus_lValid && x.PairCardNo != null).ToList();
                }

                //获取透支额列表
                IRechargeRecordDA rechargeDA = MasterDAFactory.GetDAL<IRechargeRecordDA>(MasterDAFactory.RechargeRecord);
                RechargeRecord_rcr_Info rechargeSearch = new RechargeRecord_rcr_Info();
                rechargeSearch.rcr_cRechargeType = Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString();
                List<RechargeRecord_rcr_Info> listRecharge = rechargeDA.SearchRecords(rechargeSearch);
                List<RechargeRecord_rcr> listRechargeRec = new List<RechargeRecord_rcr>();

                List<PreConsumeRecord_pcs> listInsertPreCost = new List<PreConsumeRecord_pcs>();
                if (listRecharge != null && listRecharge.Count > 0)
                {
                    IEnumerable<IGrouping<Guid, RechargeRecord_rcr_Info>> groupRecharge = listRecharge.GroupBy(x => x.rcr_cUserID);
                    foreach (var itemRecharge in groupRecharge)
                    {
                        Guid userID = itemRecharge.Key;
                        CardUserMaster_cus_Info userInfo = listUsers.Find(x => x.cus_cRecordID == userID);
                        if (userInfo == null)
                        {
                            continue;
                        }

                        RechargeRecord_rcr_Info userRecharge = itemRecharge.OrderByDescending(x => x.rcr_dRechargeTime).FirstOrDefault();
                        if (userRecharge != null)
                        {
                            Guid sourceID = Guid.NewGuid();
                            if (OverdraftInfo.rcr_fRechargeMoney > userRecharge.rcr_fRechargeMoney)
                            {
                                //新的透支额大于当前透支额
                            }
                            else if (OverdraftInfo.rcr_fRechargeMoney < userRecharge.rcr_fRechargeMoney)
                            {
                                //新的透支额小于当前透支额 eg: 0, 50
                                PreConsumeRecord_pcs preCost = new PreConsumeRecord_pcs();
                                preCost.pcs_cRecordID = Guid.NewGuid();
                                preCost.pcs_cSourceID = sourceID;
                                preCost.pcs_cAccountID = userInfo.AccountID.Value;
                                preCost.pcs_cAdd = OverdraftInfo.rcr_cAdd;
                                preCost.pcs_cConsumeType = Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString();
                                preCost.pcs_cUserID = userID;
                                preCost.pcs_dAddDate = DateTime.Now;
                                preCost.pcs_dConsumeDate = DateTime.Now;
                                preCost.pcs_fCost = Math.Abs(OverdraftInfo.rcr_fRechargeMoney - userRecharge.rcr_fRechargeMoney);

                                listInsertPreCost.Add(preCost);
                            }
                            else
                            {
                                continue;
                            }

                            RechargeRecord_rcr insertRechrage = Common.General.CopyObjectValue<RechargeRecord_rcr_Info, RechargeRecord_rcr>(userRecharge);
                            insertRechrage.rcr_cRecordID = sourceID;
                            insertRechrage.rcr_fRechargeMoney = OverdraftInfo.rcr_fRechargeMoney;
                            insertRechrage.rcr_fBalance = 0;
                            insertRechrage.rcr_dRechargeTime = DateTime.Now;
                            insertRechrage.rcr_cAdd = OverdraftInfo.rcr_cAdd;
                            insertRechrage.rcr_cLast = OverdraftInfo.rcr_cLast;
                            insertRechrage.rcr_cDesc = OverdraftInfo.rcr_cDesc;
                            insertRechrage.rcr_cStatus = Common.DefineConstantValue.ConsumeMoneyFlowStatus.Finished.ToString();

                            listRechargeRec.Add(insertRechrage);
                        }
                    }
                }

                if (listInsertPreCost.Count == listRechargeRec.Count && listRechargeRec.Count > 0)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        db.Connection.Open();
                        db.Transaction = db.Connection.BeginTransaction();
                        try
                        {
                            db.RechargeRecord_rcr.InsertAllOnSubmit(listRechargeRec);
                            db.PreConsumeRecord_pcs.InsertAllOnSubmit(listInsertPreCost);
                            db.SubmitChanges();
                            db.Transaction.Commit();
                            rvInfo.boolValue = true;
                        }
                        catch (Exception exx)
                        {
                            db.Transaction.Rollback();
                            db.Connection.Close();
                            throw exx;
                        }
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            return rvInfo;
        }
        public CardUserAccount_cua_Info SyncAccount(IModelObject KeyObject, DateTime dtDeadline)
        {
            CardUserAccount_cua_Info resInfo = null;
            try
            {
                CardUserAccount_cua_Info infoObject = KeyObject as CardUserAccount_cua_Info;
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        db.CommandTimeout = 10 * 60000;
                        CardUserAccount_cua record = db.CardUserAccount_cua.Where(x => x.cua_cRecordID == infoObject.cua_cRecordID).FirstOrDefault();
                        if (record != null)
                        {
                            StringBuilder sbSQL = new StringBuilder();
                            sbSQL.AppendLine(@"SELECT cua_cRecordID,cua_cCUSID,cua_fOriginalBalance,");
                            sbSQL.AppendLine(@"ISNULL(TotalCost.cua_fCurrentBalance,0.00) as cua_fCurrentBalance,");
                            sbSQL.AppendLine(@"ISNULL(TotalCost.cua_dLastSyncTime,GETDATE()) as cua_dLastSyncTime,");
                            sbSQL.AppendLine(@"cua_lIsActive, cua_cAdd, cua_dAddDate FROM dbo.CardUserAccount_cua");
                            sbSQL.AppendLine(@"INNER JOIN (SELECT * FROM(");
                            sbSQL.AppendLine(@"SELECT SUM(FormulaRes) as cua_fCurrentBalance,MAX(cuad_dOptTime) AS cua_dLastSyncTime");
                            sbSQL.AppendLine(@"FROM (SELECT *,(cuad_fFlowMoney * cmt_fNumber) AS FormulaRes FROM CardUserAccountDetail_cuad ");
                            sbSQL.AppendLine(@"INNER JOIN CardUserAccount_cua ON  cua_cRecordID = cuad_cCUAID");
                            sbSQL.AppendLine(@"AND cua_cCUSID = '" + record.cua_cCUSID + "'");
                            sbSQL.AppendLine(@"AND cuad_dOptTime <='" + dtDeadline + "'");
                            sbSQL.AppendLine(@"LEFT JOIN CodeMaster_cmt ON cmt_cKey1 = 'ACCOUNTFORMULA_USER' AND cmt_cKey2 = cuad_cFlowType) AS A) AS AA) AS TotalCost");
                            sbSQL.AppendLine(@"on  cua_cCUSID ='" + record.cua_cCUSID + "'");

                            IEnumerable<CardUserAccount_cua_Info> query = db.ExecuteQuery<CardUserAccount_cua_Info>(sbSQL.ToString(), new object[] { });
                            if (query != null)
                            {
                                List<CardUserAccount_cua_Info> listRes = query.ToList();
                                if (listRes.Count > 0)
                                {
                                    CardUserAccount_cua_Info accRev = listRes[0];
                                    record.cua_fCurrentBalance = accRev.cua_fCurrentBalance;
                                    record.cua_dLastSyncTime = dtDeadline;
                                    if (dtDeadline.Date == DateTime.Now.AddDays(-1))
                                    {
                                        db.SubmitChanges();
                                    }
                                }
                            }

                            resInfo = Common.General.CopyObjectValue<CardUserAccount_cua, CardUserAccount_cua_Info>(record);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return resInfo;
        }
Exemple #20
0
 public bool InsertRecord(CodeMaster_cmt_Info infoObject)
 {
     bool isSuccess = false;
     CodeMaster_cmt_Info info = new CodeMaster_cmt_Info();
     info = infoObject;
     try
     {
         using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
         {
             CodeMaster_cmt newTab = Common.General.CopyObjectValue<CodeMaster_cmt_Info, CodeMaster_cmt>(info);
             db.CodeMaster_cmt.InsertOnSubmit(newTab);
             db.SubmitChanges();
             isSuccess = true;
         }
     }
     catch (Exception Ex)
     {
         throw Ex;
     }
     return isSuccess;
 }
        public ReturnValueInfo AccountCashReFund(IModelObject infoObject, string strReason)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            CardUserAccountDetail_cuad_Info userDetailInfo = infoObject as CardUserAccountDetail_cuad_Info;
            if (userDetailInfo == null)
            {
                rvInfo.messageText = "对象类型不符合,参数需要为SystemAccountDetail_sad_Info类";
                rvInfo.isError = true;
                return rvInfo;
            }
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    db.Connection.Open();
                    db.Transaction = db.Connection.BeginTransaction();
                    try
                    {
                        PreConsumeRecord_pcs preCost = new PreConsumeRecord_pcs();
                        preCost.pcs_cAccountID = userDetailInfo.cuad_cCUAID;
                        preCost.pcs_cAdd = userDetailInfo.cuad_cOpt;
                        preCost.pcs_dAddDate = DateTime.Now;
                        preCost.pcs_cConsumeType = userDetailInfo.cuad_cFlowType;
                        preCost.pcs_cRecordID = Guid.NewGuid();
                        CardUserAccount_cua userAccount = db.CardUserAccount_cua.Where(x => x.cua_cRecordID == userDetailInfo.cuad_cCUAID).FirstOrDefault();
                        preCost.pcs_cUserID = userAccount.cua_cCUSID;
                        preCost.pcs_dConsumeDate = DateTime.Now;
                        preCost.pcs_dSettleTime = DateTime.Now;
                        preCost.pcs_fCost = userDetailInfo.cuad_fFlowMoney;
                        preCost.pcs_lIsSettled = true;
                        db.PreConsumeRecord_pcs.InsertOnSubmit(preCost);
                        userAccount.cua_fCurrentBalance -= userDetailInfo.cuad_fFlowMoney;
                        db.SubmitChanges();

                        CardUserAccountDetail_cuad userDetail = Common.General.CopyObjectValue<CardUserAccountDetail_cuad_Info, CardUserAccountDetail_cuad>(userDetailInfo);
                        userDetail.cuad_cConsumeID = preCost.pcs_cRecordID;
                        db.CardUserAccountDetail_cuad.InsertOnSubmit(userDetail);
                        db.SubmitChanges();

                        SystemAccountDetail_sad sysDetail = new SystemAccountDetail_sad();
                        sysDetail.sad_cConsumeID = preCost.pcs_cRecordID;
                        sysDetail.sad_cDesc = strReason;
                        sysDetail.sad_cFLowMoney = userDetailInfo.cuad_fFlowMoney;
                        sysDetail.sad_cFlowType = userDetailInfo.cuad_cFlowType;
                        sysDetail.sad_cOpt = userDetailInfo.cuad_cOpt;
                        sysDetail.sad_cRecordID = Guid.NewGuid();
                        sysDetail.sad_dOptTime = DateTime.Now;
                        db.SystemAccountDetail_sad.InsertOnSubmit(sysDetail);
                        db.SubmitChanges();

                        db.Transaction.Commit();
                        db.Connection.Close();
                        rvInfo.boolValue = true;
                    }
                    catch (Exception exx)
                    {
                        db.Transaction.Rollback();
                        db.Connection.Close();
                        throw exx;
                    }
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
Exemple #22
0
        public ReturnValueInfo DeleteRecord(IModelObject KeyObject)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);

            ClassMaster_csm_Info deleteInfo = KeyObject as ClassMaster_csm_Info;

            if (deleteInfo != null)
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {

                    ClassMaster_csm deleteData = db.ClassMaster_csm.FirstOrDefault(t => t.csm_cRecordID == deleteInfo.csm_cRecordID);

                    if (deleteData != null)
                    {
                        IEnumerable<CardUserMaster_cus> students = from t in db.CardUserMaster_cus
                                                                   where t.cus_cClassID == deleteData.csm_cRecordID
                                                                   select t;

                        if (students != null && students.Count() > 0)
                        {
                            returnInfo.boolValue = false;

                            returnInfo.messageText = "该班下还有学生记录!";
                        }
                        else
                        {
                            IEnumerable<ChangeClassRecord_ccr> query = from t in db.ChangeClassRecord_ccr
                                                                       where t.ccr_cClassID == deleteData.csm_cRecordID
                                                                       select t;
                            if (query != null)
                            {
                                List<ChangeClassRecord_ccr> ccrList = query.ToList();

                                for (int index = 0; index < ccrList.Count; index++)
                                {
                                    db.ChangeClassRecord_ccr.DeleteOnSubmit(ccrList[index]);
                                }
                            }

                            returnInfo.boolValue = true;

                            db.ClassMaster_csm.DeleteOnSubmit(deleteData);

                            db.SubmitChanges();
                        }

                        returnInfo.ValueObject = deleteInfo;
                    }
                    else
                    {
                        returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_DeleteDataNull;
                    }

                }
            }
            else
            {
                returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
            }

            return returnInfo;
        }
        public bool InsertRecord(Sys_RoleMaster_rlm_Info infoObject)
        {
            if (infoObject == null)
            {
                return false;
            }

            using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
            {
                Sys_RoleMaster_rlm rlm = new Sys_RoleMaster_rlm();
                try
                {
                    rlm = Common.General.CopyObjectValue<Sys_RoleMaster_rlm_Info, Sys_RoleMaster_rlm>(infoObject);

                    if (infoObject.userMasterList != null && infoObject.userMasterList.Count > 0)
                    {
                        for (int i = 0; i < infoObject.userMasterList.Count; i++)
                        {

                            Sys_UserMaster_usm_Info usmInfo = infoObject.userMasterList[i];

                            Sys_UserRoles_usr item = new Sys_UserRoles_usr();

                            item.usr_cUserLoginID = usmInfo.usm_cUserLoginID;
                            item.usr_cRoleID = infoObject.rlm_cRoleID;
                            //courseitem.cum_cNumber;
                            rlm.Sys_UserRoles_usr.Add(item);
                            //db.Sys_UserRoles_usrs.InsertOnSubmit(item);
                        }
                    }

                    db.Sys_RoleMaster_rlm.InsertOnSubmit(rlm);
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Exemple #24
0
        public ReturnValueInfo UpdateRecord(ClassMaster_csm_Info infoObject)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);

            if (infoObject != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        GetClassName(infoObject);

                        ClassMaster_csm updateData = db.ClassMaster_csm.FirstOrDefault(t => t.csm_cRecordID == infoObject.csm_cRecordID);

                        if (updateData != null)
                        {
                            updateData.csm_cClassName = infoObject.csm_cClassName;

                            updateData.csm_cClassNum = infoObject.csm_cClassNum;

                            updateData.csm_cGDMID = infoObject.csm_cGDMID;

                            updateData.csm_cMasterID = infoObject.csm_cMasterID;

                            updateData.csm_cRemark = infoObject.csm_cRemark;

                            updateData.csm_cLast = infoObject.csm_cLast;

                            updateData.csm_dLastDate = infoObject.csm_dLastDate;

                            db.SubmitChanges();

                            returnInfo.boolValue = true;

                            returnInfo.ValueObject = infoObject;
                        }
                        else
                        {
                            returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_UpdateDataNull;
                        }
                    }
                }
                catch (Exception Ex)
                {

                    returnInfo.messageText = Ex.Message;
                }
            }
            else
            {
                returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
            }

            return returnInfo;
        }
Exemple #25
0
        public bool UpdateRecord(CodeMaster_cmt_Info infoObject)
        {
            bool isSuccess = false;
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {

                    CodeMaster_cmt query = db.CodeMaster_cmt.SingleOrDefault(t => t.cmt_iRecordID == infoObject.cmt_iRecordID);
                    if (query != null)
                    {
                        query.cmt_cKey1 = infoObject.cmt_cKey1;
                        query.cmt_cKey2 = infoObject.cmt_cKey2;
                        query.cmt_cValue = infoObject.cmt_cValue;
                        query.cmt_fNumber = infoObject.cmt_fNumber;
                        query.cmt_cRemark = infoObject.cmt_cRemark;
                        query.cmt_cRemark2 = infoObject.cmt_cRemark2;

                        query.cmt_cLast = infoObject.cmt_cLast;
                        query.cmt_dLastDate = infoObject.cmt_dLastDate;
                        db.SubmitChanges();
                        isSuccess = true;
                    }
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }
            return isSuccess;
        }
 public Model.General.ReturnValueInfo InsertRecord(Model.HHZX.ConsumerDevice.ConsumeMachineMaster_cmm_Info infoObject)
 {
     ReturnValueInfo rvInfo = new ReturnValueInfo();
     try
     {
         if (infoObject != null)
         {
             using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
             {
                 ConsumeMachineMaster_cmm record = Common.General.CopyObjectValue<ConsumeMachineMaster_cmm_Info, ConsumeMachineMaster_cmm>(infoObject);
                 if (record != null)
                 {
                     db.ConsumeMachineMaster_cmm.InsertOnSubmit(record);
                     db.SubmitChanges();
                     rvInfo.boolValue = true;
                     rvInfo.ValueObject = infoObject;
                 }
                 else
                 {
                     rvInfo.messageText = "TransEntity is null";
                 }
             }
         }
         else
         {
             rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
         }
     }
     catch (Exception ex)
     {
         rvInfo.isError = true;
         rvInfo.messageText = ex.Message;
     }
     return rvInfo;
 }
        public Model.General.ReturnValueInfo UpdateRecord(Model.HHZX.ConsumerDevice.ConsumeMachineMaster_cmm_Info infoObject)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                if (infoObject != null)
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        ConsumeMachineMaster_cmm record = db.ConsumeMachineMaster_cmm.Where(x => x.cmm_cRecordID == infoObject.cmm_cRecordID).FirstOrDefault();

                        if (record != null)
                        {
                            record.cmm_cDesc = infoObject.cmm_cDesc;
                            record.cmm_cIPAddr = infoObject.cmm_cIPAddr;
                            record.cmm_cLast = infoObject.cmm_cLast;
                            record.cmm_cMacName = infoObject.cmm_cMacName;
                            record.cmm_cUsageType = infoObject.cmm_cUsageType;
                            record.cmm_dLastAccessTime = infoObject.cmm_dLastAccessTime;
                            record.cmm_dLastDate = infoObject.cmm_dLastDate;
                            record.cmm_iMacNo = infoObject.cmm_iMacNo;
                            record.cmm_iPort = infoObject.cmm_iPort;
                            record.cmm_lIsActive = infoObject.cmm_lIsActive;
                            record.cmm_cStatus = infoObject.cmm_cStatus;
                            record.cmm_lLastAccessRes = infoObject.cmm_lLastAccessRes;

                            db.SubmitChanges();
                            rvInfo.boolValue = true;
                        }
                        else
                        {
                            rvInfo.messageText = "GetEntity is null";
                        }
                    }
                }
                else
                {
                    rvInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }
        public bool InsertRecord(Sys_FunctionMaster_fum_Info infoObject)
        {
            using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
            {
                Sys_FunctionMaster_fum fum = new Sys_FunctionMaster_fum();
                try
                {
                    fum = Common.General.CopyObjectValue<Sys_FunctionMaster_fum_Info, Sys_FunctionMaster_fum>(infoObject);

                    if (infoObject.formMaster != null && infoObject.formMaster.Count > 0)
                    {
                        for (int i = 0; i < infoObject.formMaster.Count; i++)
                        {

                            Sys_FormMaster_fom_Info usmInfo = infoObject.formMaster[i];

                            Sys_FormPurview_frp item = new Sys_FormPurview_frp();

                            item.frp_cFunctionNumber = infoObject.fum_cFunctionNumber;
                            item.frp_cFormNumber = usmInfo.fom_cFormNumber;

                            item.frp_cPurviewCode = item.frp_cFunctionNumber + item.frp_cFormNumber;
                            //courseitem.cum_cNumber;
                            //fum.Sys_FormPurview_frps.Add(item);
                            //db.Sys_UserRoles_usrs.InsertOnSubmit(item);
                        }
                    }

                    db.Sys_FunctionMaster_fum.InsertOnSubmit(fum);
                    db.SubmitChanges();
                    return true;
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }
        }
Exemple #29
0
        public ReturnValueInfo InsertRecord(ClassMaster_csm_Info infoObject)
        {
            ReturnValueInfo returnInfo = new ReturnValueInfo(false);

            if (infoObject != null)
            {
                try
                {
                    using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                    {
                        GetClassName(infoObject);

                        ClassMaster_csm insertData = Common.General.CopyObjectValue<ClassMaster_csm_Info, ClassMaster_csm>(infoObject);

                        db.ClassMaster_csm.InsertOnSubmit(insertData);

                        db.SubmitChanges();

                        returnInfo.boolValue = true;

                        returnInfo.ValueObject = infoObject;
                    }
                }
                catch (Exception Ex)
                {

                    returnInfo.messageText = Ex.Message;
                }
            }
            else
            {
                returnInfo.messageText = Common.DefineConstantValue.SystemMessageText.strMessageText_E_ObjectNull;
            }

            return returnInfo;
        }
        public ReturnValueInfo BatchSyncAccountDetail(List<PreConsumeRecord_pcs_Info> listUpdatePreCost, List<PreConsumeRecord_pcs_Info> listDelPreCost, List<ConsumeRecord_csr_Info> listConsume)
        {
            ReturnValueInfo rvInfo = new ReturnValueInfo();
            try
            {
                using (SIOTSDB_HHZXDataContext db = new SIOTSDB_HHZXDataContext())
                {
                    //db.Connection.Open();
                    //db.Transaction = db.Connection.BeginTransaction();

                    List<CardUserAccountDetail_cuad> listUserAccount = new List<CardUserAccountDetail_cuad>();
                    List<SystemAccountDetail_sad> listSysAccount = new List<SystemAccountDetail_sad>();
                    List<PreConsumeRecord_pcs> listDelPreCost_DB = new List<PreConsumeRecord_pcs>();

                    #region 准备需要删除的重复扣费列表

                    if (listDelPreCost != null && listDelPreCost.Count > 0)
                    {
                        foreach (var item in listDelPreCost)
                        {
                            if (item == null)
                                continue;
                            PreConsumeRecord_pcs preCostDel = db.PreConsumeRecord_pcs.Where(x => x.pcs_cRecordID == item.pcs_cRecordID).FirstOrDefault();
                            if (preCostDel != null)
                            {
                                listDelPreCost_DB.Add(preCostDel);
                            }
                        }
                    }

                    #endregion

                    #region 归档处理实际卡消费记录

                    foreach (ConsumeRecord_csr_Info consumeItem in listConsume)
                    {
                        CardUserAccount_cua account = db.CardUserAccount_cua.Where(x => x.cua_cCUSID == consumeItem.csr_cCardUserID).FirstOrDefault();
                        ConsumeRecord_csr consumeInfo = db.ConsumeRecord_csr.Where(x => x.csr_cRecordID == consumeItem.csr_cRecordID).FirstOrDefault();
                        consumeInfo.csr_lIsSettled = consumeItem.csr_lIsSettled;
                        consumeInfo.csr_dSettleTime = consumeItem.csr_dSettleTime;

                        string strFlowType = string.Empty;//公用消费类型

                        CardUserAccountDetail_cuad userAccountDetail = new CardUserAccountDetail_cuad();
                        userAccountDetail.cuad_cRecordID = Guid.NewGuid();
                        userAccountDetail.cuad_cConsumeID = consumeInfo.csr_cRecordID;
                        userAccountDetail.cuad_cCUAID = account.cua_cRecordID;
                        userAccountDetail.cuad_fFlowMoney = consumeItem.csr_fConsumeMoney;
                        if (consumeItem.csr_cConsumeType == Common.DefineConstantValue.ConsumeMachineType.StuSetmeal.ToString())
                        {
                            strFlowType = Common.DefineConstantValue.ConsumeMoneyFlowType.SetMealCost.ToString();
                        }
                        else
                        {
                            strFlowType = Common.DefineConstantValue.ConsumeMoneyFlowType.FreeMealCost.ToString();
                        }
                        userAccountDetail.cuad_cFlowType = strFlowType;
                        userAccountDetail.cuad_cOpt = "sys";
                        userAccountDetail.cuad_dOptTime = DateTime.Now;
                        listUserAccount.Add(userAccountDetail);

                        SystemAccountDetail_sad sysAccountDetail = new SystemAccountDetail_sad();
                        sysAccountDetail.sad_cRecordID = Guid.NewGuid();
                        sysAccountDetail.sad_cConsumeID = consumeInfo.csr_cRecordID;
                        sysAccountDetail.sad_cDesc = Common.DefineConstantValue.GetMoneyFlowDesc(strFlowType);
                        sysAccountDetail.sad_cFLowMoney = consumeItem.csr_fConsumeMoney;
                        sysAccountDetail.sad_cFlowType = strFlowType;
                        sysAccountDetail.sad_cOpt = "sys";
                        sysAccountDetail.sad_dOptTime = DateTime.Now;
                        listSysAccount.Add(sysAccountDetail);
                    }

                    #endregion

                    #region 处理预扣费记录,更新已结算部分数据与未结算部分数据,未结算部分等待下次充值时补扣

                    foreach (PreConsumeRecord_pcs_Info preCostItem in listUpdatePreCost)
                    {
                        PreConsumeRecord_pcs preCostInfo = db.PreConsumeRecord_pcs.Where(x => x.pcs_cRecordID == preCostItem.pcs_cRecordID).FirstOrDefault();
                        if (preCostInfo != null)
                        {
                            preCostInfo.pcs_cSourceID = preCostItem.pcs_cSourceID;
                            preCostInfo.pcs_cConsumeType = preCostItem.pcs_cConsumeType;
                            preCostInfo.pcs_lIsSettled = preCostItem.pcs_lIsSettled;
                            preCostInfo.pcs_dSettleTime = preCostItem.pcs_dSettleTime;
                            preCostInfo.pcs_fCost = Math.Abs(preCostItem.pcs_fCost);
                            preCostInfo.pcs_cAdd = preCostItem.pcs_cAdd;
                            preCostInfo.pcs_dAddDate = preCostItem.pcs_dAddDate;
                        }
                        else
                        {
                            throw new Exception("预付款记录丢失。" + preCostItem.pcs_cRecordID.ToString());
                        }
                    }

                    #endregion

                    #region 更新用户账户的余额以及同步时间【停用,改用SQL处理】
                    /*1、取出用户最新的卡消费记录
                     * 2、取出用户最新的转账或充值记录
                     * 3、对比两者时间,取较新时间的记录去到用户的余额
                     */

                    //var groupConsumeRecord = db.ConsumeRecord_csr.GroupBy(x => x.csr_cCardUserID);
                    //foreach (var itemUserConsumeGroup in groupConsumeRecord)
                    //{
                    //    Guid userID = itemUserConsumeGroup.Key;
                    //    List<ConsumeRecord_csr> listUserRecord = itemUserConsumeGroup.OrderByDescending(x => x.csr_dConsumeDate).ToList();
                    //    if (listUserRecord != null && listUserRecord.Count > 0)
                    //    {
                    //        ConsumeRecord_csr record = listUserRecord.FirstOrDefault();//最新的消费记录
                    //        if (record != null)
                    //        {
                    //            decimal fCardCostCurrentBalance = record.csr_fCardBalance;
                    //            decimal fAdvanceRecharge = decimal.Zero;//透支额度
                    //            RechargeRecord_rcr advanceRecharge = db.RechargeRecord_rcr.Where(x =>
                    //                x.rcr_cUserID == record.csr_cCardUserID
                    //                && x.rcr_cRechargeType == Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString()
                    //                ).OrderByDescending(x => x.rcr_dRechargeTime).FirstOrDefault();
                    //            if (advanceRecharge != null)
                    //            {
                    //                fAdvanceRecharge = advanceRecharge.rcr_fRechargeMoney;
                    //            }

                    //            //找出最后消费记录后,有充值情况出现的,需使用此充值后结果
                    //            List<RechargeRecord_rcr> listCardRecharge = db.RechargeRecord_rcr.Where(x =>
                    //                x.rcr_cUserID == record.csr_cCardUserID
                    //                && x.rcr_dRechargeTime >= record.csr_dConsumeDate
                    //                ).OrderByDescending(x => x.rcr_dRechargeTime).ToList();//以充值时间倒序,取出最新的充值列表
                    //            listCardRecharge = listCardRecharge.Where(x =>
                    //                x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.AdvanceMealCost.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.FreeMealCost.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.HedgeFund.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.IndeterminateCost.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.NewCardCost.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.Recharge_AdvanceMoney.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.ReplaceCardCost.ToString()
                    //                && x.rcr_cRechargeType != Common.DefineConstantValue.ConsumeMoneyFlowType.SetMealCost.ToString()).ToList();

                    //            RechargeRecord_rcr cardRecharge = listCardRecharge.FirstOrDefault();
                    //            if (cardRecharge != null)
                    //            {
                    //                if (record.csr_dConsumeDate < cardRecharge.rcr_dRechargeTime)
                    //                {
                    //                    //如果充值记录存在,且充值时间比消费时间新,则以充值后余额为最后余额值
                    //                    fCardCostCurrentBalance = cardRecharge.rcr_fBalance;
                    //                }
                    //            }

                    //            CardUserAccount_cua userAccount = db.CardUserAccount_cua.Where(x => x.cua_cCUSID == record.csr_cCardUserID).FirstOrDefault();
                    //            if (userAccount != null)
                    //            {
                    //                decimal fCurrentBalance = fCardCostCurrentBalance - fAdvanceRecharge;
                    //                userAccount.cua_fCurrentBalance = fCurrentBalance;
                    //                userAccount.cua_dLastSyncTime = DateTime.Now;
                    //            }
                    //        }
                    //    }
                    //    else
                    //    {
                    //        continue;
                    //    }
                    //}

                    #endregion

                    db.Connection.Open();
                    db.Transaction = db.Connection.BeginTransaction();
                    try
                    {
                        if (listConsume.Count > 0)
                        {
                            if (listUserAccount.Count > 0)
                            {
                                db.CardUserAccountDetail_cuad.InsertAllOnSubmit(listUserAccount);
                                db.SystemAccountDetail_sad.InsertAllOnSubmit(listSysAccount);
                            }
                        }

                        if (listDelPreCost_DB.Count > 0)
                        {
                            db.PreConsumeRecord_pcs.DeleteAllOnSubmit(listDelPreCost_DB);
                        }

                        db.SubmitChanges();

                        #region 同步学生账户金额信息

                        string strStuSycnAccount = @"declare @tb_CardConsumeDetail table (UserID uniqueidentifier,ConsumeDate datetime,CardBalance decimal(18,2))
            declare @tb_CardRechargeDetail table (UserID uniqueidentifier,RechargeDate datetime,CardBalance decimal(18,2))

            insert into @tb_CardConsumeDetail
            select distinct csr_cCardUserID,csr_dConsumeDate,csr_fCardBalance
            from ConsumeRecord_csr with(nolock)
            join(
            select UserID=csr_cCardUserID,MaxDate=MAX(csr_dConsumeDate)
            from ConsumeRecord_csr with(nolock)
            join vie_AllStudentCardUserInfos on csr_cCardUserID=cus_cRecordID
            group by csr_cCardUserID)A
            on csr_cCardUserID=UserID and csr_dConsumeDate=MaxDate

            insert into @tb_CardRechargeDetail
            select distinct rcr_cUserID,rcr_dRechargeTime,rcr_fBalance
            from RechargeRecord_rcr with(nolock)
            join(
            select UserID=rcr_cUserID,MaxDate=MAX(rcr_dRechargeTime)
            from RechargeRecord_rcr with(nolock)
            join vie_AllStudentCardUserInfos on rcr_cUserID=cus_cRecordID and rcr_dRechargeTime is not null
            and rcr_cRechargeType<>'Recharge_AdvanceMoney'
            group by rcr_cUserID)A
            on rcr_cUserID=UserID and rcr_dRechargeTime=MaxDate

            update CardUserAccount_cua set cua_fCurrentBalance=StuBalance,cua_dLastSyncTime=GETDATE()
            from CardUserAccount_cua Acc with(nolock)
            join(
            select cua_cRecordID,StuBalance=(case when (A.UserID is not null and B.UserID is not null) then
            (case when ConsumeDate>=RechargeDate then A.CardBalance else B.CardBalance end)
            when (A.UserID is not null and B.UserID is null) then A.CardBalance
            when (A.UserID is null and B.UserID is not null) then B.CardBalance
            else 0 end)-cua_fSysAdvance
            from vie_AllStudentCardUserInfos
            left join @tb_CardConsumeDetail A on A.UserID=cus_cRecordID
            left join @tb_CardRechargeDetail B on B.UserID=cus_cRecordID
            )TT on Acc.cua_cRecordID=TT.cua_cRecordID

            select * from vie_AllStudentCardUserInfos";
                        db.ExecuteCommand(strStuSycnAccount, new object[] { });

                        #endregion

                        #region 同步教师账户金额信息

                        string strStaffSycnAccount = @"declare @tb_CardConsumeDetail table (UserID uniqueidentifier,ConsumeDate datetime,CardBalance decimal(18,2))
            declare @tb_CardRechargeDetail table (UserID uniqueidentifier,RechargeDate datetime,CardBalance decimal(18,2))

            insert into @tb_CardConsumeDetail
            select distinct csr_cCardUserID,csr_dConsumeDate,csr_fCardBalance
            from ConsumeRecord_csr with(nolock)
            join(
            select UserID=csr_cCardUserID,MaxDate=MAX(csr_dConsumeDate)
            from ConsumeRecord_csr with(nolock)
            join CardUserMaster_cus on csr_cCardUserID=cus_cRecordID
            and cus_cIdentityNum='STAFF'
            group by csr_cCardUserID)A
            on csr_cCardUserID=UserID and csr_dConsumeDate=MaxDate

            insert into @tb_CardRechargeDetail
            select distinct rcr_cUserID,rcr_dRechargeTime,rcr_fBalance
            from RechargeRecord_rcr with(nolock)
            join(
            select UserID=rcr_cUserID,MaxDate=MAX(rcr_dRechargeTime)
            from RechargeRecord_rcr with(nolock)
            join CardUserMaster_cus on rcr_cUserID=cus_cRecordID
            and cus_cIdentityNum='STAFF'
            and rcr_dRechargeTime is not null and rcr_cRechargeType<>'Recharge_AdvanceMoney'
            group by rcr_cUserID)A
            on rcr_cUserID=UserID and rcr_dRechargeTime=MaxDate

            update CardUserAccount_cua set cua_fCurrentBalance=StuBalance,cua_dLastSyncTime=GETDATE()
            from CardUserAccount_cua Acc with(nolock)
            join(
            select cua_cRecordID,StuBalance=(case when (A.UserID is not null and B.UserID is not null) then
            (case when ConsumeDate>=RechargeDate then A.CardBalance else B.CardBalance end)
            when (A.UserID is not null and B.UserID is null) then A.CardBalance
            when (A.UserID is null and B.UserID is not null) then B.CardBalance
            else 0 end)-cua_fSysAdvance--,ConsumeDate,A.CardBalance,RechargeDate,B.CardBalance
            from CardUserMaster_cus with(nolock)
            join CardUserAccount_cua with(nolock) on cua_cCUSID=cus_cRecordID
            left join @tb_CardConsumeDetail A on A.UserID=cus_cRecordID
            left join @tb_CardRechargeDetail B on B.UserID=cus_cRecordID
            where cus_cIdentityNum='STAFF'
            )Temp
            on Acc.cua_cRecordID=Temp.cua_cRecordID

            select * from CardUserAccount_cua
            join CardUserMaster_cus on cus_cRecordID=cua_cCUSID
            and cus_cIdentityNum='STAFF'";
                        db.ExecuteCommand(strStaffSycnAccount, new object[] { });

                        #endregion

                        #region 临时清除午餐误扣费

                        string strChkLunch = @"update PreConsumeRecord_pcs set pcs_lIsSettled=1,pcs_dSettleTime=GETDATE()
            where pcs_cRecordID in
            (
            select pcs_cRecordID from PreConsumeRecord_pcs
            where pcs_lIsSettled = 0
            and pcs_cConsumeType = '" + Common.DefineConstantValue.ConsumeMoneyFlowType.SetMealCost.ToString() + "'" + Environment.NewLine;
                        strChkLunch += "and pcs_dConsumeDate between '" + DateTime.Now.ToString("yyyy-MM-dd 09:00") + "' and '" + DateTime.Now.ToString("yyyy-MM-dd 13:00") + "'" + Environment.NewLine;
                        strChkLunch += @"and pcs_fCost > 2
            and pcs_cUserID in
            (
            select csr_cCardUserID from ConsumeRecord_csr
            where csr_dConsumeDate between '" + DateTime.Now.ToString("yyyy-MM-dd 09:00") + "' and '" + DateTime.Now.ToString("yyyy-MM-dd 13:59") + "'" + Environment.NewLine;
                        strChkLunch += "and csr_cConsumeType = '" + Common.DefineConstantValue.ConsumeMachineType.StuSetmeal.ToString() + "' and csr_cMealType = '" + Common.DefineConstantValue.MealType.Lunch.ToString() + "'))" + Environment.NewLine;
                        db.ExecuteCommand(strChkLunch, new object[] { });

                        #endregion

                        #region 临时清除晚餐误扣费

                        string strChkDinner = @"update PreConsumeRecord_pcs set pcs_lIsSettled=1,pcs_dSettleTime=GETDATE()
            where pcs_cRecordID in
            (
            select pcs_cRecordID from PreConsumeRecord_pcs
            where pcs_lIsSettled = 0
            and pcs_cConsumeType = '" + Common.DefineConstantValue.ConsumeMoneyFlowType.SetMealCost.ToString() + "'" + Environment.NewLine;
                        strChkDinner += "and pcs_dConsumeDate between '" + DateTime.Now.ToString("yyyy-MM-dd 13:30") + "' and '" + DateTime.Now.ToString("yyyy-MM-dd 23:59") + "'" + Environment.NewLine;
                        strChkDinner += @"and pcs_fCost > 2
            and pcs_cUserID in
            (
            select csr_cCardUserID from ConsumeRecord_csr
            where csr_dConsumeDate between '" + DateTime.Now.ToString("yyyy-MM-dd 15:00") + "' and '" + DateTime.Now.ToString("yyyy-MM-dd 23:59") + "'" + Environment.NewLine;
                        strChkDinner += "and csr_cConsumeType = '" + Common.DefineConstantValue.ConsumeMachineType.StuSetmeal.ToString() + "' and csr_cMealType = '" + Common.DefineConstantValue.MealType.Supper.ToString() + "'))" + Environment.NewLine;
                        db.ExecuteCommand(strChkDinner, new object[] { });

                        #endregion

                        if (listConsume.Count < 1 && listUpdatePreCost.Count < 1)
                        {
                            rvInfo.boolValue = false;
                            rvInfo.messageText = "没有可用的数据。";
                        }
                        else
                        {
                            rvInfo.boolValue = true;
                        }

                    }
                    catch (Exception exx)
                    {
                        db.Transaction.Rollback();
                        db.Connection.Close();
                        throw exx;
                    }
                    db.Transaction.Commit();
                    db.Connection.Close();
                }
            }
            catch (Exception ex)
            {
                rvInfo.isError = true;
                rvInfo.messageText = ex.Message;
            }
            return rvInfo;
        }