Example #1
0
        private void Copy2NyFakturaToolStripButton_Click(object sender, EventArgs e)
        {
            bool bVareforbrug = true;
            tblactebisfaktura recActebisfaktura = bsTblactebisfaktura.Current as tblactebisfaktura;

            if (recActebisfaktura.leveringsadresse.ToUpper().Contains("HAFSJOLD"))
            {
                DialogResult result = DotNetPerls.BetterDialog.ShowDialog(
                    "Trans2Summa3060",                                                             //titleString
                    " JA: Dette er en Hafsjold Data ApS anskaffelse.\nNEJ: Dette et vareforbrug.", //bigString
                    null,                                                                          //smallString
                    "JA",                                                                          //leftButton == OK
                    "NEJ",                                                                         //rightButton == Cancel
                    global::Trans2Summa3060.Properties.Resources.Message_info);                    //iconSet

                if (result == DialogResult.OK)
                {
                    bVareforbrug = false;
                }
            }
            tblwfak recWfak = new tblwfak
            {
                sk               = "K",
                dato             = recActebisfaktura.ordredato,
                konto            = 200064,
                kreditorbilagsnr = recActebisfaktura.fakturanr
            };

            foreach (tblactebisordre recActebisordre in recActebisfaktura.tblactebisordres)
            {
                tblwfaklin recWfaklin = new tblwfaklin
                {
                    antal      = recActebisordre.antal,
                    enhed      = "stk",
                    pris       = recActebisordre.stkpris,
                    varenr     = recActebisordre.varenr.ToString(),
                    nettobelob = recActebisordre.antal * recActebisordre.stkpris,
                    tekst      = getVaretekst(recActebisfaktura, recActebisordre, bVareforbrug),
                    konto      = getVarenrKonto(recActebisordre.varenr, bVareforbrug),
                    momskode   = KarKontoplan.getMomskode(getVarenrKonto(recActebisordre.varenr, bVareforbrug))
                };
                recWfak.tblwfaklins.Add(recWfaklin);
            }

            FrmMain frmMain = this.ParentForm as FrmMain;

            try
            {
                FrmNyfaktura frmNyfaktura = frmMain.GetChild("Ny faktura") as FrmNyfaktura;
                frmNyfaktura.AddNyActebisFaktura(recWfak);
            }
            catch
            {
                Program.dbDataTransSumma.tblwfaks.InsertOnSubmit(recWfak);
                Program.dbDataTransSumma.SubmitChanges();
            }
        }
Example #2
0
 private void tblwfaklinDataGridView1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         DataGridView.HitTestInfo hit = tblwfaklinDataGridView.HitTest(e.X, e.Y);
         int hitcol = hit.ColumnIndex;
         if (hit.Type == DataGridViewHitTestType.Cell && hit.ColumnIndex == 2)
         {
             tblwfaklinDataGridView.ClearSelection();
             DataGridViewCell cellVarenr = tblwfaklinDataGridView.Rows[hit.RowIndex].Cells[hit.ColumnIndex];
             cellVarenr.Selected = true;
             Point       startPoint    = tblwfaklinDataGridView.PointToScreen(new Point(e.X, e.Y));
             FrmVareList m_frmVareList = new FrmVareList(startPoint);
             m_frmVareList.ShowDialog();
             int?selectedVarenr = m_frmVareList.SelectedVarenr;
             m_frmVareList.Close();
             if (selectedVarenr != null)
             {
                 tblwfak    recWfak    = tblwfakBindingSource.Current as tblwfak;
                 tblwfaklin recWfaklin = ((DataGridView)sender).Rows[hit.RowIndex].DataBoundItem as tblwfaklin;
                 if (recWfaklin != null)
                 {
                     try
                     {
                         recVarer rec = (from k in Program.karVarer where k.Varenr == selectedVarenr select k).First();
                         recWfaklin.varenr = rec.Varenr.ToString();
                         recWfaklin.tekst  = rec.Varenavn;
                         recWfaklin.enhed  = rec.Enhed;
                         if (recWfak.sk == "S")
                         {
                             recWfaklin.konto    = rec.Salgskonto;
                             recWfaklin.momskode = KarKontoplan.getMomskode(rec.Salgskonto);
                             recWfaklin.pris     = rec.Salgspris;
                         }
                         if (recWfak.sk == "K")
                         {
                             recWfaklin.konto    = rec.Kobskonto;
                             recWfaklin.momskode = KarKontoplan.getMomskode(rec.Kobskonto);
                             recWfaklin.pris     = rec.Kobspris;
                         }
                     }
                     catch { }
                 }
             }
         }
         else if (hit.Type == DataGridViewHitTestType.Cell && hit.ColumnIndex == 4)
         {
             tblwfaklinDataGridView.ClearSelection();
             tblwfaklinDataGridView.Rows[hit.RowIndex].Cells[hit.ColumnIndex].Selected = true;
             Point            startPoint         = tblwfaklinDataGridView.PointToScreen(new Point(e.X, e.Y));
             FrmKontoplanList m_frmKontoplanList = new FrmKontoplanList(startPoint, KontoType.Drift | KontoType.Status);
             m_frmKontoplanList.ShowDialog();
             int?   selectedKontonr  = m_frmKontoplanList.SelectedKontonr;
             string selectedMomskode = m_frmKontoplanList.SelectedMomskode;
             m_frmKontoplanList.Close();
             if (selectedKontonr != null)
             {
                 tblwfaklin recWfaklin = ((DataGridView)sender).Rows[hit.RowIndex].DataBoundItem as tblwfaklin;
                 if (recWfaklin != null)
                 {
                     recWfaklin.konto    = selectedKontonr;
                     recWfaklin.momskode = selectedMomskode;
                 }
             }
         }
         else if (hit.Type == DataGridViewHitTestType.RowHeader)
         {
             this.contextMenuLineCopyPaste.Show(this.tblwfaklinDataGridView, new Point(e.X, e.Y));
         }
     }
 }
Example #3
0
        public void InsertKøbsfakturaer()
        {
            int?lastFakid = null;
            CreditorOrderClient recOrder = null;

            var rec_regnskab = Program.qryAktivRegnskab();
            var qryKFak      = from kfv in Program.karFakturavarer_k
                               join kf in Program.karFakturaer_k on new { fakid = kfv.Fakid } equals new { fakid = kf.fakid }
            where kf.faknr != 0 && kf.faktype == 2
            orderby kfv.Fakid, kfv.Line
                select new
            {
                Regnskabid  = rec_regnskab.Rid,
                Sk          = "K",
                Fakid       = kfv.Fakid,
                Faknr       = kf.faknr,
                Dato        = kf.dato,
                kreditornr  = kf.kreditornr,
                Faklinnr    = kfv.Line,
                Varenr      = kfv.Varenr,
                Tekst       = kfv.VareTekst,
                Konto       = kfv.Bogfkonto,
                Momskode    = KarKontoplan.getMomskode(kfv.Bogfkonto),
                Antal       = kfv.Antal,
                Enhed       = kfv.Enhed,
                Pris        = kfv.Pris,
                Rabat       = kfv.Rabat,
                Moms        = kfv.Moms,
                Nettobelob  = kfv.Nettobelob,
                Bruttobelob = kfv.Bruttobelob,
            };

            int antal = qryKFak.Count();

            var api = UCInitializer.GetBaseAPI;

            //var col3 = await api.Query<CreditorOrderClient>();
            //var col4 = await api.Query<CreditorOrderLineClient>();

            foreach (var k in qryKFak)
            {
                if ((!(k.Fakid == 0)) && (lastFakid != k.Fakid))
                {
                    try
                    {
                        var crit = new List <PropValuePair>();
                        var pair = PropValuePair.GenereteWhereElements("OrderNumber", typeof(int), k.Fakid.ToString());
                        crit.Add(pair);
                        var taskCreditorOrder = api.Query <CreditorOrderClient>(null, crit);
                        taskCreditorOrder.Wait();
                        var col = taskCreditorOrder.Result;
                        if (col.Count() == 0)
                        {
                            recOrder = new CreditorOrderClient()
                            {
                                OrderNumber  = k.Fakid,
                                Account      = k.kreditornr.ToString(),
                                InvoiceDate  = k.Dato,
                                DeliveryDate = k.Dato,
                            };
                            var taskInsertCreditorOrder = api.Insert(recOrder);
                            taskInsertCreditorOrder.Wait();
                            var err = taskInsertCreditorOrder.Result;
                        }
                        else
                        {
                            recOrder = col[0];
                        }
                    }
                    catch { }
                }

                CreditorOrderLineClient recOrderLine = new CreditorOrderLineClient()
                {
                    Text           = k.Tekst,
                    Qty            = (double)k.Antal,
                    Price          = (double)k.Pris,
                    PostingAccount = KarNyKontoplan.NytKontonr(k.Konto)
                };
                recOrderLine.SetMaster(recOrder);
                var taskInsertCreditorOrderLine = api.Insert(recOrderLine);
                taskInsertCreditorOrderLine.Wait();
                var err1 = taskInsertCreditorOrderLine.Result;
            }
        }
Example #4
0
        public void ImportSalgsfakturaer()
        {
            int?   lastFakid    = null;
            tblfak recFak       = null;
            var    rec_regnskab = Program.qryAktivRegnskab();
            var    qrySFak      = from sfv in Program.karFakturavarer_s
                                  join sf in Program.karFakturaer_s on new { fakid = sfv.Fakid } equals new { fakid = sf.fakid }
            where sf.faknr != 0 && sf.faktype == 0
            join fl in Program.dbDataTransSumma.tblfaklins
            on new
            {
                regnskabsid = (int?)rec_regnskab.Rid,
                fakid       = (int?)sfv.Fakid,
                sk          = "S",
                line        = (int?)sfv.Line
            }
            equals new
            {
                regnskabsid = fl.regnskabid,
                fakid       = fl.fakid,
                sk          = fl.sk,
                line        = fl.faklinnr
            }
            into tblfaklin
            from fl in tblfaklin.DefaultIfEmpty(new tblfaklin {
                pid = 0, fakpid = 0, regnskabid = null
            })
            where fl.pid == 0
            orderby sfv.Fakid, sfv.Line
                   select new
            {
                Regnskabid  = rec_regnskab.Rid,
                Sk          = "S",
                Fakid       = sfv.Fakid,
                Faknr       = sf.faknr,
                Dato        = sf.dato,
                debitornr   = sf.debitornr,
                Faklinnr    = sfv.Line,
                Varenr      = sfv.Varenr,
                Tekst       = sfv.VareTekst,
                Konto       = sfv.Bogfkonto,
                Momskode    = KarKontoplan.getMomskode(sfv.Bogfkonto),
                Antal       = sfv.Antal,
                Enhed       = sfv.Enhed,
                Pris        = sfv.Pris,
                Rabat       = sfv.Rabat,
                Moms        = sfv.Moms,
                Nettobelob  = sfv.Nettobelob,
                Bruttobelob = sfv.Bruttobelob,
            };

            int antal = qrySFak.Count();

            foreach (var s in qrySFak)
            {
                if ((!(s.Fakid == 0)) && (lastFakid != s.Fakid))
                {
                    try
                    {
                        recFak = (from f in Program.dbDataTransSumma.tblfaks
                                  where f.regnskabid == rec_regnskab.Rid && f.sk == "S" && f.fakid == s.Fakid
                                  select f).First();
                    }
                    catch
                    {
                        recFak = new tblfak
                        {
                            udskriv    = true,
                            regnskabid = s.Regnskabid,
                            sk         = s.Sk,
                            fakid      = s.Fakid,
                            faknr      = s.Faknr,
                            dato       = s.Dato,
                            konto      = s.debitornr
                        };
                        Program.dbDataTransSumma.tblfaks.InsertOnSubmit(recFak);
                    }
                }


                tblfaklin recFaklin = new tblfaklin
                {
                    sk          = s.Sk,
                    regnskabid  = s.Regnskabid,
                    fakid       = s.Fakid,
                    faklinnr    = s.Faklinnr,
                    varenr      = s.Varenr.ToString(),
                    tekst       = s.Tekst,
                    konto       = s.Konto,
                    momskode    = s.Momskode,
                    antal       = s.Antal,
                    enhed       = s.Enhed,
                    pris        = s.Pris,
                    rabat       = s.Rabat,
                    moms        = s.Moms,
                    nettobelob  = s.Nettobelob,
                    bruttobelob = s.Bruttobelob
                };
                Program.dbDataTransSumma.tblfaklins.InsertOnSubmit(recFaklin);
                if (!(s.Fakid == 0))
                {
                    recFak.tblfaklins.Add(recFaklin);
                }
                lastFakid = s.Fakid;
            }
            Program.dbDataTransSumma.SubmitChanges();
        }