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( "Trans2SummaHDA", //titleString " JA: Dette er en Hafsjold Data ApS anskaffelse.\nNEJ: Dette et vareforbrug.", //bigString null, //smallString "JA", //leftButton == OK "NEJ", //rightButton == Cancel global::Trans2SummaHDA.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(); } }
private void kontonrTextBox_TextChanged(object sender, EventArgs e) { int kontonr; if (int.TryParse(kontonrTextBox.Text, out kontonr)) { labelKontotekst.Text = KarKontoplan.getKontonavn(kontonr); } else { labelKontotekst.Text = "Konto findes ikke"; } }
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)); } } }
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(); }