当前位置:网站首页>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);
}
}
}
边栏推荐
- All in one 1407: stupid monkey
- 中电资讯-信贷业务数字化转型如何从星空到指尖?
- Mobile asynchronous sending SMS verification code solution -efficiency+redis
- Thinkphp6 integrated JWT method and detailed explanation of generation, removal and destruction
- Future source code view -juc series
- Functions and arrays of shell scripts
- 功能:求5行5列矩阵的主、副对角线上元素之和。注意, 两条对角线相交的元素只加一次。例如:主函数中给出的矩阵的两条对角线的和为45。
- QML add gradient animation during state transition
- Fundamentals of machine learning: feature selection with lasso
- Gee: create a new feature and set corresponding attributes
猜你喜欢

Introduction to unity shader essentials reading notes Chapter III unity shader Foundation

What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers

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).

On covariance of array and wildcard of generic type

Luogu p1309 Swiss wheel

中电资讯-信贷业务数字化转型如何从星空到指尖?

功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。

Since the "epidemic", we have adhered to the "no closing" of data middle office services

Huawei rip and BFD linkage
![[common error] custom IP instantiation error](/img/de/d3f90cd224274d87fcf153bb9244d7.jpg)
[common error] custom IP instantiation error
随机推荐
mysql使用视图报错,EXPLAIN/SHOW can not be issued; lacking privileges for underlying table
【.NET+MQTT】. Net6 environment to achieve mqtt communication, as well as bilateral message subscription and publishing code demonstration of server and client
MySQL -- Introduction and use of single line functions
It's OK to have hands-on 8 - project construction details 3-jenkins' parametric construction
Gee: create a new feature and set corresponding attributes
Avoid playing with super high conversion rate in material minefields
Employees' turnover intention is under the control of the company. After the dispute, the monitoring system developer quietly removed the relevant services
MPLS experiment
“疫”起坚守 保障数据中台服务“不打烊”
功能:编写函数fun求s=1^k+2^k +3^k + ......+N^k的值, (1的K次方到N的K次方的累加和)。
删除所有值为y的元素。数组元素中的值和y的值由主函数通过键盘输入。
be based on. NETCORE development blog project starblog - (14) realize theme switching function
What is regression testing? Talk about regression testing in the eyes of Ali Test Engineers
MySQL uses the view to report an error, explain/show can not be issued; lacking privileges for underlying table
[common error] custom IP instantiation error
机器学习基础:用 Lasso 做特征选择
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.
[error record] configure NDK header file path in Visual Studio
What is the GPM scheduler for go?
不得不会的Oracle数据库知识点(一)