当前位置:网站首页>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);
}
}
}
边栏推荐
- 功能:将主函数中输入的字符串反序存放。例如:输入字符串“abcdefg”,则应输出“gfedcba”。
- Introduction to A-frame virtual reality development
- A-Frame虚拟现实开发入门
- [software testing] you haven't mastered these real interview questions of big companies?
- 12. Go implementation of integer to Roman numeral and leetcode
- 2022 Software Test Engineer skill list, please check
- Severity code description the project file line prohibits the display of status error c4996 fopen ('fscanf ', StrCmp): this function or variable may be unsafe The most comprehensive solution
- Release and visualization of related data
- AI 助力艺术设计抄袭检索新突破!刘芳教授团队论文被多媒体顶级会议ACM MM录用
- From functools import reduce -- see the use of reduce function from typical examples
猜你喜欢

Self study software testing. To what extent can you go out and find a job?

打印菱形图案

HackTheBox-baby breaking grad

How to set the response description information when the response parameter in swagger is Boolean or integer

老姜的特点

Huawei rip and BFD linkage

How to be a professional software testing engineer? Listen to the byte five year old test
![[dynamic programming] leetcode 53: maximum subarray sum](/img/f0/80357f9ffc556f3ed4d3aa0901bb1d.jpg)
[dynamic programming] leetcode 53: maximum subarray sum

1-Redis架构设计到使用场景-四种部署运行模式(上)

String hash, find the string hash value after deleting any character, double hash
随机推荐
Sequence list and linked list
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,
[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)
CLP information - how does the digital transformation of credit business change from star to finger?
1-redis architecture design to use scenarios - four deployment and operation modes (Part 1)
On the day when 28K joined Huawei testing post, I cried: everything I have done in these five months is worth it
机器学习基础:用 Lasso 做特征选择
【.NET+MQTT】. Net6 environment to achieve mqtt communication, as well as bilateral message subscription and publishing code demonstration of server and client
HR disgusted interview behavior
Gee: create a new feature and set corresponding attributes
Swagger2 quick start and use
In the process of seeking human intelligent AI, meta bet on self supervised learning
Design of database table foreign key
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
Oracle database knowledge points that cannot be learned (II)
From functools import reduce -- see the use of reduce function from typical examples
Five high-frequency questions were selected from the 200 questions raised by 3000 test engineers
2-Redis架构设计到使用场景-四种部署运行模式(下)
手机异步发送短信验证码解决方案-Celery+redis
求esp32C3板子连接mssql方法