protected void buttonSave_Click(object sender, EventArgs e) { VoucherBatch batch; if (Request.QueryString["batchid"] != null) { batch = Module.GetObject <VoucherBatch>(Convert.ToInt32(Request.QueryString["batchid"])); if (batch.Issued && UserIdentity.HasPermission(AccessLevel.Administrator)) { ShowError("You can not change voucher program after issue date unless you're administrators!"); return; } } else { batch = new VoucherBatch(); } batch.Name = txtName.Text; var agencyId = -1; try { agencyId = Int32.Parse(agencySelector.Value); } catch { } batch.Agency = VoucherEditBLL.AgencyGetById(agencyId); batch.Cruise = Module.CruiseGetById(Convert.ToInt32(ddlCruises.SelectedValue)); batch.Trip = Module.TripGetById(Convert.ToInt32(ddlTrips.SelectedValue)); DateTime date; if (DateTime.TryParseExact(txtIssueDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date)) { batch.IssueDate = date; } else { batch.IssueDate = null; } batch.ValidUntil = DateTime.ParseExact(txtValidUntil.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); batch.NumberOfPerson = Convert.ToInt32(ddlPersons.SelectedValue); batch.Quantity = Convert.ToInt32(txtVoucher.Text); batch.NumberOfPerson = Convert.ToInt32(ddlPersons.SelectedValue); batch.Value = Convert.ToInt32(txtValue.Text); batch.Template = ddlTemplates.SelectedValue; batch.Note = txtNote.Text; if (fileuploadContract.HasFile) { batch.ContractFile = FileHelper.Upload(fileuploadContract); } Module.SaveOrUpdate(batch, UserIdentity); PageRedirect(string.Format("VoucherEdit.aspx?NodeId={0}&SectionId={1}&batchid={2}", Node.Id, Section.Id, batch.Id)); }
public Voucher NewData() { string year = DateTime.Now.ToString("yyyy"); string month = DateTime.Now.ToString("MM"); string day = DateTime.Now.ToString("dd"); VoucherBatch lastBatch = de.ExecuteStoreQuery <VoucherBatch>(string.Format(@"SELECT * FROM VoucherBatch WHERE VoucherBatchId LIKE '{0}{1}{2}%' ORDER BY VoucherBatchId*1 DESC LIMIT 1", year, month, day)).FirstOrDefault(); if (lastBatch == null) { throw new Exception("请先添加票券批次!"); } // 获取新Id(将数据表里的FilmId最大值+1) // 使用创建时间先后来获取最后ID string lastId; Voucher lastData = de.ExecuteStoreQuery <Voucher>(string.Format(@"SELECT * FROM Voucher WHERE VoucherId LIKE '{0}%' ORDER BY VoucherId*1 DESC LIMIT 1", lastBatch.VoucherBatchId)).FirstOrDefault(); if (lastData != null) { lastId = lastData.VoucherId.Substring(10, 6); } else { lastId = "0"; } string newId; // 生成新的Id(这里长度是6位) try { newId = string.Format("{0:D6}", Convert.ToInt64(lastId) + 1); } catch { newId = string.Format("{0:D6}", 1); } Voucher data = new Voucher(); data.VoucherId = lastBatch.VoucherBatchId + newId; // 更新数据基础值 data.Created = DateTime.Now; data.Updated = data.Created; data.ActiveFlag = true; // 更新非String类型的值,优化速度 de.Voucher.AddObject(data); de.SaveChanges(); return(data); }
/// <summary> /// kiểm tra voucher code đã được dùng hay chưa /// </summary> /// <param name="code">voucher code</param> /// <param name="count">dùng để dưa kết quả của biến count ra ngoài</param> /// <param name="batch">gói voucher</param> public void CheckCode(String code, out int count, out VoucherBatch batch) { /*Điều kiện tìm booking : tìm theo bookingid và booking chưa bị deleted và đã có voucher code và status không phải là cancelled */ int batchid; AbstractCriterion crit = Expression.Eq("Deleted", false); crit = Expression.And(crit, Expression.Or(Expression.Not(Expression.Eq("VoucherCode", null)), Expression.Not(Expression.Eq("VoucherCode", "")))); if (!string.IsNullOrEmpty(Request.QueryString["bookingid"])) { crit = Expression.And(crit, Expression.Not(Expression.Eq("Id", Convert.ToInt32(Request.QueryString["bookingid"])))); crit = Expression.And(crit, Expression.Not(Expression.Eq("Status", StatusType.Cancelled))); } count = 0; var bookingList = Module.GetObject <Booking>(crit, 0, 0); /* kiểm tra voucher nhập vào đã dùng trong các booking vừa tìm hay chưa, nếu trùng tăng biến đếm count * và đưa kết quả ra ngoài để xử lý */ foreach (Booking booking in bookingList) { string[] codeArray = booking.VoucherCode.Split(new char[] { ';' }); for (int i = 0; i < codeArray.Length; i++) { if (code == codeArray[i]) { count++; } } } try { /* giải mã voucher xem nó thuộc gói voucher nào*/ VoucherCodeEncryption.Decrypt(Convert.ToUInt32(code), out batchid); } catch (Exception ex) { throw ex; } /*tìm gói voucher và đưa kết quả ra ngoài để xử lý*/ batch = Module.GetObject <VoucherBatch>(batchid); }
/// <summary> /// 填充下拉框cbVoucherId /// </summary> public void FillcbVoucherId() { List <VoucherBatch> voucherBatchList = new List <VoucherBatch>(); cbVoucherId.DisplayMember = "VoucherBatchId"; cbVoucherId.ValueMember = "VoucherBatchId"; VoucherBatchManage dataManager = new VoucherBatchManage(); voucherBatchList = dataManager.GetDataList(); if (voucherBatchList.Count > 0 || voucherBatchList != null) { VoucherBatch vBatch = new VoucherBatch(); vBatch.VoucherName = "全部"; vBatch.VoucherBatchId = "全部"; voucherBatchList.Add(vBatch); cbVoucherId.DataSource = voucherBatchList; } }
private VoucherInformation GetTestData_VoucherInfo() { var voucher = new Voucher { documentReferenceNumber = "04114", bsbNumber = "082401", auxDom = string.Empty, accountNumber = "813208132", amount = "419.38", documentType = DocumentTypeEnum.Dr, transactionCode = "01", processingDate = new DateTime(2015, 01, 01) }; var voucherProcess = new VoucherProcess { adjustedFlag = true, adjustmentDescription = "test description", adjustmentReasonCode = 00, transactionLinkNumber = "9000001" }; var voucherBatch = new VoucherBatch { scannedBatchNumber = "67500125", collectingBank = "082401" }; var voucherInfo = new VoucherInformation { voucher = voucher, voucherProcess = voucherProcess, voucherBatch = voucherBatch }; return(voucherInfo); }
public void TestInitialize() { adapterConfiguration = new Mock <IAdapterConfiguration>(); dateTimeProvider = new Mock <IDateTimeProvider>(); dipsBatchMapHelper = new BatchCodelineRequestMapHelper(dateTimeProvider.Object, adapterConfiguration.Object); voucherBatch = new VoucherBatch { scannedBatchNumber = "58300013", workType = WorkTypeEnum.NABCHQ_POD, processingState = StateEnum.VIC, unitID = "123", batchType = "testing", subBatchType = "tst123", }; sampleCorrectBatchCodelineRequest = new CorrectBatchCodelineRequest { voucherBatch = voucherBatch, voucher = new[] { new CorrectCodelineRequest { auxDom = "001193", bsbNumber = "013812", accountNumber = "256902729", transactionCode = "50", documentReferenceNumber = "583000026", capturedAmount = "45.67", documentType = DocumentTypeEnum.DBT, accountNumberStatus = true, extraAuxDomStatus = true, auxDomStatus = true, bsbNumberStatus = true, amountStatus = true, transactionCodeStatus = true, processingDate = new DateTime(2015, 4, 16, 14, 14, 14), repostFromProcessingDate = new DateTime(2015, 8, 13, 20, 00, 00), repostFromDRN = "", collectingBank = "123456", }, new CorrectCodelineRequest { auxDom = "001193", bsbNumber = "092002", accountNumber = "814649", transactionCode = "50", documentReferenceNumber = "583000027", capturedAmount = "2341.45", documentType = DocumentTypeEnum.CRT, accountNumberStatus = true, extraAuxDomStatus = true, auxDomStatus = false, bsbNumberStatus = false, amountStatus = true, transactionCodeStatus = true, processingDate = new DateTime(2015, 4, 16, 14, 14, 14), repostFromProcessingDate = new DateTime(2015, 8, 13, 20, 00, 00), repostFromDRN = "", collectingBank = "123456", } } }; sampleDipsQueue = new DipsQueue { ConcurrencyToken = null, CorrelationId = null, ResponseCompleted = false, S_BATCH = "58300013", S_CLIENT = "NabChq ", S_COMPLETE = " 0", S_IMG_PATH = "C:\\Lombard\\Data\\ClientImages\\58300 ", S_JOB_ID = "NabChqPod ", S_LOCATION = "CodelineCorrect ", S_LOCK = " 0", S_LOCKMACHINENAME = " ", S_LOCKMODULENAME = " ", S_LOCKTIME = " ", S_LOCKUNITID = " ", S_LOCKUSER = "******", S_MODIFIED = " 0", S_PINDEX = "05-1504161414140", S_PRIORITY = " 5", S_PROCDATE = " ", S_REPORTED = " ", S_SDATE = "16/04/15", S_SELNSTRING = "16/04/15 58300013 NabChqPod ", S_STIME = "14:14:14", S_TRACE = "583000026", S_USERNAME = null, S_UTIME = " ", S_VERSION = "4.0.2.152 " }; sampleDipsNabChqs = new List <DipsNabChq> { new DipsNabChq { acc_num = "256902729", adj_code = " ", adj_desc = " ", adjustmentReasonCode = " ", adjustmentDescription = " ", adjustedBy = " ", adjustedFlag = " ", adjustmentLetterRequired = " ", adjustmentType = " ", amount = "45.67", batch = "58300013", batch_type = "testing", bsb_num = "013812", collecting_bank = "123456", creditNoteFlag = "0", delay_ind = " ", doc_ref_num = "583000026", doc_type = "DBT", ead = " ", fv_exchange = " ", fv_ind = " ", held_ind = " ", host_trans_no = " ", ie_transaction_id = " ", img_front = " ", img_location = " ", img_rear = " ", job_id = "NabChqPod ", man_rep_ind = "", manual_repair = " ", micr_flag = " ", micr_suspect_fraud_flag = " ", micr_unproc_flag = " ", op_id = " ", @override = " ", payee_name = " ", pocket = " 0", presentationMode = " ", proc_date = "20150416", proc_time = " ", processing_state = "VIC", proof_seq = " ", raw_micr = " ", raw_ocr = " ", rec_type_id = " ", receiving_bank = " ", repostFromDRN = "", repostFromProcessingDate = "20150813", S_BALANCE = " 0", S_BATCH = "58300013", S_COMMITTED = " 0", S_COMPLETE = " 0", S_DEL_IND = " 0", S_IMG1_LEN = " 0", S_IMG1_OFF = " 0", S_IMG1_TYP = " 0", S_IMG2_LEN = " 0", S_IMG2_OFF = " 0", S_IMG2_TYP = " 0", S_LENGTH = "01025", S_MODIFIED = " 0", S_REPORTED = " 0", S_REPROCESS = " 0", S_SEQUENCE = "0000 ", S_STATUS1 = " 0", S_STATUS2 = " 0", S_STATUS3 = " 0", S_STATUS4 = " 0", S_TRACE = "583000026", S_TYPE = " 0", ser_num = "001193", sub_batch_type = "tst123", sys_date = "20150416", trace = "583000026", trancode = "50", trans_seq = " ", unit_id = "123", volume = " " }, new DipsNabChq { acc_num = "814649", adj_code = " ", adj_desc = " ", adjustmentReasonCode = " ", adjustmentDescription = " ", adjustedBy = " ", adjustedFlag = " ", adjustmentLetterRequired = " ", adjustmentType = " ", amount = "2341.45", batch = "58300013", batch_type = "testing", bsb_num = "092002", collecting_bank = "123456", creditNoteFlag = "0", delay_ind = " ", doc_ref_num = "583000027", doc_type = "CRT", ead = " ", fv_exchange = " ", fv_ind = " ", held_ind = " ", host_trans_no = " ", ie_transaction_id = " ", img_front = " ", img_location = " ", img_rear = " ", job_id = "NabChqPod ", man_rep_ind = "", manual_repair = " ", micr_flag = " ", micr_suspect_fraud_flag = " ", micr_unproc_flag = " ", op_id = " ", @override = " ", payee_name = " ", pocket = " 0", presentationMode = " ", proc_date = "20150416", proc_time = " ", processing_state = "VIC", proof_seq = " ", raw_micr = " ", raw_ocr = " ", rec_type_id = " ", receiving_bank = " ", repostFromDRN = "", repostFromProcessingDate = "20150813", S_BALANCE = " 0", S_BATCH = "58300013", S_COMMITTED = " 0", S_COMPLETE = " 0", S_DEL_IND = " 0", S_IMG1_LEN = " 0", S_IMG1_OFF = " 0", S_IMG1_TYP = " 0", S_IMG2_LEN = " 0", S_IMG2_OFF = " 0", S_IMG2_TYP = " 0", S_LENGTH = "01025", S_MODIFIED = " 0", S_REPORTED = " 0", S_REPROCESS = " 0", S_SEQUENCE = "0000 ", S_STATUS1 = " 96", S_STATUS2 = " 0", S_STATUS3 = " 0", S_STATUS4 = " 0", S_TRACE = "583000027", S_TYPE = " 0", ser_num = "001193", sub_batch_type = "tst123", sys_date = "20150416", trace = "583000027", trancode = "50", trans_seq = " ", unit_id = "123", volume = " " } }; sampleDipsDbIndexes = new List <DipsDbIndex> { new DipsDbIndex { BATCH = "58300013", DEL_IND = " 0", REC_NO = "0 ", SEQUENCE = "0000 ", TABLE_NO = " 0", TRACE = "583000026" }, new DipsDbIndex { BATCH = "58300013", DEL_IND = " 0", REC_NO = "0 ", SEQUENCE = "0000 ", TABLE_NO = " 0", TRACE = "583000027" } }; ExpectAdapterConfigurationToReturnValues("5", "4.0.2.152", @"C:\Lombard\Data\ClientImages"); ExpectDateTimeProviderToReturnCurrentTimeInAustralianEasternTimeZone(new DateTime(2015, 4, 16, 14, 14, 14)); }