/// <summary> /// 添加友情连接 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { int place = Convert.ToInt32(ddlPlace.SelectedValue); string name = this.txtLinkName.Text.Trim(); string title = this.txtLinkTitle.Text.Trim(); string url = this.txtLinkUrl.Text.Trim(); if (name.Length == 0 || url.Length == 0) { lblError.Text = "各项不能为空"; return; } Links item = new Links(); item.linkname = name; item.linktitle = "0"; if (title != "") { if (!RegExp.IsNumeric(title)) { lblError.Text = "顺序号输入有误!"; return; } else { item.linktitle = title; } } item.linkurl = url; item.addtime = DateTime.Now; item.istj = place; if (lblId.Text != "") { item.id = Convert.ToInt32(lblId.Text.Trim()); int num = LinksService.Update(item); } else { int num = LinksService.Add(item); } pnlAdd.Visible = false; pnlList.Visible = true; sp.InitBindData(repInfo, pager1, "Links", "id", sear()); }
/// <summary> /// 控件行命令事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName.Equals("del")) { int id = Convert.ToInt32(e.CommandArgument); IndexUserService.Delete(id); sp.InitBindData(repInfo, pager1, "IndexUser", "id", sear()); } if (e.CommandName.Equals("mod")) { IndexUser nt = IndexUserService.GetModel(Convert.ToInt32(e.CommandArgument)); if (nt != null) { Label lblOrder = e.Item.FindControl("lblOrder") as Label; lblOrder.Visible = false; TextBox txtOrderNum = e.Item.FindControl("txtOrderNum") as TextBox; txtOrderNum.Visible = true; Label lblFullName = e.Item.FindControl("lblFullName") as Label; lblFullName.Visible = false; TextBox txtFullName = e.Item.FindControl("txtFullName") as TextBox; txtFullName.Visible = true; LinkButton lbtnMod = e.Item.FindControl("lbtnMod") as LinkButton; lbtnMod.Visible = false; LinkButton lbtnSave = e.Item.FindControl("lbtnSave") as LinkButton; lbtnSave.Visible = true; } else { Label lblName = e.Item.FindControl("lblName") as Label; lblName.Visible = false; TextBox txtName = e.Item.FindControl("txtModName") as TextBox; txtName.Visible = true; LinkButton lbtnMod = e.Item.FindControl("lbtnMod") as LinkButton; lbtnMod.Visible = false; LinkButton lbtnSave = e.Item.FindControl("lbtnSave") as LinkButton; lbtnSave.Visible = true; } } if (e.CommandName.Equals("save")) { TextBox txtOrderNum = e.Item.FindControl("txtOrderNum") as TextBox; string orderNum = txtOrderNum.Text.Trim(); if (orderNum.Length != 0) { if (!RegExp.IsNumeric(orderNum)) { ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('顺序号输入有误!');", true); return; } } TextBox txtFullName = e.Item.FindControl("txtFullName") as TextBox; string fullName = txtFullName.Text.Trim(); if (fullName.Length == 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('名称不能为空!');", true); return; } IndexUser nt = IndexUserService.GetModel(Convert.ToInt32(e.CommandArgument)); if (nt != null) { if (txtOrderNum.Text.Trim() != "") { nt.infoType = Convert.ToInt32(txtOrderNum.Text.Trim()); } nt.id = Convert.ToInt32(e.CommandArgument); int num = IndexUserService.Update(nt.id, nt.infoType); if (num > 0) { ///更新基本信息全称和用户表全称 UserBase ub = UserBaseService.GetModelByUserId(nt.userId); if (ub != null) { UserBaseService.UpdateFullName(ub.id, fullName); UserInfo user = UserInfoService.GetModel(ub.userId); if (user != null) { user.comName = fullName; UserInfoService.UpdateComName(user); } } ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('保存成功!');", true); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "", "alert('保存失败!');", true); } } sp.InitBindData(this.repInfo, pager1, "IndexUser", "id", sear()); } }
/// <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> /// Save信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnAdd_Click(object sender, EventArgs e) { UserInfo user = Session["user"] as UserInfo; if (user == null) { return; } Product item = new Product(); if (this.hidId.Value != "") { if (ViewState["modItem"] != null) { item = ViewState["modItem"] as Product; if (item != null) { item.proName = proname.Text.Trim(); item.productType = Convert.ToInt32(ddlProductType.SelectedValue); item.productTypeName = ddlProductType.SelectedItem.Text; item.proType = 0; if (storeCount.Text.Trim() != "") { if (RegExp.IsNumeric(storeCount.Text.Trim())) { item.proType = Convert.ToInt32(storeCount.Text.Trim()); } } item.oneId = Convert.ToInt32(ddlProductType.SelectedValue); item.listImgUrl = ""; if (this.hidImg.Value != "" && this.hidImg.Value.IndexOf("data") != -1) { item.listImgUrl = UploadImg(hidImg.Value); } item.unit1 = unit1.Text.Trim(); item.price1 = 0; if (price1.Text.Trim() != "") { item.price1 = Convert.ToDouble(price1.Text.Trim()); } item.advantage = infoDesc.Text.Trim(); if (ProductService.Update(item)) { ScriptManager.RegisterStartupScript(btnAdd, GetType(), "", "alert('Saved succesfully');location.href='shoper_product.html'", true); } else { ScriptManager.RegisterStartupScript(btnAdd, GetType(), "", "alert('Failed to save');", true); } } } } else { #region 新增 item.proName = proname.Text.Trim(); item.proNameEn = ""; item.productType = Convert.ToInt32(ddlProductType.SelectedValue); item.productTypeName = ddlProductType.SelectedItem.Text; item.proType = 0; if (storeCount.Text.Trim() != "") { if (RegExp.IsNumeric(storeCount.Text.Trim())) { item.proType = Convert.ToInt32(storeCount.Text.Trim()); } } item.proTypeName = ""; item.oneId = Convert.ToInt32(ddlProductType.SelectedValue); item.twoId = 0; item.threeId = 0; item.fourId = 0; if (item.twoId != 0) { item.productType = item.twoId; } if (item.threeId != 0) { item.productType = item.threeId; } item.listImgUrl = ""; if (this.hidImg.Value != "") { item.listImgUrl = UploadImg(hidImg.Value); } item.detailImg1 = ""; item.detailImg2 = ""; item.detailImg3 = ""; item.detailImg4 = ""; item.creditImg1 = ""; item.creditImg2 = ""; item.creditImg3 = ""; item.creditImg4 = ""; item.fromImg = ""; item.otherImg = ""; item.fromId = 0; item.fromName = ""; item.fromDesc = ""; item.brandId = 0; item.brandName = ""; item.varietyId = 0; item.varietyName = ""; item.relieveId = 0; item.relieveName = ""; item.cookId = 0; item.cookName = ""; item.useId = user.id; item.useName = ""; item.unit1 = unit1.Text.Trim(); item.price1 = 0; if (price1.Text.Trim() != "") { item.price1 = Convert.ToDouble(price1.Text.Trim()); } item.unit2 = ""; item.price2 = 0; item.unit3 = ""; item.price3 = 0; item.unit4 = ""; item.price4 = 0; item.advantage = infoDesc.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; item.stopType = 0; item.stopTypeName = ""; item.proContent = ""; item.proDesc = ""; item.ImgDesc = ""; 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 = user.id; item.addUserName = user.username; int maxId = ProductService.Add(item); if (maxId > 0) { ScriptManager.RegisterStartupScript(btnAdd, GetType(), "", "alert('Saved succesfully');location.href='shoper_product.html'", true); } else { ScriptManager.RegisterStartupScript(btnAdd, GetType(), "", "alert('Failed to save');", true); } #endregion } }
/// <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) { if (ViewState["guangGaoImg1"] == null) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('请上传广告图片!');", true); return; } string linkUrl = this.txtLinkurl.Text.Trim(); string comName = this.txtComName.Text.Trim(); string relUser = this.txtRelUser.Text.Trim(); string tel = txtTel.Text.Trim(); string order = txtOrder.Text.Trim(); if (comName.Length == 0 || tel.Length == 0) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('投放企业和联系方式不能为空!');", true); return; } if (!RegExp.IsNumeric(order)) { ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('顺序号信息有误!');", true); return; } GuangGao item = new GuangGao(); item.imgUrl = ViewState["guangGaoImg1"].ToString(); item.title = comName; item.alt = comName; item.linkurl = linkUrl; item.comName = comName; item.relUser = relUser; item.tel = tel; item.timeStr = ddlTimeStr.SelectedItem.Text; item.infoType = Convert.ToInt32(ddlTimeStr.SelectedValue); item.timeFrom = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")); item.timeEnd = Convert.ToDateTime(DateTime.Now.AddMonths(item.infoType).ToString("yyyy-MM-dd")); item.placeSite = Convert.ToInt32(ddlPlace.SelectedValue); item.placeName = ddlPlace.SelectedItem.Text; item.isTj = 0; item.isHot = 0; item.isNew = 0; if (order != "") { item.isNew = Convert.ToInt32(order); } item.views = 0; item.status = 0; item.remark = ""; item.addTime = DateTime.Now; if (Session["loginUser"] == null) { Response.Redirect("/admin/login.aspx"); return; } AdminUser admin = Session["loginUser"] as AdminUser; item.addUser = admin.id; if (ViewState["modId"] != null) { item.id = Convert.ToInt32(ViewState["modId"]); GuangGaoService.Update(item); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true); } else { int num = GuangGaoService.Add(item); } sp.InitBindData(repInfo, pager1, "GuangGao", "id", sear()); ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('保存成功!');", true); }