protected void btnSaveNewDCount_Click(object sender, EventArgs e) { try { if (System.Web.HttpContext.Current.Session["user"] != null) { CheckLogin.Userinfo = System.Web.HttpContext.Current.Session["user"].ToString(); } Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); AppSettingsSection appSetting = config.AppSettings; //如果不存在则添加 if (appSetting.Settings["NewsDetailCount"] == null) { appSetting.Settings.Add("NewsDetailCount", this.txtSaveNewDCount.Text.ToString().Trim()); } else//否则修改 { appSetting.Settings["NewsDetailCount"].Value = this.txtSaveNewDCount.Text.ToString().Trim(); } config.Save(ConfigurationSaveMode.Modified); JS.Alert("修改成功!"); } catch (System.Exception ex) { JS.Alert("修改失败!错误信息:" + ex); } }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); try { string sql = "delete from t_plat where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); if (e.Item.Cells[6] != null && e.Item.Cells[6].Text.Length > 0) { string filePath = Page.Server.MapPath(@"~\" + e.Item.Cells[6].Text); if (File.Exists(filePath)) { File.Delete(filePath); } } JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
/// <summary> /// 显示图片数量修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveCountList_Click(object sender, EventArgs e) { try { Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); AppSettingsSection appSetting = config.AppSettings; //如果不存在则添加 if (appSetting.Settings["PicNewsCount"] == null) { appSetting.Settings.Add("PicNewsCount", this.txtSaveCountList.Text.ToString().Trim()); } else//否则修改 { appSetting.Settings["PicNewsCount"].Value = this.txtSaveCountList.Text.ToString().Trim(); } config.Save(ConfigurationSaveMode.Full); JS.Alert("修改成功!"); } catch (System.Exception ex) { JS.Alert("修改失败!错误信息:" + ex); } }
private void editIni() { string sql = "select * from t_sample where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("读数据失败"); Response.End(); } else { _dr = dt.Rows[0]; } this.txt_title.Text = DR["ptitle"].ToString(); this.txt_Url.Text = DR["purl"].ToString(); this.content2.Value = DR["pcontent"].ToString(); this.HyperLink1.NavigateUrl = DR["ppic"].ToString(); this.HyperLink1.Target = "_blank"; this.txt_DateTime.Value = DR["pdate"].ToString(); if (DR["ppic"].ToString().Trim() != "") { this.HyperLink1.Text = "点击查看"; } else { this.HyperLink1.Text = "---"; } }
public override object Run() { var a = JS.Id("a"); return(JS.For(JS.Var(a.AssignWith(10)), a.IsGreaterThan(0), a.PostDecrement()).Do( JS.Alert(a))); }
public override object Run() { var e = JS.Id("e"); return(JS.Try(JS.Throw("Raise Hell!")) .Catch(e, JS.Alert(e)) .Finally(JS.Alert("Finally!"))); }
private void editNoPic() { string title = this.txt_title.Text; if (title == null | title.Length <= 0) { JS.Alert("题目不能为空!"); return; } if (title.Length >= 255) { JS.Alert("题目过长!"); return; } string url = this.txt_Url.Text; if (url == null | url.Length <= 0) { JS.Alert("地址不能为空!"); return; } if (url.Length >= 255) { JS.Alert("地址过长!"); return; } string content = content2.Value; string strDateTime = this.txt_DateTime.Value; string sqlEdit = "update t_sample set ptitle=@ptitle,pcontent=@pcontent , purl=@url, pdate=@pdate where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); OleDbParameter purl = new OleDbParameter("@purl", OleDbType.VarChar); purl.Value = url; insertValue.Add(purl); OleDbParameter pdate = new OleDbParameter("@pdate", OleDbType.Date); pdate.Value = strDateTime; insertValue.Add(pdate); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }
public override object Run() { var a = JS.Id("a"); return(JS.For(null, a.IsGreaterThan(0), a.PostDecrement()).Do( JS.Alert(a), JS.If(a.IsEqualTo(5)).Then( JS.Break()))); }
private void edit() { string title = this.txt_title.Text; if (title == null || title.Length <= 0) { JS.Alert("题目不能为空!"); return; } if (title.Length >= 255) { JS.Alert("题目过长!"); return; } string content = content2.Value; if (content == null || content.Length <= 0) { JS.Alert("内容不能为空!"); return; } string FilePath = ""; FilePath = File1.Value; if (FilePath.Length > 0) { FilePath = FileUp.meUpfile(this.File1, @"~\file\", true); FilePath = FilePath.Substring(FilePath.IndexOf('\\') + 1); } string sqlEdit = "update t_plat set ptitle=@ptitle,pcontent=@pcontent ,purl=@purl where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); OleDbParameter purl = new OleDbParameter("@purl", OleDbType.LongVarWChar); purl.Value = FilePath; insertValue.Add(purl); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }
protected void but_default_Click(object sender, EventArgs e) { FrameSet one = new FrameSet(); one.Height = int.Parse(this.txt_height.Text); one.Width = int.Parse(this.txt_width.Text); one.Src = this.txt_src.Text; FrameSet.Edit(one, "资源中心"); JS.Alert("保存成功"); }
private void ini() { try { } catch { JS.Alert("编码错误!没找到用户信息"); this.but_save.Enabled = false; return; } }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); string sql = "delete from t_programs where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); JS.Alert("删除成功"); showgrid(source, e); }
private void ini() { string sql = "select * from t_about where pname='padv'"; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("发生错误"); Response.End(); } this.content2.Value = dt.Rows[0]["pcontent"].ToString(); }
public void JQueryHasAjax() { var expression1 = JQ.Ajax("http://service.com"); var expression2 = JQ.Ajax("http://service.com", new { accepts = "text/html", cache = false, complete = JS.Function().Parameters("xhr", "status").Do(JS.Alert(JS.Id("status"))) }); Assert.AreEqual(@"$.ajax(""http://service.com"");", expression1.ToString()); Assert.AreEqual(@"$.ajax(""http://service.com"",{accepts:""text/html"",cache:false,complete:function(xhr,status){alert(status);}});", expression2.ToString()); }
private void DGList_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { try { AccessDb.ExecuteNonQuery("delete from t_user where id=" + int.Parse(e.Item.Cells[0].Text)); JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
public override object Run() { return(JS.Switch(JS.Id("event")) .Case("click") .Case("contextmenu").Do( JS.Alert("clicked!"), JS.Break()) .Case("enter").Do( JS.Alert("entered"), JS.Break()) .Case("leave").Do( JS.Alert("leave"), JS.Break())); }
protected void Button1_Click(object sender, EventArgs e) { string content = content2.Value; string sql = "update t_about_top set pcontent=@pcontent where pname='s2'"; ArrayList insertValue = new ArrayList(); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); int p = AccessDb.ExecuteNon(sql, ref insertValue); JS.Alert("修改成功!"); }
public void LoopStatementProducesLoopWithAllTheBellsAndWhistles() { var a = JS.Id("a"); var initialization = JS.Var(a.AssignWith(0)); var condition = a.IsLessThan(10); var iteration = a.PostIncrement(); var alert = JS.Alert(a); var statement = new LoopStatement(initialization, condition, iteration, alert); Assert.AreEqual("var a=0;", statement.Initialization.ToString()); Assert.AreEqual("a++;", statement.Iteration.ToString()); Assert.AreEqual("a<10;", statement.Condition.ToString()); Assert.AreEqual("alert(a);", statement.Statement.ToString()); Assert.AreEqual("for(var a=0;a<10;a++)alert(a);", statement.ToString()); }
public void SwitchStatementProducesSwitch() { var statement1 = JS.Switch(JS.Id("a")) .Case("a").Do(JS.Return("a")); Assert.AreEqual("switch(a){case \"a\":return \"a\";}", statement1.ToString()); var statement2 = JS.Switch(JS.Id("b")) .Case(1).Do(JS.Return(100)) .Case(2).Case(3).Do(JS.Return(200)) .Case(4, 5, 6).Do(new List <Statement> { JS.Alert("Not Done!"), JS.Break() }) .Case(Enumerable.Range(7, 4).Select(i => (Expression)JS.Number(i))).Do( JS.Alert(JS.Id("a")), JS.Break()) .Default().Do(JS.Break()); statement2.Cases.Add(null); Assert.AreEqual( "switch(b){case 1:return 100;case 2:case 3:return 200;" + "case 4:case 5:case 6:alert(\"Not Done!\");break;" + "case 7:case 8:case 9:case 10:alert(a);break;default:break;}", statement2.ToString()); CaseStatement test = new CaseStatement(3); test.Value = 4; test.Statements.Add(JS.Break()); var cases = new List <CaseStatement> { new CaseStatement(1, JS.Break()), new CaseStatement(2, new List <Statement> { JS.Break() }), test }; var statement3 = new SwitchStatement(JS.Id("c"), cases); Assert.AreEqual("switch(c){case 1:break;case 2:break;case 4:break;}", statement3.ToString()); }
protected void but_save_Click(object sender, EventArgs e) { string sql = "insert into t_frind(ptitle,purl,ptype) values('{0}','{1}','{2}')"; string title = this.txt_title.Text; string type = this.DropDownList1.SelectedValue; string url = this.txt_url.Text; sql = string.Format(sql, title, url, type); AccessDb.ExecuteNonQuery(sql); JS.Alert("添加成功"); this.txt_title.Text = ""; this.txt_url.Text = ""; showgrid(null, null); }
private void editIni() { string sql = "select * from t_interface where id=" + UID; DataTable dt = AccessDb.Execute(sql).Tables[0]; if (dt.Rows.Count == 0) { JS.Alert("读数据失败"); Response.End(); } else { _dr = dt.Rows[0]; } this.txt_title.Text = DR["ptitle"].ToString(); this.content2.Value = DR["pcontent"].ToString(); }
protected void DGList_DeleteCommand(object source, DataGridCommandEventArgs e) { int nowRow = int.Parse(e.Item.Cells[0].Text); string sql = "delete from t_frind where id=" + nowRow.ToString(); AccessDb.ExecuteNonQuery(sql); try { JS.Alert("删除成功"); } catch (Exception ex) { JS.Alert("删除失败:" + ex); } showgrid(source, e); }
/// <summary> /// 处理异常,为以下顺序 /// 1. 如果为 false,则表明没处理,让 BasePage_Error 处理 /// 2. 如果重载为 true,则由页面处理 /// </summary> /// <param name="ex">异常</param> /// <param name="step">哪个环节出现的</param> /// <param name="id">额外的 id 信息</param> /// <returns></returns> protected virtual bool _HandleException(Type callerType, ExceptionFilter exFilter, string step, Action <string> msgSend = null) { // 首次加载报的错 if (!IsPostBack && !_IsPartial) { if (exFilter.Exception != null) { new DTException.DataSetter(exFilter.Exception.Data) .Record("BASE.Step", step) .Record("BASE.PageUrl", Request.RawUrl); throw exFilter.Exception; } } if (!exFilter.Handled) { string msg = exFilter.Exception.Message; exFilter.DT(ex => { if (ex is TTableRecordNotFound) { msg = "您好,数据未能访问 "; } if (ex.Data != null && ex.Data.Count > 0) { msg += "\r\n参考(用于运维):\r\n----------"; foreach (var key in exFilter.Exception.Data.Keys) { msg += string.Format("\r\n {0}:{1} ", key.ToStringEx(), exFilter.Exception.Data[key].ToStringEx()); } msg += "\r\n----------"; } }); if (msgSend != null) { msgSend(msg); } else { _JS.Alert(msg); } } return(true); }
protected void but_save_Click(object sender, EventArgs e) { int sort = 0; try { sort = int.Parse(this.txt_sort.Text); } catch { JS.Alert("请输入整数!"); return; } if (this.txt_title.Text.Length >= 255) { JS.Alert("栏目名称过长,请重新输入!"); return; } if (ViewState["pk"] != null) { //edit string sql = "update t_programs set ptitle='{0}' ,purl='{1}',pstate={2}, picurl='{3}',psort={4} where id=" + ViewState["pk"].ToString(); sql = string.Format(sql, this.txt_title.Text, this.txt_url.Text, this.drp_isUse.SelectedValue == "是" ? "True" : "False", "", sort.ToString()); AccessDb.ExecuteNonQuery(sql); JS.Alert("修改成功"); ViewState["pk"] = null; //this.txt_title.Enabled = true; } else { //tianjia string sql = "insert into t_programs(ptitle,purl,pstate,picurl,psort) values('{0}','{1}',{2},'{3}',{4})"; sql = string.Format(sql, this.txt_title.Text, this.txt_url.Text, this.drp_isUse.SelectedValue == "是" ? "True" : "False", "", sort); AccessDb.ExecuteNonQuery(sql); JS.Alert("添加成功"); } this.txt_title.Text = ""; this.txt_url.Text = ""; txt_sort.Text = ""; this.drp_isUse.SelectedIndex = 0; showgrid(null, null); }
private void add() { string title = this.txt_title.Text; string content = content2.Value; string sql = "insert into t_interface (ptitle,pcontent) values(@ptitle,@pcontent)"; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); int p = AccessDb.ExecuteNon(sql, ref insertValue); JS.Alert("添加成功!"); }
private void but_save_Click(object sender, System.EventArgs e) { //add if (ViewState["pk"] != null) {//edit txt_user.Enabled = true; try { string pass = this.txt_pass.Text; AccessDb.ExecuteNonQuery("update t_user set pass='******' where id=" + ViewState["pk"].ToString()); JS.Alert("修改成功"); ViewState["pk"] = null; } catch (Exception ex) { JS.Alert("修改失败:" + ex); } } else { if (AccessDb.Execute("select * from t_user where Uname='" + this.txt_user.Text.Trim().Replace("'", "''") + "'").Tables[0].Rows.Count != 0) { JS.Alert("存在同名用户"); return; } try { string pass = this.txt_pass.Text; string uname = this.txt_user.Text; string sql = "insert into t_user (uname,pass) values('{0}','{1}')"; sql = string.Format(sql, uname, pass); AccessDb.ExecuteNonQuery(sql); JS.Alert("添加成功"); ViewState["pk"] = null; } catch (Exception ex) { JS.Alert("添加失败:" + ex); } } showgrid(null, null); this.txt_user.Text = ""; this.txt_pass.Text = ""; }
private void editPic(string pic) { string title = this.txt_title.Text; string content = content2.Value; bool _pAnswered = false; if (content != null && content.Length > 0) { _pAnswered = true; } else { _pAnswered = false; } string sqlEdit = "update t_question set ptitle=@ptitle,pcontent=@pcontent ,ppic=@ppic ,pAnswered=@pAnswered where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); OleDbParameter ppic = new OleDbParameter("@ppic", OleDbType.LongVarWChar); ppic.Value = pic; insertValue.Add(ppic); OleDbParameter pAnswered = new OleDbParameter("@pAnswered", OleDbType.Boolean); pAnswered.Value = _pAnswered; insertValue.Add(pAnswered); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }
/// <summary> /// 常见问题修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnQuestionSave_Click(object sender, EventArgs e) { try { string strURL = this.txtQuestionURL.Text; string strInfo = this.txtAreaQuestion.Value; if (strURL.Trim().Equals(String.Empty)) { JS.Alert("链接输入不正确!"); return; } if (strInfo.Trim().Equals(String.Empty)) { JS.Alert("简介输入不正确!"); return; } Configuration config = WebConfigurationManager.OpenWebConfiguration("~"); AppSettingsSection appSetting = config.AppSettings; //如果不存在则添加 if (appSetting.Settings["QuestionInfo"] == null) { appSetting.Settings.Add("QuestionInfo", strURL + "|" + strInfo); } else//否则修改 { appSetting.Settings["QuestionInfo"].Value = strURL + "|" + strInfo; } config.Save(ConfigurationSaveMode.Full); JS.Alert("修改成功!"); } catch (System.Exception ex) { JS.Alert("修改失败!错误信息:" + ex); } }
protected void Button1_Click(object sender, EventArgs e) { string sql = "update t_3th set purl='" + this.txt_url.Text.Trim() + "' where id="; switch (UID) { case "interface": sql += "1"; break; case "use": sql += "2"; break; case "source": sql += "3"; break; } AccessDb.ExecuteNonQuery(sql); JS.Alert("成功."); }
private void edit() { string title = this.txt_title.Text; string content = content2.Value; //string sql = "insert into t_news (ptitle,pcontent,puser,pdate,ptype) values(@ptitle,@pcontent,@puser,@pdate,@ptype)"; string sqlEdit = "update t_interface set ptitle=@ptitle,pcontent=@pcontent where id=" + UID; ArrayList insertValue = new ArrayList(); OleDbParameter ptitle = new OleDbParameter("@ptitle", OleDbType.VarChar); ptitle.Value = title; insertValue.Add(ptitle); OleDbParameter pcontent = new OleDbParameter("@pcontent", OleDbType.LongVarWChar); pcontent.Value = content; insertValue.Add(pcontent); int p = AccessDb.ExecuteNon(sqlEdit, ref insertValue); JS.Alert("修改成功!"); }