private void kryptonButtonTestSQLite_Click(object sender, EventArgs e)
        {
            KryptonAccessController.SQLite.Model.UserRelation.UserInfo modelUserInfo = new KryptonAccessController.SQLite.Model.UserRelation.UserInfo();
            KryptonAccessController.SQLite.BLL.UserRelation.UserInfo bllUserInfo = new KryptonAccessController.SQLite.BLL.UserRelation.UserInfo();

            modelUserInfo.UserID = bllUserInfo.GetMaxId();
            modelUserInfo.UserName = "******";
            modelUserInfo.Photograph = null;
            modelUserInfo.UserGroupID1 = 0;
            modelUserInfo.UserGroupID2 = 0;
            modelUserInfo.UserGroupID3 = 0;
            modelUserInfo.FingerPosition0 = 0;
            modelUserInfo.FingerPosition1 = 0;
            modelUserInfo.FingerPrint0 = null;
            modelUserInfo.FingerPrint1 = null;
            modelUserInfo.SercurityAccessLevel = 0;
            modelUserInfo.PrimaryCardID = "AAAAAA";
            modelUserInfo.SecondCardID = "BBBBBB";
            bllUserInfo.Add(modelUserInfo);
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public KryptonAccessController.SQLite.Model.UserRelation.UserInfo GetModel(int UserID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select UserID,UserName,Photograph,UserGroupID1,UserGroupID2,UserGroupID3,UserGroupID4,FingerPosition0,FingerPrint0,FingerPosition1,FingerPrint1,SercurityAccessLevel,PrimaryCardID,SecondCardID from UserInfo ");
            strSql.Append(" where UserID=@UserID ");
            SQLiteParameter[] parameters = {
                    new SQLiteParameter("@UserID", DbType.Int32,4)			};
            parameters[0].Value = UserID;

            KryptonAccessController.SQLite.Model.UserRelation.UserInfo model=new KryptonAccessController.SQLite.Model.UserRelation.UserInfo();
            DataSet ds=DbHelperSQLite.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(KryptonAccessController.SQLite.Model.UserRelation.UserInfo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserInfo set ");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Photograph=@Photograph,");
            strSql.Append("UserGroupID1=@UserGroupID1,");
            strSql.Append("UserGroupID2=@UserGroupID2,");
            strSql.Append("UserGroupID3=@UserGroupID3,");
            strSql.Append("UserGroupID4=@UserGroupID4,");
            strSql.Append("FingerPosition0=@FingerPosition0,");
            strSql.Append("FingerPrint0=@FingerPrint0,");
            strSql.Append("FingerPosition1=@FingerPosition1,");
            strSql.Append("FingerPrint1=@FingerPrint1,");
            strSql.Append("SercurityAccessLevel=@SercurityAccessLevel,");
            strSql.Append("PrimaryCardID=@PrimaryCardID,");
            strSql.Append("SecondCardID=@SecondCardID");
            strSql.Append(" where UserID=@UserID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@UserName",             DbType.String),
                new SQLiteParameter("@Photograph",           DbType.Binary),
                new SQLiteParameter("@UserGroupID1",         DbType.Int32,   4),
                new SQLiteParameter("@UserGroupID2",         DbType.Int32,   4),
                new SQLiteParameter("@UserGroupID3",         DbType.Int32,   4),
                new SQLiteParameter("@UserGroupID4",         DbType.Int32,   4),
                new SQLiteParameter("@FingerPosition0",      DbType.Int32,   4),
                new SQLiteParameter("@FingerPrint0",         DbType.Binary),
                new SQLiteParameter("@FingerPosition1",      DbType.Int32,   4),
                new SQLiteParameter("@FingerPrint1",         DbType.Binary),
                new SQLiteParameter("@SercurityAccessLevel", DbType.Int32,   4),
                new SQLiteParameter("@PrimaryCardID",        DbType.String),
                new SQLiteParameter("@SecondCardID",         DbType.String),
                new SQLiteParameter("@UserID",               DbType.Int32, 4)
            };
            parameters[0].Value  = model.UserName;
            parameters[1].Value  = model.Photograph;
            parameters[2].Value  = model.UserGroupID1;
            parameters[3].Value  = model.UserGroupID2;
            parameters[4].Value  = model.UserGroupID3;
            parameters[5].Value  = model.UserGroupID4;
            parameters[6].Value  = model.FingerPosition0;
            parameters[7].Value  = model.FingerPrint0;
            parameters[8].Value  = model.FingerPosition1;
            parameters[9].Value  = model.FingerPrint1;
            parameters[10].Value = model.SercurityAccessLevel;
            parameters[11].Value = model.PrimaryCardID;
            parameters[12].Value = model.SecondCardID;
            parameters[13].Value = model.UserID;

            int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public KryptonAccessController.SQLite.Model.UserRelation.UserInfo DataRowToModel(DataRow row)
 {
     KryptonAccessController.SQLite.Model.UserRelation.UserInfo model=new KryptonAccessController.SQLite.Model.UserRelation.UserInfo();
     if (row != null)
     {
         if(row["UserID"]!=null && row["UserID"].ToString()!="")
         {
             model.UserID=int.Parse(row["UserID"].ToString());
         }
         if(row["UserName"]!=null)
         {
             model.UserName=row["UserName"].ToString();
         }
         if(row["Photograph"]!=null && row["Photograph"].ToString()!="")
         {
             model.Photograph=(byte[])row["Photograph"];
         }
         if(row["UserGroupID1"]!=null && row["UserGroupID1"].ToString()!="")
         {
             model.UserGroupID1=int.Parse(row["UserGroupID1"].ToString());
         }
         if(row["UserGroupID2"]!=null && row["UserGroupID2"].ToString()!="")
         {
             model.UserGroupID2=int.Parse(row["UserGroupID2"].ToString());
         }
         if(row["UserGroupID3"]!=null && row["UserGroupID3"].ToString()!="")
         {
             model.UserGroupID3=int.Parse(row["UserGroupID3"].ToString());
         }
         if(row["UserGroupID4"]!=null && row["UserGroupID4"].ToString()!="")
         {
             model.UserGroupID4=int.Parse(row["UserGroupID4"].ToString());
         }
         if(row["FingerPosition0"]!=null && row["FingerPosition0"].ToString()!="")
         {
             model.FingerPosition0=int.Parse(row["FingerPosition0"].ToString());
         }
         if(row["FingerPrint0"]!=null && row["FingerPrint0"].ToString()!="")
         {
             model.FingerPrint0=(byte[])row["FingerPrint0"];
         }
         if(row["FingerPosition1"]!=null && row["FingerPosition1"].ToString()!="")
         {
             model.FingerPosition1=int.Parse(row["FingerPosition1"].ToString());
         }
         if(row["FingerPrint1"]!=null && row["FingerPrint1"].ToString()!="")
         {
             model.FingerPrint1=(byte[])row["FingerPrint1"];
         }
         if(row["SercurityAccessLevel"]!=null && row["SercurityAccessLevel"].ToString()!="")
         {
             model.SercurityAccessLevel=int.Parse(row["SercurityAccessLevel"].ToString());
         }
         if(row["PrimaryCardID"]!=null)
         {
             model.PrimaryCardID=row["PrimaryCardID"].ToString();
         }
         if(row["SecondCardID"]!=null)
         {
             model.SecondCardID=row["SecondCardID"].ToString();
         }
     }
     return model;
 }