Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(PartyConstruction.Model.DBBranch model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BranchInfo set ");
            strSql.Append("Name=@Name,");
            strSql.Append("ParentBranchID=@ParentBranchID");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@Name",           DbType.String, 2147483647),
                new SQLiteParameter("@ParentBranchID", DbType.String, 2147483647),
                new SQLiteParameter("@ID",             DbType.String, 2147483647)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.ParentBranchID;
            parameters[2].Value = model.ID;

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

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

            strSql.Append("insert into BranchInfo(");
            strSql.Append("ID,Name,ParentBranchID)");
            strSql.Append(" values (");
            strSql.Append("@ID,@Name,@ParentBranchID)");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID",             DbType.String, 2147483647),
                new SQLiteParameter("@Name",           DbType.String, 2147483647),
                new SQLiteParameter("@ParentBranchID", DbType.String, 2147483647)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.ParentBranchID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public PartyConstruction.Model.DBBranch DataRowToModel(DataRow row)
 {
     PartyConstruction.Model.DBBranch model = new PartyConstruction.Model.DBBranch();
     if (row != null)
     {
         if (row["ID"] != null)
         {
             model.ID = row["ID"].ToString();
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["ParentBranchID"] != null)
         {
             model.ParentBranchID = row["ParentBranchID"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PartyConstruction.Model.DBBranch GetModel(string ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,Name,ParentBranchID from BranchInfo ");
            strSql.Append(" where ID=@ID ");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.String, 2147483647)
            };
            parameters[0].Value = ID;

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

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