示例#1
0
        private void SetData()
        {
            if (configWindow.ConfField.AppPath != "")
            {
                try
                {
                    fa = new JPKFA.JPKFA
                    {
                        DbPath     = configWindow.ConfField.AppPath,
                        CodingName = JPKGenerator.GetCode(configWindow.ConfField.CodeName),
                        Jpk        = new JPKFA.JPK()
                    };
                    Cb_kodUrzedu.SelectedValue = configWindow.ConfField.CompanyData.KodUS;
                    fa.Jpk.Podmiot1            = configWindow.ConfField.CompanyData.ToJPKPodmiot1();
                    FillSender(fa.Jpk.Podmiot1);

                    Cb_kodUrzedu.SelectedValue = configWindow.ConfField.CompanyData.KodUS;

                    B_create.IsEnabled = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#2
0
        private void B_create_Click(object sender, RoutedEventArgs e)
        {
            l_kodForm.Content = "JPK_FA (1)";
            l_warForm.Content = "1-0";

            if (MainStatic.PathIsOK(configWindow.ConfField.AppPath, JPKGenerator.GetCode(configWindow.ConfField.CodeName)))
            {
                string uzupelnij = "";
                if (Cb_kodUrzedu.SelectedItem == null)
                {
                    uzupelnij += "\nKod urzędu";
                }
                if (Cb_waluta.SelectedItem == null)
                {
                    uzupelnij += "\nDomyślny kod waluty";
                }
                if (Dp_dateFrom.SelectedDate == null)
                {
                    uzupelnij += "\nOkres od";
                }
                if (Dp_dateTo.SelectedDate == null)
                {
                    uzupelnij += "\nOkres do";
                }
                if (Dp_dateCr.SelectedDate == null)
                {
                    uzupelnij += "\nData utworzenia";
                }
                if (uzupelnij.Length != 0)
                {
                    lsb.Content = "Nie wszystkie pola zostały uzupełnione.";
                    MessageBox.Show("Uzupełnij brakujące pola:" + uzupelnij, "Brak danych", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    JPKPodmiot1 podmiot = GetPodmiot();
                    if (!CheckAddress(podmiot.AdresPodmiotu))
                    {
                        MessageBox.Show("Uzupełnij adres", "Brak danych", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                    else
                    {
                        try
                        {
                            fa = new JPKFA.JPKFA()
                            {
                                //Naglowek
                                CelZlozenia = Cb_cel.SelectedItem.ToString() == cele[0] ? (sbyte)1 : (sbyte)2,
                                Kodus       = (TKodUS)Cb_kodUrzedu.SelectedValue,
                                DateFrom    = (DateTime)Dp_dateFrom.SelectedDate,
                                DateTo      = (DateTime)Dp_dateTo.SelectedDate,
                                CodingName  = JPKGenerator.GetCode(configWindow.ConfField.CodeName),
                                DbPath      = configWindow.ConfField.AppPath,
                            };
                            DateTime now = (DateTime)Dp_dateCr.SelectedDate;
                            fa.CrDate       = new DateTime(now.Year, now.Month, now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
                            fa.Jpk.Podmiot1 = podmiot;

                            System.ComponentModel.BackgroundWorker worker = new System.ComponentModel.BackgroundWorker();
                            worker.RunWorkerCompleted   += Worker_RunWorkerCompletedFA;
                            worker.WorkerReportsProgress = true;
                            worker.DoWork          += Worker_DoWorkFA;
                            worker.ProgressChanged += Worker_ProgressChangedFA;
                            worker.RunWorkerAsync();
                        }
                        catch (Exception ex)
                        {
                            if (ex.Message == "Obiekt dopuszczający wartość pustą musi mieć wartość.")
                            {
                                MessageBox.Show("Wybierz datę", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                            else
                            {
                                MessageBox.Show(ex.Message, "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Błędna ścieżka programu Hurt.", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
                lsb.Content = "Błędna ścieżka programu Hurt.";
            }
        }