public void add(MusicModel music) { SqlConnection cn = null; SqlTransaction tc = null; try { cn = DbHelperSQL.getConnection(); tc = DbHelperSQL.startTransaction(cn); //执行新增写进数据库 musicDal.add(cn, tc, music); DbHelperSQL.commitTransaction(tc); } catch (Exception dalEx) { DbHelperSQL.rollBackTransaction(tc); throw new MakeException(ExpSort.数据库, dalEx.Message); } finally { DbHelperSQL.closeConnection(cn); } }
public bool update(SqlConnection cn, SqlTransaction tc, MusicModel model) { return DbHelperSQL.updateModel<MusicModel>(model, "Music", "Evenid", model.Evenid.ToString(), "'", cn, tc); }
protected void UpPicCmd_Click(object sender, EventArgs e) { if (MusicName.Text == "") { this.Label1.Text = "请输入音乐名称"; return; } string name = FileUpload1.FileName; if (name.Trim() == "") { this.Label1.Text = "请选择要上传的文件"; return; } else { this.Label1.Text = ""; } string type = name.Substring(name.LastIndexOf(".")); string fileName = Guid.NewGuid().ToString(); string path = Server.MapPath(Helper.MusicPath) + fileName + type; string wpath = Helper.MusicPath + fileName + type; if (FileUpload1.PostedFile.ContentType.Substring(0, 5) == "audio") { //解除音乐大小的限制 // if (FileUpload1.PostedFile.ContentLength > Helper.MusicLimit) // { // this.Label1.Text = Helper.MusicLimitWraning; // return; // } FileUpload1.SaveAs(path); image = wpath; SelectMusic = MusicName.Text; var music = new MusicModel(); music.Path = fileName + type; music.MusicName = MusicName.Text; bll.add(music); } else { this.Label1.Text = "请上传音乐格式文件"; return; } this.DataBind(); }
public bool add(SqlConnection cn, SqlTransaction tc, MusicModel model) { return DbHelperSQL.insertModel<MusicModel>(model, "Music", cn, tc); }