当前位置:网站首页>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);
}
}
}
边栏推荐
- Introduction to A-frame virtual reality development
- From functional testing to automated testing, how did I successfully transform my salary to 15K +?
- Sequence list and linked list
- Pratique technique | analyse et solution des défaillances en ligne (Partie 1)
- 数据库表外键的设计
- Wechat official account and synchronization assistant
- 不得不会的Oracle数据库知识点(一)
- The culprit of unrestrained consumption -- Summary
- Functions and arrays of shell scripts
- 使用dnSpy对无源码EXE或DLL进行反编译并且修改
猜你喜欢

String hash, find the string hash value after deleting any character, double hash

Hash table, string hash (special KMP)

Huawei rip and BFD linkage

机器学习基础:用 Lasso 做特征选择

What is the future of software testing industry? Listen to the test veterans' answers

Audio resource settings for U3D resource management

Is it really possible that the monthly salary is 3K and the monthly salary is 15K?

Employees' turnover intention is under the control of the company. After the dispute, the monitoring system developer quietly removed the relevant services

What is the GPM scheduler for go?

【.NET+MQTT】.NET6 环境下实现MQTT通信,以及服务端、客户端的双边消息订阅与发布的代码演示
随机推荐
Swagger2 quick start and use
AI 助力艺术设计抄袭检索新突破!刘芳教授团队论文被多媒体顶级会议ACM MM录用
Introduction to unity shader essentials reading notes Chapter III unity shader Foundation
2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)
Typescript basic knowledge sorting
On covariance of array and wildcard of generic type
Oracle database knowledge points that cannot be learned (II)
Sorry, Tencent I also refused
Sequence list and linked list
Analysis and solution of lazyinitializationexception
The difference between fetchtype lazy and eagle in JPA
A dichotomy of Valentine's Day
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.
Gee: create a new feature and set corresponding attributes
From functools import reduce -- see the use of reduce function from typical examples
Related configuration commands of Huawei rip
长文综述:大脑中的熵、自由能、对称性和动力学
From functional testing to automated testing, how did I successfully transform my salary to 15K +?
1-redis architecture design to use scenarios - four deployment and operation modes (Part 1)