Example #1
0
        public Historico BuscarPorID(DateTime _id)
        {
            Historico c = null;

            try
            {
                String SQL = String.Format("SELECT * FROM historico WHERE datainicio = {0} ", _id);

                SqlCeDataReader data = BD.ExecutarSelect(SQL);

                if (data.Read())
                {
                    c = new Historico();

                    c.DataInicio = data.GetDateTime(0);
                    c.DataFim    = data.GetDateTime(1);
                    c.Preco      = data.GetFloat(2);
                }

                data.Close();
                BD.FecharConexao();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(c);
        }
Example #2
0
        public Tuple <LinkedList <int>, LinkedList <String>, LinkedList <DateTime>, LinkedList <double> > scanValueForPatient(int ScanID)
        {
            LinkedList <int>      scanID = new LinkedList <int>();
            LinkedList <String>   pointCloudFileReference = new LinkedList <String>();
            LinkedList <DateTime> timestamp = new LinkedList <DateTime>();
            LinkedList <double>   value     = new LinkedList <double>();

            SqlCeCommand selectQuery = this.con.CreateCommand();

            selectQuery.CommandText = "Select Scans.scanID, pointCloudFileReference, timestamp, Records.value from Scans join Records on Scans.scanID = Records.scanID where Scans.scanID = @ScanID;";
            selectQuery.Parameters.Clear();
            selectQuery.Parameters.Add("@ScanID", ScanID);
            SqlCeDataReader reader = selectQuery.ExecuteReader();

            while (reader.Read())
            {
                scanID.AddLast(reader.GetInt32(0));
                pointCloudFileReference.AddLast(reader.GetString(1));
                timestamp.AddLast(Convert.ToDateTime(reader.GetDateTime(2).ToString()));
                value.AddLast((double)reader.GetFloat(3));
            }
            reader.Close();

            return(Tuple.Create(scanID, pointCloudFileReference, timestamp, value));
        }
        protected float?getFloat(SqlCeDataReader reader, string columnName)
        {
            int index = reader.GetOrdinal(columnName);

            if (!reader.IsDBNull(index))
            {
                return((float)reader.GetFloat(index));
            }
            return(null);
        }
        public void LoadDB()
        {
            using (conn = new SqlCeConnection(stringCon))
            {
                conn.Open();
                using (cmd = new SqlCeCommand(@"SELECT * FROM FaceList", conn))
                {
                    SqlCeDataReader re = cmd.ExecuteReader();
                    while (re.Read())
                    {
                        TFaceRecord fr = new TFaceRecord();
                        fr.ImageFileName = re.GetString(0);
                        fr.subjectName   = re.GetString(1);

                        fr.FacePosition       = new FSDK.TFacePosition();
                        fr.FacePosition.xc    = re.GetInt32(2);
                        fr.FacePosition.yc    = re.GetInt32(3);
                        fr.FacePosition.w     = re.GetInt32(4);
                        fr.FacePosition.angle = re.GetFloat(5);

                        fr.FacialFeatures      = new FSDK.TPoint[2];
                        fr.FacialFeatures[0]   = new FSDK.TPoint();
                        fr.FacialFeatures[0].x = re.GetInt32(6);
                        fr.FacialFeatures[0].y = re.GetInt32(7);

                        fr.FacialFeatures[1]   = new FSDK.TPoint();
                        fr.FacialFeatures[1].x = re.GetInt32(8);
                        fr.FacialFeatures[1].y = re.GetInt32(9);

                        fr.Template = new byte[FSDK.TemplateSize];
                        re.GetBytes(10, 0, fr.Template, 0, FSDK.TemplateSize);

                        Image img      = Image.FromStream(new System.IO.MemoryStream(re.GetSqlBinary(11).Value));
                        Image img_face = Image.FromStream(new System.IO.MemoryStream(re.GetSqlBinary(12).Value));
                        fr.image     = new FSDK.CImage(img);
                        fr.faceImage = new FSDK.CImage(img_face);



                        dbList.Add(fr);

                        img.Dispose();
                        img_face.Dispose();
                    }
                }
                conn.Close();
            }
        }
Example #5
0
        public List <Historico> ListarTodos(DateTime _id)
        {
            List <Historico> listaHistoricos = new List <Historico>();

            try
            {
                String SQL = String.Format("SELECT * FROM historico WHERE estado id = {0};", _id);

                SqlCeDataReader data = BD.ExecutarSelect(SQL);

                while (data.Read())
                {
                    Historico c = new Historico();

                    c.DataInicio = data.GetDateTime(0);
                    c.DataFim    = data.GetDateTime(1);
                    c.Preco      = data.GetFloat(2);

                    listaHistoricos.Add(c);
                }

                foreach (Historico h in listaHistoricos)
                {
                    CarroDAO       dao  = new CarroDAO();
                    VagaDAO        dao1 = new VagaDAO();
                    FuncionarioDAO dao2 = new FuncionarioDAO();
                    Carro          c    = new Carro();

                    h.Carro       = dao.BuscarPorID(h.Carro.Id);
                    h.Vaga        = dao1.BuscarPorID(h.Vaga.Id);
                    h.Funcionario = dao2.BuscarPorID(h.Funcionario.Id);
                }


                data.Close();
                BD.FecharConexao();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            return(listaHistoricos);
        }
Example #6
0
        private int RunDataReader(SqlCeCommand cmd, SqlCeConnection connection, Char colSepChar, bool removeSpaces)
        {
            cmd.Connection = connection;
            SqlCeDataReader rdr      = cmd.ExecuteReader();
            int             rows     = 0;
            int             maxWidth = 256;
            string          colSep   = colSepChar.ToString();
            List <Column>   headings = new List <Column>();

            CreateHeadings(cmd, conn, rdr, maxWidth, headings);
            while (rdr.Read())
            {
                bool doWrite = (rows == 0 && writeHeaders);
                if (!doWrite && rows > 0)
                {
                    doWrite = ((rows % headerInterval) == 0);
                }

                if (doWrite)
                {
                    for (int x = 0; x < rdr.FieldCount; x++)
                    {
                        if (removeSpaces)
                        {
                            Console.Write(headings[x].Name);
                        }
                        else
                        {
                            Console.Write(headings[x].Name.PadRight(headings[x].Width));
                        }
                        Console.Write(colSep);
                    }
                    Console.WriteLine();
                    for (int x = 0; x < rdr.FieldCount; x++)
                    {
                        System.Text.StringBuilder sb = new System.Text.StringBuilder();
                        if (removeSpaces)
                        {
                            sb.Append('-', headings[x].Name.Length);
                        }
                        else
                        {
                            sb.Append('-', headings[x].Width);
                        }
                        Console.Write(sb.ToString());
                        Console.Write(colSep);
                    }
                    Console.WriteLine();
                }
                for (int i = 0; i < rdr.FieldCount; i++)
                {
                    if (!rdr.IsDBNull(i))
                    {
                        string value     = string.Empty;
                        string fieldType = rdr.GetDataTypeName(i);
                        if (fieldType == "Image" || fieldType == "VarBinary" || fieldType == "Binary" || fieldType == "RowVersion")
                        {
                            Byte[]        buffer = (Byte[])rdr[i];
                            StringBuilder sb     = new StringBuilder();
                            sb.Append("0x");
                            for (int y = 0; y < (headings[i].Width - 2) / 2; y++)
                            {
                                sb.Append(buffer[y].ToString("X2", CultureInfo.InvariantCulture));
                            }
                            value = sb.ToString();
                        }
                        else if (fieldType == "DateTime")
                        {
                            value = ((DateTime)rdr[i]).ToString("O");
                        }
                        else if (fieldType == "Float")
                        {
                            value = rdr.GetDouble(i).ToString("R", System.Globalization.CultureInfo.InvariantCulture);
                        }
                        else if (fieldType == "Real")
                        {
                            value = rdr.GetFloat(i).ToString("R", System.Globalization.CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            value = Convert.ToString(rdr[i], cultureInfo);
                        }

                        if (removeSpaces)
                        {
                            Console.Write(value);
                        }
                        else if (headings[i].PadLeft)
                        {
                            Console.Write(value.PadLeft(headings[i].Width));
                        }
                        else
                        {
                            Console.Write(value.PadRight(headings[i].Width));
                        }
                    }
                    else
                    {
                        if (removeSpaces)
                        {
                            Console.Write("NULL");
                        }
                        else
                        {
                            Console.Write("NULL".PadRight(headings[i].Width));
                        }
                    }
                    if (i < rdr.FieldCount - 1)
                    {
                        Console.Write(colSep);
                    }
                }
                rows++;
                Console.WriteLine();
            }
            return(rows);
        }
Example #7
0
        public List <TFaceRecord> LoadSubject(string conString)
        {
            InitializeSDK();
            SubjectImageList = new ImageList();

            List <TFaceRecord> SubjectList = new List <TFaceRecord>();

            try
            {
                using (conn = new SqlCeConnection(conString))
                {
                    conn.Open();

                    using (cmd = new SqlCeCommand(@"Select * From FaceList", conn))
                    {
                        SqlCeDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            TFaceRecord fr = new TFaceRecord();
                            fr.ImageFileName = reader.GetString(0);
                            fr.suspectName   = reader.GetString(1);

                            fr.FacePosition       = new FSDK.TFacePosition();
                            fr.FacePosition.xc    = reader.GetInt32(2);
                            fr.FacePosition.yc    = reader.GetInt32(3);
                            fr.FacePosition.w     = reader.GetInt32(4);
                            fr.FacePosition.angle = reader.GetFloat(5);

                            fr.FacialFeatures      = new FSDK.TPoint[2];
                            fr.FacialFeatures[0]   = new FSDK.TPoint();
                            fr.FacialFeatures[0].x = reader.GetInt32(6);
                            fr.FacialFeatures[0].y = reader.GetInt32(7);

                            fr.FacialFeatures[1]   = new FSDK.TPoint();
                            fr.FacialFeatures[1].x = reader.GetInt32(8);
                            fr.FacialFeatures[1].y = reader.GetInt32(9);

                            fr.Template = new byte[FSDK.TemplateSize];
                            reader.GetBytes(10, 0, fr.Template, 0, FSDK.TemplateSize);

                            Image img      = Image.FromStream(new System.IO.MemoryStream(reader.GetSqlBinary(11).Value));
                            Image img_face = Image.FromStream(new System.IO.MemoryStream(reader.GetSqlBinary(12).Value));
                            fr.image     = new FSDK.CImage(img);
                            fr.faceImage = new FSDK.CImage(img_face);

                            SubjectList.Add(fr);
                            SubjectImageList.Images.Add(fr.faceImage.ToCLRImage());

                            img.Dispose();
                            img_face.Dispose();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception on loading database");
            }

            return(SubjectList);
        }