protected void btnProjectImport_Click(object sender, EventArgs e) { var projectnamelist = new List <ProjectNamesEntity>(); // NEED 1 (first) if (txtImportDate.Text != "" && txtImportDate.Text != null) { var projectDeno = new ProjectNames().FindByImportedDateWithSheet(GeneralUtility.ConvertMonthYearStringFormat(txtImportDate.Text.Trim()), ddlJobName.SelectedValue, ddlStatus.SelectedValue); if (projectDeno.Count() == 0) { if (FileUpload1.HasFile) { if (Path.GetExtension(FileUpload1.FileName) == ".xlsx") { ExcelPackage package = new ExcelPackage(FileUpload1.FileContent); // NEED 2 (first) ExcelWorksheet workSheet = package.Workbook.Worksheets.First(); // NEED 2 (first) // workSheet.DeleteRow(1); // NEED 3 (first) ProjectName_BindBusiness(projectnamelist, workSheet); // NEED 4 (first) } } #region Save Project Names (first) ProjectNames itemBusiness = new ProjectNames(); using (TransactionScope Scope = new TransactionScope()) { try { foreach (var v in projectnamelist) { itemBusiness.Entity = v; itemBusiness.Save(); } Scope.Complete(); MessageBox.MessageShow(this.GetType(), "Project Names Import Successfully!.", ClientScript); } catch (Exception ex) { Response.Redirect("error.aspx"); throw ex; } } #endregion } else { MessageBox.MessageShow(this.GetType(), "This Excel File has already been Imported!", ClientScript); } } else { MessageBox.MessageShow(this.GetType(), "Please Choose Import Date!.", ClientScript); } }