private IEnumerable <IntrastatClient> CallValidate(bool onlyValidate) { if (!CallPrevalidate()) { return(null); } dgIntraStatGrid.Columns.GetColumnByName("SystemInfo").Visible = true; var intralst = (IEnumerable <IntrastatClient>)dgIntraStatGrid.GetVisibleRows(); intraHelper.Validate(intralst, compressed, onlyValidate); if (onlyValidate) { var countErr = intralst.Count(s => s.SystemInfo != IntraHelper.VALIDATE_OK); if (countErr == 0) #if SILVERLIGHT { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("ValidateNoError"), Uniconta.ClientTools.Localization.lookup("Validate"), MessageBoxButton.OK); } #else { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("ValidateNoError"), Uniconta.ClientTools.Localization.lookup("Validate"), MessageBoxButton.OK, MessageBoxImage.Information); } #endif else #if SILVERLIGHT { UnicontaMessageBox.Show(string.Format("{0} {1}", countErr, Localization.lookup("JournalFailedValidation")), Localization.lookup("Validate"), MessageBoxButton.OK); } #else { UnicontaMessageBox.Show(string.Format("{0} {1}", countErr, Localization.lookup("JournalFailedValidation")), Localization.lookup("Validate"), MessageBoxButton.OK, MessageBoxImage.Warning); } #endif }
public async void GetInvoiceLinesToIntraStat(DateTime fromDate, DateTime toDate, bool includeImport, bool includeExport) { var prop = PropValuePair.GenereteWhereElements("Item", typeof(string), "!null"); List <PropValuePair> propValPair = new List <PropValuePair>() { prop }; if (fromDate != DateTime.MinValue || toDate != DateTime.MinValue) { string filter; if (fromDate != DateTime.MinValue) { filter = String.Format("{0:d}..", fromDate); } else { filter = ".."; } if (toDate != DateTime.MinValue) { filter += String.Format("{0:d}", toDate); } prop = PropValuePair.GenereteWhereElements("Date", typeof(DateTime), filter); propValPair.Add(prop); } var intraList = new List <IntrastatClient>(); if (includeImport) { prop = PropValuePair.GenereteWhereElements("MovementType", typeof(int), "2"); propValPair.Insert(0, prop); var listIntraStatCred = await api.Query <IntrastatClient>(propValPair); var listCred = UpdateValues(listIntraStatCred, ImportOrExportIntrastat.Import, 1); propValPair.RemoveAt(0); // remove it so we can reuse the list if (listCred != null || listCred?.Count > 0) { intraList.AddRange(listCred); } } if (includeExport) { prop = PropValuePair.GenereteWhereElements("MovementType", typeof(int), "1"); propValPair.Add(prop); var listIntraStatDeb = await api.Query <IntrastatClient>(propValPair); var listDeb = UpdateValues(listIntraStatDeb, ImportOrExportIntrastat.Export, -1); if (listDeb != null || listDeb?.Count > 0) { intraList.AddRange(listDeb); } } if (intraList.Count <= 0) { UnicontaMessageBox.Show(Localization.lookup("zeroRecords"), Uniconta.ClientTools.Localization.lookup("Warning")); } dgIntraStatGrid.ItemsSource = intraList; dgIntraStatGrid.Visibility = Visibility.Visible; }
private void CreateFile() { if (compressed == false) { UnicontaMessageBox.Show(Uniconta.ClientTools.Localization.lookup("CompressPosting"), Uniconta.ClientTools.Localization.lookup("Warning")); return; } var intralst = CallValidate(false); if (intralst == null) { return; } var lstIntraStat = intralst.Where(s => s.SystemInfo == IntraHelper.VALIDATE_OK).ToArray(); var countOk = lstIntraStat.Count(); var countErr = intralst.Count() - countOk; if (countOk > 0) { var mappedItems = MapColumnsToIndices(); var sfd = UtilDisplay.LoadSaveFileDialog; sfd.DefaultExt = "xlsx"; sfd.Filter = "XLSX Files (*.xlsx)|*.xlsx"; sfd.FilterIndex = 1; bool?userClickedSave = sfd.ShowDialog(); if (userClickedSave != true) { return; } busyIndicator.IsBusy = true; busyIndicator.BusyContent = string.Format(Localization.lookup("ExportingFile"), Localization.lookup("IntraStat")); Stream stream = null; try { #if !SILVERLIGHT stream = File.Create(sfd.FileName); #endif var cnt = ExportDataGrid(stream, (UnicontaBaseEntity[])lstIntraStat, mappedItems); if (cnt > 0) { foreach (var rec in lstIntraStat) { rec.SystemInfo = Localization.lookup("Exported"); } } stream.Flush(); stream.Close(); busyIndicator.IsBusy = false; } catch (Exception ex) { busyIndicator.IsBusy = false; stream?.Dispose(); UnicontaMessageBox.Show(ex); } var msgTxt = string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Exported"), countOk); if (countErr > 0) { msgTxt = string.Concat(msgTxt, string.Format("\n{0}: {1}", Uniconta.ClientTools.Localization.lookup("Error"), countErr)); } UnicontaMessageBox.Show(msgTxt, Uniconta.ClientTools.Localization.lookup("Message")); } else { UnicontaMessageBox.Show(string.Format("{0}: {1}", Uniconta.ClientTools.Localization.lookup("Exported"), countOk), Uniconta.ClientTools.Localization.lookup("Message")); } }