using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Data.Entity; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Text; namespace sbcLabSystem.Import { public partial class Form1 : Form { public Form1() { InitializeComponent(); byte[] buf = new byte[] { 0xA8, 0x01, 0x00, 0x00 }; float data = BitConverter.ToSingle(buf,0); } private void button1_Click(object sender, EventArgs e) { try { sbcLabSystemEntities current_db = new sbcLabSystemEntities(); using (hds1230001_dbEntities ori_db = new hds1230001_dbEntities()) { var regList = ori_db.EQAParticipant.OrderBy(p => p.LabID).ToList(); regList.ForEach(x => { QCDistributionRegisterInfoes regInfo = new QCDistributionRegisterInfoes(); regInfo.ProjectId = x.ProjectID; regInfo.ModifyTime = DateTime.Now; regInfo.IsCharged = x.IsCharged; regInfo.IsSendEMS = x.IsExpressSended; regInfo.SampleNo = x.SampleSNO; regInfo.EMSNo = x.ExpressBillCode; regInfo.PacketContent = x.ExpressContent; regInfo.IsModified = x.IsDataChanged; regInfo.IsSubmit = x.IsDataSubmitted; regInfo.SubmitTime = x.DateSubmitted; regInfo.AnswerJSON = x.DataProject; regInfo.LetterNo = x.RegisteredLetter; var distInfo = ori_db.EQADistribution.FirstOrDefault(p => p.ID == x.DistributionID); var labInfo = ori_db.Lab.FirstOrDefault(p => p.ID == x.LabID); var distInfo2 = current_db.QCDistributions.FirstOrDefault(p => p.DistNo == distInfo.DistNo); var labInfo2 = current_db.UserRequestInfoes.FirstOrDefault(p => p.LabCode == labInfo.LabCode); regInfo.QCDistributionId = distInfo2.Id; regInfo.LabId = labInfo2.Id; current_db.QCDistributionRegisterInfoes.Add(regInfo); current_db.SaveChanges(); }); } current_db.Dispose(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } }