コード例 #1
0
    protected void Import_Click(object sender, EventArgs e)
    {
        ImportLeaveBalanceAdjustmentProcess leaveBalanceAdjustImport = new ImportLeaveBalanceAdjustmentProcess(dbConn, Session.SessionID);

        leaveBalanceAdjustImport.ImportToDatabase();
        loadData(info, db, Repeater);
        PageErrors.getErrors(db, Page).addError(HROne.Translation.PageMessage.IMPORT_SUCCESSFUL);
    }
コード例 #2
0
    protected void btnExportTemplate_Click(object sender, EventArgs e)
    {
        string exportFileName = System.IO.Path.GetTempFileName();

        System.IO.File.Delete(exportFileName);
        exportFileName += ".xls";
        //System.IO.File.Copy(Server.MapPath("~/template/HistoryList_Template.xls"), exportFileName, true);
        HROne.Export.ExcelExport export = new HROne.Export.ExcelExport(exportFileName);

        export.Update(ImportLeaveBalanceAdjustmentProcess.Export(dbConn, new ArrayList(), false, false, false, new DateTime()));
        WebUtils.TransmitFile(Response, exportFileName, "LeaveBalanceAdjustmentTemplate_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
        return;
    }
コード例 #3
0
    public DataView loadData(ListInfo info, DBManager db, Repeater repeater)
    {
        //filter.add(new Match("EmpPayrollID",EmpPayrollID.Value));

        ImportLeaveBalanceAdjustmentProcess leaveBalanceAdjustImport = new ImportLeaveBalanceAdjustmentProcess(dbConn, Session.SessionID);
        DataTable table = leaveBalanceAdjustImport.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);
    }
コード例 #4
0
    protected void Upload_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        if (ImportFile.HasFile)
        {
            //DataTable dataTable = HROne.CSVProcess.CSVReader.parse(CNDImportFile.PostedFile.InputStream);
            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_") + ImportFile.FileName);
            ImportFile.SaveAs(strTmpFile);

            ImportLeaveBalanceAdjustmentProcess leaveBalanceAdjustImport = new ImportLeaveBalanceAdjustmentProcess(dbConn, Session.SessionID);
            //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
            {
                Repeater.DataSource = leaveBalanceAdjustImport.UploadToTempDatabase(strTmpFile, WebUtils.GetCurUser(Session).UserID, string.Empty);
                Repeater.DataBind();
                ImportSection.Visible = true;
            }
            catch (HRImportException ex)
            {
                if (leaveBalanceAdjustImport.errors.List.Count > 0)
                {
                    foreach (string errorString in leaveBalanceAdjustImport.errors.List)
                    {
                        errors.addError(errorString);
                    }
                }
                else
                {
                    errors.addError(ex.Message);
                }
            }
            //System.IO.File.Delete(strTmpFile);
        }
        else
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE);
        }
    }