Ejemplo n.º 1
0
        ///// <summary>
        ///// 以userId為鍵項,查詢使用者資料
        ///// </summary>
        ///// <param name="userId"></param>
        ///// <returns></returns>
        //public CODE_USER qryByKey(String userId) {
        //    using (dbTreasuryEntities db = new dbTreasuryEntities())
        //    {
        //        CODE_USER codeUser = db.CODE_USER.Where(x => x.USER_ID == userId).FirstOrDefault<CODE_USER>();

        //        return codeUser;
        //    }

        //}



        /// <summary>
        /// 異動user的login、logout時間
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="type"></param>
        public void updateLogInOut(String userId, String type)
        {
            using (dbTreasuryEntities db = new dbTreasuryEntities())
            {
                CODE_USER codeUser = db.CODE_USER.Where(x => x.USER_ID == userId).FirstOrDefault <CODE_USER>();


                if ("I".Equals(type))
                {
                    codeUser.LAST_LOGIN_DT = DateUtil.getCurDateTime();
                }
                else
                {
                    codeUser.LAST_LOGOUT_DT = DateUtil.getCurDateTime();
                }

                int cnt = db.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        public int qrySeqNo(String cType, String cPreCode)
        {
            int intseq = 0;
            int cnt    = 0;

            //using (new TransactionScope(
            //       TransactionScopeOption.Required,
            //       new TransactionOptions
            //       {
            //           IsolationLevel = IsolationLevel.ReadUncommitted
            //       }))
            //{

            using (dbTreasuryEntities db = new dbTreasuryEntities())
            {
                try
                {
                    if ("".Equals(cPreCode))
                    {
                        SYS_SEQ sysDeq = db.SYS_SEQ.Where(x => x.SEQ_TYPE == cType).FirstOrDefault <SYS_SEQ>();
                        if (sysDeq == null)
                        {
                            sysDeq                = new SYS_SEQ();
                            intseq                = 1;
                            sysDeq.SEQ_TYPE       = cType;
                            sysDeq.PRECODE        = "";
                            sysDeq.CURR_VALUE     = intseq + 1;
                            sysDeq.LAST_UPDATE_DT = DateTime.Now;

                            db.SYS_SEQ.Add(sysDeq);
                            cnt = db.SaveChanges();
                        }
                        else
                        {
                            intseq = sysDeq.CURR_VALUE;

                            sysDeq.CURR_VALUE     = intseq + 1;
                            sysDeq.LAST_UPDATE_DT = DateTime.Now;

                            cnt = db.SaveChanges();
                        }
                    }
                    else
                    {
                        SYS_SEQ sysDeq = db.SYS_SEQ.Where(x => x.SEQ_TYPE == cType & x.PRECODE == cPreCode).FirstOrDefault <SYS_SEQ>();

                        if (sysDeq == null)
                        {
                            sysDeq                = new SYS_SEQ();
                            intseq                = 1;
                            sysDeq.SEQ_TYPE       = cType;
                            sysDeq.PRECODE        = cPreCode;
                            sysDeq.CURR_VALUE     = intseq + 1;
                            sysDeq.LAST_UPDATE_DT = DateTime.Now;

                            db.SYS_SEQ.Add(sysDeq);
                            cnt = db.SaveChanges();
                        }
                        else
                        {
                            intseq = sysDeq.CURR_VALUE;

                            sysDeq.CURR_VALUE     = intseq + 1;
                            sysDeq.LAST_UPDATE_DT = DateTime.Now;

                            cnt = db.SaveChanges();
                        }
                    }


                    return(intseq);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            //}
        }