/// <summary> /// 更新一条数据 /// </summary> public bool Update(TF.RunSafty.Model.VIEW_LED_Files_Clients model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update VIEW_LED_Files_Clients set "); strSql.Append("nid=@nid,"); strSql.Append("strFileGUID=@strFileGUID,"); strSql.Append("strWorkShopGUID=@strWorkShopGUID,"); strSql.Append("DtUpdate=@DtUpdate,"); strSql.Append("strFilePathName=@strFilePathName,"); strSql.Append("strFileName=@strFileName,"); strSql.Append("clientid=@clientid"); strSql.Append(" where "); SqlParameter[] parameters = { new SqlParameter("@nid", SqlDbType.Int, 4), new SqlParameter("@strFileGUID", SqlDbType.NVarChar, 100), new SqlParameter("@strWorkShopGUID", SqlDbType.NVarChar, 100), new SqlParameter("@DtUpdate", SqlDbType.DateTime), new SqlParameter("@strFilePathName", SqlDbType.NVarChar, 500), new SqlParameter("@strFileName", SqlDbType.NVarChar, 200), new SqlParameter("@clientid", SqlDbType.VarChar, 50) }; parameters[0].Value = model.nid; parameters[1].Value = model.strFileGUID; parameters[2].Value = model.strWorkShopGUID; parameters[3].Value = model.DtUpdate; parameters[4].Value = model.strFilePathName; parameters[5].Value = model.strFileName; parameters[6].Value = model.clientid; int rows = (int)SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Model.VIEW_LED_Files_Clients GetModel() { //该表无主键信息,请自定义主键/条件字段 StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 nid,strFileGUID,strWorkShopGUID,DtUpdate,strFilePathName,strFileName,clientid from VIEW_LED_Files_Clients "); strSql.Append(" where "); SqlParameter[] parameters = { }; TF.RunSafty.Model.VIEW_LED_Files_Clients model = new TF.RunSafty.Model.VIEW_LED_Files_Clients(); DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(TF.RunSafty.Model.VIEW_LED_Files_Clients model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into VIEW_LED_Files_Clients("); strSql.Append("nid,strFileGUID,strWorkShopGUID,DtUpdate,strFilePathName,strFileName,clientid)"); strSql.Append(" values ("); strSql.Append("@nid,@strFileGUID,@strWorkShopGUID,@DtUpdate,@strFilePathName,@strFileName,@clientid)"); SqlParameter[] parameters = { new SqlParameter("@nid", SqlDbType.Int, 4), new SqlParameter("@strFileGUID", SqlDbType.NVarChar, 100), new SqlParameter("@strWorkShopGUID", SqlDbType.NVarChar, 100), new SqlParameter("@DtUpdate", SqlDbType.DateTime), new SqlParameter("@strFilePathName", SqlDbType.NVarChar, 500), new SqlParameter("@strFileName", SqlDbType.NVarChar, 200), new SqlParameter("@clientid", SqlDbType.VarChar, 50) }; parameters[0].Value = model.nid; parameters[1].Value = model.strFileGUID; parameters[2].Value = model.strWorkShopGUID; parameters[3].Value = model.DtUpdate; parameters[4].Value = model.strFilePathName; parameters[5].Value = model.strFileName; parameters[6].Value = model.clientid; int rows = (int)SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public TF.RunSafty.Model.VIEW_LED_Files_Clients DataRowToModel(DataRow row) { TF.RunSafty.Model.VIEW_LED_Files_Clients model = new TF.RunSafty.Model.VIEW_LED_Files_Clients(); if (row != null) { if (row["nid"] != null && row["nid"].ToString() != "") { model.nid = int.Parse(row["nid"].ToString()); } if (row["strFileGUID"] != null) { model.strFileGUID = row["strFileGUID"].ToString(); } if (row["strWorkShopGUID"] != null) { model.strWorkShopGUID = row["strWorkShopGUID"].ToString(); } if (row["DtUpdate"] != null && row["DtUpdate"].ToString() != "") { model.DtUpdate = DateTime.Parse(row["DtUpdate"].ToString()); } if (row["strFilePathName"] != null) { model.strFilePathName = row["strFilePathName"].ToString(); } if (row["strFileName"] != null) { model.strFileName = row["strFileName"].ToString(); } if (row["clientid"] != null) { model.clientid = row["clientid"].ToString(); } } return(model); }