//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel(channel_id, DTEnums.ActionEnum.Delete.ToString()); //检查权限 BLL.guidaudio bll = new BLL.guidaudio(); Model.guidaudio model_audio = null; for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { model_audio = bll.GetGuidAudioModel(id); if (model_audio != null) { if (File.Exists(Server.MapPath(model_audio.audio_path))) { //如果存在则删除 File.Delete(Server.MapPath(model_audio.audio_path)); } } bll.Delete(id); } } JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); }
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; }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { BLL.guidaudio bll = new BLL.guidaudio(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } JscriptMsg("保存排序成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property), "Success"); }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); this.ddlProperty.SelectedValue = this.property; this.txtKeywords.Text = this.keywords; BLL.guidaudio bll = new BLL.guidaudio(); this.rptList.DataSource = bll.GetGuidAudioList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("list.aspx", "channel_id={0}&category_id={1}&keywords={2}&property={3}&page={4}", this.channel_id.ToString(), this.category_id.ToString(), this.keywords, this.property, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel(channel_id, DTEnums.ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.guidaudio bll = new BLL.guidaudio(); Model.guidaudio model = bll.GetGuidAudioModel(id); switch (e.CommandName.ToLower()) { case "ibtntop": if (model.is_top == 1) bll.UpdateField(id, "is_top=0"); else bll.UpdateField(id, "is_top=1"); break; case "ibtnred": if (model.is_red == 1) bll.UpdateField(id, "is_red=0"); else bll.UpdateField(id, "is_red=1"); break; } this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc"); }
private void ShowInfo(int _id) { BLL.guidaudio bll = new BLL.guidaudio(); Model.guidaudio model = bll.GetGuidAudioModel(_id); txtTitle.Text = model.audio_name; txtImgUrl.Text = model.img_url; if (model.is_top == 1) { cblItem.Items[0].Selected = true; } if (model.is_red == 1) { cblItem.Items[1].Selected = true; } txtSortId.Text = model.sort_id.ToString(); }
private bool DoEdit(int _id) { bool result = true; BLL.guidaudio bll = new BLL.guidaudio(); Model.guidaudio model = bll.GetGuidAudioModel(_id); model.channel_id = this.channel_id; model.audio_name = txtTitle.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_red = 0; model.is_top = 0; if (cblItem.Items[0].Selected == true) { model.is_top = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (!bll.Update(model)) { result = false; } return result; }
public void GetDaoYouCiList(int page, string version, string equType, string equName) { string json = string.Empty; string tempStr = string.Empty; try { int count = 0;// daoyouciManager.GetDaoYouCiNum_WebService(area); BLL.guidaudio bll_guidaudio = new BLL.guidaudio(); DataSet ds_audio = bll_guidaudio.GetGuidAudioList(10, page, "", "sort_id asc,add_time desc", out count); bool nextPage = false; //是否有下一页 if (count < 10) { nextPage = false; } else { nextPage = true; } if (ds_audio != null && ds_audio.Tables[0].Rows.Count > 0) { var lst_audio = from p in ds_audio.Tables[0].AsEnumerable() select new { id = p.Field<int>("id"), audioname = p.Field<string>("audio_name"), audioimg = this.webUrl + p.Field<string>("img_url"), audiourl = this.webUrl + p.Field<string>("audio_path"), audiotype = p.Field<string>("remark1"), audiotime = p.Field<string>("audio_time"), audiosize = p.Field<string>("audio_size"), }; tempStr = Common.ObjToJson.ToJson(lst_audio.ToList()); } string dateStr = DateTime.Now.ToString("yyyy-MM"); json = "{\"status\":\"true\",\"currentDate\":\"" + dateStr + "\",\"nextPage\":\"" + nextPage.ToString().ToLower() + "\",\"data\":" + tempStr + "}"; } catch (Exception ex) { json = "{\"status\":\"false\",\"data\":\"" + ex.Message + "\"}"; } WriteWebServiceLog(version, equType, equName, "GetDaoYouCiList", ""); Context.Response.Write(json); Context.Response.End(); }