当前位置:网站首页>C import Xls data method summary IV (upload file de duplication and database data De duplication)
C import Xls data method summary IV (upload file de duplication and database data De duplication)
2022-07-04 01:11:00 【Xiao Zhong wants to learn!!!】
C# Import .xls Data method summary IV ( Upload file and database data deduplication )
One 、 Imported data De duplication
1.1、 Redeclare a studentVo Object list records data
// Place data in myListStudentVo China and listStudentVo Compare the data in
List<studentVo> myListStudentVo = new List<studentVo>();
1.2、 Cycle the total number of uploaded data for de duplication
listStudentVo The data has been written in the previous article , Get the object of each piece of data circularly and connect it with the newly created myListStudentVo Object for a comparison , You can achieve a weight removal effect
// Judge whether there are duplicates in the information imported into students
for (int i = 0; i < listStudentVo.Count; i++)
{
if (i != 0)
{
for (int j = 0; j < myListStudentVo.Count; j++)
{
if (listStudentVo[i].StudentIDNum.Trim() == myListStudentVo[j].StudentIDNum.Trim() ||
listStudentVo[i].StudentNumber.Trim() == myListStudentVo[j].StudentNumber.Trim() ||
listStudentVo[i].UniformAuthenticationCode.Trim() == myListStudentVo[j].UniformAuthenticationCode.Trim())
{
returnJson.Text = string.Format("Excel Page in the table {0} Duplicate data with other data ,<br> Please check the ID number. 、 Student number and unified authentication code !", i + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
myListStudentVo.Add(listStudentVo[i]);
}
else
{
// The first data is directly put into myListStudentVo in
myListStudentVo.Add(listStudentVo[0]);
}
}
Two 、 De duplication with the data in the database
2.1、 First go back to the data list in the database
// Query student table & Data from user tables
List<PW_Student> dbListStudent = myModel.PW_Student.ToList();
List<PW_User> dbListUser = myModel.PW_User.ToList();
2.2、 Circularly processed listStudentVo Total times
The main i The idea is to make a list of the above query database, such as the list of files to be added 【 equal 】 operation , The same return true If it is repeated, it will prompt the uploader where the data is repeated
// Judge whether the imported data is duplicate with the data in the database
// Traverse imported data
for (int n = 0; n < listStudentVo.Count; n++)
{
// Traverse database student data
for (int m = 0; m < dbListStudent.Count; m++)
{
if (listStudentVo[n].StudentIDNum == dbListStudent[m].StudentIDNum ||
listStudentVo[n].StudentNumber == dbListStudent[m].StudentNumber)
{
returnJson.Text = string.Format("Excel Page in the table {0} Duplicate student data and database data ,<br> Please check the ID card number and student ID number. !", n + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
// Traverse database user data
for (int k = 0; k < dbListUser.Count; k++)
{
if (listStudentVo[n].UniformAuthenticationCode == dbListUser[k].UniformAuthenticationCode)
{
returnJson.Text = string.Format("Excel Page in the table {0} Student authentication codes already exist , Please check !", n + 1);
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
}
}
边栏推荐
- Thinkphp6 integrated JWT method and detailed explanation of generation, removal and destruction
- Force deduction solution summary 1189- maximum number of "balloons"
- mysql使用视图报错,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
- Sequence list and linked list
- Cloud dial test helps Weidong cloud education to comprehensively improve the global user experience
- How to use AHAS to ensure the stability of Web services?
- Function: find the approximate value of the limit of the ratio of the former term to the latter term of Fibonacci sequence. For example, when the error is 0.0001, the function value is 0.618056.
- Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
- Release and visualization of related data
- Windos10 reinstallation system tutorial
猜你喜欢
Technical practice online fault analysis and solutions (Part 1)
技术实践|线上故障分析及解决方法(上)
Unity Shader入门精要读书笔记 第三章 Unity Shader基础
In the process of seeking human intelligent AI, meta bet on self supervised learning
基于.NetCore开发博客项目 StarBlog - (14) 实现主题切换功能
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
Huawei BFD and NQA
“疫”起坚守 保障数据中台服务“不打烊”
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
Gee: create a new feature and set corresponding attributes
随机推荐
Leetcode 121 best time to buy and sell stock (simple)
Decompile and modify the non source exe or DLL with dnspy
使用dnSpy对无源码EXE或DLL进行反编译并且修改
Who moved my code!
[error record] configure NDK header file path in Visual Studio (three header file paths of NDK | ASM header file path selection related to CPU architecture)
数据库表外键的设计
Technical practice online fault analysis and solutions (Part 1)
Sorry, Tencent I also refused
功能:求出菲波那契数列的前一项与后一项之比的极限的 近似值。例如:当误差为0.0001时,函数值为0.618056。
Function: write function fun to find s=1^k+2^k +3^k ++ The value of n^k, (the cumulative sum of the K power of 1 to the K power of n).
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
Print diamond pattern
Software testers, how can you quickly improve your testing skills? Ten minutes to teach you
中电资讯-信贷业务数字化转型如何从星空到指尖?
Luogu p1309 Swiss wheel
关于 uintptr_t和intptr_t 类型
Mongodb learning notes: command line tools
Function: find the sum of the elements on the main and sub diagonal of the matrix with 5 rows and 5 columns. Note that the elements where the two diagonals intersect are added only once. For example,
[software testing] you haven't mastered these real interview questions of big companies?
Introduction to A-frame virtual reality development