/// <summary> /// Create a new tblrefnr object. /// </summary> /// <param name="keyname">Initial value of the keyname property.</param> /// <param name="nr">Initial value of the nr property.</param> public static tblrefnr Createtblrefnr(global::System.String keyname, global::System.Int32 nr) { tblrefnr tblrefnr = new tblrefnr(); tblrefnr.keyname = keyname; tblrefnr.nr = nr; return(tblrefnr); }
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(); } } }
/// <summary> /// Deprecated Method for adding a new object to the tblrefnr EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotblrefnr(tblrefnr tblrefnr) { base.AddObject("tblrefnr", tblrefnr); }
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(); } } }