private void ucLeverancierOpdracht_Load(object sender, EventArgs e)
 {
     txtID.Text           = miniopdracht.opdracht_id.ToString();
     txtPlaatsen.Text     = miniopdracht.aantal_personen.ToString();
     txtKlant.Text        = miniopdracht.klant.naam;
     txtKlantPlaats.Text  = KlantManagement.getAdresVanKlant(miniopdracht.klant.klant_id).plaats;
     dtVan.Value          = (DateTime)miniopdracht.vanaf_datum;
     dtTot.Value          = (DateTime)miniopdracht.tot_datum;
     txtVanUur.Text       = miniopdracht.vanaf_uur;
     txtTotUur.Text       = miniopdracht.tot_uur;
     txtOmschrijving.Text = miniopdracht.ritomschrijving;
     txtVetrekPlaats.Text = OpdrachtManagement.getVertrek(miniopdracht.opdracht_id).FullAdress;
     txtTerugPlaats.Text  = OpdrachtManagement.getBestemming(miniopdracht.opdracht_id).FullAdress;
 }
Beispiel #2
0
        private void ucChauffeurRit_Load(object sender, EventArgs e)
        {
            txtID.Text           = miniopdracht.opdracht_id.ToString();
            txtNummerplaat.Text  = "bla";
            txtVoertuigNr.Text   = "bli";
            txtKlant.Text        = miniopdracht.klant.naam;
            txtKlantPlaats.Text  = KlantManagement.getAdresVanKlant(miniopdracht.klant.klant_id).plaats;
            dtVan.Value          = (DateTime)miniopdracht.vanaf_datum;
            dtTot.Value          = (DateTime)miniopdracht.tot_datum;
            txtVanUur.Text       = miniopdracht.vanaf_uur;
            txtTotUur.Text       = miniopdracht.tot_uur;
            txtOmschrijving.Text = miniopdracht.ritomschrijving;

            txtVetrekPlaats.Text = (OpdrachtManagement.getVertrek(miniopdracht.opdracht_id) == null) ? "" : OpdrachtManagement.getVertrek(miniopdracht.opdracht_id).FullAdress;
            txtTerugPlaats.Text  = (OpdrachtManagement.getBestemming(miniopdracht.opdracht_id) == null)? "":OpdrachtManagement.getBestemming(miniopdracht.opdracht_id).FullAdress;
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            String  opdrachtenInhoud = "";
            decimal totalAmount      = 0;

            foreach (DataGridViewRow row in facturenGridView.Rows)
            {
                if ((Boolean)row.Cells[0].Value != false)
                {
                    int opdrachtID = 0;
                    if (!int.TryParse(row.Cells[1].Value.ToString(), out opdrachtID))
                    {
                        continue;
                    }
                    opdracht         op = OpdrachtManagement.getOpdracht(opdrachtID);
                    opdracht_factuur of = FactuurManagement.getFactuurVanOpdracht(op);
                    foreach (opdracht_factuur_detail ofd in FactuurManagement.getFactuurDetails(of))
                    {
                        opdrachtenInhoud += of.opdracht_id + "\t";
                        opdrachtenInhoud += ofd.omschrijving + "\t";
                        opdrachtenInhoud += ofd.bedrag_basis + "\t";
                        opdrachtenInhoud += ofd.btw_percent + "\t";
                        opdrachtenInhoud += ofd.btw_bedrag + "\t";
                        opdrachtenInhoud += ofd.bedrag_inclusief + "\t";
                        opdrachtenInhoud += System.Environment.NewLine;

                        totalAmount += ofd.bedrag_inclusief.Value;
                        FactuurNummering nummer = new FactuurNummering();
                        nummer.bedrijf      = opdracht.FactuurNummering.bedrijf;
                        nummer.FactuurNr    = opdracht.FactuurNummering.FactuurNr;
                        nummer.FactuurJaar  = opdracht.FactuurNummering.FactuurJaar;
                        op.FactuurNummering = nummer;
                        Backend.DataContext.dc.SubmitChanges();
                    }


                    //opdrachtenInhoud += row.Cells[1].Value + "\t" + row.Cells[2].Value + "\t" + row.Cells[4].Value + "\t" + row.Cells[5].Value + "\t€" + row.Cells[6].Value + System.Environment.NewLine;
                    //totalAmount += Convert.ToDouble(row.Cells[6].Value.ToString());
                }
            }

            if (totalAmount > 0)
            {
                locatie adres = KlantManagement.getAdresVanKlant(opdracht.klant.klant_id);

                //Convert date to acceptable format for use in file name
                String datum = DateTime.Today.ToString("yyyy-MM-dd");

                //missing oject to use with various word commands
                object missing = System.Reflection.Missing.Value;

                //the template file you will be using
                object fileToOpen = (object)@"R:\CarGo\opdracht_template.docx";

                //Where the new file will be saved to.
                object fileToSave = (object)@"R:\CarGo\opdrachten\opdracht_" + opdracht.klant.naam + "_" + datum + ".docx";

                //Create new instance of word and create a new document
                Word.Application wordApp = new Word.Application();
                Word.Document    doc     = null;

                //Properties for the new word document
                object readOnly  = false;
                object isVisible = false;

                //Settings the application to invisible, so the user doesn't notice that anything is going on
                wordApp.Visible = false;
                try
                {
                    try
                    {
                        File.Copy(fileToOpen.ToString(), fileToSave.ToString(), true);
                    }
                    catch
                    {
                        MessageBox.Show("Loading the template file failed.", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    readOnly = false;
                    doc      = wordApp.Documents.Open(ref fileToSave, ref missing,
                                                      ref readOnly, ref missing, ref missing, ref missing,
                                                      ref missing, ref missing, ref missing, ref missing,
                                                      ref missing, ref isVisible, ref missing, ref missing,
                                                      ref missing, ref missing);
                }
                catch { }



                PrintManagement.findAndReplace(doc, "factuurdatum", datum);
                PrintManagement.findAndReplace(doc, "factuurnummer", opdracht.FactuurNummering.FactuurNr + " " + opdracht.FactuurNummering.FactuurJaar);
                PrintManagement.findAndReplace(doc, "startOfDocument", opdrachtenInhoud);
                PrintManagement.findAndReplace(doc, "totaal", "Totaal: €" + totalAmount);
                Console.WriteLine(opdrachtenInhoud);

                doc.Save();
                doc.Activate();
                //Making word visible to be able to show the print preview.
                wordApp.Visible = true;
                wordApp.Activate();
                //doc.PrintPreview();
            }
            else
            {
                MessageBox.Show("Onvoldoende gegevens om factuur op te stellen. Kijk Detail Facturatie na", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
Beispiel #4
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            //opdracht ophalen
            opdracht opdracht = (opdracht)cbbID.SelectedItem;

            if (opdracht == null)
            {
                MainForm.updateStatus = "Er is geen factuur geselecteerd, selecteer een opdracht en probeer dan opnieuw.";
            }
            else
            {
                //adres ophalen van klant
                locatie adres = KlantManagement.getAdresVanKlant(opdracht.klant.klant_id);

                //Convert date to acceptable format for use in file name
                DateTime begindatum = (DateTime)dtPeriodeBegin2.Value;
                String   datum1     = begindatum.ToString("yyyy-MM-dd");

                DateTime einddatum = (DateTime)dtPeriodeEinde2.Value;
                String   datum2    = einddatum.ToString("yyyy-MM-dd");


                //missing oject to use with various word commands
                object missing = System.Reflection.Missing.Value;

                //the template file you will be using
                object fileToOpen = (object)@"R:\CarGo\factuur_contract_template.docx";

                //Where the new file will be saved to.
                object fileToSave = (object)@"R:\CarGo\contractfacturen\factuur_" + opdracht.klant.naam + "_" + datum1 + "-" + datum2 + ".docx";

                //Create new instance of word and create a new document
                Word.Application wordApp = new Word.Application();
                Word.Document    doc     = null;

                //Properties for the new word document
                object readOnly  = false;
                object isVisible = false;

                //Settings the application to invisible, so the user doesn't notice that anything is going on
                wordApp.Visible = false;

                try
                {
                    File.Copy(fileToOpen.ToString(), fileToSave.ToString(), true);
                }
                catch
                {
                    MainForm.updateStatus = "Kan nieuw document niet opslaan";
                    return;
                }
                doc = wordApp.Documents.Open(ref fileToSave, ref missing,
                                             ref readOnly, ref missing, ref missing, ref missing,
                                             ref missing, ref missing, ref missing, ref missing,
                                             ref missing, ref isVisible, ref missing, ref missing,
                                             ref missing, ref missing);



                //Search for bookmarks and replace them with the text you want
                PrintManagement.findAndReplace(doc, "naam_bedrijf", opdracht.klant.naam);
                PrintManagement.findAndReplace(doc, "straat_bedrijf", adres.straat);
                PrintManagement.findAndReplace(doc, "huisnummer_bedrijf", adres.nr);
                PrintManagement.findAndReplace(doc, "postcode_bedrijf", adres.postcode);
                PrintManagement.findAndReplace(doc, "gemeente_bedrijf", adres.plaats);
                PrintManagement.findAndReplace(doc, "id", opdracht.factuur_id_full);
                PrintManagement.findAndReplace(doc, "telefoon_klant", opdracht.klant.telefoon);
                PrintManagement.findAndReplace(doc, "fax_klant", opdracht.klant.fax);

                PrintManagement.findAndReplace(doc, "contractnummer", opdracht.contract_id_full);
                PrintManagement.findAndReplace(doc, "periode_begin1", datum1);
                PrintManagement.findAndReplace(doc, "periode_tot1", datum2);

                PrintManagement.findAndReplace(doc, "omschrijving", opdracht.ritomschrijving);
                PrintManagement.findAndReplace(doc, "vertrek", cbbVertrek.Text.ToString());
                PrintManagement.findAndReplace(doc, "bestemming", cbbBestemming.Text.ToString());
                PrintManagement.findAndReplace(doc, "aantal_plaatsen", opdracht.aantal_personen);
                PrintManagement.findAndReplace(doc, "opstap1", ContractManagement.getLocatie(opdracht.opdracht_id, "opstap_1").FullAdress);
                PrintManagement.findAndReplace(doc, "opstap2", ContractManagement.getLocatie(opdracht.opdracht_id, "opstap_1").FullAdress);
                PrintManagement.findAndReplace(doc, "dagprijs", opdracht.contract_dagprijs.ToString());
                PrintManagement.findAndReplace(doc, "saldo", txtPrijs.Text);

                ////Tabel invullen, lukte mij niet
                //Word.Tables tables = doc.Tables;
                //if (tables.Count > 0)
                //{
                //    //Eerste tabel eruit halen
                //    Word.Table table = tables[2];

                //    int rowsCount = table.Rows.Count;
                //    int coulmnsCount = table.Columns.Count;

                //    foreach (contract_rit rit in ContractManagement.getRitten(opdracht.opdracht_id))
                //    {
                //        Word.Row row = table.Rows.Add(ref missing);

                //        for (int j = 1; j <= coulmnsCount; j++)
                //        {
                //            row.Cells[j].Range.Text = string.Format("{0} : {1}", ofd.omschrijving, ofd.bedrag_inclusief.ToString());
                //            row.Cells[j].WordWrap = true;
                //            row.Cells[j].Range.Underline = Word.WdUnderline.wdUnderlineNone;
                //            row.Cells[j].Range.Bold = 0;
                //        }
                //    }
                //}

                //rest aan te vullen...


                doc.Save();
                doc.Activate();

                //Making word visible to be able to show the print preview.
                wordApp.Visible = true;

                //Close the document and the application (otherwise the process will keep running)

                /*doc.Close(ref missing, ref missing, ref missing);
                 * wordApp.Quit(ref missing, ref missing, ref missing);*/
            }
        }
Beispiel #5
0
        private void btnPrintCredit_Click(object sender, EventArgs e)
        {
            String  opdrachtenInhoud = "";
            decimal totalAmount      = 0;

            if (cbbID.SelectedItem == null)
            {
                return;
            }

            opdracht op = (opdracht)cbbID.SelectedItem;

            if (op.FactuurNummering1 == null)
            {
                return;
            }
            if (op.FactuurNummering1.FactuurJaar == null || op.FactuurNummering1.FactuurNr == null)
            {
                return;
            }

            opdracht_factuur of = FactuurManagement.getFactuurVanOpdracht(op);

            opdrachtenInhoud += of.opdracht_id + "\t";
            opdrachtenInhoud += of.credit_omschrijving + "\t";
            opdrachtenInhoud += of.credit_basis + "\t";
            opdrachtenInhoud += of.credit_btwpercent + "\t";
            opdrachtenInhoud += of.credit_btwbedrag + "\t";
            opdrachtenInhoud += of.credit_inc + "\t";
            opdrachtenInhoud += System.Environment.NewLine;

            totalAmount += of.credit_inc.Value;



            //opdrachtenInhoud += row.Cells[1].Value + "\t" + row.Cells[2].Value + "\t" + row.Cells[4].Value + "\t" + row.Cells[5].Value + "\t€" + row.Cells[6].Value + System.Environment.NewLine;
            //totalAmount += Convert.ToDouble(row.Cells[6].Value.ToString());


            if (totalAmount > 0)
            {
                locatie adres = KlantManagement.getAdresVanKlant(opdracht.klant.klant_id);

                //Convert date to acceptable format for use in file name
                String datum = DateTime.Today.ToString("yyyy-MM-dd");

                //missing oject to use with various word commands
                object missing = System.Reflection.Missing.Value;

                //the template file you will be using
                //object fileToOpen = (object)@"R:\CarGo\CreditNota_template.docx";
                object fileToOpen = (object)@"R:\CarGo\opdracht_template.docx";

                //Where the new file will be saved to.
                object fileToSave = (object)@"R:\CarGo\opdrachten\Credit_" + opdracht.klant.naam + "_" + datum + ".docx";

                //Create new instance of word and create a new document
                Word.Application wordApp = new Word.Application();
                Word.Document    doc     = null;

                //Properties for the new word document
                object readOnly  = false;
                object isVisible = false;

                //Settings the application to invisible, so the user doesn't notice that anything is going on
                wordApp.Visible = false;
                try
                {
                    try
                    {
                        File.Copy(fileToOpen.ToString(), fileToSave.ToString(), true);
                    }
                    catch
                    {
                        MessageBox.Show("Loading the template file failed.", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        return;
                    }

                    readOnly = false;
                    doc      = wordApp.Documents.Open(ref fileToSave, ref missing,
                                                      ref readOnly, ref missing, ref missing, ref missing,
                                                      ref missing, ref missing, ref missing, ref missing,
                                                      ref missing, ref isVisible, ref missing, ref missing,
                                                      ref missing, ref missing);
                }
                catch { }



                PrintManagement.findAndReplace(doc, "factuurdatum", datum);
                PrintManagement.findAndReplace(doc, "factuurnummer", opdracht.FactuurNummering1.FactuurNr + " " + opdracht.FactuurNummering1.FactuurJaar);
                PrintManagement.findAndReplace(doc, "startOfDocument", opdrachtenInhoud);
                PrintManagement.findAndReplace(doc, "totaal", "Totaal: €" + totalAmount);
                Console.WriteLine(opdrachtenInhoud);

                doc.Save();
                doc.Activate();
                //Making word visible to be able to show the print preview.
                wordApp.Visible = true;
                wordApp.Activate();
                //doc.PrintPreview();
            }
            else
            {
                MessageBox.Show("Credit bedrag moet groter dan 0 zijn.", "Important Note", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
            }
        }
Beispiel #6
0
        //Juiste klant selecteren en het formulier invullen met de juiste gegevens
        private void cbbID_SelectedIndexChanged(object sender, EventArgs e)
        {
            btnOpslaan.Enabled = true;

            btnNieuw.Enabled     = true;
            btnVerwijder.Enabled = true;

            klant klant = new klant();

            klant = (klant)cbbID.SelectedItem;

            emptyFields();
            enableFields();
            btnOpslaan.Name = "btnOpslaan";

            txtNaam.Text  = klant.naam;
            cbbTitel.Text = klant.titel;
            cbbActiviteit.SelectedText = klant.activiteit.ToString();
            txtVerantwoordelijke.Text  = klant.verantwoordelijke;


            cbbAdres.DataSource    = LocatieManagement.getLocaties();
            cbbAdres.SelectedItem  = KlantManagement.getAdresVanKlant(klant.klant_id);
            cbbAdres.DisplayMember = "FullAdress";
            cbbAdres.ValueMember   = "locatie_id";

            txtTelefoon.Text = klant.telefoon;
            txtGsm.Text      = klant.gsm;
            txtFax.Text      = klant.fax;
            txtEmail.Text    = klant.email;

            txtBTW.Text                = klant.btw_nummer;
            txtKorting.Text            = klant.korting.ToString();
            txtVervaldagenOfferte.Text = klant.vervaldagen_offerte;
            txtVervalDagenFactuur.Text = klant.vervaldagen_factuur;
            txtAantalFacturen.Text     = klant.aantal_facturen.ToString();
            txtMemo.Text               = klant.memo;

            flpOpstapplaats.Controls.Clear();

            IEnumerable <locatie> opstapPlaatsen = OpstapplaatsManagement.getOpstapplaatsen(klant.klant_id);

            foreach (locatie opstapplaats in opstapPlaatsen)
            {
                if (opstapPlaatsen.Count() <= 0)
                {
                }
                else
                {
                    ComboBox cbbOpstap = new ComboBox();

                    cbbOpstap.Width  = 200;
                    cbbOpstap.Height = 20;

                    flpOpstapplaats.Controls.Add(cbbOpstap);

                    cbbOpstap.ValueMember   = "locatie_id";
                    cbbOpstap.DisplayMember = "FullAdress";
                    cbbOpstap.DataSource    = LocatieManagement.getLocaties();

                    cbbOpstap.SelectedValue = opstapplaats.locatie_id;
                    cbbOpstap.SelectedItem  = opstapplaats;
                }
            }

            MainForm.updateStatus = "Klant: " + klant.naam + ", is succesvol geladen";
        }