Zbiór zmian 479 dla trunk/TruckExpoCDN/ExpoToCDNExport.cs
- Data:
- 2009-03-24 12:01:24 (17 years ago)
- Pliki:
-
- 1 zmodyfikowane
-
trunk/TruckExpoCDN/ExpoToCDNExport.cs (zmodyfikowane) (25 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
trunk/TruckExpoCDN/ExpoToCDNExport.cs
r427 r479 1 1 using System; 2 using System.Collections.Generic;3 using System.Data;4 2 using System.Data.SqlClient; 5 using System.Text;6 3 using System.Text.RegularExpressions; 7 8 4 9 5 namespace ExportFaktur … … 12 8 { 13 9 14 #region Fields (3) 10 #region Fields (3) 15 11 16 12 public CDNDataSet CDNDataset; 17 SqlConnection CDN_conn = new SqlConnection(ConnString.getConnString().CdnExpoConnStr); 18 SqlConnection truck_expo_conn = new SqlConnection(ConnString.getConnString().TruckExpoConnStr); 19 20 #endregion Fields 21 22 #region Methods (10) 23 24 25 // Public Methods (10) 13 readonly SqlConnection CDN_conn = new SqlConnection(ConnString.CDNConnection); 14 15 #endregion Fields 16 17 #region Methods (10) 18 19 20 // Public Methods (10) 26 21 27 22 public void DodajElementyFaktury(EXPODataSet.FAKTURA_DETAILSDataTable table, CDNDataSet.TraNagRow naglowekFaktury) … … 57 52 { 58 53 pozycjaFaktury.TrE_KatID = naglowek.TrN_KatID; 59 } 60 54 } 55 61 56 pozycjaFaktury.TrE_TwrId = 1; 62 57 pozycjaFaktury.TrE_TwrNazwa = row.NAZWA_USLUGI + " " + row.MIESIAC + "/" + row.ROK; … … 73 68 74 69 pozycjaFaktury.TrE_CenaT = row.NETTO; //Math.Abs(rsdet("netto")); 75 // pozycjaFaktury.TrE_CenaT = row.CENA_JEDN; //Math.Abs(rsdet("netto"));70 // pozycjaFaktury.TrE_CenaT = row.CENA_JEDN; //Math.Abs(rsdet("netto")); 76 71 77 72 78 73 pozycjaFaktury.TrE_Cena0 = row.NETTO; //Math.Abs(netto); 79 74 //pozycjaFaktury.TrE_Cena0 = row.CENA_JEDN; //Math.Abs(netto); 80 pozycjaFaktury.TrE_Rabat = (decimal)row.UPUST_PR *100;81 // pozycjaFaktury.TrE_Rabat = 0;75 pozycjaFaktury.TrE_Rabat = (decimal)row.UPUST_PR * 100; 76 // pozycjaFaktury.TrE_Rabat = 0; 82 77 pozycjaFaktury.TrE_CenaW = row.NETTO; //Math.Abs(netto); 83 84 78 79 85 80 /* 86 81 * if rsdet("netto")<0 then … … 166 161 public void DodajKlienta(EXPODataSet.KLIENCIRow klient) 167 162 { 168 CDNDataSetTableAdapters.KontrahenciTableAdapter adapter = new ExportFaktur.CDNDataSetTableAdapters.KontrahenciTableAdapter();163 CDNDataSetTableAdapters.KontrahenciTableAdapter adapter = new CDNDataSetTableAdapters.KontrahenciTableAdapter(); 169 164 adapter.Connection = CDN_conn; 170 165 171 adapter.FillByKnt_Kod( this.CDNDataset.Kontrahenci, klient.CustomerID.ToString());166 adapter.FillByKnt_Kod(CDNDataset.Kontrahenci, klient.CustomerID.ToString()); 172 167 173 168 bool klientIstnieje; 174 169 CDNDataSet.KontrahenciRow kontrahent; 175 170 176 if ( this.CDNDataset.Kontrahenci.Count == 0)171 if (CDNDataset.Kontrahenci.Count == 0) 177 172 { 178 173 klientIstnieje = false; 179 kontrahent = (CDNDataSet.KontrahenciRow) this.CDNDataset.Kontrahenci.NewRow();174 kontrahent = (CDNDataSet.KontrahenciRow)CDNDataset.Kontrahenci.NewRow(); 180 175 } 181 176 else 182 177 { 183 178 klientIstnieje = true; 184 kontrahent = this.CDNDataset.Kontrahenci[0];179 kontrahent = CDNDataset.Kontrahenci[0]; 185 180 } 186 181 … … 194 189 kontrahent.Knt_Nazwa2 = klient.IsLastNameNull() ? "" : klient.LastName; 195 190 kontrahent.Knt_Nazwa3 = klient.IsOrganizationNameNull() ? "" : klient.OrganizationName; 196 191 197 192 string kraj = ""; 198 193 if (!klient.IsCountryNull()) … … 200 195 kraj = (klient.Country.Length > 40) ? klient.Country.Substring(0, 40) : klient.Country; 201 196 } 202 197 203 198 kontrahent.Knt_Kraj = kraj; 204 199 … … 231 226 kontrahent.Knt_Miasto = miasto; 232 227 kontrahent.Knt_Poczta = miasto; 233 228 234 229 string kodPocztowy = ""; 235 230 if (!klient.IsPostalCodeNull()) … … 238 233 } 239 234 kontrahent.Knt_KodPocztowy = kodPocztowy; 240 235 241 236 kontrahent.Knt_Adres2 = ""; 242 237 243 238 if (!klient.IsNipNull()) 244 239 { 245 // kontrahent.Knt_NipKraj = PodajKrajNIP(klient.Nip);246 // kontrahent.Knt_NipE = PodajNumerNIP(klient.Nip);247 // kontrahent.Knt_Nip = PodajNumerNIP(klient.Nip);240 // kontrahent.Knt_NipKraj = PodajKrajNIP(klient.Nip); 241 // kontrahent.Knt_NipE = PodajNumerNIP(klient.Nip); 242 // kontrahent.Knt_Nip = PodajNumerNIP(klient.Nip); 248 243 if (klient.nipKraj == "" && klient.Country.Trim() == "Polska") 249 244 { … … 258 253 259 254 kontrahent.Knt_NipE = klient.Nip.Length > 13 ? klient.Nip.Substring(0, 13) : klient.Nip; 260 kontrahent.Knt_Nip = klient.Nip.Length > 13 ? klient.Nip.Substring(0, 13) : klient.Nip;261 255 kontrahent.Knt_Nip = klient.Nip.Length > 13 ? klient.Nip.Substring(0, 13) : klient.Nip; 256 262 257 } 263 258 else … … 281 276 } 282 277 kontrahent.Knt_Email = email; 283 278 284 279 kontrahent.Knt_URL = ""; 285 280 286 281 287 282 if (!klientIstnieje) … … 373 368 if (!klientIstnieje) 374 369 { 375 this.CDNDataset.Kontrahenci.AddKontrahenciRow(kontrahent);370 CDNDataset.Kontrahenci.AddKontrahenciRow(kontrahent); 376 371 } 377 372 … … 381 376 { 382 377 383 CDNDataSet.TraNagRow nowaFaktura = (CDNDataSet.TraNagRow) this.CDNDataset.TraNag.NewRow();378 CDNDataSet.TraNagRow nowaFaktura = (CDNDataSet.TraNagRow)CDNDataset.TraNag.NewRow(); 384 379 385 380 //!!!!!!!!!!!!!!! 386 381 //nowaFaktura.TrN_DDfId = 1; 387 382 388 CDNDataSetTableAdapters.DokDefinicjeTableAdapter adapter = new ExportFaktur.CDNDataSetTableAdapters.DokDefinicjeTableAdapter();383 CDNDataSetTableAdapters.DokDefinicjeTableAdapter adapter = new CDNDataSetTableAdapters.DokDefinicjeTableAdapter(); 389 384 adapter.Connection = CDN_conn; 390 385 … … 394 389 nowaFaktura.TrN_TypDokumentu = 302; 395 390 396 nowaFaktura.TrN_NumerNr = Int32.Parse(EXPOfaktura.NUMER);391 nowaFaktura.TrN_NumerNr = EXPOfaktura.NUMER; 397 392 nowaFaktura.TrN_NumerString = "@numerS" + "/" + EXPOfaktura.NUMER_ROZ + "/" + EXPOfaktura.NUMER_ROK; //numerstring' @P4 varchar(13) '@numer/O/2007' 398 393 … … 408 403 nowaFaktura.TrN_Korekta = 1; 409 404 nowaFaktura.TrN_Rodzaj = 302001; 410 int idkorekty = 0;405 const int idkorekty = 0; 411 406 nowaFaktura.TrN_ZwrId = idkorekty; 412 407 } … … 487 482 nowaFaktura.TrN_RazemNetto = sumaNETTO; 488 483 nowaFaktura.TrN_RazemVAT = VAT * sumaNETTO; 489 nowaFaktura.TrN_RazemBrutto = ( decimal)((1 + VAT) * nowaFaktura.TrN_RazemNetto);484 nowaFaktura.TrN_RazemBrutto = (1 + VAT) * nowaFaktura.TrN_RazemNetto; 490 485 nowaFaktura.TrN_BlokadaPlatnosci = 0; 491 486 nowaFaktura.TrN_MagZrdId = 1; 492 487 nowaFaktura.TrN_TypNB = 1; 493 488 nowaFaktura.TrN_Rabat = rabatProcent * 100; 494 //nowaFaktura.TrN_Rabat = 0; 495 496 497 if (EXPOfaktura.IsPODPIS_ODEBRALNull()) 498 { 499 nowaFaktura.TrN_Odebral = "zgodnie z owiadczeniem nabywcy"; 500 } 501 else 502 { 503 nowaFaktura.TrN_Odebral = EXPOfaktura.PODPIS_ODEBRAL; 504 } 489 //nowaFaktura.TrN_Rabat = 0; 490 491 492 nowaFaktura.TrN_Odebral = EXPOfaktura.IsPODPIS_ODEBRALNull() ? "zgodnie z owiadczeniem nabywcy" : EXPOfaktura.PODPIS_ODEBRAL; 505 493 506 494 nowaFaktura.TrN_Opis = EXPOfaktura.opis; … … 525 513 nowaFaktura.TrN_PlatElemWalSys = 0; 526 514 527 nowaFaktura.TrN_RazemVATWal = VAT *100;528 nowaFaktura.TrN_RazemBruttoWal = ( decimal)((1 + VAT) * nowaFaktura.TrN_RazemNetto);515 nowaFaktura.TrN_RazemVATWal = VAT * 100; 516 nowaFaktura.TrN_RazemBruttoWal = (1 + VAT) * nowaFaktura.TrN_RazemNetto; 529 517 nowaFaktura.TrN_StaZalId = 1; 530 518 nowaFaktura.TrN_StaModId = 1; … … 547 535 nowaFaktura.TrN_Export = 7; 548 536 nowaFaktura.TrN_WartoscZakupu = 0; 549 nowaFaktura.TrN_RazemVATWal = VAT * 100; 537 nowaFaktura.TrN_RazemVATWal = VAT * 100; 550 538 nowaFaktura.TrN_RazemBruttoWal = (decimal)EXPOfaktura.waluta_brutto; 551 539 nowaFaktura.TrN_RazemNettoWal = ((decimal)EXPOfaktura.waluta_brutto / (1 + VAT)); 552 nowaFaktura.TrN_Waluta = EXPOfaktura.Iswaluta_mianoNull() ? "" : EXPOfaktura.waluta_miano;553 nowaFaktura.TrN_KursL = EXPOfaktura.Iswaluta_kursNull() ? 1M : (decimal)EXPOfaktura.waluta_kurs;540 nowaFaktura.TrN_Waluta = EXPOfaktura.Iswaluta_mianoNull() ? "" : EXPOfaktura.waluta_miano; 541 nowaFaktura.TrN_KursL = EXPOfaktura.Iswaluta_kursNull() ? 1M : (decimal)EXPOfaktura.waluta_kurs; 554 542 nowaFaktura.TrN_KursM = 1; 555 543 nowaFaktura.TrN_KursNumer = 1; 556 544 } 557 545 558 this.CDNDataset.TraNag.AddTraNagRow(nowaFaktura);546 CDNDataset.TraNag.AddTraNagRow(nowaFaktura); 559 547 560 548 } … … 562 550 public void DodajVAT(CDNDataSet.TraNagRow naglowekFaktury, decimal sumaNetto, decimal stawkaVAT) 563 551 { 564 CDNDataSet.TraVatRow nowyVat = (CDNDataSet.TraVatRow) this.CDNDataset.TraVat.NewRow();552 CDNDataSet.TraVatRow nowyVat = (CDNDataSet.TraVatRow)CDNDataset.TraVat.NewRow(); 565 553 566 554 nowyVat.TrV_TrNID = naglowekFaktury.TrN_TrNID; … … 578 566 nowyVat.TrV_Flaga = 4; 579 567 nowyVat.TrV_VATWal = naglowekFaktury.TrN_RazemBruttoWal - naglowekFaktury.TrN_RazemNettoWal; 580 nowyVat.TrV_NettoWal = naglowekFaktury.TrN_RazemNettoWal; 581 } 582 583 this.CDNDataset.TraVat.AddTraVatRow(nowyVat);568 nowyVat.TrV_NettoWal = naglowekFaktury.TrN_RazemNettoWal; 569 } 570 571 CDNDataset.TraVat.AddTraVatRow(nowyVat); 584 572 } 585 573 … … 631 619 return 124; 632 620 case 5: 633 return 125; 621 return 125; 634 622 } 635 623 break; … … 647 635 return "PL"; 648 636 } 649 else 650 { 651 if ((nip.Length >= 2) && (!isNumeric(nip.Substring(0, 2)))) 652 { 653 return nip.Substring(0, 2); 654 } 655 else 656 { 657 return ""; 658 } 659 660 } 637 if ((nip.Length >= 2) && (!isNumeric(nip.Substring(0, 2)))) 638 { 639 return nip.Substring(0, 2); 640 } 641 642 return ""; 661 643 } 662 644 … … 664 646 { 665 647 string nip = NIP.Replace(" ", "").Replace("-", "").Trim(); 666 648 667 649 if (polskiNIP(nip)) 668 650 { 669 651 return nip.Length > 13 ? nip.Substring(0, 13) : nip; 670 652 } 671 else 672 { 673 if ((nip.Length >= 2) && (!isNumeric(nip.Substring(0, 2)))) 674 { 675 return nip.Length > 15 ? nip.Substring(2, 13) : nip.Substring(2, nip.Length - 2); 676 } 677 else 678 { 679 return nip.Length > 13 ? nip.Substring(0, 13) : nip; 680 } 681 682 } 653 if ((nip.Length >= 2) && (!isNumeric(nip.Substring(0, 2)))) 654 { 655 return nip.Length > 15 ? nip.Substring(2, 13) : nip.Substring(2, nip.Length - 2); 656 } 657 return nip.Length > 13 ? nip.Substring(0, 13) : nip; 683 658 } 684 659 685 660 public bool polskiNIP(string nip) 686 661 { 687 int[] wagi = new int[] {6,5,7,2,3,4,5,6,7}; 688 689 string shortNIP; 690 int suma, iloczyn, kontrolny; 691 suma=0; 692 kontrolny=0; 693 shortNIP = nip.Replace(" ", "").Replace("-", "").Trim(); 662 int[] wagi = new int[] { 6, 5, 7, 2, 3, 4, 5, 6, 7 }; 663 664 int suma = 0; 665 string shortNIP = nip.Replace(" ", "").Replace("-", "").Trim(); 694 666 695 667 if ((shortNIP.Length == 10) && isNumeric(shortNIP)) … … 698 670 for (int i = 0; i <= 8; i++) 699 671 { 700 i loczyn = Convert.ToInt32(shortNIP.Substring(i, 1)) * wagi[i];672 int iloczyn = Convert.ToInt32(shortNIP.Substring(i, 1)) * wagi[i]; 701 673 suma = suma + iloczyn; 702 674 } 703 kontrolny = suma % 11;675 int kontrolny = suma % 11; 704 676 705 677 if (kontrolny == Convert.ToInt32(shortNIP.Substring(shortNIP.Length - 1, 1))) … … 712 684 713 685 714 #endregion Methods 686 #endregion Methods 715 687 716 688 }
