Esempio n. 1
0
        public int addPeople(People _obj)
        {
            int iResult = -1;

            try
            {
                if (con != null)
                {
                    string sql = "INSERT INTO Peoples(PeopleID,FirstName,LastName,Position,Sex,Phone,Address,Comment,BirthDay,DateAdded,isDeleted) values(";
                    sql += "'" + _obj.PeopleID + "'";
                    sql += ",N'" + _obj.FirstName + "'";
                    sql += ",N'" + _obj.LastName + "'";

                    sql += ",N'" + _obj.Position + "'";
                    sql += ",'" + _obj.Sex + "'";
                    sql += ",'" + _obj.Phone + "'";
                    sql += ",N'" + _obj.Address + "'";
                    sql += ",N'" + _obj.Comment + "'";
                    if (_obj.BirthDay >= DateTime.Now)
                    {
                        sql += ",'" + _obj.BirthDay + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    if (_obj.DateAdded >= DateTime.Now)
                    {
                        sql += ",'" + _obj.DateAdded + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    sql += ",'" + _obj.isDeleted.ToString() + "')";
                    Console.WriteLine("Sql add employee: " + sql);
                    iResult = SqlDataHelper.ExecuteNonQuery(sql, con);
                    if (iResult == 1)
                    {
                        sql     = "SELECT MAX(ID) FROM Peoples";
                        iResult = SqlDataHelper.GetMaxID(sql, con);
                        iResult = int.Parse(_obj.ID.ToString());
                    }
                    Console.WriteLine(sql);
                }
            }
            catch { }
            return(iResult);
        }
Esempio n. 2
0
        public int addHistory(History _obj)
        {
            var datetimenow = Convert.ToDateTime(DateTime.Now.ToString()).ToString("yyyy-MM-dd HH:mm:ss");
            int iResult     = -1;

            try
            {
                if (con != null)
                {
                    string sql = "INSERT INTO History(CameraID,PeopleID,FaceCaptured,DateCaptured,TimeIn,TimeOut,FrameCaptured,isDeleted) values(";
                    sql += "" + _obj.CameraID + "";
                    sql += "," + _obj.PeopleID + "";
                    sql += ",N'" + _obj.FaceCaptured + "'";
                    sql += ",'" + datetimenow + "'";
                    if (_obj.TimeIn >= DateTime.Now)
                    {
                        sql += ",'" + _obj.TimeIn + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    if (_obj.TimeOut >= DateTime.Now)
                    {
                        sql += ",'" + _obj.TimeOut + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    sql += ",'" + _obj.FrameCaptured + "'";
                    sql += ",'" + _obj.isDeleted.ToString() + "')";

                    iResult = SqlDataHelper.ExecuteNonQuery(sql, con);
                    if (iResult == 1)
                    {
                        sql     = "SELECT MAX(ID) FROM History";
                        iResult = SqlDataHelper.GetMaxID(sql, con);
                        iResult = int.Parse(_obj.ID.ToString());
                    }
                    Console.WriteLine(sql);
                }
            }
            catch { }
            return(iResult);
        }
        public int addCamera(Camera _obj)
        {
            int iResult = -1;

            try
            {
                if (con != null)
                {
                    string sql = "INSERT INTO Cameras(CamName,CamAddress,Comment,DateAdded,DateModified,UserAdded,UserModded,isDeleted) values(";
                    sql += "N'" + _obj.CamName + "'";
                    sql += ",'" + _obj.CamAddress + "'";
                    sql += ",N'" + _obj.Comment + "'";
                    if (_obj.DateAdded >= DateTime.Now)
                    {
                        sql += ",'" + _obj.DateAdded + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    if (_obj.DateModded >= DateTime.Now)
                    {
                        sql += ",'" + _obj.DateModded + "'";
                    }
                    else
                    {
                        sql += ",''";
                    }
                    sql += ",'" + _obj.UserAdded + "'";
                    sql += ",'" + _obj.UserModded + "'";
                    sql += ",'" + _obj.isDeleted.ToString() + "')";
                    Console.WriteLine("Sql add employee: " + sql);
                    iResult = SqlDataHelper.ExecuteNonQuery(sql, con);
                    if (iResult == 1)
                    {
                        sql     = "SELECT MAX(ID) FROM Cameras";
                        iResult = SqlDataHelper.GetMaxID(sql, con);
                        iResult = int.Parse(_obj.ID.ToString());
                    }
                    Console.WriteLine(sql);
                }
            }
            catch { }
            return(iResult);
        }
Esempio n. 4
0
        public History getLatestHistorybyPeopleID(int _id)
        {
            History obj = new History();

            //sql = "Select top(1) * from CapturedHistory where PeopleID="+ _id +" order by _dectionID desc;";
            sql = "Select top(1) * from History  where PeopleID=" + _id + " order by ID desc";
            dt  = SqlDataHelper.GetDataToStringSQL(sql, con);
            if (dt.Rows.Count == 1)
            {
                obj.ID       = int.Parse(dt.Rows[0]["ID"].ToString());
                obj.PeopleID = int.Parse(dt.Rows[0]["PeopleID"].ToString());
                // obj.FirstName = dt.Rows[0]["FirstName"].ToString();
                //obj.LastName = dt.Rows[0]["LastName"].ToString();
                obj.DateCaptured = DateTime.Parse(dt.Rows[0]["DateCaptured"].ToString());
                Console.WriteLine(obj.DateCaptured.ToString() + "ID: " + _id);
            }
            return(obj);
        }
Esempio n. 5
0
 public HistoryDAO()
 {
     con = SqlDataHelper.Connect(SqlDataHelper.strConnectionString);
 }
 public CameraDAO()
 {
     con = SqlDataHelper.Connect(SqlDataHelper.strConnectionString);
 }
Esempio n. 7
0
 public PeopleDAO()
 {
     con = SqlDataHelper.Connect(SqlDataHelper.strConnectionString);
 }