using EntMSM.SmsDbContext;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Mvc; namespace EntMSM.Controllers
{
public class ContactsController : BaseController
{
EntSmsDbContext esd = new EntSmsDbContext(); /// <summary>
/// iqueryable转datatable
/// </summary>
/// <param name="enumerable"></param>
/// <returns></returns>
public static DataTable ConvertToDataTable(IQueryable<EntMSM.Models.ContactList> database)
{
DataTable table = new DataTable();
table.Columns.Add("编号", typeof(long));
table.Columns.Add("姓名", typeof(string));
table.Columns.Add("电话", typeof(string));
table.Columns.Add("邮箱", typeof(string));
table.Columns.Add("公司", typeof(string));
foreach (EntMSM.Models.ContactList info in database)
{
DataRow row = table.NewRow();
row["编号"] = info.Id;
row["姓名"] = info.LinkName;
row["电话"] = info.LinkMobile;
row["邮箱"] = info.LinkEmails;
row["公司"] = info.LinkCompany;
table.Rows.Add(row);
}
return table;
}
/// <summary>
/// ASP.NET MVC导出CSV文件
/// </summary>
/// <returns></returns>
public ActionResult DataSetToCsv()
{ //定义模版(标题、内容字段、格式化参数)
string[] template = new string[] { "编号,", "姓名,", "电话,", "邮箱,", "公司,","分组名" };
string contactsfileName = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
System.IO.MemoryStream output = new System.IO.MemoryStream();
System.IO.StreamWriter writer = new System.IO.StreamWriter(output, System.Text.Encoding.Default);
//输出标题
int lenght = template.GetLength();
for (int i = ; i < lenght; i++)
writer.Write(template[i]);
writer.WriteLine();
//输出内容
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users; //通过lambda表达式实现多表连接查询 显示对应的 短信账户名称 和角色权限对应名称
var contactsList = esd.ContactLists.AsEnumerable().Join(esd.Groupss, a => a.Groups_Id, b => b.Id,
(a, b) => new { a.Id, a.LinkCompany, a.LinkEmails, a.LinkMobile, a.LinkName, a.Uses_Id, b.Name }).Where(a => a.Uses_Id == curr.Id).DefaultIfEmpty();
//var contactsList = esd.ContactLists.Where(u => u.Uses_Id == curr.Id);
//List<EntMSM.Models.ContactList> lstUser = contactsList.Where(a=>a.Uses_Id==curr.Id).ToList();
if (contactsList != null)
{
foreach (var user in contactsList)
{
writer.Write(user.Id + ",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkName) + "\",");
writer.Write(System.Web.HttpUtility.HtmlDecode(user.LinkMobile) + ",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkEmails) + "\",");
writer.Write("\"" + System.Web.HttpUtility.HtmlDecode(user.LinkCompany) + "\",");
writer.Write(user.Name);
writer.WriteLine();
}
}
writer.Flush();
output.Position = ;
return File(output, "text/comma-separated-values", contactsfileName + ".csv"); } #region Oledb方式读取EXCEL 导入通讯录
/// <summary>
/// Oledb方式读取EXCEL
/// </summary>
/// <param name="fileNamePath">文件路径</param>
/// <returns>DataTable</returns>
private DataTable ReadExcelByOledb(string fileNamePath, EntMSM.Models.Users currentUser)
{
string connStr = "Provider=Microsoft.Ace.OleDb.12.0;" + "data source=" + fileNamePath + ";Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
OleDbConnection oledbconn1 = new OleDbConnection(connStr);
oledbconn1.Open();
DataTable _table = oledbconn1.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" }); string strTableName = string.Empty;
if (_table.Rows.Count > )
{
strTableName = _table.Rows[]["TABLE_NAME"].ToString().Trim();
string sql = string.Format("SELECT * FROM [{0}]", strTableName);
_table = new DataTable();
OleDbDataAdapter da = new OleDbDataAdapter(sql, oledbconn1);
_table.Columns.Add(new DataColumn("Uses_Id", typeof(int)));
_table.Columns["Uses_Id"].DefaultValue = currentUser.Id;//设置该列默认值
da.Fill(_table);
}
oledbconn1.Close();
return _table;
}
/// <summary>
/// 利用NPOI读取Excel
/// </summary>
IWorkbook hssfworkbook;
public DataTable ImportExcelFile(string fileNamePath, string groupsId, EntMSM.Models.Users currentUser)
{
#region//初始化信息
string fileType = fileNamePath.Split('.')[].Trim();
try
{
using (FileStream file = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read))
{
if (fileType == "xlsx")
{
hssfworkbook = new XSSFWorkbook(file);
}
else
{
hssfworkbook = new HSSFWorkbook(file);
}
}
}
catch (Exception e)
{
throw e;
}
#endregion ISheet sheet = hssfworkbook.GetSheetAt();
System.Collections.IEnumerator rows = sheet.GetRowEnumerator(); DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(Int32));
dt.Columns.Add("Uses_Id", typeof(Int32));
dt.Columns.Add("LinkName", typeof(string));
dt.Columns.Add("LinkMobile", typeof(string));
dt.Columns.Add("LinkEmails", typeof(string));
dt.Columns.Add("LinkCompany", typeof(string));
dt.Columns.Add("Groups_Id", typeof(Int32));
rows.MoveNext();
while (rows.MoveNext())
{
IRow row = null;
if (fileType == "xlsx")
{
row = (XSSFRow)rows.Current;
}
else
{
row = (HSSFRow)rows.Current;
} DataRow dr = dt.NewRow();
for (int i = ; i < ; i++)
{
ICell cell = row.GetCell(i);
if (i == )
{
if (cell == null)
{
dr[i] = null;
}
else
{
dr[i] = cell.ToString();
}
}
else if (i == )
{
dr[i] = currentUser.Id;
dr[i + ] = cell.ToString();
}
else if (i == )
{
dr[i+] =int.Parse(groupsId);
}
else
{
if (cell == null)
{
dr[i + ] = null;
}
else
{
dr[i + ] = cell.ToString();
}
}
}
dt.Rows.Add(dr);
}
return dt;
} /// <summary>
/// 读取csv
/// </summary>
/// <param name="filepath"></param>
/// <returns></returns>
private DataTable ReadCsv(string filepath,string groupsId ,EntMSM.Models.Users currentUser)
{
base.IsLogin();
StreamReader sr;
string strTol = string.Empty;
string strTemp = string.Empty;
DataTable dt = new DataTable();
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users;
int count = ;//导入成功的计数
try
{
sr = new StreamReader(filepath, Encoding.Default);
dt.Columns.Add("Id", typeof(Int32));
dt.Columns.Add("Uses_Id", typeof(Int32));
dt.Columns.Add("LinkName", typeof(string));
dt.Columns.Add("LinkMobile", typeof(string));
dt.Columns.Add("LinkEmails", typeof(string));
dt.Columns.Add("LinkCompany", typeof(string));
dt.Columns.Add("Groups_Id",typeof(Int32));
strTemp = sr.ReadLine();//跳过头部
strTemp = sr.ReadLine();//跳过模板号码 if (strTemp.Split(',').Length > )
{
//针对360手机助手导出的通讯录导入
while (!string.IsNullOrEmpty(strTemp))//如果还有数据,继续读数据
{
count++;
DataRow row = dt.NewRow();
string tel = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Id"] = ;
row["Uses_Id"] = currentUser.Id;
row["LinkName"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkMobile"] = tel;
row["LinkEmails"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkCompany"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Groups_Id"] =int.Parse(groupsId);
dt.Rows.Add(row);
strTemp = sr.ReadLine();//读取下一行 }
}
else
{
//普通格式的文档导入
while (!string.IsNullOrEmpty(strTemp))//如果还有数据,继续读数据
{
count++;
DataRow row = dt.NewRow();
string tel = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Id"] = ;
row["Uses_Id"] = currentUser.Id;
row["LinkName"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkMobile"] = tel;
row["LinkEmails"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["LinkCompany"] = strTemp.Split(',')[].Trim('"').Trim(' ');
row["Groups_Id"] =int.Parse(groupsId);
dt.Rows.Add(row);
strTemp = sr.ReadLine();//读取下一行 }
}
}
catch (Exception)
{
dt = null;
throw;
}
sr.Close();//关闭流
return dt; }
/// <summary>
/// 判断两个DataTable中,第一个dataTable中在第二个dataTable中不存在的记录集
/// </summary>
/// <param name="returnTable">返回的不重复的结果集</param>
/// <param name="table1">即将导入的数据集</param>
/// <param name="table2">数据库中的数据集</param>
/// <param name="fieldsStr">字段名</param>
/// <returns></returns>
public static DataTable ComPare2DataTable(DataTable table1, DataTable table2, string fieldsStr)
{
try
{
DataTable returnTable = new DataTable();
returnTable = table1.Clone(); //for循环将数据库中的table2的每行数据转换为一个字符串,保存的HashTable中
Hashtable hashtable = new Hashtable();
DataRow[] dataRows = table2.Select(""); string[] fieldArr = fieldsStr.Split(','); foreach (DataRow row in dataRows)
{
string rowStr = "";
for (int i = ; i < fieldArr.Length; i++)
{
Object obj = row[fieldArr[i]];
if (!String.IsNullOrEmpty(obj.ToString()))
{
rowStr += obj.ToString();
}
}
hashtable.Add(rowStr, "");
} //将要导入的DataTable,将每一行数据转换为字符串之后,在hashTable中找是否存在这个key,存在的加入返回的DataTable中,反之不加入。
DataRow[] dataRows1 = table1.Select();
foreach (DataRow row in dataRows1)
{
string rowStr1 = "";
for (int i = ; i < fieldArr.Length; i++)
{
Object obj = row[fieldArr[i]];
if (!String.IsNullOrEmpty(obj.ToString()))
{
rowStr1 += obj.ToString();
}
}
if (!hashtable.ContainsKey(rowStr1))
{
returnTable.Rows.Add(row.ItemArray);
}
}
return returnTable;
}
catch (Exception ex)
{
throw ex;
}
} /// <summary>
/// 文档上传 读取文档内容并保存到 数据库
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public string UploadFile()
{
string result = "导入失败!";
try
{
base.IsLogin();
int sucCount = ;
int allCount = ;
string reqs = Request.Form["fileName"];
string groupsId=Request.Form["groupsId"];
string strPath = Server.MapPath("/UpLoadFile/" + reqs);
EntMSM.Models.Users curr = Session["LoginUser"] as EntMSM.Models.Users;
DataTable dt = null;
DataTable dt1 = ConvertToDataTable(esd.ContactLists.Where(a => a.Uses_Id == curr.Id));
dt1.Columns["电话"].ColumnName = "LinkMobile";
if (reqs.Split('.')[].ToUpper() == "CSV")
{
dt = ReadCsv(strPath, groupsId, curr);//csv
}
else
{
dt = ImportExcelFile(strPath, groupsId, curr);
//ReadExcelByOledb(strPath, curr);//xls
// dt.Columns["电话"].ColumnName = "LinkMobile";
}
allCount = dt.Rows.Count;
//去掉重复行 ,重复数据过滤
DataTable dd = DeleteSameRow(dt, "LinkMobile");//去除上传文件中重复的数据
DataTable ddt = ComPare2DataTable(dd, dt1, "LinkMobile");//出去已经存在数据库中的重复数据 int currCount = ddt.Rows.Count;
for (int i = ; i < ddt.Rows.Count; )
{
//ddt.Rows[i][2] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][2].ToString());
//ddt.Rows[i][3] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][3].ToString());
//ddt.Rows[i][4] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][4].ToString());
//ddt.Rows[i][5] = System.Web.HttpUtility.HtmlEncode(ddt.Rows[i][5].ToString());
if (ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null || ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null || ddt.Rows[i][].ToString().Trim() == "" || ddt.Rows[i][] == null)
{
ddt.Rows[i].Delete();
}
else
{
if (!IsChiOrEng(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (!IsPhone(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (!IsEmail(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else if (StrLenth(ddt.Rows[i][].ToString()))
{
ddt.Rows[i].Delete();
}
else
{
i++;
}
}
} int twoCount = ddt.Rows.Count;
if (currCount > )
{
sucCount = addTable(ddt);
if (sucCount > )
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
else
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
}
else
{
result = "导入通讯录共计:" + allCount + "条\n\t导入成功:" + sucCount + "条\n\t过滤重复联系人:" + (allCount - currCount) + "条\n\t过滤错误数据:" + (currCount - twoCount) + "条";
}
if (System.IO.File.Exists(strPath)) //存在文件
{
System.IO.File.Delete(strPath);//删除文件
}
}
catch
{
result = "文档内容格式有误,导入失败!";
}
return result;
}
/// <summary>
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</param>
/// <returns>替换完的文本。</returns>
public string HtmlEncode(string theString)
{
theString = theString.Replace(">", "&gt;");
theString = theString.Replace("<", "&lt;");
theString = theString.Replace("\"", "&quot;");
theString = theString.Replace("\'", "'");
theString = theString.Replace("\n", "<br/> ");
return theString;
}
#region 删除DataTable重复列,类似distinct
/// <summary>
/// 删除DataTable重复列,类似distinct
/// </summary>
/// <param name="dt">DataTable</param>
/// <param name="Field">字段名</param>
/// <returns></returns>
public static DataTable DeleteSameRow(DataTable dt, string Field)
{
ArrayList indexList = new ArrayList();
// 找出待删除的行索引
for (int i = ; i < dt.Rows.Count - ; i++)
{
if (!IsContain(indexList, i))
{
for (int j = i + ; j < dt.Rows.Count; j++)
{
if (dt.Rows[i][Field].ToString() == dt.Rows[j][Field].ToString())
{
indexList.Add(j);
}
}
}
}
indexList.Sort();
// 排序
for (int i = indexList.Count - ; i >= ; i--)// 根据待删除索引列表删除行
{
int index = Convert.ToInt32(indexList[i]);
dt.Rows.RemoveAt(index);
}
return dt;
} /// <summary>
/// 判断数组中是否存在
/// </summary>
/// <param name="indexList">数组</param>
/// <param name="index">索引</param>
/// <returns></returns>
public static bool IsContain(ArrayList indexList, int index)
{
for (int i = ; i < indexList.Count; i++)
{
int tempIndex = Convert.ToInt32(indexList[i]);
if (tempIndex == index)
{
return true;
}
}
return false;
}
#endregion
/// <summary>
/// 添加table
/// </summary>
/// <param name="dtt"></param>
/// <returns></returns>
public int addTable(DataTable dtt)
{
string a = ConfigurationManager.ConnectionStrings["EntSmsDbContext"].ToString();
SqlConnection con = new SqlConnection(a);
SqlCommand cmd = new SqlCommand("select * from ContactList", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
SqlCommandBuilder Builder = new SqlCommandBuilder(sda);
sda.Fill(dtt);
int states = sda.Update(dtt);
return states;
}
/// <summary>
/// 字符串长度
/// </summary>
/// <param name="len"></param>
/// <returns></returns>
public bool StrLenth(string len)
{ if (IsChinese(len))
{
if (len.ToString().Length > )
{
return true;
}
}
else
{
if (len.ToString().Length > )
{
return true;
}
}
return false;
}
/// <summary>
/// 判断是否为Email
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsEmail(string s)
{
return Regex.IsMatch(s, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}
/// <summary>
/// 判断是否为手机号码格式
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsPhone(string s)
{
return Regex.IsMatch(s, @"^(((13[0-9]{1})|14[0-9]{1}|15[0-9]{1}|18[0-9]{1})+\d{8})$");
}
/// <summary>
/// 判断是否为中文字符
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsChinese(string s)
{
return Regex.IsMatch(s, @"[\u4e00-\u9fa5]");
}
/// <summary>
/// 验证用户名为中、英文
/// </summary>
/// <param name="val"></param>
/// <returns></returns>
public static bool IsChiOrEng(string val)
{
string strRegex = @"[\u4e00-\u9fa5_a-zA-Z]";
return Regex.IsMatch(val, strRegex);
}
/// <summary>
/// 判断是否为正整数
/// </summary>
/// <param name="s">字符串</param>
/// <returns></returns>
public static bool IsInt(string s)
{
return Regex.IsMatch(s, @"^\d+$");
}
#endregion /// <summary>
/// 非法字符转换
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public string ReplaceStr(string str)
{
//str=str.Replace(",","");
str = str.Replace("'", "");
str = str.Replace(";", "");
str = str.Replace(":", "");
str = str.Replace("/", "");
str = str.Replace("?", "");
str = str.Replace("<", "");
str = str.Replace(">", "");
str = str.Replace(".", "");
str = str.Replace("#", "");
str = str.Replace("%", "");
str = str.Replace("%", "");
str = str.Replace("^", "");
str = str.Replace("//", "");
str = str.Replace("@", "");
str = str.Replace("(", "");
str = str.Replace(")", "");
str = str.Replace("*", "");
str = str.Replace("~", "");
str = str.Replace("`", "");
str = str.Replace("$", "");
str = str.Replace("&", "");
str = str.Replace("\n", "");
return str;
} }
}

NPOI文件导入操作的更多相关文章

  1. C# Excel文件导入操作

    Excel文件导出的操作我们经经常使用到,可是讲一个Excel文档导入并显示到界面还是第一次用到. 以下简介下在C#下怎样进行Excel文件的导入操作. 首先加入两个引用 using System.I ...

  2. ajax模拟表单提交,后台使用npoi实现导入操作 方式一

    页面代码: <form id="form1" enctype="multipart/form-data"> <div style=" ...

  3. ajax模拟表单提交,后台使用npoi实现导入操作 方式二

    页面代码: <form id="form1" enctype="multipart/form-data"> <div style=" ...

  4. 3.数据库操作相关术语,Oracle认证,insert into,批量插入,update tablename set,delete和truncate的差别,sql文件导入

     1相关术语 语句 含义 操作 DML语句 (Data Manipulation Language) 数据库操作语言 insert update delete select DDL语言 (Date ...

  5. asp.net mvc4 easyui datagrid 增删改查分页 导出 先上传后导入 NPOI批量导入 导出EXCEL

    效果图 数据库代码 create database CardManage use CardManage create table CardManage ( ID ,) primary key, use ...

  6. 用NPOI实现导入导出csv、xls、xlsx数据功能

    用NPOI实现导入导出csv.xls.xlsx数据功能   直接上代码 首先定义一个接口   如果需要直接操作文件的话,就自己在封装一次 然后定义csv类的具体实现 这个需要引入命名空间LumenWo ...

  7. 使用NPOI进行Excel操作

    一.NPOI组件导入 右键项目菜单,“管理NuGet程序包” 直接搜索“NPOI”即会出现列表,下载第一个进行安装即可 安装完成后项目引用会出现以下几项 二.基础使用 添加引用 using NPOI. ...

  8. unity3d教程游戏包含的一切文件导入资源

    http://www.58player.com/blog-2327-954.html 导入资源 将文件增加至工程文件夹的资源 (Assets) 文件夹后,Unity 将自动检测文件.将任何资源 (As ...

  9. 用SQLSERVER里的bcp命令或者bulkinsert命令也可以把dat文件导入数据表

    用SQLSERVER里的bcp命令或者bulkinsert命令也可以把dat文件导入数据表 下面的内容的实验环境我是在SQLSERVER2005上面做的 之前在园子里看到两篇文章<C# 读取纯真 ...

随机推荐

  1. HDU3533 Escape

    题目: The students of the HEU are maneuvering for their military training. The red army and the blue a ...

  2. python3+request接口自动化框架中自动发送邮件

    在上一篇中的自动化框架中没有放上自动发送测试结果到邮箱的功能,在这篇文章中在补一下,哈哈 1.上一篇的代码就不在一一介绍了,本篇只介绍发送邮件的功能代码 2.在public common 文件夹中创建 ...

  3. js实现“级联菜单”

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  4. python特性小记(一)

    一.关于构造函数和析构函数 1.python中有构造函数和析构函数,和其他语言是一样的.如果子类需要用到父类的构造函数,则需要在子类的构造函数中显式的调用,且如果子类有自己的构造函数,必然不会自动调用 ...

  5. dotnetnuke 中使用ado.net entityframework 如果在程序中动态调用系统的连接字符串信息

    1,打开如下图的Model1.Context.cs文件 2,找到 Base:(ConnString.conn)是我改的.默认生成的是"name=实体连接字符串" Connstrin ...

  6. dubbo之本地调用

    本地调用 本地调用使用了 injvm 协议,是一个伪协议,它不开启端口,不发起远程调用,只在 JVM 内直接关联,但执行 Dubbo 的 Filter 链. 配置 定义 injvm 协议 <du ...

  7. 在 ef 中执行 DbContext.Table.AddRange(Enitites).ToList() 会发生什么

    在 ef 中执行 DbContext.Table.AddRange(Enitites).ToList() 会发生什么 昨天和朋友摸鱼,无意之间聊到了执行 DbContext.Table.AddRang ...

  8. 【sqli-labs】 less13 POST - Double Injection - Single quotes- String -twist (POST型单引号变形双注入)

    报错 闭合掉括号 这关登录成功之后不显示登录的用户名密码了

  9. SQLite 的使用

    private void button1_Click(object sender, EventArgs e) { //查询数据库内容并绑定 string sql= "select* from ...

  10. XML的解析方式

    //解析和输出XML public void showXml() { string filepath = Application.dataPath + @"/my.xml"; if ...