protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { DataRowView row = (DataRowView)e.Item.DataItem; CheckBox cb = (CheckBox)e.Item.FindControl("ItemSelect"); WebFormUtils.LoadKeys(sdb, row, cb); Button cancelButton = (Button)e.Item.FindControl("Cancel"); Button SignButton = (Button)e.Item.FindControl("Sign"); Label SignedBy = (Label)e.Item.FindControl("SignedBy"); ECompanyAutopayFile obj = new ECompanyAutopayFile(); sdb.toObject(row.Row, obj); cb.Visible = false; if (!isAuthorizer || !obj.CompanyAutopayFileConfirmDateTime.Ticks.Equals(0)) { SignButton.Visible = false; } else { SignButton.Visible = true; } if (!obj.CompanyAutopayFileConsolidateDateTime.Ticks.Equals(0) || bankFileLastCancelTime < AppUtils.ServerDateTime()) { cancelButton.Visible = false; } else { cancelButton.Visible = IsAllowEdit; cancelButton.OnClientClick = HROne.Translation.PromptMessage.CreateDeleteConfirmDialogJavascript(cancelButton); } DBFilter countSignatureFilter = new DBFilter(); countSignatureFilter.add(new Match("CompanyAutopayFileID", obj.CompanyAutopayFileID)); countSignatureFilter.add(new Match("CompanyDBID", CurID)); ArrayList signedList = ECompanyAutopayFileSignature.db.select(masterDBConn, countSignatureFilter); foreach (ECompanyAutopayFileSignature signature in signedList) { if (string.IsNullOrEmpty(SignedBy.Text)) { SignedBy.Text = signature.CompanyAutopayFileSignatureUserName; } else { SignedBy.Text += ",<br/>" + signature.CompanyAutopayFileSignatureUserName; } } }
protected void Repeater_ItemDataBound(object sender, RepeaterItemEventArgs e) { DataRowView row = (DataRowView)e.Item.DataItem; CheckBox cb = (CheckBox)e.Item.FindControl("ItemSelect"); WebFormUtils.LoadKeys(sdb, row, cb); ECompanyAutopayFile obj = new ECompanyAutopayFile(); sdb.toObject(row.Row, obj); cb.Visible = false; }
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); } } }
protected void Repeater_ItemCommand(object source, RepeaterCommandEventArgs e) { PageErrors errors = PageErrors.getErrors(sdb, Page.Master); errors.clear(); Button b = (Button)e.CommandSource; CheckBox cb = (CheckBox)e.Item.FindControl("ItemSelect"); DataRowView row = (DataRowView)e.Item.DataItem; ECompanyAutopayFile obj = new ECompanyAutopayFile(); WebFormUtils.GetKeys(sdb, obj, cb); if (sdb.select(masterDBConn, obj)) { if (b.ID.Equals("Cancel")) { if (!obj.CompanyAutopayFileConsolidateDateTime.Ticks.Equals(0) || bankFileLastCancelTime < AppUtils.ServerDateTime()) { errors.addError("The system fail to remove the request because the bank file is submitting to bank."); } else { string UploadBankFilePath = ESystemParameter.getParameter(masterDBConn, ESystemParameter.PARAM_CODE_BANKFILE_UPLOAD_FOLDER); if (System.IO.Directory.Exists(UploadBankFilePath)) { string fullPath = System.IO.Path.Combine(UploadBankFilePath, obj.CompanyAutopayFileDataFileRelativePath); System.IO.File.Delete(fullPath); } ECompanyAutopayFile.db.delete(masterDBConn, obj); } } else if (b.ID.Equals("Sign")) { DateTime currentDateTime = AppUtils.ServerDateTime(); DateTime bankFileCutOffDateTime = currentDateTime.Date; while (HROne.SaaS.Entities.EPublicHoliday.IsHoliday(masterDBConn, bankFileCutOffDateTime) || bankFileCutOffDateTime.DayOfWeek == DayOfWeek.Sunday) { bankFileCutOffDateTime = bankFileCutOffDateTime.AddDays(1); } string tmpDateTimeString = ESystemParameter.getParameter(masterDBConn, ESystemParameter.PARAM_CODE_BANKFILE_CUTOFF_TIME); TimeSpan bankFileCutOffTimeSpan; if (TimeSpan.TryParse(tmpDateTimeString, out bankFileCutOffTimeSpan)) { bankFileCutOffDateTime = bankFileCutOffDateTime.Add(bankFileCutOffTimeSpan); } if (obj.CompanyAutopayFileValueDate <= bankFileCutOffDateTime) { errors.addError("Invalid value date:" + obj.CompanyAutopayFileValueDate.ToString("dd-MMM")); return; } int numOfSignatureRequired = 0; if (!int.TryParse(HROne.Lib.Entities.ESystemParameter.getParameter(dbConn, HROne.Lib.Entities.ESystemParameter.PARAM_CODE_ECHANNEL_NUM_SIGNATURE_REQUIRED), out numOfSignatureRequired)) { numOfSignatureRequired = 0; } DBFilter currentSignatureFilter = new DBFilter(); currentSignatureFilter.add(new Match("CompanyAutopayFileID", obj.CompanyAutopayFileID)); currentSignatureFilter.add(new Match("CompanyDBID", CurID)); currentSignatureFilter.add(new Match("UserID", currentUser.UserID)); if (ECompanyAutopayFileSignature.db.count(masterDBConn, currentSignatureFilter) <= 0) { ECompanyAutopayFileSignature signature = new ECompanyAutopayFileSignature(); signature.CompanyAutopayFileID = obj.CompanyAutopayFileID; signature.CompanyDBID = CurID; signature.UserID = currentUser.UserID; signature.CompanyAutopayFileSignatureUserName = currentUser.UserName; signature.CompanyAutopayFileSignatureDateTime = currentDateTime; ECompanyAutopayFileSignature.db.insert(masterDBConn, signature); } DBFilter countSignatureFilter = new DBFilter(); countSignatureFilter.add(new Match("CompanyAutopayFileID", obj.CompanyAutopayFileID)); countSignatureFilter.add(new Match("CompanyDBID", CurID)); if (ECompanyAutopayFileSignature.db.count(masterDBConn, currentSignatureFilter) >= numOfSignatureRequired) { obj.CompanyAutopayFileConfirmDateTime = currentDateTime; ECompanyAutopayFile.db.update(masterDBConn, obj); } } } view = loadData(info, sdb, Repeater); }