当前位置:网站首页>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);
}
}
}
边栏推荐
- [common error] custom IP instantiation error
- Luogu p1309 Swiss wheel
- Functions and arrays of shell scripts
- 0 basic learning C language - nixie tube dynamic scanning display
- Since the "epidemic", we have adhered to the "no closing" of data middle office services
- be based on. NETCORE development blog project starblog - (14) realize theme switching function
- Cesiumjs 2022^ source code interpretation [8] - resource encapsulation and multithreading
- @EnableAsync @Async
- 老姜的特点
- About uintptr_ T and IntPtr_ T type
猜你喜欢

OS interrupt mechanism and interrupt handler

A-Frame虚拟现实开发入门

AI 助力艺术设计抄袭检索新突破!刘芳教授团队论文被多媒体顶级会议ACM MM录用

在寻求人类智能AI的过程中,Meta将赌注押向了自监督学习

0 basic learning C language - nixie tube dynamic scanning display

Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".

Beijing invites reporters and media

Conditional test, if, case conditional test statements of shell script

Mobile asynchronous sending SMS verification code solution -efficiency+redis

What is the GPM scheduler for go?
随机推荐
Weekly open source project recommendation plan
How to be a professional software testing engineer? Listen to the byte five year old test
删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
不得不会的Oracle数据库知识点(二)
Sorry, Tencent I also refused
Day05 表格
be based on. NETCORE development blog project starblog - (14) realize theme switching function
A dichotomy of Valentine's Day
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
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
Gee: create a new feature and set corresponding attributes
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
CLP information - how does the digital transformation of credit business change from star to finger?
HR disgusted interview behavior
What is the future of software testing industry? Listen to the test veterans' answers
机器学习基础:用 Lasso 做特征选择
Function: store the strings entered in the main function in reverse order. For example, if you input the string "ABCDEFG", you should output "gfedcba".
Mobile asynchronous sending SMS verification code solution -efficiency+redis
2-redis architecture design to use scenarios - four deployment and operation modes (Part 2)
不得不会的Oracle数据库知识点(一)