//从控件上传文件 public void fileUpload(int num) { string spic = ""; if (num == 1) { if (filepic.PostedFile != null && filepic.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsTopImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsTopImgPath)); //创建目录 } spic = DoClass.UploadFile(filepic.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsTopImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.NewsTopImgPath + spic; ViewState["newsImg1"] = spic; } } } }
//从控件上传文件 public void fileUpload(int num) { string spic = ""; if (num == 1) { if (filepic.PostedFile != null && filepic.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.GuangGaoImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.GuangGaoImgPath)); //创建目录 } spic = DoClass.UploadFile(filepic.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.GuangGaoImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.GuangGaoImgPath + spic; ViewState["guangGaoImg1"] = spic; } } } ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "overKeyWordDiv();", true); }
//从控件上传文件 public void fileUpload(int num) { string spic = ""; if (num == 1) { #region 微博上传 if (filepic_weibo.PostedFile != null && filepic_weibo.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.ErWeiImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.ErWeiImgPath)); //创建目录 } spic = DoClass.UploadFile(filepic_weibo.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.ErWeiImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { //ViewState["img1Name"] = spic; spic = Global_Upload.ErWeiImgPath + spic; // ViewState["newsImg1"] = spic; lblImgWeiBo.Text = spic; } } #endregion } }
//从控件Upload文件 public void fileUpload(int num) { string spic = ""; if (num == 1) { if (filepic.PostedFile != null && filepic.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsTopImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsTopImgPath)); //创建目录 } spic = DoClass.UploadFile(filepic.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsTopImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsTopImgPath + spic; UserInfo user = Session["user"] as UserInfo; if (user != null) { user.imgUrl = spic; int rows = UserInfoService.UpdateImg(user, 5); if (rows > 0) { Session["user"] = user; ViewState["headImg"] = spic; } } } } } }
/// <summary> /// 保存事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { BaseConfigService.SetValue(1, this.txtMonthValue.Text.Trim()); BaseConfigService.SetValue(2, this.txtYearValue.Text.Trim()); BaseConfigService.SetValue(5, this.txtVideo.Text.Trim()); BaseConfigService.SetValue(11, this.txtBase1.Text.Trim()); BaseConfigService.SetValue(12, this.txtBase2.Text.Trim()); BaseConfigService.SetValue(13, this.txtBase3.Text.Trim()); BaseConfigService.SetValue(14, this.txtBase4.Text.Trim()); BaseConfigService.SetValue(15, this.txtBase5.Text.Trim()); BaseConfigService.SetValue(16, this.txtBase6.Text.Trim()); BaseConfigService.SetValue(17, this.txtBase7.Text.Trim()); BaseConfigService.SetValue(18, this.txtBase8.Text.Trim()); BaseConfigService.SetValue(19, this.txtBase9.Text.Trim()); BaseConfigService.SetValue(20, this.txtBase12.Text.Trim()); BaseConfigService.SetValue(21, this.txtBase13.Text.Trim()); BaseConfigService.SetValue(22, this.txtBase14.Text.Trim()); BaseConfigService.SetValue(23, this.txtBase15.Text.Trim()); BaseConfigService.SetValue(39, this.tb_id.Text.Trim()); BaseConfigService.SetValue(40, this.tb_secret.Text.Trim()); BaseConfigService.SetValue(41, this.tb_URL.Text.Trim()); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; lblURL1.Text = spic; } } if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; lblURL2.Text = spic; } } if (this.FileUpload3.PostedFile != null && FileUpload3.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload3.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; lblURL3.Text = spic; } } if (this.FileUpload4.PostedFile != null && FileUpload4.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload4.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; lblURL4.Text = spic; } } if (this.FileUpload5.PostedFile != null && FileUpload5.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload5.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; lblURL5.Text = spic; } } BaseConfigService.SetValue(24, this.lblURL1.Text.Trim()); BaseConfigService.SetValue(25, this.lblURL2.Text.Trim()); BaseConfigService.SetValue(26, this.lblURL3.Text.Trim()); BaseConfigService.SetValue(27, this.lblURL4.Text.Trim()); BaseConfigService.SetValue(28, this.lblURL5.Text.Trim()); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true); }
/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string url = this.txtLinkUrl.Text.Trim(); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg1"] = spic; lblURL1.Text = spic; } } ProductImgMobile item = new ProductImgMobile(); item.typeId = Convert.ToInt32(ddlType.SelectedValue); item.typeName = txtLinkUrl.Text.Trim(); if (item.typeId == 1) { item.typeName = "移动端Banner"; } if (item.typeId == 2) { item.typeName = "移动端证书"; } if (item.typeId == 3) { item.typeName = "成长阶段"; } if (item.typeId == 4) { item.typeName = "移动端产品展示图"; } item.productId = productId; item.orderNum = 0; item.imgUrl = lblURL1.Text; item.status = 0; if (cboYes.Checked) { item.status = 1; } item.remark = content1.Value; item.addTime = DateTime.Now; item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } item.infoType = Convert.ToInt32(ddlType.SelectedValue); if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); ProductImgMobileService.Update(item); } else { int num = ProductImgMobileService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; LoadData(); }
/// <summary> /// 添加产品 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRelease_Click(object sender, EventArgs e) { string spic = ""; #region 列表图片 if (filepic.PostedFile != null && filepic.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.ProductImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.ProductImgPath)); //创建目录 } spic = DoClass.UploadFile(filepic.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.ProductImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { //ViewState["img1Name"] = spic; spic = Global_Upload.ProductImgPath + spic; this.lblImgUrl.Text = spic; } } #endregion #region 产品详细图片1 if (FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.ProductImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.ProductImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.ProductImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { //ViewState["img1Name"] = spic; spic = Global_Upload.ProductImgPath + spic; this.Label1.Text = spic; } } #endregion #region 验证输入 if (Session["loginUser"] == null) { Jscript.AlertAndRedirect("请登录", "/admin/login.aspx"); return; } string productName = txtProductName.Text.Trim(); if (productName.Length == 0) { lblError.Text = "产品名称不能为空"; return; } if (this.lblImgUrl.Text.Trim().Length == 0) { lblError.Text = "请上传产品列表图片"; return; } #endregion Product item = new Product(); item.proName = productName; item.advantage = content2.Value.Trim(); item.proNameEn = ""; item.productType = Convert.ToInt32(ddlOne.SelectedValue); item.productTypeName = ddlOne.SelectedItem.Text; item.proType = 0; if (txtStoreCount.Text.Trim() != "") { if (RegExp.IsNumeric(txtStoreCount.Text.Trim())) { item.proType = Convert.ToInt32(txtStoreCount.Text.Trim()); } } item.proTypeName = ""; item.oneId = Convert.ToInt32(ddlOne.SelectedValue); item.twoId = Convert.ToInt32(ddlTwo.SelectedValue); item.threeId = Convert.ToInt32(ddlThree.SelectedValue); item.fourId = 0; if (item.twoId != 0) { item.productType = item.twoId; } if (item.threeId != 0) { item.productType = item.threeId; } item.listImgUrl = lblImgUrl.Text; item.detailImg1 = Label1.Text; item.detailImg2 = ""; item.detailImg3 = ""; item.detailImg4 = ""; item.creditImg1 = ""; item.creditImg2 = ""; item.creditImg3 = ""; item.creditImg4 = ""; item.fromImg = ""; item.otherImg = ""; item.fromId = 0; item.fromName = txtFrom.Text.Trim(); item.fromDesc = ""; item.brandId = 0; item.brandName = ""; item.varietyId = Convert.ToInt32(ddlVariety.SelectedValue); item.varietyName = ddlVariety.SelectedItem.Text; item.relieveId = Convert.ToInt32(ddlRelieve.SelectedValue); item.relieveName = ddlRelieve.SelectedItem.Text; item.cookId = Convert.ToInt32(ddlCook.SelectedValue); item.cookName = ddlCook.SelectedItem.Text; item.useId = 0; item.useName = ""; if (ViewState["userId"] != null) { item.useId = Convert.ToInt32(ViewState["userId"]); } item.unit1 = unit1.Text.Trim(); item.price1 = 0; if (price1.Text.Trim() != "") { item.price1 = Convert.ToDouble(price1.Text.Trim()); } item.unit2 = unit2.Text.Trim(); item.price2 = 0; if (price2.Text.Trim() != "") { item.price2 = Convert.ToDouble(price2.Text.Trim()); } item.unit3 = unit3.Text.Trim(); item.price3 = 0; if (price3.Text.Trim() != "") { item.price3 = Convert.ToDouble(price3.Text.Trim()); } item.unit4 = unit4.Text.Trim(); item.price4 = 0; if (price4.Text.Trim() != "") { item.price4 = Convert.ToDouble(price4.Text.Trim()); } item.advantage = content2.Value.Trim(); // advantage.Text.Trim(); item.saveInfo = ""; // saveInfo.Text.Trim(); item.rankingType = 0; item.rankingTypeName = ""; item.ranking = 0; item.listeTime = DateTime.Now; item.proGrade = 0; item.proGradeName = ""; item.proMaterial = 0; item.proMaterialName = ""; item.speed = 0; if (txtTjOrder.Text.Trim() != "") { if (RegExp.IsNumeric(txtTjOrder.Text.Trim())) { item.speed = Convert.ToInt32(txtTjOrder.Text.Trim()); } } item.stopType = 0; item.stopTypeName = txtMobileGood.Text.Trim(); item.proContent = content1.Value.Trim(); item.proDesc = prodesc.Text.Trim(); item.ImgDesc = content3.Value.Trim(); item.propertyDesc = ""; item.labelInfo = ""; item.remark = ""; item.assessCount = 0; item.shareCount = 0; item.viewsCount = 0; item.author = ""; item.isTj = 0; item.isHot = 0; item.isNew = 0; item.goodCount = 0; item.badCount = 0; item.status = 0; item.infoType = 0; item.addTime = DateTime.Now; item.addUser = 0; item.addUserName = ""; AdminUser admin = Session["loginUser"] as AdminUser; if (admin != null) { item.author = admin.username; item.addUserName = admin.realName; item.addUser = admin.id; } if (id != 0) { #region 修改 item.id = id; ViewState["maxId"] = id; if (ProductService.Update(item)) { ScriptManager.RegisterStartupScript(this.btnRelease, GetType(), "", "alert('保存成功');location.href='productList.aspx?userId=" + ViewState["userId"] + "';", true); } #endregion } else { #region 添加 int maxId = ProductService.Add(item); if (maxId > 0) { ScriptManager.RegisterStartupScript(this.btnRelease, GetType(), "", "alert('保存成功');location.href='productList.aspx?userId=" + ViewState["userId"] + "';", true); } else { lblError.Text = "保存失败"; } #endregion } }
/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string title = txtTitle.Text.Trim(); string alt = this.txtAlt.Text.Trim(); string url = this.txtLinkUrl.Text.Trim(); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg1"] = spic; lblURL1.Text = spic; } } if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img2Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg2"] = spic; lblURL2.Text = spic; } } FriendsInfo item = new FriendsInfo(); item.title = title; item.alt = alt; item.linkurl = url; item.img1path = ""; item.img2Path = ""; if (ViewState["newsImg1"] != null || lblURL1.Text != "") { item.img1path = lblURL1.Text; } else { lblError.Text = "请上传图片1"; return; } item.addTime = DateTime.Now; item.status = 0; item.infoType = 0; if (ViewState["typeId"] != null) { item.infoType = Convert.ToInt32(ViewState["typeId"]); } item.orderNum = 0; if (txtOrder.Text.Trim() != "") { if (RegExp.IsNumeric(txtOrder.Text.Trim())) { item.orderNum = Convert.ToInt32(txtOrder.Text.Trim()); } } item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); int num = FriendsInfoService.Update(item); } else { int num = FriendsInfoService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; LoadData(); }
/// <summary> /// 添加类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string typename = this.txtTypeName.Text.Trim(); if (typename.Length == 0) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('类型名称不能为空!');", true); return; } ProductType item = new ProductType(); item.typeName = typename; item.parentId = 0; item.oneId = Convert.ToInt32(ddlOne.SelectedValue); item.oneName = ddlOne.SelectedItem.Text; if (item.oneId != 0) { item.parentId = item.oneId; } item.twoId = Convert.ToInt32(ddlTwo.SelectedValue); item.twoName = ddlTwo.SelectedValue; if (item.twoId != 0) { item.parentId = item.twoId; } item.threeId = Convert.ToInt32(ddlThree.SelectedValue); item.threeName = ddlThree.SelectedItem.Text; if (item.threeId != 0) { item.parentId = item.threeId; } item.fourId = Convert.ToInt32(ddlFour.SelectedValue); item.fourName = ddlFour.SelectedItem.Text; if (item.fourId != 0) { item.parentId = item.fourId; } string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; this.lblUrl.Text = spic; } } if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; this.lblUrl2.Text = spic; } } if (this.FileUpload3.PostedFile != null && FileUpload3.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload3.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; this.lblUrl3.Text = spic; } } item.imgUrl = lblUrl.Text; item.diaryImg = lblUrl2.Text; item.typeContent = ""; item.typeDesc = txtNameEn.Text.Trim(); item.status = 0; item.remark = lblUrl3.Text.Trim(); item.addTime = DateTime.Now; if (Session["loginUser"] == null) { Response.Redirect("/admin/login.aspx"); return; } AdminUser admin = Session["loginUser"] as AdminUser; item.addUser = admin.id; item.infoType = 0; if (ViewState["mod"] != null) { item.id = Convert.ToInt32(ViewState["mod"]); ProductTypeService.Update(item); } else { int num = ProductTypeService.Add(item); } ViewState["mod"] = null; txtTypeName.Text = ""; txtNameEn.Text = ""; sp.InitBindData(repInfo, this.pager1, "ProductType", "id", sear()); }
/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string title = txtTitle.Text.Trim(); string proDesc = this.txtTitle2.Text.Trim(); string proPrice = this.txtPrice.Text.Trim(); string unitDesc = txtUnit.Text.Trim(); string url = this.txtLinkUrl.Text.Trim(); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg1"] = spic; lblURL1.Text = spic; } } IndexProduct item = new IndexProduct(); item.typeId = Convert.ToInt32(ddlCate.SelectedValue); item.typeName = ddlCate.SelectedItem.Text; item.proName = title; item.proDesc = proDesc; item.proPrice = 0; item.priceStr = proPrice; item.unitDesc = unitDesc; if (ViewState["newsImg1"] != null || lblURL1.Text != "") { item.imgUrl = lblURL1.Text; } else { lblError.Text = "请上传图片"; return; } item.status = 0; item.remark = url; item.addTime = DateTime.Now; item.infoType = 0; item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); IndexProductService.Update(item); } else { int num = IndexProductService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; LoadData(); }
/// <summary> /// 添加事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { lblError.Text = ""; string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; this.lblUrl.Text = spic; } } if (txtOrder.Text.Trim() != "") { if (!RegExp.IsNumeric(txtOrder.Text.Trim())) { lblError.Text = "顺序号输入有误!"; return; } } NewsType item = new NewsType(); item.name = txtTitle.Text.Trim(); if (item.name.Length == 0) { lblError.Text = "分类名称不能为空!"; return; } item.parentId = Convert.ToInt32(ddlParent.SelectedValue); item.status = 0; if (txtOrder.Text.Trim() != "") { item.status = Convert.ToInt32(txtOrder.Text.Trim()); } item.remark = lblUrl.Text; item.typedesc = ""; item.pagename = ""; string hidId = this.hidId.Value; if (hidId != "") { item.id = Convert.ToInt32(hidId); NewsTypeService.UpdateModel(item); } else { if (NewsTypeService.Exists(item)) { lblError.Text = "该分类以及存在"; return; } NewsTypeService.Add(item); txtTitle.Text = ""; lblUrl.Text = ""; txtOrder.Text = ""; } this.hidId.Value = ""; sp.InitBindData(this.repInfo, pager1, "NewsType", "id", sear()); }
/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { string title = txtTitle.Text.Trim(); string title2 = txtTitle2.Text.Trim(); string contentTitle = txtContentTitle.Text.Trim(); string url = this.txtLinkUrl.Text.Trim(); string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { ViewState["img1Name"] = spic; spic = Global_Upload.FriendImgPath + spic; ViewState["newsImg1"] = spic; lblURL1.Text = spic; } } NavInfo item = new NavInfo(); item.indexTitle = title; item.indexTitle2 = title2; item.linkurl = url; item.indexImg = ""; if (ViewState["newsImg1"] != null || lblURL1.Text != "") { item.indexImg = lblURL1.Text; } else { lblError.Text = "请上传图片"; return; } item.title = contentTitle; item.infoDesc = content1.Value.Trim(); item.infoRemark = ""; item.addTime = DateTime.Now; item.status = 0; item.remark = ""; item.infoType = 0; item.addUser = 0; AdminUser au = Session["loginUser"] as AdminUser; if (au != null) { item.addUser = au.id; } if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); NavInfoService.Update(item); } else { int num = NavInfoService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; LoadData(); }
/// <summary> /// 发布资讯 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnRelease_Click(object sender, EventArgs e) { if (Session["loginUser"] == null) { Jscript.AlertAndRedirect("请登录", "/admin/login.aspx"); return; } string spic = ""; if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; ViewState["newsImg1"] = spic; lblURL.Text = spic; } } //热点大图 if (this.FileUpload2.PostedFile != null && FileUpload2.PostedFile.FileName != "") { if (!Directory.Exists(Server.MapPath(Global_Upload.NewsImgPath))) //判断目录是否存在 { Directory.CreateDirectory(Server.MapPath(Global_Upload.NewsImgPath)); //创建目录 } spic = DoClass.UploadFile(FileUpload2.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.NewsImgPath); if (spic == "-1") { return; } else if (spic == "0") { return; } else { spic = Global_Upload.NewsImgPath + spic; //ViewState["newsImg2"] = spic; this.lblIndexImg.Text = spic; } } News item = new News(); item.title = this.txtTitle.Text.Trim(); item.pageName = txtZhaiYao.Text.Trim(); item.newsType = 0; item.newsType = Convert.ToInt32(ddlCate.SelectedValue); item.newImg = lblURL.Text; item.newsContent = this.content1.Value;// Request.Form["content1"]; //this.txtContent.Value; item.keyword = this.txtKeyWord.Text.Trim(); item.newsDesc = this.content2.Value.Trim(); if (id != 0) { item.linkurl = "/news/" + Convert.ToDateTime(ViewState["addTime"]).ToString("yyyyMMddhhmmss") + ".html"; } else { item.addTime = DateTime.Now; item.linkurl = "/news/" + item.addTime.ToString("yyyyMMddhhmmss") + ".html"; } item.is_tj = 0; item.is_hot = 0; item.ordernum = 0; item.add_userid = Convert.ToInt32((Session["loginUser"] as AdminUser).id); item.res_views = 0; item.areaid = 0; item.sid = txtDesc.Text.Trim(); item.releaseTime = DateTime.Now; item.author = lblIndexImg.Text; if (item.pageName == "") { this.lblError.Text = "请填写摘要信息"; return; } if (id != 0) { item.id = id; int num = NewsService.Update(item); if (num > 0) { Jscript.AlertAndRedirectJstr("修改成功", "location.href='infoList.aspx?typeId=" + typeId + "';"); } else { this.lblError.Text = "修改失败"; } } else { int num = NewsService.Add(item); if (num > 0) { Jscript.AlertAndRedirectJstr("添加成功", "location.href='infoList.aspx?typeId=" + typeId + "';"); } else { this.lblError.Text = "添加失败"; } } }