Asp.net中把Excel数据存储至SQL Server中的具体实现方(3)

if (String.IsNullOrEmpty(birth))
                        {
                            error += "出生日期不能为空 ";
                        }
                        else if (!Utility.IsDateTime(birth))
                        {
                            error += "出生日期格式不正确 ";
                        }
                        if (String.IsNullOrEmpty(sex))
                        {
                            error += "性别不能为空 ";
                        }
                        if (String.IsNullOrEmpty(error))
                        {
                            M_Student stu = new M_Student();
                            stu.Num = num;
                            stu.Name = name;
                            stu.Pwd = pwd;
                            stu.CollegeNum = collegeNum;
                            stu.Birthday = Convert.ToDateTime(birth);

// 该学号不存在
                            if (!BLL.M_StudentBLL.GetAllStuNum().Contains(num))
                            {
                                BLL.M_StudentBLL.Add(stu);
                            }
                            else
                            {
                                BLL.M_StudentBLL.Modify(stu);
                            }
                        }
                        else
                        {
                            lstMsg.Add("学号为" + num + "未导入成功," + "原因:" + error + "。");
                        }
                    }
                }
                this.lblHint.Text = "导入完成。";
                if (null != lstMsg)
                {
                    this.lblHint.Text += "共有" + lstMsg.Count() + "条记录未成功。<br /><br />";
                    foreach (string s in lstMsg)
                    {
                        this.lblHint.Text += s;
                    }
                }
            }
            catch
            {
                this.lblHint.Text = "程序出错,请您检查需要导入的表!";
            }
        }


效果图

Asp.net中把Excel数据存储至SQL Server中的具体实现方

您可能感兴趣的文章:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjgjfw.html