/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.projectCostlujing model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update projectCostlujing set "); strSql.Append("projectCostUrl=@projectCostUrl,"); strSql.Append("ProjectId=@ProjectId"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@projectCostUrl", SqlDbType.NVarChar, 500), new SqlParameter("@ProjectId", SqlDbType.Int, 4), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.projectCostUrl; parameters[1].Value = model.ProjectId; parameters[2].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.projectCostlujing model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into projectCostlujing("); strSql.Append("projectCostUrl,ProjectId)"); strSql.Append(" values ("); strSql.Append("@projectCostUrl,@ProjectId)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@projectCostUrl", SqlDbType.NVarChar, 500), new SqlParameter("@ProjectId", SqlDbType.Int, 4) }; parameters[0].Value = model.projectCostUrl; parameters[1].Value = model.ProjectId; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.projectCostlujing DataRowToModel(DataRow row) { Model.projectCostlujing model = new Model.projectCostlujing(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["projectCostUrl"] != null) { model.projectCostUrl = row["projectCostUrl"].ToString(); } if (row["ProjectId"] != null && row["ProjectId"].ToString() != "") { model.ProjectId = int.Parse(row["ProjectId"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.projectCostlujing GetModels(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,projectCostUrl,ProjectId from projectCostlujing "); strSql.Append(" where ProjectId=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.projectCostlujing model = new Model.projectCostlujing(); DataSet ds = DbHelperSQL.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(Model.projectCostlujing model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.projectCostlujing model) { return(dal.Add(model)); }