Exemplo n.º 1
0
    public MySqlTest()
    {
      traceService = new TestTraceService();
      db = MySqlDb.Connect( "localhost", "Test", "root", "", configuration: new MySqlDbConfiguration() { TraceService = traceService } );
      db.T( "DROP TABLE IF EXISTS testTable" ).ExecuteNonQuery();
      db.T( @"
CREATE TABLE testTable(
Id int(11) NOT NULL,
Name varchar(50) DEFAULT NULL,
Content text,
PRIMARY KEY (Id)
)" ).ExecuteNonQuery();
    }
Exemplo n.º 2
0
        public MySqlTest()
        {
            traceService = new TestTraceService();
            db           = MySqlDb.Connect("localhost", "Test", "root", "", configuration: new MySqlDbConfiguration()
            {
                TraceService = traceService
            });
            db.T("DROP TABLE IF EXISTS testTable").ExecuteNonQuery();
            db.T(@"
CREATE TABLE testTable(
Id int(11) NOT NULL,
Name varchar(50) DEFAULT NULL,
Content text,
PRIMARY KEY (Id)
)").ExecuteNonQuery();
        }
Exemplo n.º 3
0
        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <returns>0=成功;1=帐号密码错误;2=帐号已经过期;3=帐号已经锁定</returns>
        public int AdminLogin(string F002TB001, string F003TB001, string F006TB001, ref EMC.Model.tb001 model, ref string Message)
        {
            int res = 1;

            #region 管理员登录
            string sqlStr = "select * from TB001 where F002TB001={0} and F003TB001={1}";
            model = db.T(sqlStr, F002TB001, F003TB001).ExecuteDynamicObject();
            if (model != null)
            {
                if (model.F004TB001 > DateTime.Now || model.F005TB001 < DateTime.Now)
                {
                    res     = 2;
                    Message = "帐号已经过期";
                }
                else if (model.F099TB001 != 1)
                {
                    res     = 3;
                    Message = "帐号已经锁定";
                }
                else
                {
                    res     = 0;
                    Message = "登录成功";
                }
            }
            else
            {
                res     = 1;
                Message = "用户名或者密码错误";
            }
            #endregion
            #region 插入登录日志
            try
            {
                using (var tran = db.BeginTransaction())
                {
                    //更新最后登录时间日志
                    if (res == 0)
                    {
                        tran.T("update TB001 set F006TB001={1},F007TB001=now() where NOIDTB001={0}", model.NOIDTB001, F006TB001).ExecuteNonQuery();
                    }

                    //插入登录日志
                    Model.tb1001 model_TB1001 = new Model.tb1001();
                    model_TB1001.F001TB1001 = F002TB001;
                    model_TB1001.F002TB1001 = F003TB001;
                    model_TB1001.F003TB1001 = res;
                    model_TB1001.F004TB1001 = Message;
                    model_TB1001.F005TB1001 = F006TB001;
                    model_TB1001.TIMETB1001 = DateTime.Now;

                    TModel tmodel = EMC.DbUtility.Utility.GetInsertTModel <EMC.Model.tb1001>(model_TB1001);
                    tran.T(tmodel.SQL, tmodel.ParameterValues).ExecuteNonQuery();

                    tran.Commit();
                }
            }
            catch
            {
                //插入日志失败 暂不做处理
            }
            #endregion
            return(res);
        }
Exemplo n.º 4
0
 public void Initialize()
 {
     db.T("TRUNCATE TABLE testTable").ExecuteNonQuery();
 }