protected void btnSub_Click(object sender, EventArgs e) { if (txtEditor.Text == "") { Response.Write("<script>alert('请输入内容')</script>"); return; } if (txtTitle.Text == "") { Response.Write("<script>alert('请输入标题')</script>"); return; } string Title = txtTitle.Text; string Content = txtEditor.Text; string Author = "法学院"; string Time = DateTime.Now.ToShortDateString(); string sql = ""; if(Request["ID"] ==null) { sql = "insert into SchoolNews (Title,Content,Author,[Time]) values ('" + Title + "','" + Content + "','" + Author + "','" + Time + "')"; } else { string ID=Request["ID"] as string; sql = "update SchoolNews set Title='" + Title + "',Content='" + Content + "',Author='" + Author + "',[Time]='" + Time + "' where ID=" + ID; } if(AccessDBHelper.Update(sql)) { Response.Write("<script>alert('发布成功');window.location.href='/backstage/EditSchoolNews.aspx'</script>"); } else { Response.Write("<script>alert('发布失败')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request["ID"] != null) { string ID=Request["Id"] as string; DataSet ds = AccessDBHelper.Select("select * from SchoolNews where ID=" + ID); txtEditor.Text = ds.Tables[0].Rows[0]["Content"].ToString(); txtTitle.Text = ds.Tables[0].Rows[0]["Title"].ToString(); } } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/html"; string ID = context.Request["ID"]; if (AccessDBHelper.Update("delete from PublicInfo where ID=" + ID)) { context.Response.Write("<script>alert('删除成功');window.location.href='/backstage/ManagerPublicInfo.aspx';</script>"); } else { context.Response.Write("<script>alert('删除失败,请重试');window.location.href='/backstage/ManagerPublicInfo.aspx';</script>"); } }
public void IntercomShoutDataInit() { string SQL = "Select * From IntercomShoutList"; DataTable dt = new DataTable(); string path = "xwxayj_Local.mdb"; dt = AccessDBHelper.dataTable(SQL, path); for (int i = 0; i < dt.Rows.Count; i++) { string temp_IP_Channel = dt.Rows[i]["VideoIP"].ToString() + "," + dt.Rows[i]["VideoChannel"].ToString(); if (!Dic_IntercomShoutMapped.ContainsKey(temp_IP_Channel)) { IntercomShoutMapped temp_IntercomShoutMapped = new IntercomShoutMapped(); temp_IntercomShoutMapped.VideoIP = dt.Rows[i]["VideoIP"].ToString(); temp_IntercomShoutMapped.VideoChannel = int.Parse(dt.Rows[i]["VideoChannel"].ToString()); temp_IntercomShoutMapped.ShoutIP = dt.Rows[i]["ShoutIP"].ToString(); temp_IntercomShoutMapped.ShoutChannel = int.Parse(dt.Rows[i]["ShoutChannel"].ToString()); temp_IntercomShoutMapped.IntercomIP = dt.Rows[i]["IntercomIP"].ToString(); temp_IntercomShoutMapped.IntercomChannel = int.Parse(dt.Rows[i]["IntercomChannel"].ToString()); Dic_IntercomShoutMapped.Add(temp_IP_Channel, temp_IntercomShoutMapped); } } }
protected void btnSub_Click(object sender, EventArgs e) { if (txtUserName.Text == "") { Response.Write("<script>alert('请输入用户名');</script>"); return; } if (txtPassword.Text == "") { Response.Write("<script>alert('请输入密码');</script>"); return; } string UserName = txtUserName.Text; string Password = txtPassword.Text; if (AccessDBHelper.Update("insert into Users (UserName,[Password]) values ('" + UserName + "','" + Password + "')")) { Response.Write("<script>alert('管理员添加成功');window.location.href='/backstage/AddUser.aspx'</script>"); } else { Response.Write("<script>alert('管理员添加失败,请重试')</script>"); } }
protected void btnSub_Click(object sender, EventArgs e) { if (txtLinkName.Text == "") { Response.Write("<script>alert('请输入链接名称');</script>"); return; } if (txtLinkAddress.Text == "") { Response.Write("<script>alert('请输入链接地址');</script>"); return; } string LinkName = txtLinkName.Text; string LinkAddress = txtLinkAddress.Text; if (AccessDBHelper.Update("insert into FriendshipLink (LinkName,LinkAddress) values ('" + LinkName + "','" + LinkAddress + "')")) { Response.Write("<script>alert('友情链接添加成功');window.location.href='/backstage/AddFriendshipLink.aspx'</script>"); } else { Response.Write("<script>alert('友情链接添加失败,请重试')</script>"); } }
public static bool Insert2Access(string[] arrzknos, string accesspath) { ErrorMessage = ""; bool blresult = true; bool blresult1 = true; bool blresult2 = true; bool blresult3 = true; bool blresult4 = true; bool blresult5 = true; bool blresult6 = true; bool blresult7 = true; _dbOrl = RequestUtil.GlobalDBHelper; IDBHelper accessdb = new AccessDBHelper(); accessdb.DBPath = accesspath; //要导出Access数据库对应的DBHelper DataTable dttest = accessdb.DoQueryEx("select * from g_OrgTree"); GeoZkPointsDataRepository geozkResposity = new GeoZkPointsDataRepository(); DataRow[] drSelected = geozkResposity.GetDataWhereInArrId(arrzknos); List <GeoZkPointsData> lstzkData = MappingUtil.GetEntityFromDataRowArr <GeoZkPointsData>(drSelected); string gcbh = ""; string zkbh = ""; int zkcount = lstzkData.Count; string orl_sql_zuankong = "", orl_sql_shuiwei = "", orl_sql_quyang = "", orl_sql_connect = "", orl_sql_temptuceng = "", orl_sql_tuceng = "", orl_sql_biaoguan = ""; OleDbConnection accConn = (OleDbConnection)accessdb.ActiveConnection; List <object[]> lstrows_zk = new List <object[]>(); List <object[]> lstrows_sw = new List <object[]>(); List <object[]> lstrows_qy = new List <object[]>(); List <object[]> lstrows_conn = new List <object[]>(); List <object[]> lstrows_ttc = new List <object[]>(); List <object[]> lstrows_tc = new List <object[]>(); List <object[]> lstrows_bg = new List <object[]>(); DataTable dtzk = new DataTable(); DataTable dtsw = new DataTable(); DataTable dtqy = new DataTable(); DataTable dtconnect = new DataTable(); DataTable dtttc = new DataTable(); DataTable dttc = new DataTable(); DataTable dtbg = new DataTable(); DataTable dtgc = new DataTable(); int gcsyRepalce = Convert.ToInt32(DateTime.Now.Year + "" + DateTime.Now.Month + "" + DateTime.Now.Day); string gcmcRepalce = "Exported" + gcsyRepalce; int zknum = 0;//统计钻孔数目,也作为钻孔新的编号 try { for (int i = 0; i < zkcount; i++) { zknum++; gcbh = lstzkData[i].ProjectNo; zkbh = lstzkData[i].ZKBH; dtzk.Clear(); orl_sql_zuankong = string.Format("select * from z_zuankong where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtzk = _dbOrl.DoQueryEx(orl_sql_zuankong); if (dtzk.Rows.Count > 0) { dtzk.Columns.RemoveAt(0); foreach (DataRow dr in dtzk.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_zk.Add(obj); } } dtsw.Clear(); orl_sql_shuiwei = string.Format("select * from z_g_shuiwei where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtsw = _dbOrl.DoQueryEx(orl_sql_shuiwei); if (dtsw.Rows.Count > 0) { dtsw.Columns.RemoveAt(0); foreach (DataRow dr in dtsw.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_sw.Add(obj); } } dtqy.Clear(); orl_sql_quyang = string.Format("select * from z_c_quyang where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtqy = _dbOrl.DoQueryEx(orl_sql_quyang); if (dtqy.Rows.Count > 0) { dtqy.Columns.RemoveAt(0); foreach (DataRow dr in dtqy.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_qy.Add(obj); } } dtconnect.Clear(); orl_sql_connect = string.Format("select * from p_connect where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtconnect = _dbOrl.DoQueryEx(orl_sql_connect); if (dtconnect.Rows.Count > 0) { dtconnect.Columns.RemoveAt(0); foreach (DataRow dr in dtconnect.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[2] = zknum; lstrows_conn.Add(obj); } } dtttc.Clear(); orl_sql_temptuceng = string.Format("select * from z_g_temptuceng where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtttc = _dbOrl.DoQueryEx(orl_sql_temptuceng); if (dtttc.Rows.Count > 0) { dtttc.Columns.RemoveAt(0); foreach (DataRow dr in dtttc.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_ttc.Add(obj); } } dttc.Clear(); orl_sql_tuceng = string.Format("select * from z_g_tuceng where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dttc = _dbOrl.DoQueryEx(orl_sql_tuceng); if (dttc.Rows.Count > 0) { dttc.Columns.RemoveAt(0); foreach (DataRow dr in dttc.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_tc.Add(obj); } } dtbg.Clear(); orl_sql_biaoguan = string.Format("select * from z_y_biaoguan where F_PROJECTNO='{0}' and zkbh='{1}'", gcbh, zkbh); dtbg = _dbOrl.DoQueryEx(orl_sql_biaoguan); if (dtbg.Rows.Count > 0) { dtbg.Columns.RemoveAt(0); foreach (DataRow dr in dtbg.Rows) { object[] obj = dr.ItemArray; obj[0] = gcsyRepalce; obj[1] = zknum; lstrows_bg.Add(obj); } } } blresult1 = CreateCmdsAndUpdate("z_zuankong", accConn, lstrows_zk); blresult2 = CreateCmdsAndUpdate("z_g_shuiwei", accConn, lstrows_sw); blresult3 = CreateCmdsAndUpdate("z_c_quyang", accConn, lstrows_qy); blresult4 = CreateCmdsAndUpdate("p_connect", accConn, lstrows_conn); blresult5 = CreateCmdsAndUpdate("z_g_temptuceng", accConn, lstrows_ttc); blresult6 = CreateCmdsAndUpdate("z_g_tuceng", accConn, lstrows_tc); blresult7 = CreateCmdsAndUpdate("z_y_biaoguan", accConn, lstrows_bg); string sql_gc = string.Format("update x_GongCheng set GCSY='{0}',GCMC='{1}', GCBH='{2}', GCBHOLD='{3}'", gcsyRepalce, gcmcRepalce, gcmcRepalce, gcmcRepalce);//另外两个字段GCBH,GCBHOLD, accessdb.DoSQL(sql_gc); } catch (Exception ex) { LogManager.WriteToError("导出Access数据库"); LogManager.WriteToError(ex.Message); ErrorMessage += "导出Access数据库:" + ex.Message; } finally { if (accessdb.ActiveConnection.State == ConnectionState.Open) { accessdb.ActiveConnection.Close(); } StreamsFile(accesspath); } blresult = blresult1 && blresult2 && blresult3 && blresult4 && blresult5 && blresult6 && blresult7; return(blresult); }
public static void LoadSettings() { AccessDBHelper.LoadDBSettingsForWeb(ConfigurationManager.AppSettings["AccessConnectionString"], HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["DBPath"]), ConfigurationManager.AppSettings["DBPassword"]); }
public DataView getDataView() { return(AccessDBHelper.Select("select * from FriendshipLink").Tables[0].DefaultView); }
public DataView getDataView() { return(AccessDBHelper.Select("select * from PartyWork order by Time desc").Tables[0].DefaultView); }
public DataView getDataView() { return(AccessDBHelper.Select("select * from Users").Tables[0].DefaultView); }