コード例 #1
0
ファイル: ImportCND.cs プロジェクト: dhamotharang/H-R-One
        public static void ClearTempTable(DatabaseConnection dbConn, string sessionID)
        {
            ImportClaimsAndDeductionsProcess import = new ImportClaimsAndDeductionsProcess(dbConn, sessionID, 0);

            import.ClearTempTable();
        }
コード例 #2
0
    protected void btnGenerate_Command(object sender, CommandEventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        ArrayList empList = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpPersonalInfo o = (EEmpPersonalInfo)EEmpPersonalInfo.db.createObject();
                WebFormUtils.GetKeys(EEmpPersonalInfo.db, o, cb);
                empList.Add(o);
            }
        }



        if (empList.Count > 0)
        {
            DataSet dataSet = GenerateAttendanceRecordDataSet(empList, CurPayPeriodID);

            if (e.CommandName.Equals("Export", StringComparison.CurrentCultureIgnoreCase))
            {
                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(dataSet);
                //WebUtils.RegisterDownloadFileJavaScript(this, exportFileName, "AttendancePaymentCND_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true, 0);
                WebUtils.TransmitFile(Response, exportFileName, "AttendancePaymentCND_" + AppUtils.ServerDateTime().ToString("yyyyMMddHHmmss") + ".xls", true);
            }
            else if (e.CommandName.Equals("ImportCND", StringComparison.CurrentCultureIgnoreCase))
            {
                HROne.Import.ImportClaimsAndDeductionsProcess CNDImport = new HROne.Import.ImportClaimsAndDeductionsProcess(dbConn, Session.SessionID, WebUtils.GetCurUser(Session).UserID);
                CNDImport.ClearTempTable();

                EPayrollPeriod payPeriod = new EPayrollPeriod();
                payPeriod.PayPeriodID = CurPayPeriodID;
                if (EPayrollPeriod.db.select(dbConn, payPeriod))
                {
                    CNDImport.Remark = "Attendance Payment from " + payPeriod.PayPeriodAttnFr.ToString("yyyy-MM-dd") + " to " + payPeriod.PayPeriodAttnTo.ToString("yyyy-MM-dd");
                    EPayrollGroup payGroup = new EPayrollGroup();
                    payGroup.PayGroupID = payPeriod.PayGroupID;
                    if (EPayrollGroup.db.select(dbConn, payGroup))
                    {
                        CNDImport.Remark += " (" + payGroup.PayGroupCode + ")";
                    }
                }
                try
                {
                    CNDImport.UploadToTempDatabase(dataSet.Tables[0], WebUtils.GetCurUser(Session).UserID);
                    CNDImport.ImportToDatabase();
                    errors.addError(HROne.Translation.PageMessage.IMPORT_SUCCESSFUL);
                }
                catch (HROne.Import.HRImportException ex)
                {
                    if (CNDImport.errors.List.Count > 0)
                    {
                        foreach (string errorString in CNDImport.errors.List)
                        {
                            errors.addError(errorString);
                        }
                    }
                    else
                    {
                        errors.addError(ex.Message);
                    }
                }
            }
        }
        else
        {
            errors.addError("Employee not selected");
        }
    }