Пример #1
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            PaymentFormat = debPaymentFormat.SelectedItem as DebtorPaymentFormatClient;

            if (PaymentFormat != null)
            {
                this.DialogResult = true;
            }
            else
            {
                UnicontaMessageBox.Show("Please select a payment format", Uniconta.ClientTools.Localization.lookup("Warning"));
                return;
            }
        }
Пример #2
0
        void InitPage(CrudAPI crudapi)
        {
            layoutControl = layoutItems;
            cmbPaymentMethod.ItemsSource = Enum.GetValues(typeof(DebtorPaymFormatType));
            leBankAccount.api            = crudapi;
            leJournal.api = crudapi;

            if (LoadedRow == null && editrow == null)
            {
                frmRibbon.DisableButtons(new string[] { "Delete" });
                editrow = CreateNew() as DebtorPaymentFormatClient;
            }
            layoutItems.DataContext  = editrow;
            frmRibbon.OnItemClicked += frmRibbon_OnItemClicked;
        }
Пример #3
0
 public DebtorPaymentFormatPage2(UnicontaBaseEntity sourcedata, bool isEdit = true)
     : base(sourcedata, isEdit)
 {
     InitializeComponent();
     if (!isEdit)
     {
         editrow = (DebtorPaymentFormatClient)StreamingManager.Clone(sourcedata);
         IdKey idkey = (IdKey)editrow;
         if (idkey.KeyStr != null)
         {
             idkey.KeyStr = null;
         }
     }
     InitPage(api);
 }
        async void ImportFile()
        {
            CWDirectDebit             cwwin            = new CWDirectDebit(api, Uniconta.ClientTools.Localization.lookup("Upload File"));
            DebtorPaymentFormatClient debPaymentFormat = null;

            cwwin.Closing += delegate
            {
                if (cwwin.DialogResult == true)
                {
                    debPaymentFormat = cwwin.PaymentFormat;
                }
            };
            cwwin.Show();

            if (debPaymentFormat == null)
            {
                return;
            }

            ErrorCodes error     = ErrorCodes.Succes;
            var        showError = false;

            try
            {
                var sfd             = UtilDisplay.LoadOpenFileDialog;
                var userClickedSave = sfd.ShowDialog();
                if (userClickedSave != true)
                {
                    return;
                }

                var nextPaymentFileIdTest = 1;

                using (var stream = File.Open(sfd.FileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (var sr = new StreamReader(stream))
                    {
                        var filecontentText = await sr.ReadToEndAsync();

                        var debPaymFile = new DebtorPaymentFile
                        {
                            _Created           = DateTime.Now,
                            _CredDirectDebitId = debPaymentFormat._CredDirectDebitId,
                            _Filename          = sfd.SafeFileName,
                            _Data       = Encoding.GetEncoding("iso-8859-1").GetBytes(filecontentText),
                            _FileId     = string.Format("{0}_{1}_{2}", debPaymentFormat._Format, DateTime.Now.ToString("yyMMdd"), nextPaymentFileIdTest.ToString().PadLeft(5, '0')),
                            _Format     = debPaymentFormat._Format,
                            _StatusInfo = string.Format("{0} return file", debPaymentFormat._Format),
                            _Status     = DebtorPaymentStatus.Pending,
                            _Output     = false
                        };
                        showError = true;
                        error     = await api.Insert(debPaymFile);
                    }
                }
                gridRibbon_BaseActions("RefreshGrid");
            }
            catch (Exception ex)
            {
                if (showError)
                {
                    UnicontaMessageBox.Show(ex.Message + "\n" + error, Uniconta.ClientTools.Localization.lookup("Execption"));
                }
                else
                {
                    UnicontaMessageBox.Show(ex.Message, Uniconta.ClientTools.Localization.lookup("Exception"));
                }
            }
        }