public void BindData() { if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null) { int msgId = Convert.ToInt32(Request.QueryString["id"]); List <Msg> list = MsgBll.GetMsgbyId(msgId); if (list.Count > 0) { lblName.Text = list[0].Author; lblPhone.Text = list[0].Phone; lblEmail.Text = list[0].Email; lblAdr.Text = list[0].Adress; lblTime.Text = list[0].CreateTime; lblDetail.Text = list[0].Details; if (list[0].IsRead == 0) { try { MsgBll.UpdateRead(msgId, 1); } catch (Exception ex) { MessageBox.Alert("未知错误:" + ex.Message, Page); /*throw;*/ } } } else { Response.Redirect("Message.aspx"); } } }
public void FillTable() { List <string> campos = new List <string> { "uid", "id", "name" }; XResponse resp = CrsData.TableSelect(campos, "almacenes", "", BuildType.LstDctStrStr); if (resp.error) { MessageBox.Alert("Ocurrio un error al cargar los datos: " + resp.msgerr, this.Page, this); return; } List <Dictionary <string, string> > data = (List <Dictionary <string, string> >)resp.objecto; HtmlTableRow row = new HtmlTableRow(); foreach (Dictionary <string, string> item in data) { row = new HtmlTableRow(); row.Cells.Add(new HtmlTableCell { InnerHtml = "<button id=\"btn" + item["uid"] + "\" class=\"btn btn - primary btn - sm\">Edit</button>" }); //<asp:Button runat = "server" ID = "btnsave" OnClick = "btnsave_Click" CssClass = "btn btn-primary btn-lg" Text = "Crear" /> row.Cells.Add(new HtmlTableCell { InnerText = item["id"] }); row.Cells.Add(new HtmlTableCell { InnerText = item["name"] }); tableSeek.Rows.Add(row); } }
public void FillTable() { XResponse resp = CrsData.TableSelect(new List <string> { "uid", "nombre" }, "familias", "type = '1'", BuildType.LstDctStrStr); if (resp.error) { MessageBox.Alert("Ocurrio un error al cargar los datos: " + resp.msgerr, this.Page, this); return; } List <Dictionary <string, string> > data = (List <Dictionary <string, string> >)resp.objecto; HtmlTableRow row = new HtmlTableRow(); Button btn; foreach (Dictionary <string, string> item in data) { btn = new Button(); btn.CssClass = "btn btn-primary btn-sm"; btn.ID = "btn" + item["uid"]; btn.Text = "Edit"; btn.Click += EditFam; row = new HtmlTableRow(); HtmlTableCell cel = new HtmlTableCell(); cel.Controls.Add(btn); row.Cells.Add(cel); row.Cells.Add(new HtmlTableCell { InnerText = item["uid"] }); row.Cells.Add(new HtmlTableCell { InnerText = item["nombre"] }); tableSeek.Rows.Add(row); } }
protected void btnAdd_Click(object sender, EventArgs e) { string strErr = ""; if (this.bPic.Text.Trim().Length == 0) { strErr += "图片不能为空!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_prodimage model = new PaducnSoft.Model.ay_prodimage(); model.bProdID = (int)StringPlus.ConvertNullToInt(this.bId.Value); model.bPic = this.bPic.Text; model.bOrder = dal.GetRecordCount(" and a.bProdID=" + this.bId.Value) + 1; model.bIsDefault = 0; model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; bool result = dal.Add(model); if (result) { MessageBox.Alert(this, "保存成功!", true, "btnReset"); } else { MessageBox.Alert(this, "保存失败!"); } }
protected void lbtnDeletes_Click(object sender, EventArgs p1) { if (BasePage.IsPermissions(59)) { int num = 0; foreach (RepeaterItem item in this.rpt_List.Items) { HtmlInputCheckBox box = (HtmlInputCheckBox)item.FindControl("cheId"); if (box.Checked) { bll.Delete(int.Parse(box.Value)); num++; } } //if (num > 0) //{ // B_Operationlog.CreateOperationLog(BasePage.UId,string.Format("共批量删除{0}条信息", num)); //} base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } else { MessageBox.Alert(this, "没有删除权限!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bName.Text.Trim().Length == 0) { strErr += "名称不能为空!\\n"; } if (this.bOrder.Text.Trim().Length == 0) { strErr += "排序不能为空!\\n"; } if (!PageValidate.IsNumber(this.bOrder.Text)) { strErr += "排序格式错误!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_menu model = new PaducnSoft.Model.ay_menu(); model.bId = (int)StringPlus.ConvertNullToZero(this.bId.Value); model.bName = this.bName.Text; model.bUrl = this.bUrl.Text; model.bParent = (int)StringPlus.ConvertNullToZero(this.bParent.SelectedValue); model.bOpenMode = this.bOpenMode.SelectedValue; model.bLocation = this.bLocation.Value; model.bIsShow = (int)StringPlus.ConvertNullToZero(this.bIsShow.SelectedValue); model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Text); model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and bId<>{0}", this.bId.Value); strWhere.AppendFormat(" and bName='{0}'", model.bName); if (dal.Exists(strWhere.ToString())) { MessageBox.Alert(this, "名称已存在,请重新输入!"); return; } bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "更新成功!", "default.aspx"); } else { MessageBox.Alert(this, "更新失败!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bTitle.Text.Trim().Length == 0) { strErr += "标题不能为空!\\n"; } if (this.bContent.Text.Trim().Length == 0) { strErr += "内容不能为空!\\n"; } if (this.bClick.Text.Trim().Length == 0) { strErr += "点击量不能为空!\\n"; } if (!PageValidate.IsNumber(this.bClick.Text)) { strErr += "点击量格式错误!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_case model = new PaducnSoft.Model.ay_case(); model.bId = (int)StringPlus.ConvertNullToZero(this.bId.Value); model.bTitle = this.bTitle.Text; model.bClassID = (int)StringPlus.ConvertNullToZero(this.bClassID.SelectedValue); model.bTypeID = (int)StringPlus.ConvertNullToZero(this.bTypeID.SelectedValue); model.bUrl = this.bUrl.Text; model.bKeywords = this.bKeywords.Text; model.bPic = this.bPic.Text; model.bIsTop = (this.bIsTop.Checked ? 1 : 0); model.bIsBest = (this.bIsBest.Checked ? 1 : 0); model.bIsPass = (this.bIsPass.Checked ? 1 : 0); model.bClick = (int)StringPlus.ConvertNullToZero(this.bClick.Text); model.bContent = StringPlus.SafeSQL(Server.HtmlEncode(this.bContent.Text)); model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "更新成功!", "default.aspx"); } else { MessageBox.Alert(this, "更新失败!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { if (txtpwd.Text == "") { MessageBox.Alert("原密码不能为空!", Page); txtpwd.Focus(); } else if (txtNewPwd.Text == "") { MessageBox.Alert("请输入新密码!", Page); txtNewPwd.Focus(); } else if (txtNewPwd.Text.Trim() != txtPwd1.Text.Trim()) { MessageBox.Alert("新密码不一致!", Page); txtNewPwd.Focus(); } else if (txtNewPwd.Text.Length < 6) { MessageBox.Alert("密码长度不能小于6个字符!", Page); txtNewPwd.Focus(); } else { int adminId = Convert.ToInt32(Session["AdminId"]); string pwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtpwd.Text.Trim(), "md5"); string newPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtNewPwd.Text.Trim(), "md5"); List <Model.Admin> list = AdminBll.GetAdmin(adminId); if (list.Count > 0) { if (pwd != list[0].Password) { MessageBox.Alert("原密码错误!", Page); txtpwd.Focus(); } else { try { AdminBll.UpdatePwd(adminId, newPwd); MessageBox.Alert("修改成功!", Page); } catch (Exception) { MessageBox.Alert("修改失败!", Page); } } } } }
protected void btnUpload1_Click(object sender, EventArgs e) { bool isfileOk = false; string filePath = Server.MapPath("/Upload/"); if (fileupload2.HasFile) { string fileName = DateTime.Now.ToString().Replace("-", "").Replace(" ", "").Replace(":", "").Replace("/", ""); string fileExtension = System.IO.Path.GetExtension(fileupload2.FileName).ToLower(); string[] allowExtension = { ".jpg", ".gif", ".png", ".jpeg", ".bmp", ".rar", ".txt", ".zip" }; for (int i = 0; i < allowExtension.Length; i++) { if (allowExtension[i] == fileExtension) { isfileOk = true; break; } } if (fileupload2.PostedFile.ContentLength > 1024000 * 1000) { isfileOk = false; } if (isfileOk) { try { fileupload2.PostedFile.SaveAs(filePath + fileName + fileExtension); string imgUrl = "Upload/" + fileName + fileExtension; lblUploadStatus1.Text = "上传成功!"; txtImg.Text = imgUrl; lblUploadStatus1.ForeColor = System.Drawing.Color.Red; hfImgUrl1.Value = imgUrl; /*Response.Write("<script>parent.document.form1.hfImgUrl.value='" + imgUrl + "';</script>");*/ } catch (Exception) { MessageBox.Alert("上传失败!", Page); } } else { MessageBox.Alert("文件类型错误或文件大小超过10M", Page); } } else { MessageBox.Alert("请选择文件!", Page); } }
protected void btnSave_Click(object sender, EventArgs e) { if (hfImgId.Value != "") { int imgId = Convert.ToInt32(hfImgId.Value); string imgUrl = hfImgUrl.Value; try { ImgBll.UpdateImgUrl(imgId, imgUrl); MessageBox.Alert("保存成功!", Page); Bind(); } catch (Exception) { MessageBox.Alert("保存失败!", Page); } } else { Img img = new Img(); img.Title = "首页盛大开幕图片"; img.Rank = 1; img.ImgUrl = hfImgUrl.Value; string typeName = "盛大开幕图片"; List <ImgType> list = ImgTypeBll.GetImgTypebyName(typeName); if (list.Count > 0) { img.ImgTypeId = list[0].ImgTypeId; } else { img.ImgTypeId = 3; } img.IsShow = 1; img.LinkUrl = "#"; img.Remark = ""; img.CreateTime = DateTime.Now.ToString("yyyy-MM-dd"); try { ImgBll.AddImg(img); Bind(); MessageBox.Alert("保存成功!", Page); } catch (Exception) { MessageBox.Alert("保存失败!", Page); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bName.Text.Trim().Length == 0) { strErr += "标题不能为空!\\n"; } if (this.bOrder.Text.Trim().Length == 0) { strErr += "排序不能为空!\\n"; } if (!PageValidate.IsNumber(this.bOrder.Text)) { strErr += "排序格式错误!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_flash model = new PaducnSoft.Model.ay_flash(); model.bName = this.bName.Text; model.bPic = this.bPic.Text; model.bUrl = this.bUrl.Text; model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Text); model.bRemark = StringPlus.SafeSQL(this.bRemark.Text); model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and bName='{0}'", model.bName); if (dal.Exists(strWhere.ToString())) { MessageBox.Alert(this, "名称已存在,请重新输入!"); return; } bool result = dal.Add(model); if (result) { MessageBox.Alert(this, "保存成功!", true, "btnReset"); } else { MessageBox.Alert(this, "保存失败!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { Model.SiteInfo site = new Model.SiteInfo(); site.SiteInfoId = Convert.ToInt32(hfId.Value); site.SiteTitle = txtSiteTitle.Text; site.SiteKey = txtKeyWords.Text; site.SiteDes = txtDescription.Text; site.LogoUrl = hfImgUrl.Value; site.CompanyName = txtCompany.Text.Trim(); site.SiteUrl = txtUrl.Text.Trim(); site.Adress = txtAdress.Text; site.PostCode = txtPostCode.Text; site.Contacts = txtLinkMan.Text; site.Tel = txtTel.Text; site.Phone = txtPhone.Text; site.Fax = txtFax.Text; site.Email = txtEmail.Text; site.Record = txtRecord.Text; site.StatCode = txtStatCode.Text; if (hfImgUrl.Value == "") { site.LogoUrl = txtBgsound.Text.Trim(); } else { site.LogoUrl = hfImgUrl.Value; } if (hfImgUrl2.Value == "") { site.BgsoundUrl = txtBgsound.Text.Trim(); } else { site.BgsoundUrl = hfImgUrl2.Value; } try { SiteInfoBll.UpdateSiteInfo(site); BindData(); MessageBox.Alert("保存成功!", Page); } catch (Exception) { MessageBox.Alert("保存失败!", Page); throw; } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bName.Text.Trim().Length == 0) { strErr += "用户不能为空!\\n"; } if (this.bPassword.Text.Trim().Length == 0) { strErr += "密码不能为空!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_admin model = new PaducnSoft.Model.ay_admin(); model.bId = (int)StringPlus.ConvertNullToZero(this.bId.Value); model.bName = this.bName.Text; model.bRealName = this.bRealName.Text; model.bPassword = SecurityEncryption.DESEncrypt(this.bPassword.Text.ToString().Trim()); model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Value); model.bAddTime = DateTime.Now; model.bRemark = this.bRemark.Text; model.bAddUser = paducncms.Module.UserRights.AdminUserID; StringBuilder strWhere = new StringBuilder(); strWhere.AppendFormat(" and bId<>{0}", this.bId.Value); strWhere.AppendFormat(" and bName='{0}'", model.bName); if (dal.Exists(strWhere.ToString())) { MessageBox.Alert(this, "名称已存在,请重新输入!"); return; } bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "更新成功!", "default.aspx"); } else { MessageBox.Alert(this, "更新失败!"); } }
protected void btnSave_Click(object sender, EventArgs e) { int infoId = Convert.ToInt32(Request.QueryString["id"]); string detail = fck_detail.Value; try { InfoBll.UpdateDetail(infoId, detail); BindData(); MessageBox.Alert("保存成功!", Page); } catch (Exception ex) { MessageBox.Alert("错误:" + ex, Page); /*throw;*/ } }
protected void dgBanner_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName.ToLower() == "status") { int imgId = Convert.ToInt32(e.CommandArgument); List <Model.Img> list = ImgBll.GetImgbyId(imgId); if (list.Count > 0) { int status = 0; if (list[0].IsShow == 0) { status = 1; } else { status = 0; } try { ImgBll.UpdateStatus(imgId, status); BindData(); } catch (Exception ex) { MessageBox.Alert("未知错误:" + ex, Page); /*throw;*/ } } } else if (e.CommandName.ToLower() == "del") { int id = Convert.ToInt32(e.CommandArgument); try { ImgBll.DeleteImg(id); MessageBox.Alert("删除成功!", Page); BindData(); } catch (Exception) { MessageBox.Alert("删除失败!", Page); /*throw;*/ } } }
protected void dgMsg_ItemCommand(object source, DataGridCommandEventArgs e) { if (e.CommandName == "del") { int msgId = Convert.ToInt32(e.CommandArgument); try { MsgBll.DeleteMsg(msgId); MessageBox.Alert("删除成功!", Page); BindData(); } catch (Exception) { MessageBox.Alert("删除失败!", Page); /*throw;*/ } } }
protected void rpt_List_ItemCommand(object source, RepeaterCommandEventArgs p1) { int num = int.Parse(p1.CommandArgument.ToString()); if (p1.CommandName == "lbtnDelete") { #warning delte IsPermissions(0x6c) if (!BasePage.IsPermissions(0x6c)) { MessageBox.Alert(this, "没有删除权限!"); } else { bll.Delete(num); base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } } }
//函数 private void UpdateItem() { PaducnSoft.Model.ay_system model = new PaducnSoft.Model.ay_system(); model.bCompany = this.bCompany.Text; model.bContact = this.bContact.Text; model.bPhone = this.bPhone.Text; model.bEmail = this.bEmail.Text; bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "联系信息配置成功!"); } else { MessageBox.Alert(this, "联系信息配置失败,请检查数据是否正确!"); } }
private void CreateQR(int voteid) { try { QRCodeEncoder encoder2 = new QRCodeEncoder { QRCodeEncodeMode = QRCodeEncoder.ENCODE_MODE.BYTE, QRCodeScale = 4, QRCodeVersion = 5, QRCodeErrorCorrect = QRCodeEncoder.ERROR_CORRECTION.M }; string str3 = string.Concat(new object[] { "http://", HttpContext.Current.Request.ServerVariables["HTTP_HOST"], BasePage.GetWebPath, "/mw/onlinesurvey/", voteid, ".html" }); encoder2.Encode(str3).Save(base.Server.MapPath(string.Concat(new object[] { BasePage.GetWebPath, "/mw/onlinesurvey/qr/", voteid, ".gif" })), ImageFormat.Gif); } catch { MessageBox.Alert(this, "生成二维码图片失败!"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bTitle.Text.Trim().Length == 0) { strErr += "标题不能为空!\\n"; } if (this.bContent.Text.Trim().Length == 0) { strErr += "内容不能为空!\\n"; } if (this.bOrder.Text.Trim().Length == 0) { strErr += "排序不能为空!\\n"; } if (!PageValidate.IsNumber(this.bOrder.Text)) { strErr += "排序格式错误!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_page model = new PaducnSoft.Model.ay_page(); model.bId = (int)StringPlus.ConvertNullToZero(this.bId.Value); model.bTitle = this.bTitle.Text; model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Text); model.bContent = StringPlus.SafeSQL(Server.HtmlEncode(this.bContent.Text)); model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "更新成功!", "default.aspx"); } else { MessageBox.Alert(this, "更新失败!"); } }
protected void rpt_List_ItemCommand(object source, RepeaterCommandEventArgs p1) { int num = int.Parse(p1.CommandArgument.ToString()); if (p1.CommandName == "lbtnDelete") { if ((!BasePage.IsPermissions(59))) { MessageBox.Alert(this, "没有删除权限!"); } else { bll.Delete(num); //Literal literal = (Literal)p1.Item.FindControl("litName"); //B_Operationlog.CreateOperationLog(BasePage.UId, B_Operationlog.operationLogType.Del, "信息", literal.Text); base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { string strErr = ""; if (this.bName.Text.Trim().Length == 0) { strErr += "名称不能为空!\\n"; } if (this.bOrder.Text.Trim().Length == 0) { strErr += "排序不能为空!\\n"; } if (!PageValidate.IsNumber(this.bOrder.Text)) { strErr += "排序格式错误!\\n"; } if (strErr != "") { MessageBox.Alert(this, strErr); return; } PaducnSoft.Model.ay_menu model = new PaducnSoft.Model.ay_menu(); model.bName = this.bName.Text; model.bUrl = this.bUrl.Text; model.bParent = (int)StringPlus.ConvertNullToZero(this.bParent.SelectedValue); model.bOpenMode = this.bOpenMode.SelectedValue; model.bLocation = this.bLocation.Value; model.bIsShow = (int)StringPlus.ConvertNullToZero(this.bIsShow.SelectedValue); model.bOrder = (int)StringPlus.ConvertNullToZero(this.bOrder.Text); model.bAddTime = DateTime.Now; model.bAddUser = paducncms.Module.UserRights.AdminUserID; bool result = dal.Add(model); if (result) { MessageBox.Alert(this, "保存成功!", true, "btnReset"); } else { MessageBox.Alert(this, "保存失败!"); } }
//函数 private void UpdateItem() { PaducnSoft.Model.ay_system model = new PaducnSoft.Model.ay_system(); model.bName = this.bName.Text; model.bTitle = this.bTitle.Text; model.bUrl = this.bUrl.Text; model.bPic = this.bPic.Text; model.bMiibeian = this.bMiibeian.Text; model.bKeywords = this.bKeywords.Text; model.bDescriptions = this.bDescriptions.Text; model.bCounter = this.bCounter.Text; bool result = dal.Update(model); if (result) { MessageBox.Alert(this, "网站配置成功!"); } else { MessageBox.Alert(this, "网站配置失败,请检查数据是否正确!"); } }
protected void lbtnDeletes_Click(object sender, EventArgs p1) { #warning BasePage.IsPermissions(1) if (BasePage.IsPermissions(1)) { //int num = 0; foreach (RepeaterItem item in this.rpt_List.Items) { HtmlInputCheckBox box = (HtmlInputCheckBox)item.FindControl("cheId"); if (box.Checked) { bll.Delete(int.Parse(box.Value)); // num++; } } base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } else { MessageBox.Alert(this, "没有删除权限!"); } }
protected void btnLogin_Click(object sender, EventArgs e) { string userName = txtUserName.Text.Trim(); string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPwd.Text.Trim(), "md5"); string checkCode = txtCodeImage.Text.Trim(); if (userName == "") { MessageBox.Alert("用户名不能为空!", Page); txtUserName.Focus(); } else if (pwd == "") { MessageBox.Alert("密码不能为空!", Page); txtPwd.Focus(); } else if (checkCode.ToLower() != Session["CheckCode"].ToString().ToLower()) { MessageBox.Alert("验证码错误!", Page); txtCodeImage.Text = ""; txtCodeImage.Focus(); } else { List <Model.Admin> list = AdminBll.AdminLogin(userName, pwd); if (list.Count > 0) { Session["AdminName"] = userName; Session["AdminId"] = list[0].AdminId; Session["Admin"] = list[0]; Response.Redirect("Main.aspx"); } else { MessageBox.Alert("用户名或密码错误!", Page); } } }
protected void btnDelSelect_Click(object sender, EventArgs e) { int selectNum = 0; for (int i = 0; i < dgPro.Items.Count; i++) { CheckBox chk = dgPro.Items[i].FindControl("chkSelect") as CheckBox; if (chk.Checked) { selectNum++; } } if (selectNum == 0) { MessageBox.Alert("请选择要删除的项!", Page); } else { for (int i = 0; i < dgPro.Items.Count; i++) { CheckBox chk = dgPro.Items[i].FindControl("chkSelect") as CheckBox; if (chk.Checked) { int sId = Convert.ToInt32(dgPro.DataKeys[i]); try { ProductBll.DeleteProduct(sId); } catch (Exception) { MessageBox.Alert("删除失败!", Page); break; } } } } BindData(); }
protected void btnSave_Click(object sender, EventArgs p1) { string filepath = ""; //文件上传 if (this.fileFilePath.HasFile) { JUpload up = new JUpload(); up.FileSize = 10000; up.FileType = "image"; up.IsChangeName = true; string rev = up.SaveFile(fileFilePath, "/upLoads/info/"); string strMsg = ""; switch (rev) { case "0": strMsg = "上传文件格式不正确"; break; case "1": strMsg = "上传文件过大"; break; case "3": strMsg = "非法的图片"; break; } if (strMsg != "") { MessageBox.Alert(this, strMsg); return; } filepath = rev; } int addID = 0; if (Id > 0) { model = bll.GetModel(Id); //if (hidAidUsers.Value == "0") //{ // model.AId = MW.BLL.B_TBAdmin.AId; //} //else //{ // model.AId = int.Parse(hidAidUsers.Value); //} model.CreateTime = Utils.StrToDateTime(txtBeginTime.Text, DateTime.Now); model.UpdateTime = DateTime.Now; model.Title = txtTitle.Text; model.TypeId = dropTypeId.SelectedValue; model.ShareUsers = txtShareUsers.Text; model.Contents = Utils.HtmlEncode(txtContents.Text); model.Sort = int.Parse(txtSort.Text); model.fj = txtFj.Text; if (filepath != "") { model.FilePath = filepath; } // addID = Id; if (bll.Update(model)) { MessageBox.AlertToUrl(this, "保存成功!", hidurl.Value); //B_Operationlog.CreateOperationLog(BasePage.UId, B_Operationlog.operationLogType.Edit, "信息", model.Title); // MessageBox.JSLoad(this, "alert('保存成功!');location.href='infolist.aspx?typeId =" + Id + "'"); } } else { model.Audit = 1; model.RecoveryState = 0; //if (hidAidUsers.Value == "0") //{ model.AId = BasePage.UId.ToString(); //} //else //{ // model.AId = int.Parse(hidAidUsers.Value); //} model.ShareUsers = txtShareUsers.Text; model.UpdateTime = DateTime.Now; model.Title = txtTitle.Text; model.TypeId = dropTypeId.SelectedValue; model.Contents = Utils.HtmlEncode(txtContents.Text); model.FilePath = filepath; model.Sort = int.Parse(txtSort.Text); model.fj = txtFj.Text; model.CreateTime = Utils.StrToDateTime(txtBeginTime.Text, DateTime.Now); bool falg = bll.Add(model); if (falg) { MessageBox.AlertToUrl(this, "保存成功!", hidurl.Value); //B_Operationlog.CreateOperationLog(BasePage.UId, B_Operationlog.operationLogType.Add, "信息", model.Title); //MessageBox.JSLoad(this, "alert('保存成功!');location.href='infolist.aspx?typeId =" + Id + "'"); } } }
protected void dgPro_ItemCommand(object source, DataGridCommandEventArgs e) { switch (e.CommandName.ToLower()) { case "status": int proId = Convert.ToInt32(e.CommandArgument); List <Model.Product> list = ProductBll.GetProductbyId(proId); if (list.Count > 0) { int status = 0; if (list[0].IsShow == 1) { status = 0; } else { status = 1; } try { ProductBll.UpdateStatus(proId, status); BindData(); } catch (Exception ex) { MessageBox.Alert("未知错误:" + ex, Page); /*throw;*/ } } break; case "index": int proId1 = Convert.ToInt32(e.CommandArgument); List <Model.Product> list1 = ProductBll.GetProductbyId(proId1); if (list1.Count > 0) { int status1 = 0; if (list1[0].IndexShow == 1) { status1 = 0; } else { status1 = 1; } try { ProductBll.UpdateIndex(proId1, status1); BindData(); } catch (Exception ex) { MessageBox.Alert("未知错误:" + ex, Page); /*throw;*/ } } break; case "del": int id = Convert.ToInt32(e.CommandArgument); try { ProductBll.DeleteProduct(id); MessageBox.Alert("删除成功!", Page); } catch (Exception) { MessageBox.Alert("删除失败!", Page); /*throw;*/ } break; default: break; } }
/// <summary> /// 警告消息 /// </summary> protected async Task Alert(string message, string title = null, CancellationToken?cancelToken = null) { await MessageBox.Alert(message, title, cancelToken); }
protected void rpt_List_ItemCommand(object source, RepeaterCommandEventArgs p1) { object num = p1.CommandArgument.ToString(); if (p1.CommandName == "lbtnDelete") { #warning delte IsPermissions(0x6c) if (!BasePage.IsPermissions(1)) { MessageBox.Alert(this, "没有删除权限!"); } else { bll.Delete(Utils.StrToInt(num, 0)); base.Response.Redirect(HttpContext.Current.Request.Url.PathAndQuery); } } else if (p1.CommandName == "lbtnBuild") { var arr = num.ToString().Split('|'); string votetemp = ""; if (FileHelper.FileExists(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/votetemplate_" + arr[0] + ".htm"))) { votetemp = FileHelper.ReadFile(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/votetemplate_" + arr[0] + ".htm")) + "\n";; } else { votetemp = FileHelper.ReadFile(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/votetemplate.htm")) + "\n"; } Build build = new Build(); var model = bll.GetModel(Utils.StrToInt(arr[0], 0)); votetemp = votetemp.Replace("{id}", model.Id.ToString()) .Replace("{path}", BasePage.GetWebPath) .Replace("{title}", model.C_Title) .Replace("{course}", model.C_course) .Replace("{teacher}", model.C_Tearcher) .Replace("{address}", model.C_Adrees) .Replace("{starttime}", model.DT_StartDate.ToShortDateString()) .Replace("{endtime}", model.DT_OverDate.ToShortDateString()) .Replace("{coursestarttime}", model.CourseStart.ToShortDateString()) .Replace("{courseendtime}", model.CourseEnd.ToShortDateString()); votetemp = votetemp.Replace("{Content}", build.PubBuildHtml(model.Id, Utils.StrToInt(arr[1], 0))).Replace("{Images}", BasePage.GetWebPath + "/mw/onlinesurvey/SysImages"); if (votetemp.IndexOf("{QR}", StringComparison.OrdinalIgnoreCase) > 0) { this.CreateQR(model.N_SysId); votetemp = votetemp.Replace("{QR}", string.Concat(new object[] { "<img src=\"", BasePage.GetWebPath, "/mw/onlinesurvey/qr/", model.Id, ".gif\" width=\"100\" height=\"100\" />" })); } if (FileHelper.FileExists(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/" + arr[0] + ".html"))) { System.IO.File.Delete(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/" + arr[0] + ".html")); } FileHelper.WriteFile(Utils.GetMapPath(BasePage.GetWebPath + "/mw/onlinesurvey/" + arr[0] + ".html"), votetemp); MessageBox.Alert(this, "生成投票问卷成功!"); } else if (p1.CommandName == "lbtnCopy") { bll.CopyVote(Utils.StrToInt(num, 0)); MessageBox.AlertToUrl(this, "调查复制成功", "votelist.aspx"); } }