/// <summary>
 /// 得到一个对象实体
 /// </summary>
 public PartyConstruction.Model.DBUser DataRowToModel(DataRow row)
 {
     PartyConstruction.Model.DBUser model = new PartyConstruction.Model.DBUser();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["IsBranchMaster"] != null && row["IsBranchMaster"].ToString() != "")
         {
             if ((row["IsBranchMaster"].ToString() == "1") || (row["IsBranchMaster"].ToString().ToLower() == "true"))
             {
                 model.IsBranchMaster = true;
             }
             else
             {
                 model.IsBranchMaster = false;
             }
         }
         if (row["IsManager"] != null && row["IsManager"].ToString() != "")
         {
             if ((row["IsManager"].ToString() == "1") || (row["IsManager"].ToString().ToLower() == "true"))
             {
                 model.IsManager = true;
             }
             else
             {
                 model.IsManager = false;
             }
         }
         if (row["BranchID"] != null)
         {
             model.BranchID = row["BranchID"].ToString();
         }
         if (row["Account"] != null)
         {
             model.Account = row["Account"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["ServicingBranchID"] != null)
         {
             model.ServicingBranchID = row["ServicingBranchID"].ToString();
         }
         if (row["Score"] != null && row["Score"].ToString() != "")
         {
             model.Score = int.Parse(row["Score"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PartyConstruction.Model.DBUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update UserInfo set ");
            strSql.Append("Name=@Name,");
            strSql.Append("IsBranchMaster=@IsBranchMaster,");
            strSql.Append("IsManager=@IsManager,");
            strSql.Append("BranchID=@BranchID,");
            strSql.Append("Account=@Account,");
            strSql.Append("Password=@Password,");
            strSql.Append("ServicingBranchID=@ServicingBranchID,");
            strSql.Append("Score=@Score");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Name",              DbType.String,   2147483647),
                new SQLiteParameter("@IsBranchMaster",    DbType.Boolean),
                new SQLiteParameter("@IsManager",         DbType.Boolean),
                new SQLiteParameter("@BranchID",          DbType.String,   2147483647),
                new SQLiteParameter("@Account",           DbType.String,   2147483647),
                new SQLiteParameter("@Password",          DbType.String,   2147483647),
                new SQLiteParameter("@ServicingBranchID", DbType.String,   2147483647),
                new SQLiteParameter("@Score",             DbType.Int32,             4),
                new SQLiteParameter("@ID",                DbType.String, 2147483647)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.IsBranchMaster;
            parameters[2].Value = model.IsManager;
            parameters[3].Value = model.BranchID;
            parameters[4].Value = model.Account;
            parameters[5].Value = model.Password;
            parameters[6].Value = model.ServicingBranchID;
            parameters[7].Value = model.Score;
            parameters[8].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(PartyConstruction.Model.DBUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserInfo(");
            strSql.Append("ID,Name,IsBranchMaster,IsManager,BranchID,Account,Password,ServicingBranchID,Score)");
            strSql.Append(" values (");
            strSql.Append("@ID,@Name,@IsBranchMaster,@IsManager,@BranchID,@Account,@Password,@ServicingBranchID,@Score)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID",                DbType.String,   2147483647),
                new SQLiteParameter("@Name",              DbType.String,   2147483647),
                new SQLiteParameter("@IsBranchMaster",    DbType.Boolean),
                new SQLiteParameter("@IsManager",         DbType.Boolean),
                new SQLiteParameter("@BranchID",          DbType.String,   2147483647),
                new SQLiteParameter("@Account",           DbType.String,   2147483647),
                new SQLiteParameter("@Password",          DbType.String,   2147483647),
                new SQLiteParameter("@ServicingBranchID", DbType.String,   2147483647),
                new SQLiteParameter("@Score",             DbType.Int32, 4)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.IsBranchMaster;
            parameters[3].Value = model.IsManager;
            parameters[4].Value = model.BranchID;
            parameters[5].Value = model.Account;
            parameters[6].Value = model.Password;
            parameters[7].Value = model.ServicingBranchID;
            parameters[8].Value = model.Score;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public PartyConstruction.Model.DBUser GetModelByAccount(string account)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,Name,IsBranchMaster,IsManager,BranchID,Account,Password,ServicingBranchID,Score from UserInfo ");
            strSql.Append(" where Account=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.String, 2147483647)
            };
            parameters[0].Value = account;

            PartyConstruction.Model.DBUser model = new PartyConstruction.Model.DBUser();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }