private bool DoAdd() { bool result = true; Model.guidaudio model = new Model.guidaudio(); BLL.guidaudio bll = new BLL.guidaudio(); model.channel_id = this.channel_id; model.audio_name = txtTitle.Text.Trim(); model.content = ""; model.is_top = 0; model.is_free = 0; model.is_slide = 0; model.is_red = 0; model.add_time = DateTime.Now; model.remark1 = ""; model.remark2 = 0; model.img_url = txtImgUrl.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text); if (cblItem.Items[0].Selected == true) { model.is_top = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } model.albums = null; model.audio_time = txtTimeSize.Text.Trim(); // audio_path audio_time audio_size string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); model.remark1 = fileArr[3].Trim(); model.audio_size = fileArr[1].Trim(); model.audio_path = fileArr[2].Trim(); if (bll.Add(model) < 1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script type=\"text/javascript\">alert('上传失败!');</script>"); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script type=\"text/javascript\"> if(confirm('添加成功,是否继续添加?')) {window.location.href='edit.aspx?action='" + DTEnums.ActionEnum.Add + "'&channel_id=" + this.channel_id + "';} else {window.location.href= 'list.aspx?channel_id='" + this.channel_id + " }</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script type=\"text/javascript\">alert('请上传文件!');</script>"); } return result; }
/// <summary> /// 获取实体 /// </summary> public Model.guidaudio GetGuidAudioModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from dt_guidaudio "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.guidaudio model = new Model.guidaudio(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { #region DATA if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["channel_id"] != null && ds.Tables[0].Rows[0]["channel_id"].ToString() != "") { model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString()); } if (ds.Tables[0].Rows[0]["audio_name"] != null && ds.Tables[0].Rows[0]["audio_name"].ToString() != "") { model.audio_name = ds.Tables[0].Rows[0]["audio_name"].ToString(); } if (ds.Tables[0].Rows[0]["audio_path"] != null && ds.Tables[0].Rows[0]["audio_path"].ToString() != "") { model.audio_path = ds.Tables[0].Rows[0]["audio_path"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["audio_time"] != null && ds.Tables[0].Rows[0]["audio_time"].ToString() != "") { model.audio_time = ds.Tables[0].Rows[0]["audio_time"].ToString(); } if (ds.Tables[0].Rows[0]["audio_size"] != null && ds.Tables[0].Rows[0]["audio_size"].ToString() != "") { model.audio_size = ds.Tables[0].Rows[0]["audio_size"].ToString(); } if (ds.Tables[0].Rows[0]["is_free"] != null && ds.Tables[0].Rows[0]["is_free"].ToString() != "") { model.is_free = int.Parse(ds.Tables[0].Rows[0]["is_free"].ToString()); } if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } if (ds.Tables[0].Rows[0]["is_top"] != null && ds.Tables[0].Rows[0]["is_top"].ToString() != "") { model.is_top = int.Parse(ds.Tables[0].Rows[0]["is_top"].ToString()); } if (ds.Tables[0].Rows[0]["is_slide"] != null && ds.Tables[0].Rows[0]["is_slide"].ToString() != "") { model.is_slide = int.Parse(ds.Tables[0].Rows[0]["is_slide"].ToString()); } if (ds.Tables[0].Rows[0]["is_red"] != null && ds.Tables[0].Rows[0]["is_red"].ToString() != "") { model.is_red = int.Parse(ds.Tables[0].Rows[0]["is_red"].ToString()); } if (ds.Tables[0].Rows[0]["remark1"] != null && ds.Tables[0].Rows[0]["remark1"].ToString() != "") { model.remark1 = ds.Tables[0].Rows[0]["remark1"].ToString(); } if (ds.Tables[0].Rows[0]["remark2"] != null && ds.Tables[0].Rows[0]["remark2"].ToString() != "") { model.remark2 = int.Parse(ds.Tables[0].Rows[0]["remark2"].ToString()); } if (ds.Tables[0].Rows[0]["img_url"] != null && ds.Tables[0].Rows[0]["img_url"].ToString() != "") { model.img_url = ds.Tables[0].Rows[0]["img_url"].ToString(); } #endregion model.albums = new article_albums().GetList(id); return model; } else { return null; } }