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

            strSql.Append("update Brand set ");
            strSql.Append("Name=@Name,");
            strSql.Append("CompanyId=@CompanyId,");
            strSql.Append("code=@code");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",      SqlDbType.NVarChar, 200),
                new SqlParameter("@CompanyId", SqlDbType.Int,        4),
                new SqlParameter("@code",      SqlDbType.NVarChar,  50),
                new SqlParameter("@Id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.CompanyId;
            parameters[2].Value = model.code;
            parameters[3].Value = model.Id;

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

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

            strSql.Append("insert into Brand(");
            strSql.Append("Name,CompanyId,code)");
            strSql.Append(" values (");
            strSql.Append("@Name,@CompanyId,@code)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",      SqlDbType.NVarChar, 200),
                new SqlParameter("@CompanyId", SqlDbType.Int,        4),
                new SqlParameter("@code",      SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.CompanyId;
            parameters[2].Value = model.code;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 3
0
 private static Brand MapToDomain(this Model.Brand b)
 {
     return(new Brand
     {
         Appearances = b.appearances?.Select(MapToDomain).ToList(),
         Description = b.description,
         Name = b.name,
         WikiId = b.wikiId,
         WikiUrl = b.wikiUrl,
     });
 }
 private string addBrandss(string Comyanyname, string code)
 {
     Model.Brand model = new Model.Brand();
     if (Comyanyname != null && code != null)
     {
         model.Name = Comyanyname;
         model.code = code;
         bll2.Add(model);
         return("{\"status\": 1,\"msg\": \"添加成功!\"}");
     }
     else
     {
         return("{\"status\": 0,\"msg\": \"错误提示:添加失败!\"}");
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.Brand DataRowToModel(DataRow row)
 {
     Model.Brand model = new  Model.Brand();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["CompanyId"] != null && row["CompanyId"].ToString() != "")
         {
             model.CompanyId = int.Parse(row["CompanyId"].ToString());
         }
         if (row["code"] != null)
         {
             model.code = row["code"].ToString();
         }
     }
     return(model);
 }
Exemplo n.º 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Brand GetModels(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Name,CompanyId,code from Brand ");
            strSql.Append(" where CompanyId=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            Model.Brand model = new Model.Brand();
            DataSet     ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.Brand model)
 {
     return(dal.Update(model));
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(Model.Brand model)
 {
     return(dal.Add(model));
 }