Пример #1
0
        private void tbldocDataGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                DataGridViewRow selectedRow = tbldocDataGridView.Rows[e.RowIndex];
                tbldoc          selectedrow = selectedRow.DataBoundItem as tbldoc;

                var qry = from doc in dblite.tbldoc
                          where doc.id == selectedrow.id
                          join data in dblite.tblData on doc.id equals data.id
                          select new
                {
                    Id        = doc.id,
                    kilde_sti = doc.kilde_sti,
                    Data      = data.data
                };

                foreach (var rec in qry)
                {
                    FileInfo fi   = new FileInfo(rec.kilde_sti);
                    var      Ext  = fi.Extension;
                    var      Name = fi.Name;

                    if (Ext.ToLower() == ".pdf")
                    {
                        byte[] bytes = rec.Data;
                        m_frmIE = new frmIE();
                        m_frmIE.WebBrowser1.LoadBytes(bytes, MediaTypeNames.Application.Pdf);
                        m_frmIE.Show();
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Create a new tbldoc object.
        /// </summary>
        /// <param name="id">Initial value of the id property.</param>
        public static tbldoc Createtbldoc(global::System.Guid id)
        {
            tbldoc tbldoc = new tbldoc();

            tbldoc.id = id;
            return(tbldoc);
        }
Пример #3
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection cells = tbldocDataGridView.SelectedCells;

            if (cells.Count > 0)
            {
                try
                {
                    DataGridViewTextBoxCell cell = cells[0] as DataGridViewTextBoxCell;
                    tbldoc    rec_doc_view       = cell.OwningRow.DataBoundItem as tbldoc;
                    frmAddDoc m_frmAddDoc        = new frmAddDoc();
                    m_frmAddDoc.Ref_nr        = (int)rec_doc_view.ref_nr;
                    m_frmAddDoc.Dokument      = rec_doc_view.kilde_sti;
                    m_frmAddDoc.Virksomhed    = rec_doc_view.virksomhed;
                    m_frmAddDoc.Emne          = rec_doc_view.emne;
                    m_frmAddDoc.Dokument_type = rec_doc_view.dokument_type;
                    m_frmAddDoc.År            = (int)rec_doc_view.år;
                    m_frmAddDoc.Ekstern_kilde = rec_doc_view.ekstern_kilde;
                    m_frmAddDoc.Beskrivelse   = rec_doc_view.beskrivelse;
                    m_frmAddDoc.Oprettet_af   = rec_doc_view.oprettes_af;
                    m_frmAddDoc.Oprettet_dato = (DateTime)rec_doc_view.oprettet_dato;
                    m_frmAddDoc.Opret         = false;
                    DialogResult Result = m_frmAddDoc.ShowDialog();
                    if (Result == System.Windows.Forms.DialogResult.OK)
                    {
                        tbldoc rec_doc_db = null;
                        try
                        {
                            rec_doc_db = (from doc in dblite.tbldoc where doc.id == rec_doc_view.id select doc).First();

                            rec_doc_db.virksomhed    = m_frmAddDoc.Virksomhed;
                            rec_doc_db.emne          = m_frmAddDoc.Emne;
                            rec_doc_db.dokument_type = m_frmAddDoc.Dokument_type;
                            rec_doc_db.år            = m_frmAddDoc.År;
                            rec_doc_db.ekstern_kilde = m_frmAddDoc.Ekstern_kilde;
                            rec_doc_db.beskrivelse   = m_frmAddDoc.Beskrivelse;

                            rec_doc_view.virksomhed    = m_frmAddDoc.Virksomhed;
                            rec_doc_view.emne          = m_frmAddDoc.Emne;
                            rec_doc_view.dokument_type = m_frmAddDoc.Dokument_type;
                            rec_doc_view.år            = m_frmAddDoc.År;
                            rec_doc_view.ekstern_kilde = m_frmAddDoc.Ekstern_kilde;
                            rec_doc_view.beskrivelse   = m_frmAddDoc.Beskrivelse;

                            dblite.SaveChanges();
                        }
                        catch { }
                    }
                }
                catch { }
            }
        }
Пример #4
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection cells = tbldocDataGridView.SelectedCells;

            if (cells.Count > 0)
            {
                try
                {
                    DataGridViewTextBoxCell cell = cells[0] as DataGridViewTextBoxCell;
                    tbldoc rec_doc_view          = cell.OwningRow.DataBoundItem as tbldoc;

                    tbldoc rec = (from doc in dblite.tbldoc where doc.id == rec_doc_view.id select doc).First();
                    dblite.tbldoc.DeleteObject(rec);
                    dblite.SaveChanges();
                    blSortableBindingList.Remove(rec);
                }
                catch { }
            }
        }
Пример #5
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection cells = tbldocDataGridView.SelectedCells;

            if (cells.Count > 0)
            {
                try
                {
                    DataGridViewTextBoxCell cell = cells[0] as DataGridViewTextBoxCell;
                    tbldoc rec_doc_view          = cell.OwningRow.DataBoundItem as tbldoc;

                    var rec = (from doc in dblite.tbldoc
                               where doc.id == rec_doc_view.id
                               join data in dblite.tblData on doc.id equals data.id
                               select new
                    {
                        Id = doc.id,
                        kilde_sti = doc.kilde_sti,
                        Data = data.data
                    }).First();

                    FileInfo fi   = new FileInfo(rec.kilde_sti);
                    var      Ext  = fi.Extension;
                    var      Name = fi.Name;

                    SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                    saveFileDialog1.Filter           = "|*" + Ext;
                    saveFileDialog1.Title            = "Save File";
                    saveFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                    saveFileDialog1.FileName         = Name;
                    saveFileDialog1.ShowDialog();

                    string path      = saveFileDialog1.FileName;
                    byte[] file_byte = rec.Data.ToArray();

                    FileInfo   fileInfo = new FileInfo(path);
                    FileStream fs       = fileInfo.OpenWrite();
                    fs.Write(file_byte, 0, file_byte.Length);
                    fs.Flush();
                }
                catch { }
            }
        }
Пример #6
0
        private void visDokumentToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedCellCollection cells = tbldocDataGridView.SelectedCells;

            if (cells.Count > 0)
            {
                try
                {
                    DataGridViewTextBoxCell cell = cells[0] as DataGridViewTextBoxCell;
                    tbldoc rec_doc_view          = cell.OwningRow.DataBoundItem as tbldoc;

                    var rec = (from doc in dblite.tbldoc
                               where doc.id == rec_doc_view.id
                               join data in dblite.tblData on doc.id equals data.id
                               select new
                    {
                        Id = doc.id,
                        kilde_sti = doc.kilde_sti,
                        Data = data.data
                    }).First();

                    FileInfo fi   = new FileInfo(rec.kilde_sti);
                    var      Ext  = fi.Extension;
                    var      Name = fi.Name;

                    if (Ext.ToLower() == ".pdf")
                    {
                        byte[] bytes = rec.Data;
                        m_frmIE = new frmIE();
                        m_frmIE.WebBrowser1.LoadBytes(bytes, MediaTypeNames.Application.Pdf);
                        m_frmIE.Show();
                    }
                }
                catch { }
            }
        }
Пример #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tbldoc EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotbldoc(tbldoc tbldoc)
 {
     base.AddObject("tbldoc", tbldoc);
 }
Пример #8
0
        void Stifinder_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string file in files)
            {
                FileInfo fileInfo  = new FileInfo(file);
                string   kilde_sti = fileInfo.FullName;

                frmAddDoc m_frmAddDoc = new frmAddDoc();
                m_frmAddDoc.Dokument = kilde_sti;
                DialogResult Result = m_frmAddDoc.ShowDialog();
                if (Result == System.Windows.Forms.DialogResult.OK)
                {
                    Guid id     = Guid.NewGuid();
                    int  ref_nr = 0;
                    try
                    {
                        tblrefnr rec_refnr = (from n in dblite.tblrefnr where n.keyname == "ref_nr" select n).First();
                        rec_refnr.nr++;
                        ref_nr = rec_refnr.nr;
                        dblite.SaveChanges();
                    }
                    catch
                    {
                        ref_nr = 1;
                        tblrefnr rec_refnr = new tblrefnr {
                            keyname = "ref_nr", nr = ref_nr
                        };
                        dblite.tblrefnr.AddObject(rec_refnr);
                        dblite.SaveChanges();
                    }

                    tbldoc rec_doc = new tbldoc
                    {
                        id            = id,
                        ref_nr        = ref_nr,
                        virksomhed    = m_frmAddDoc.Virksomhed,
                        emne          = m_frmAddDoc.Emne,
                        dokument_type = m_frmAddDoc.Dokument_type,
                        år            = m_frmAddDoc.År,
                        ekstern_kilde = m_frmAddDoc.Ekstern_kilde,
                        beskrivelse   = m_frmAddDoc.Beskrivelse,
                        oprettes_af   = m_frmAddDoc.Oprettet_af,
                        oprettet_dato = m_frmAddDoc.Oprettet_dato,
                        kilde_sti     = kilde_sti
                    };
                    dblite.tbldoc.AddObject(rec_doc);
                    dblite.SaveChanges();
                    blSortableBindingList.Add(rec_doc);

                    FileStream fs         = fileInfo.OpenRead();
                    long       ln         = fileInfo.Length;
                    byte[]     file_bytes = new byte[ln];
                    fs.Read(file_bytes, 0, (int)ln);

                    tblData rec_Data = new tblData
                    {
                        id   = id,
                        data = file_bytes
                    };
                    dblite.tblData.AddObject(rec_Data);
                    dblite.SaveChanges();
                }
            }
        }
Пример #9
0
        void Outlook_DragDrop(object sender, DragEventArgs e)
        {
            //wrap standard IDataObject in OutlookDataObject
            OutlookDataObject dataObject = new OutlookDataObject(e.Data);

            //get the names and data streams of the files dropped
            string[]       filenames   = (string[])dataObject.GetData("FileGroupDescriptor");
            MemoryStream[] filestreams = (MemoryStream[])dataObject.GetData("FileContents");

            for (int fileIndex = 0; fileIndex < filenames.Length; fileIndex++)
            {
                //use the fileindex to get the name and data stream
                string       file = filenames[fileIndex];
                MemoryStream fs   = filestreams[fileIndex];

                FileInfo fileInfo  = new FileInfo(file);
                string   kilde_sti = fileInfo.Name;

                frmAddDoc m_frmAddDoc = new frmAddDoc();
                m_frmAddDoc.Dokument = kilde_sti;
                DialogResult Result = m_frmAddDoc.ShowDialog();
                if (Result == System.Windows.Forms.DialogResult.OK)
                {
                    Guid id     = Guid.NewGuid();
                    int  ref_nr = 0;
                    try
                    {
                        tblrefnr rec_refnr = (from n in dblite.tblrefnr where n.keyname == "ref_nr" select n).First();
                        rec_refnr.nr++;
                        ref_nr = rec_refnr.nr;
                        dblite.SaveChanges();
                    }
                    catch
                    {
                        ref_nr = 1;
                        tblrefnr rec_refnr = new tblrefnr {
                            keyname = "ref_nr", nr = ref_nr
                        };
                        dblite.tblrefnr.AddObject(rec_refnr);
                        dblite.SaveChanges();
                    }

                    tbldoc rec_doc = new tbldoc
                    {
                        id            = id,
                        ref_nr        = ref_nr,
                        virksomhed    = m_frmAddDoc.Virksomhed,
                        emne          = m_frmAddDoc.Emne,
                        dokument_type = m_frmAddDoc.Dokument_type,
                        år            = m_frmAddDoc.År,
                        ekstern_kilde = m_frmAddDoc.Ekstern_kilde,
                        beskrivelse   = m_frmAddDoc.Beskrivelse,
                        oprettes_af   = m_frmAddDoc.Oprettet_af,
                        oprettet_dato = m_frmAddDoc.Oprettet_dato,
                        kilde_sti     = kilde_sti
                    };
                    dblite.tbldoc.AddObject(rec_doc);
                    dblite.SaveChanges();
                    blSortableBindingList.Add(rec_doc);

                    //FileStream fs = fileInfo.OpenRead();
                    long   ln         = fs.Length;
                    byte[] file_bytes = new byte[ln];
                    fs.Read(file_bytes, 0, (int)ln);

                    tblData rec_Data = new tblData
                    {
                        id   = id,
                        data = file_bytes
                    };
                    dblite.tblData.AddObject(rec_Data);
                    dblite.SaveChanges();
                }
            }
        }