protected void btnSearch_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); if (txtTaxRefNo.FieldValue == null) { MessageBox.Show("Tax Reference Number is required."); return; } var queue = new FDRQueueService(); var doc = queue.EnquireRegistration(txtTaxRefNo.Text); if (doc != null) { txtXml.SetValue(doc.OuterXml); } }
public void LookUpRegistrationDetails(string taxReferenceNo) { var serviceClient = new FDRQueueService(); var id = serviceClient.GetTaxpayerRegistrationData(taxReferenceNo); var data = DBReadManager.GetResponse(id); var i = 1; while (!data.HasRows && i <= Configurations.QueueResponseTime) { Thread.Sleep(1); i++; data = DBReadManager.GetResponse(id); } if (!data.HasRows && i >= Configurations.QueueResponseTime) { DetailsFound = false; Message = Configurations.QueueTimeoutMessage; return; } if (Convert.ToInt32(data[0]["ReturnCode"]) != 0) { DetailsFound = false; Message = data[0]["ReturnMessage"].ToString(); //MessageBox.Show(data[0]["ReturnMessage"].ToString()); return; } DetailsFound = true; var xml = data[0]["Message"].ToString(); RegistrationData = xml; const string _namespace = "http://www.sars.gov.za/enterpriseMessagingModel/RegistrationManagement/xml/schemas/version/3.3"; var registrationManagementResponse = FdrCommon.SelectNode(xml, "ns0", _namespace, "RegistrationManagementResponse"); if (registrationManagementResponse != null) { var reg = Sars.Systems.Serialization.XmlObjectSerializer .ConvertXmlToObject <RegistrationManagementResponseStructure> ( registrationManagementResponse.OuterXml ); if (reg != null) { if (reg.Registration != null && reg.Registration.Parties != null && reg.Registration.Parties.Any()) { if (reg.Registration.Parties[0].Addresses != null && reg.Registration.Parties[0].Addresses.Any()) { foreach (var addressStructure in reg.Registration.Parties[0].Addresses) { if (addressStructure.PhysicalAddress != null) { PhysicalAddresses.Add(addressStructure.PhysicalAddress); } if (addressStructure.PostalAddress != null) { PostalAddresses.Add(addressStructure.PostalAddress); } } } if (reg.Registration.Parties[0].TradingNameDetails != null && reg.Registration.Parties[0].TradingNameDetails.Any()) { foreach (var tradingNameDetailStructure in reg.Registration.Parties[0].TradingNameDetails) { if (!string.IsNullOrWhiteSpace(tradingNameDetailStructure.Name)) { RegistrationName = tradingNameDetailStructure.Name; break; } } } } } } if (PhysicalAddresses.Any()) { foreach (var address in PhysicalAddresses) { if ( !string.IsNullOrEmpty(address.PostalCode) && !string.IsNullOrEmpty(address.StreetName) && (!string.IsNullOrEmpty(address.Suburb) || !string.IsNullOrEmpty(address.City)) ) { PreferredAddress = address; break; } } if (PreferredAddress == null) { PreferredAddress = PhysicalAddresses.Find( a => !string.IsNullOrEmpty(a.StreetName) || !string.IsNullOrEmpty(a.ComplexName) || !string.IsNullOrEmpty(a.UnitNo)); } } RecordSet.ReadXml(new StringReader(xml)); }
protected void btnSubmit_Click(object sender, EventArgs e) { int j = 0, k = 0; var listOfFiles = new List <FileValidationOutcomeDetails>(); foreach (GridViewRow row in gvMasterFiles.Rows) { var ddlOutcome = row.FindControl("ddlOutcome") as DropDownList; var txtOutcomeReason = row.FindControl("txtOutcomeReason") as TextBox; if (ddlOutcome != null && txtOutcomeReason != null) { ddlOutcome.BackColor = Color.Transparent; if (ddlOutcome.SelectedIndex <= 0) { ddlOutcome.BackColor = Color.Red; k++; break; } var dataKey = gvMasterFiles.DataKeys[row.RowIndex]; if (dataKey != null) { var fileId = Convert.ToDecimal(dataKey.Value); listOfFiles.Add(new FileValidationOutcomeDetails { Id = 0, SubmissionId = Convert.ToDecimal(SubmissionId), FileId = fileId, ValidationOutcomeId = Convert.ToInt32(ddlOutcome.SelectedValue), SID = Sars.Systems.Security.ADUser.CurrentSID, OutcomeReason = string.IsNullOrEmpty(txtOutcomeReason.Text) ? null : txtOutcomeReason.Text } ); } } } foreach (GridViewRow row in gvLocalFiles.Rows) { var ddlOutcome = row.FindControl("ddlOutcome") as DropDownList; var txtOutcomeReason = row.FindControl("txtOutcomeReason") as TextBox; if (ddlOutcome != null && txtOutcomeReason != null) { ddlOutcome.BackColor = Color.Transparent; if (ddlOutcome.SelectedIndex <= 0) { ddlOutcome.BackColor = Color.Red; j++; break; } var dataKey = gvLocalFiles.DataKeys[row.RowIndex]; if (dataKey != null) { var fileId = Convert.ToDecimal(dataKey.Value); listOfFiles.Add( new FileValidationOutcomeDetails { Id = 0, SubmissionId = Convert.ToDecimal(SubmissionId), FileId = fileId, ValidationOutcomeId = Convert.ToInt32(ddlOutcome.SelectedValue), SID = Sars.Systems.Security.ADUser.CurrentSID, OutcomeReason = string.IsNullOrEmpty(txtOutcomeReason.Text) ? null : txtOutcomeReason.Text } ); } } } if (k > 0) { tbMain.ActiveTabIndex = 0; MessageBox.Show("Please select validation outcome for all the files."); return; } if (j > 0) { tbMain.ActiveTabIndex = 1; MessageBox.Show("Please select validation outcome for all the files."); return; } if (listOfFiles.Any()) { var numSaved = 0; foreach (var detailse in listOfFiles) { numSaved += DBWriteManager.SaveFileValidationOutcome(detailse); } if (_fileSubmission == null) { _fileSubmission = DBReadManager.GeFileSubmissionById(Convert.ToDecimal(SubmissionId)); } if (numSaved == (gvLocalFiles.Rows.Count + gvMasterFiles.Rows.Count)) { btnSave.Enabled = false; btnSubmit.Enabled = false; MessageBox.Show("Validation submitted successfully"); } var status = 0; var accepted = listOfFiles.Count(a => a.ValidationOutcomeId == 1); var rejected = listOfFiles.Count(a => a.ValidationOutcomeId == 2); if (accepted == listOfFiles.Count()) { // accepted = 3 status = 3; try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(2); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { byte[] attachment = null;//FdrCommon.GetFileAcceptenceLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format(DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(2), _fileSubmission.TaxRefNo); service.SendEmail ( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } try{ var attachment = FdrCommon.GetEfilingAcceptanceLetter(_fileSubmission.Year); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Acceptance of Master Files and Local Files" , true , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception) { ; } } else if (rejected == listOfFiles.Count()) { //rejected = 4 status = 4; try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(3); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms ( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try{ if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { //var attachment = FdrCommon.GetFileRejectionLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format( DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(3), _fileSubmission.TaxRefNo); service.SendEmail( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } //SEND EFILING REJECTION LETTERS try{ var attachment = FdrCommon.GetEfilingRejectionLetter(_fileSubmission.TaxRefNo, _fileSubmission.Year, Convert.ToDecimal(SubmissionId)); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Rejection of Master Files and Local Files" , false , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception exception) { MessageBox.Show(exception.ToString()); } } else { try { if (!string.IsNullOrEmpty(_fileSubmission.ContactMobileNumber) && _fileSubmission.ContactMobileNumber.IsValid(StringValidationType.CellularNumber)) { var smsBody = DBReadManager.GetMasterLocalFileNotificationSmsBodyTemplate(4); if (!string.IsNullOrEmpty(smsBody)) { var service = new FDRQueueService(); service.SendSms ( _fileSubmission.ContactMobileNumber , _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); DBWriteManager.SaveSentSmsCommunications( _fileSubmission.TaxRefNo , string.Format(smsBody, _fileSubmission.TaxRefNo) , _fileSubmission.Year ); } } } catch (Exception) { ; } try { if (!string.IsNullOrEmpty(_fileSubmission.ContactEmail)) { //var attachment = FdrCommon.GetFileRejectionLetter(SubmissionId); var service = new FDRQueueService(); var messageBody = string.Format( DBReadManager.GetMasterLocalFileNotificationEmailBodyTemplate(4), _fileSubmission.TaxRefNo); service.SendEmail( messageBody , "CBC File validation outcome" , _fileSubmission.ContactEmail , null , "CBC File validation outcome" , _fileSubmission.TaxRefNo , _fileSubmission.Year ); } } catch (Exception) { ; } //SEND EFILING ACCEPTANCE LETTERS try { var attachment = FdrCommon.GetEfilingRejectionLetter(_fileSubmission.TaxRefNo, _fileSubmission.Year, Convert.ToDecimal(SubmissionId)); if (!string.IsNullOrEmpty(attachment)) { var service = new FDRQueueService(); service.SendLetter ( _fileSubmission.SubmissionId , _fileSubmission.TaxRefNo , _fileSubmission.Year , attachment , "Rejection of Master Files and Local Files" , false , Sars.Systems.Security.ADUser.CurrentSID ); } } catch (Exception) { ; } //Accepted With Warnings = 5 status = 5; } if (status != 0) { DBWriteManager.ChangeSubmissionStatus(Convert.ToDecimal(SubmissionId), status); } } else { MessageBox.Show("No validation was submitted"); } }