Exemplo n.º 1
0
        protected void BtnUpload_Click(object sender, EventArgs e)
        {
            if (ImportFile.HasFile)
            {
                // Get the file extension
                string fileExtension = System.IO.Path.GetExtension(ImportFile.FileName);

                if (fileExtension.ToLower() != ".csv" && fileExtension.ToLower() != ".xlsx")
                {
                    lblMessage.ForeColor = System.Drawing.Color.Red;
                    lblMessage.Text      = "Only files with .csv and .xlsx extension are allowed";
                }
                else
                {
                    // Upload the file
                    //string Fname = System.DateTime.Now.ToString("ddMMyyhhmmss") + FileUpload1.FileName;
                    ImportFile.SaveAs(Server.MapPath("~/Upload/ClientsInvoices/" + ImportFile.FileName));
                    //FileUpload1.SaveAs(Server.MapPath("~/Archive/" + FileUpload1.FileName));
                    lblMessage.ForeColor = System.Drawing.Color.Green;
                    lblMessage.Text      = "File uploaded successfully";
                }
            }
            else
            {
                lblMessage.ForeColor = System.Drawing.Color.Red;
                lblMessage.Text      = "Please select a file";
            }
            ReadWriteCSVFile();
            GetClinetInvoice(null, null, 0, DateTime.MinValue, DateTime.MinValue);
        }
    protected void Upload_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(null, 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);

            ImportTimeCardRecordProcess timeCardRecordImport = new ImportTimeCardRecordProcess(dbConn, Session.SessionID);
            timeCardRecordImport.DateSequence  = this.Attendance_ImportFormatParameterControl1.DateSequence;
            timeCardRecordImport.DateSeparator = this.Attendance_ImportFormatParameterControl1.DateSeparator;
            timeCardRecordImport.YearFormat    = this.Attendance_ImportFormatParameterControl1.YearFormat;
            timeCardRecordImport.TimeSeparator = this.Attendance_ImportFormatParameterControl1.TimeSeparator;

            timeCardRecordImport.DateColumnIndex        = this.Attendance_ImportFormatParameterControl1.DateColumnIndex;
            timeCardRecordImport.TimeColumnIndex        = this.Attendance_ImportFormatParameterControl1.TimeColumnIndex;
            timeCardRecordImport.DateColumnIndex2       = this.Attendance_ImportFormatParameterControl1.DateColumnIndex2;
            timeCardRecordImport.TimeColumnIndex2       = this.Attendance_ImportFormatParameterControl1.TimeColumnIndex2;
            timeCardRecordImport.LocationColumnIndex    = this.Attendance_ImportFormatParameterControl1.LocationColumnIndex;
            timeCardRecordImport.TimeCardNumColumnIndex = this.Attendance_ImportFormatParameterControl1.TimeCardNumColumnIndex;

            timeCardRecordImport.ColumnDelimiter = this.Attendance_ImportFormatParameterControl1.ColumnDelimiter;

            timeCardRecordImport.UploadFileHasHeader = this.Attendance_ImportFormatParameterControl1.UploadFileHasHeader;
            //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
            {
                timeCardRecordImport.UploadToTempDatabase(strTmpFile, WebUtils.GetCurUser(Session).UserID, string.Empty);
                timeCardRecordImport.ImportToDatabase();
                errors.addError(HROne.Translation.PageMessage.IMPORT_SUCCESSFUL);
                Attendance_ImportFormatParameterControl1.SaveSettings();
            }
            catch (HRImportException ex)
            {
                if (timeCardRecordImport.errors.List.Count > 0)
                {
                    foreach (string errorString in timeCardRecordImport.errors.List)
                    {
                        errors.addError(errorString);
                    }
                }
                else
                {
                    errors.addError(ex.Message);
                }
            }
            System.IO.File.Delete(strTmpFile);
        }
        else
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE);
        }
    }
Exemplo n.º 3
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);
        }
    }
    protected void Upload_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        if (ImportFile.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_") + ImportFile.FileName);
            ImportFile.SaveAs(strTmpFile);

            ImportHitRateBasedPaymentProcess m_import = new ImportHitRateBasedPaymentProcess(dbConn, Session.SessionID, WebUtils.GetCurUser(Session).UserID);

            try
            {
                DataTable m_table = m_import.UploadToTempDatabase(strTmpFile, WebUtils.GetCurUser(Session).UserID, string.Empty);
                ImportSection.Visible = true;
                txtRemark.Text        = string.Empty;
            }
            catch (HRImportException ex)
            {
                if (m_import.errors.List.Count > 0)
                {
                    foreach (string errorString in m_import.errors.List)
                    {
                        errors.addError(errorString);
                    }
                }
                else
                {
                    errors.addError(ex.Message);
                }
                m_import.ClearTempTable();
            }
            System.IO.File.Delete(strTmpFile);
        }
        else
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_INVALID_FILE);
        }
    }