/// <summary> /// 增加一条数据 /// </summary> public int Add(Dianda.Model.Document_File_Share model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Document_File_Share("); strSql.Append("FileID,ShareForUser,DATETIME)"); strSql.Append(" values ("); strSql.Append("@FileID,@ShareForUser,@DATETIME)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@FileID", SqlDbType.Int, 4), new SqlParameter("@ShareForUser", SqlDbType.VarChar, 50), new SqlParameter("@DATETIME", SqlDbType.DateTime) }; parameters[0].Value = model.FileID; parameters[1].Value = model.ShareForUser; parameters[2].Value = model.DATETIME; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(1); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Dianda.Model.Document_File_Share model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Document_File_Share set "); strSql.Append("FileID=@FileID,"); strSql.Append("ShareForUser=@ShareForUser,"); strSql.Append("DATETIME=@DATETIME"); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@FileID", SqlDbType.Int, 4), new SqlParameter("@ShareForUser", SqlDbType.VarChar, 50), new SqlParameter("@DATETIME", SqlDbType.DateTime) }; parameters[0].Value = model.ID; parameters[1].Value = model.FileID; parameters[2].Value = model.ShareForUser; parameters[3].Value = model.DATETIME; DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Dianda.Model.Document_File_Share GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ID,FileID,ShareForUser,DATETIME from Document_File_Share "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4) }; parameters[0].Value = ID; Dianda.Model.Document_File_Share model = new Dianda.Model.Document_File_Share(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ID"].ToString() != "") { model.ID = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if (ds.Tables[0].Rows[0]["FileID"].ToString() != "") { model.FileID = int.Parse(ds.Tables[0].Rows[0]["FileID"].ToString()); } model.ShareForUser = ds.Tables[0].Rows[0]["ShareForUser"].ToString(); if (ds.Tables[0].Rows[0]["DATETIME"].ToString() != "") { model.DATETIME = DateTime.Parse(ds.Tables[0].Rows[0]["DATETIME"].ToString()); } return(model); } else { return(null); } }