protected void Import_Click(object sender, EventArgs e) { ImportEmpWorkingSummaryProcess workingSummaryImport = new ImportEmpWorkingSummaryProcess(dbConn, Session.SessionID, WebUtils.GetCurUser(Session).UserID); WebUtils.StartFunction(Session, FUNCTION_CODE); workingSummaryImport.ImportToDatabase(); WebUtils.EndFunction(dbConn); //loadData(info, db, Repeater); PageErrors.getErrors(db, Page).addError(HROne.Translation.PageMessage.IMPORT_SUCCESSFUL); }
public DataView loadData(ListInfo info, DBManager db, DataList repeater) { //filter.add(new Match("EmpPayrollID",EmpPayrollID.Value)); ImportEmpWorkingSummaryProcess workingSummaryImport = new ImportEmpWorkingSummaryProcess(dbConn, Session.SessionID, WebUtils.GetCurUser(Session).UserID); DataTable table = workingSummaryImport.GetImportDataFromTempDatabase(info); if (info != null) { if (!string.IsNullOrEmpty(info.orderby)) { if (info.orderby.Equals("EmpEngFullName", StringComparison.CurrentCultureIgnoreCase)) { if (!table.Columns.Contains("EmpEngFullName")) { table.Columns.Add("EmpEngFullName", typeof(string)); foreach (System.Data.DataRow row in table.Rows) { EEmpPersonalInfo empInfo = new EEmpPersonalInfo(); empInfo.EmpID = (int)row["EmpID"]; if (EEmpPersonalInfo.db.select(dbConn, empInfo)) { row["EmpEngFullName"] = empInfo.EmpEngFullName; } } } } } } table = WebUtils.DataTableSortingAndPaging(table, info); view = new DataView(table); if (repeater != null) { repeater.DataSource = view; repeater.DataBind(); } if (table.Rows.Count > 0) { ImportSection.Visible = true; } else { ImportSection.Visible = false; } return(view); }
protected void Upload_Click(object sender, EventArgs e) { PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); if (CNDImportFile.HasFile) { string strTmpFolder = HROne.Common.Folder.GetOrCreateSessionTempFolder(Session.SessionID).FullName;; //Environment.GetFolderPath(Environment.SpecialFolder.InternetCache); string strTmpFile = System.IO.Path.Combine(strTmpFolder, AppUtils.ServerDateTime().ToString("~yyyyMMddHHmmss_") + CNDImportFile.FileName); CNDImportFile.SaveAs(strTmpFile); ImportEmpWorkingSummaryProcess workingSummaryImport = new ImportEmpWorkingSummaryProcess(dbConn, Session.SessionID, WebUtils.GetCurUser(Session).UserID); //DataTable dataTable = HROne.Import.ExcelImport.parse(strTmpFile); //using (OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\csv\;Extended Properties='Text;'")) try { DataTable table = workingSummaryImport.UploadToTempDatabase(strTmpFile, WebUtils.GetCurUser(Session).UserID, string.Empty); //table = WebUtils.DataTableSortingAndPaging(table, info); //Repeater.DataSource = table; //Repeater.DataBind(); ImportSection.Visible = true; } catch (HRImportException ex) { if (workingSummaryImport.errors.List.Count > 0) { foreach (string errorString in workingSummaryImport.errors.List) { errors.addError(errorString); } } else { errors.addError(ex.Message); } workingSummaryImport.ClearTempTable(); } System.IO.File.Delete(strTmpFile); } else { errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE); } }