Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebSiteModel.Relation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Relation set ");
            strSql.Append("WebSiteID=@WebSiteID,");
            strSql.Append("WebStatusID=@WebStatusID,");
            strSql.Append("PartnerID=@PartnerID,");
            strSql.Append("WebSiteloginID=@WebSiteloginID,");
            strSql.Append("BrandsID=@BrandsID,");
            strSql.Append("DomainID=@DomainID");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@WebSiteID",      DbType.Int32, 8),
                new SQLiteParameter("@WebStatusID",    DbType.Int32, 8),
                new SQLiteParameter("@PartnerID",      DbType.Int32, 8),
                new SQLiteParameter("@WebSiteloginID", DbType.Int32, 8),
                new SQLiteParameter("@BrandsID",       DbType.Int32, 8),
                new SQLiteParameter("@DomainID",       DbType.Int32, 8),
                new SQLiteParameter("@ID",             DbType.Int32, 8)
            };
            parameters[0].Value = model.WebSiteID;
            parameters[1].Value = model.WebStatusID;
            parameters[2].Value = model.PartnerID;
            parameters[3].Value = model.WebSiteloginID;
            parameters[4].Value = model.BrandsID;
            parameters[5].Value = model.DomainID;
            parameters[6].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebSiteModel.Relation DataRowToModel(DataRow row)
 {
     WebSiteModel.Relation model = new WebSiteModel.Relation();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["WebSiteID"] != null && row["WebSiteID"].ToString() != "")
         {
             model.WebSiteID = int.Parse(row["WebSiteID"].ToString());
         }
         if (row["WebStatusID"] != null && row["WebStatusID"].ToString() != "")
         {
             model.WebStatusID = int.Parse(row["WebStatusID"].ToString());
         }
         if (row["PartnerID"] != null && row["PartnerID"].ToString() != "")
         {
             model.PartnerID = int.Parse(row["PartnerID"].ToString());
         }
         if (row["WebSiteloginID"] != null && row["WebSiteloginID"].ToString() != "")
         {
             model.WebSiteloginID = int.Parse(row["WebSiteloginID"].ToString());
         }
         if (row["BrandsID"] != null && row["BrandsID"].ToString() != "")
         {
             model.BrandsID = int.Parse(row["BrandsID"].ToString());
         }
         if (row["DomainID"] != null && row["DomainID"].ToString() != "")
         {
             model.DomainID = int.Parse(row["DomainID"].ToString());
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebSiteModel.Relation model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Relation(");
            strSql.Append("WebSiteID,WebStatusID,PartnerID,WebSiteloginID,BrandsID,DomainID)");
            strSql.Append(" values (");
            strSql.Append("@WebSiteID,@WebStatusID,@PartnerID,@WebSiteloginID,@BrandsID,@DomainID)");
            strSql.Append(";select LAST_INSERT_ROWID()");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@WebSiteID",      DbType.Int32, 8),
                new SQLiteParameter("@WebStatusID",    DbType.Int32, 8),
                new SQLiteParameter("@PartnerID",      DbType.Int32, 8),
                new SQLiteParameter("@WebSiteloginID", DbType.Int32, 8),
                new SQLiteParameter("@BrandsID",       DbType.Int32, 8),
                new SQLiteParameter("@DomainID",       DbType.Int32, 8)
            };
            parameters[0].Value = model.WebSiteID;
            parameters[1].Value = model.WebStatusID;
            parameters[2].Value = model.PartnerID;
            parameters[3].Value = model.WebSiteloginID;
            parameters[4].Value = model.BrandsID;
            parameters[5].Value = model.DomainID;

            object obj = DbHelperSQLite.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebSiteModel.Relation GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,WebSiteID,WebStatusID,PartnerID,WebSiteloginID,BrandsID,DomainID from Relation ");
            strSql.Append(" where ID=@ID");
            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@ID", DbType.Int32, 4)
            };
            parameters[0].Value = ID;

            WebSiteModel.Relation model = new WebSiteModel.Relation();
            DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters);

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