示例#1
0
    protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);

        e.Item.FindControl("DeleteItem").Visible = false;//IsAllowEdit;
        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            ebinding = new Binding(masterDBConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("HSBCExchangeProfileID"));
            ebinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("HSBCExchangeProfileIsLocked")));
            ebinding.init(Request, Session);


            EHSBCExchangeProfile obj = new EHSBCExchangeProfile();
            db.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            db.populate(obj, values);
            ebinding.toControl(values);
        }
        else
        {
            //e.Item.FindControl("Edit").Visible = IsAllowEdit;
            HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("HSBCExchangeProfileID");
            h.Value = ((DataRowView)e.Item.DataItem)["HSBCExchangeProfileID"].ToString();
        }
    }
示例#2
0
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;



        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("HSBCExchangeProfileID"));
            ebinding.add(new CheckBoxBinder(db, (CheckBox)e.Item.FindControl("HSBCExchangeProfileIsLocked")));
            ebinding.init(Request, Session);


            EHSBCExchangeProfile obj    = new EHSBCExchangeProfile();
            Hashtable            values = new Hashtable();

            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.clear();


            ebinding.toValues(values);
            db.validate(errors, values);

            if (!errors.isEmpty())
            {
                return;
            }

            db.parse(values, obj);
            //if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "PublicHolidayDate"))
            //    return;

            //WebUtils.StartFunction(Session, FUNCTION_CODE);
            db.update(dbConn, obj);
            //WebUtils.EndFunction(dbConn);

            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
    }
示例#3
0
    protected void Add_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        Repeater.EditItemIndex = -1;
        EHSBCExchangeProfile c = new EHSBCExchangeProfile();

        c.HSBCExchangeProfileBankCode = HSBCExchangeProfileBankCode.SelectedValue;
        AND checkConstraintTerm = new AND();

        checkConstraintTerm.add(new Match("CompanyDBID", CompanyDBID));

        if (!AppUtils.checkDuplicate(dbConn, EHSBCExchangeProfile.db, c, errors, "HSBCExchangeProfileBankCode", checkConstraintTerm))
        {
            return;
        }
        c.CompanyDBID = CompanyDBID;
        c.HSBCExchangeProfileRemoteProfileID = "DUMMY";

        EHSBCExchangeProfile.db.insert(dbConn, c);
        int tempID = c.HSBCExchangeProfileID;

        while (c.HSBCExchangeProfileRemoteProfileID == "DUMMY")
        {
            string prefix = string.Empty;
            if (c.HSBCExchangeProfileBankCode.Equals("HSBC", StringComparison.CurrentCultureIgnoreCase))
            {
                prefix = "H";
            }
            else if (c.HSBCExchangeProfileBankCode.Equals("HangSeng", StringComparison.CurrentCultureIgnoreCase))
            {
                prefix = "X";
            }
            string tmpRemoteProfileID = CreateRemoteProfileID(prefix, tempID);

            DBFilter exchangeProfileFilter = new DBFilter();
            exchangeProfileFilter.add(new Match("HSBCExchangeProfileRemoteProfileID", " LIKE ", "%" + tmpRemoteProfileID.Substring(prefix.Length) + "%"));
            if (EHSBCExchangeProfile.db.count(dbConn, exchangeProfileFilter) <= 0)
            {
                //if (AppUtils.checkDuplicate(dbConn, EHSBCExchangeProfile.db, c, errors, "HSBCExchangeProfileRemoteProfileID"))
                c.HSBCExchangeProfileRemoteProfileID = tmpRemoteProfileID;
            }
            else
            {
                tempID++;
            }
        }
        EHSBCExchangeProfile.db.update(dbConn, c);

        view = loadData(info, db, Repeater);
    }
示例#4
0
        public string[] CreateOutput()
        {
            string outputPathAMPFF_HSBC = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".M50");
            string outputPathAMPFF_HASE = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".E50");

            string outputPathAMCND_HSBC = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".M23");
            string outputPathAMCND_HASE = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".E23");


            HSBCFileExchangeProcess HSBCAMPFFFileExchange = new HSBCFileExchangeProcess();

            HSBCAMPFFFileExchange.FileID      = HSBCFileIDEnum.AMPFF;
            HSBCAMPFFFileExchange.Environment = Environment;
            HSBCAMPFFFileExchange.CreateWriter(outputPathAMPFF_HSBC);

            HSBCFileExchangeProcess HangSengAMPFFFileExchange = new HSBCFileExchangeProcess();

            HangSengAMPFFFileExchange.FileID      = HSBCFileIDEnum.AMPFF;
            HangSengAMPFFFileExchange.Environment = Environment;
            HangSengAMPFFFileExchange.CreateWriter(outputPathAMPFF_HASE);

            HSBCFileExchangeProcess HSBCAMCNDFileExchange = new HSBCFileExchangeProcess();

            HSBCAMCNDFileExchange.FileID      = HSBCFileIDEnum.AMCND;
            HSBCAMCNDFileExchange.Environment = Environment;
            HSBCAMCNDFileExchange.CreateWriter(outputPathAMCND_HSBC);

            HSBCFileExchangeProcess HangSengAMCNDFileExchange = new HSBCFileExchangeProcess();

            HangSengAMCNDFileExchange.FileID      = HSBCFileIDEnum.AMCND;
            HangSengAMCNDFileExchange.Environment = Environment;
            HangSengAMCNDFileExchange.CreateWriter(outputPathAMCND_HASE);

            DBFilter filter = new DBFilter();

            filter.add(new NullTerm("CompanyMPFFileConsolidateDateTime"));
            filter.add(new Match("CompanyMPFFileConfirmDateTime", "<=", m_SubmissionCutOffDateTime));

            ArrayList list = ECompanyMPFFile.db.select(m_dbConn, filter);

            foreach (ECompanyMPFFile mpfFile in list)
            {
                string transactionRefreence = "HREXM" + mpfFile.CompanyMPFFileID.ToString("0000000000");
                transactionRefreence += CheckDigit(transactionRefreence);

                HSBCFileExchangeProcess currentFileProcess = null;

                if (mpfFile.CompanyMPFFileFileType.Equals("AMPFF"))
                {
                    if (mpfFile.CompanyMPFFileTrusteeCode.Equals("HSBC"))
                    {
                        currentFileProcess = HSBCAMPFFFileExchange;
                    }
                    else if (mpfFile.CompanyMPFFileTrusteeCode.Equals("HangSeng"))
                    {
                        currentFileProcess = HangSengAMPFFFileExchange;
                    }

                    EHSBCExchangeProfile exchangeProfile = new EHSBCExchangeProfile();
                    exchangeProfile.HSBCExchangeProfileID = mpfFile.HSBCExchangeProfileID;
                    EHSBCExchangeProfile.db.select(m_dbConn, exchangeProfile);
                    string[] submissionHeader = new string[6];
                    submissionHeader[0] = "S";
                    submissionHeader[1] = exchangeProfile.HSBCExchangeProfileRemoteProfileID.PadRight(18).Substring(0, 18);
                    submissionHeader[2] = string.Empty.PadRight(28);
                    submissionHeader[3] = transactionRefreence.PadRight(16).Substring(0, 16);
                    submissionHeader[4] = "   ";
                    submissionHeader[5] = mpfFile.CompanyMPFFileConfirmDateTime.ToString("yyyyMMddHHmmss");

                    string strSubmissionHeader = string.Join(string.Empty, submissionHeader);
                    if (strSubmissionHeader.Length != currentFileProcess.RecordLength)
                    {
                        throw new Exception("Invalid submission header length");
                    }

                    currentFileProcess.AddLine(strSubmissionHeader);


                    string   currentBankFilePath = System.IO.Path.Combine(m_DefaultBankFilePath, mpfFile.CompanyMPFFileDataFileRelativePath);
                    FileInfo fileInfo            = new System.IO.FileInfo(currentBankFilePath);

                    StreamReader bankFileStream = fileInfo.OpenText();
                    char[]       charRead       = new char[80];

                    try
                    {
                        while (bankFileStream.Read(charRead, 0, 80) > 0)
                        {
                            string line = new string(charRead);
                            currentFileProcess.AddLine(line);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        bankFileStream.Close();
                    }
                }
                else if (mpfFile.CompanyMPFFileFileType.Equals("AMCND"))
                {
                    if (mpfFile.CompanyMPFFileTrusteeCode.Equals("HSBC"))
                    {
                        currentFileProcess = HSBCAMCNDFileExchange;
                    }
                    else if (mpfFile.CompanyMPFFileTrusteeCode.Equals("HangSeng"))
                    {
                        currentFileProcess = HangSengAMCNDFileExchange;
                    }

                    ECompanyDatabase companyDB = new ECompanyDatabase();
                    companyDB.CompanyDBID = mpfFile.CompanyDBID;
                    ECompanyDatabase.db.select(m_dbConn, companyDB);
                    //string[] submissionHeader = new string[7];
                    //submissionHeader[0] = "S";
                    //submissionHeader[1] = companyDB.CompanyDBClientCode.PadRight(18).Substring(0, 18);
                    //submissionHeader[2] = string.Empty.PadRight(28);
                    //submissionHeader[3] = transactionRefreence.PadRight(16).Substring(0, 16);
                    //submissionHeader[4] = "   ";
                    //submissionHeader[5] = mpfFile.CompanyMPFFileConfirmDateTime.ToString("yyyyMMddHHmmss");
                    //submissionHeader[6] = string.Empty.PadRight(1420);

                    //string strSubmissionHeader = string.Join(string.Empty, submissionHeader);
                    //if (strSubmissionHeader.Length != currentFileProcess.RecordLength)
                    //    throw new Exception("Invalid submission header length");

                    //currentFileProcess.AddLine(strSubmissionHeader);


                    string   currentBankFilePath = System.IO.Path.Combine(m_DefaultBankFilePath, mpfFile.CompanyMPFFileDataFileRelativePath);
                    FileInfo fileInfo            = new System.IO.FileInfo(currentBankFilePath);

                    StreamReader bankFileStream = fileInfo.OpenText();

                    try
                    {
                        while (!bankFileStream.EndOfStream)
                        {
                            string line = bankFileStream.ReadLine();
                            if (!line.StartsWith("HEADER "))
                            {
                                currentFileProcess.AddLine(line.PadRight(currentFileProcess.RecordLength));
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        bankFileStream.Close();
                    }
                }
                if (Environment == HSBCEnvironmentIndicatorEnum.Production)
                {
                    mpfFile.CompanyMPFFileConsolidateDateTime  = AppUtils.ServerDateTime();
                    mpfFile.CompanyMPFFileTransactionReference = transactionRefreence;
                    ECompanyMPFFile.db.update(m_dbConn, mpfFile);
                }
            }
            HSBCAMPFFFileExchange.Close();
            HangSengAMPFFFileExchange.Close();
            HSBCAMCNDFileExchange.Close();
            HangSengAMCNDFileExchange.Close();


            return(new string[] { outputPathAMPFF_HSBC, outputPathAMPFF_HASE, outputPathAMCND_HSBC, outputPathAMCND_HASE });
        }
示例#5
0
        public string[] CreateOutput()
        {
            string outputPathHSBC = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".M60");
            string outputPathHASE = System.IO.Path.Combine(m_FileOutputFolder, "APSMPFI." + m_VendorCode + "." + m_SubmissionCutOffDateTime.ToString("yyyyMMdd") + ".E60");

            HSBCFileExchangeProcess HSBCAutoPayFileExchange = new HSBCFileExchangeProcess();

            HSBCAutoPayFileExchange.FileID      = HSBCFileIDEnum.AISTN;
            HSBCAutoPayFileExchange.Environment = Environment;
            HSBCAutoPayFileExchange.CreateWriter(outputPathHSBC);

            HSBCFileExchangeProcess HangSengAutoPayFileExchange = new HSBCFileExchangeProcess();

            HangSengAutoPayFileExchange.FileID      = HSBCFileIDEnum.AISTN;
            HangSengAutoPayFileExchange.Environment = Environment;
            HangSengAutoPayFileExchange.CreateWriter(outputPathHASE);

            DBFilter filter = new DBFilter();

            filter.add(new NullTerm("CompanyAutopayFileConsolidateDateTime"));
            filter.add(new Match("CompanyAutopayFileConfirmDateTime", "<=", m_SubmissionCutOffDateTime));

            ArrayList list = ECompanyAutopayFile.db.select(m_dbConn, filter);

            foreach (ECompanyAutopayFile autoPayFile in list)
            {
                string transactionRefreence = "HREXA" + autoPayFile.CompanyAutopayFileID.ToString("0000000000");
                transactionRefreence += CheckDigit(transactionRefreence);

                HSBCFileExchangeProcess currentFileProcess = null;
                if (autoPayFile.CompanyAutopayFileBankCode.Equals("004"))
                {
                    currentFileProcess = HSBCAutoPayFileExchange;
                }
                else if (autoPayFile.CompanyAutopayFileBankCode.Equals("024"))
                {
                    currentFileProcess = HangSengAutoPayFileExchange;
                }

                EHSBCExchangeProfile exchangeProfile = new EHSBCExchangeProfile();
                exchangeProfile.HSBCExchangeProfileID = autoPayFile.HSBCExchangeProfileID;
                EHSBCExchangeProfile.db.select(m_dbConn, exchangeProfile);
                string[] submissionHeader = new string[6];
                submissionHeader[0] = "S";
                submissionHeader[1] = exchangeProfile.HSBCExchangeProfileRemoteProfileID.PadRight(18).Substring(0, 18);
                submissionHeader[2] = string.Empty.PadRight(28);
                submissionHeader[3] = transactionRefreence.PadRight(16).Substring(0, 16);
                submissionHeader[4] = "   ";
                submissionHeader[5] = autoPayFile.CompanyAutopayFileConfirmDateTime.ToString("yyyyMMddHHmmss");

                string strSubmissionHeader = string.Join(string.Empty, submissionHeader);
                if (strSubmissionHeader.Length != currentFileProcess.RecordLength)
                {
                    throw new Exception("Invalid submission header length");
                }

                currentFileProcess.AddLine(strSubmissionHeader);

                string   currentBankFilePath = System.IO.Path.Combine(m_DefaultBankFilePath, autoPayFile.CompanyAutopayFileDataFileRelativePath);
                FileInfo fileInfo            = new System.IO.FileInfo(currentBankFilePath);

                StreamReader bankFileStream = fileInfo.OpenText();
                char[]       charRead       = new char[80];

                try
                {
                    while (bankFileStream.Read(charRead, 0, 80) > 0)
                    {
                        string line = new string(charRead);
                        currentFileProcess.AddLine(line);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    bankFileStream.Close();
                }
                if (Environment == HSBCEnvironmentIndicatorEnum.Production)
                {
                    autoPayFile.CompanyAutopayFileConsolidateDateTime  = AppUtils.ServerDateTime();
                    autoPayFile.CompanyAutopayFileTransactionReference = transactionRefreence;
                    ECompanyAutopayFile.db.update(m_dbConn, autoPayFile);
                }
            }
            HSBCAutoPayFileExchange.Close();
            HangSengAutoPayFileExchange.Close();
            return(new string[] { outputPathHSBC, outputPathHASE });
        }
    protected void UploadToMasterDB(string uploadFile)
    {
        // uploadFile will be MOVED to bankfile folder
        if (!IsAllowEdit)
        {
            throw new Exception("Access Deny");
        }

        HROne.BankFile.HSBCBankFile bankFile = new HROne.BankFile.HSBCBankFile(dbConn);
        bankFile.LoadBankFileDetail(uploadFile);

        DateTime firstValueDate = bankFile.GetFirstValueDate();

        if (firstValueDate <= bankFileCutOffDateTime)
        {
            throw new Exception("Invalid value date:" + firstValueDate.ToString("dd-MMM"));
        }
        if (firstValueDate.DayOfWeek == DayOfWeek.Saturday || firstValueDate.DayOfWeek == DayOfWeek.Sunday)
        {
            throw new Exception("Invalid value date:" + firstValueDate.ToString("dd-MMM"));
        }
        if (HROne.SaaS.Entities.EPublicHoliday.IsHoliday(masterDBConn, firstValueDate))
        {
            throw new Exception("Invalid value date:" + firstValueDate.ToString("dd-MMM"));
        }
        DBFilter bankPaymentCodeFilter = new DBFilter();

        bankPaymentCodeFilter.add(new Match("CompanyDBID", (int)Session["CompanyDBID"]));
        ArrayList BankPaymentCodeList           = EHSBCBankPaymentCode.db.select(masterDBConn, bankPaymentCodeFilter);
        string    bankFileBranchAccountNoString = bankFile.BranchCode + bankFile.AccountNo;
        string    bankFileInOutFlag             = string.Empty;

        if ((bankFile.PlanCode.Equals("E") || bankFile.PlanCode.Equals("F")))
        {
            bankFileInOutFlag = "O";
        }
        else if ((bankFile.PlanCode.Equals("G") || bankFile.PlanCode.Equals("H")))
        {
            bankFileInOutFlag = "I";
        }
        int exchangeProfileID = 0;

        foreach (EHSBCBankPaymentCode bankPaymentCode in BankPaymentCodeList)
        {
            if (bankPaymentCode.HSBCBankPaymentCodeBankAccountNo.Substring(3).Trim().Equals(bankFileBranchAccountNoString.Trim()) &&
                bankPaymentCode.HSBCBankPaymentCode.Trim().Equals(bankFile.BankPaymentCode.Trim()) &&
                bankPaymentCode.HSBCBankPaymentCodeAutoPayInOutFlag.Trim().Equals(bankFileInOutFlag)
                )
            {
                HROne.SaaS.Entities.EHSBCExchangeProfile profile = new EHSBCExchangeProfile();
                profile.HSBCExchangeProfileID = bankPaymentCode.HSBCExchangeProfileID;
                if (HROne.SaaS.Entities.EHSBCExchangeProfile.db.select(masterDBConn, profile))
                {
                    if (!profile.HSBCExchangeProfileIsLocked)
                    {
                        bankFile.BankCode = bankPaymentCode.HSBCBankPaymentCodeBankAccountNo.Substring(0, 3);
                        exchangeProfileID = bankPaymentCode.HSBCExchangeProfileID;
                        break;
                    }
                }
            }
        }

        if (string.IsNullOrEmpty(bankFile.BankCode))
        {
            throw new Exception("Bank Account No. or Bank Payment Code is not registered.");
        }

        //if (errors.isEmpty())
        {
            string UploadBankFilePath = ESystemParameter.getParameter(masterDBConn, ESystemParameter.PARAM_CODE_BANKFILE_UPLOAD_FOLDER);
            if (System.IO.Directory.Exists(UploadBankFilePath))
            {
                System.IO.FileInfo bankFileInfo = new System.IO.FileInfo(uploadFile);
                string             relativePath = System.IO.Path.Combine(System.IO.Path.Combine(Session["CompanyDBID"].ToString(), "Autopay"), bankFileInfo.Name);
                string             fullPath     = System.IO.Path.Combine(UploadBankFilePath, relativePath);

                System.IO.Directory.CreateDirectory((new System.IO.FileInfo(fullPath)).Directory.FullName);
                bankFileInfo.MoveTo(fullPath);

                ECompanyAutopayFile CompanyAutopayFile = new ECompanyAutopayFile();
                CompanyAutopayFile.CompanyDBID                            = (int)Session["CompanyDBID"];
                CompanyAutopayFile.HSBCExchangeProfileID                  = exchangeProfileID;
                CompanyAutopayFile.CompanyAutopayFileBankCode             = bankFile.BankCode;
                CompanyAutopayFile.CompanyAutopayFileDataFileRelativePath = relativePath;
                CompanyAutopayFile.CompanyAutopayFileSubmitDateTime       = currentDateTime;
                CompanyAutopayFile.CompanyAutopayFileValueDate            = firstValueDate;
                if (!HROne.Lib.Entities.ESystemParameter.getParameter(dbConn, HROne.Lib.Entities.ESystemParameter.PARAM_CODE_ECHANNEL_SIGNATURE_REQUIRED_FOR_AUTOPAY_FILE).Equals("Y", StringComparison.CurrentCultureIgnoreCase))
                {
                    CompanyAutopayFile.CompanyAutopayFileConfirmDateTime = currentDateTime;
                }
                ECompanyAutopayFile.db.insert(masterDBConn, CompanyAutopayFile);
            }
        }
    }