Ejemplo n.º 1
0
        public static DataTable getByMonth(int month, int year)
        {
            var lst     = DAL_ATTENDANCE.getByMonth(month, year);
            var lstName = DAL_EMPLOYEE.GetAll().Select(x => x.ID).Distinct().ToList();

            if (lst != null)
            {
                DataTable  rs  = new DataTable();
                DataColumn STT = new DataColumn();
                STT.ColumnName = "STT";
                rs.Columns.Add(STT);
                DataColumn ID = new DataColumn();
                ID.ColumnName = "ID";
                rs.Columns.Add(ID);
                DataColumn Name = new DataColumn();
                Name.ColumnName = "Name";
                rs.Columns.Add(Name);
                for (int i = 0; i < DateTime.DaysInMonth(year, month); i++)
                {
                    string     name = (i + 1).ToString();
                    DataColumn cl   = new DataColumn();
                    cl.ColumnName = name;
                    rs.Columns.Add(cl);
                }
                DataColumn Tong = new DataColumn();
                Tong.ColumnName = "Tong";
                rs.Columns.Add(Tong);
                for (int i = 0; i < lstName.Count; i++)
                {
                    DataRow row  = rs.NewRow();
                    int     tong = 0;
                    row[0] = i + 1;
                    row[1] = lstName[i];
                    row[2] = DAL_EMPLOYEE.GetFullName(int.Parse(lstName[i].ToString()));
                    for (int j = 2; j < DateTime.DaysInMonth(year, month) + 2; j++)
                    {
                        if (Check(lst, lstName[i], j, month, year))
                        {
                            row[j] = "x";
                            tong++;
                        }
                    }
                    row["Tong"] = tong.ToString();
                    rs.Rows.Add(row);
                }
                return(rs);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public static DataTable getHisMonth(int id, int month, int year)
        {
            //EMPLOYEE emp = DAL_EMPLOYEE.SearchEmpByName(name);
            var lst = new List <ATTENDANCE>();
            var dt  = new DataTable();

            //if (emp!=null)
            //{
            //int id = emp.ID;
            lst = DAL_ATTENDANCE.getByMonthEmp(month, year, id);
            if (lst.Count > 0)
            {
                dt = BLL_ExtendList.ToDataTable(lst);
                DataColumn STT = new DataColumn();
                STT.ColumnName = "STT";
                dt.Columns.Add(STT);
                DataColumn NAME = new DataColumn();
                NAME.ColumnName = "NAME";
                dt.Columns.Add(NAME);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    dt.Rows[i]["STT"]  = i + 1;
                    dt.Rows[i]["NAME"] = DAL_EMPLOYEE.GetFullName(int.Parse(dt.Rows[i]["ID_EMP"].ToString()));
                    var IN = (TimeSpan)dt.Rows[i]["TIME_IN"];
                    //string OUT = dt.Rows[i]["TIME_OUT"];
                    dt.Rows[i]["TIME_IN"] = IN.Hours + ":" + IN.Minutes + ":" + IN.Seconds;
                    try
                    {
                        var OUT = (TimeSpan)dt.Rows[i]["TIME_OUT"];
                        dt.Rows[i]["TIME_OUT"] = OUT.Hours + ":" + OUT.Minutes + ":" + OUT.Seconds;
                    }
                    catch (Exception ex) { }

                    //}
                }
                dt.Columns.Remove("EMPLOYEE");
            }
            return(dt);
        }
Ejemplo n.º 3
0
        public void Recognize(/* Bitmap src*/)
        {
            //while (m_isReadCamera)
            //  {
            try
            {
                updatedTracking = false;
                if (m_isFaceTrack && m_bitmap_to_tracking != null)
                {
                    m_faceTracking.update(m_bitmap_to_tracking);
                    //nhan dang tai day
                    if (m_faceTracking.getSize() > 0)
                    {
                        for (int i = 0; i < m_faceTracking.getSize(); i++)
                        {
                            if (!m_faceTracking.getRecognize_status(i))
                            {
                                Bitmap bmp = null;
                                if (m_faceTracking.getFaceImage(i, ref bmp))
                                {
                                    m_faceTracking.setRecognize_status(i, true);
                                    m_time_list.Add(m_faceTracking.getStartTime(i));
                                    m_bitmap_list.Add(bmp);
                                    int n = 0;
                                }
                            }
                        }
                    }
                }
                if (m_bitmap_list.Count > 0)
                {
                    if (m_bitmap_face != null)
                    {
                        m_bitmap_face.Dispose();
                    }
                    m_bitmap_face = (Bitmap)m_bitmap_list[0].Clone();

                    double confident = 0;
                    String name      = "";
                    int    id        = -1;
                    m_face_recog.recognizeFromImage(m_bitmap_face, out confident, out id, out name);
                    m_panel_result.Invoke(new Action(() =>
                    {
                        Graphics g = Graphics.FromHwnd(m_panel_result.Handle);
                        g.DrawImage(m_bitmap_face, 4, 4, m_panel_result.Width - 8, m_panel_result.Height - 8);
                        g.Dispose();
                    }));
                    m_text_confident.Invoke(new Action(() =>
                    {
                        m_text_confident.Text = Math.Floor(confident * 100).ToString();
                    }));
                    m_text_name.Invoke(new Action(() =>
                    {
                        m_text_name.Text = name;
                    }));
                    m_text_time.Invoke(new Action(() =>
                    {
                        m_text_time.Text = m_time_list[0].ToString();
                    }));
                    if (confident < m_nguongphanloai)
                    {
                        name = "Unknown";
                    }
                    //luu tru tai day
                    if (name != "Unknown")
                    {
                        string fullname = DAL_EMPLOYEE.GetFullName(int.Parse(name));
                        m_text_name.Invoke(new Action(() =>
                        {
                            m_text_name.Text = fullname;
                        }));
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_know_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        //string imgSave = saveImg(/* Bitmap(s), */name);
                        m_bitmap_list[0].Save(s);

                        HISTORY his = new HISTORY();
                        his.ID          = DAL_HISTORY.getIDNew();
                        his.ID_PER      = int.Parse(name);
                        his.IMG_FACE    = s;
                        his.IMG         = s;
                        his.IN_OUT      = false;
                        his.TIME_UPDATE = DateTime.Now;
                        DAL_HISTORY.INSERT(his);
                        if (DAL_ATTENDANCE.Check(int.Parse(name), his.TIME_UPDATE))
                        {
                            ATTENDANCE att = new ATTENDANCE();
                            att.ID       = DAL_ATTENDANCE.getIDNew();
                            att.ID_EMP   = int.Parse(name);
                            att.DATE_ATT = DateTime.Now.Date;
                            att.TIME_IN  = DateTime.Now.TimeOfDay;
                            att.IMG_IN   = s;
                            DAL_ATTENDANCE.INSERT(att);
                        }
                        else
                        {
                            DAL_ATTENDANCE.updateTimeOut(int.Parse(name), s);
                        }
                        //m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = fullname;
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));

                        //add thong tin vao report
                        string[] arr = new string[6];
                        arr[0] = name;
                        arr[1] = fullname;
                        arr[2] = DateTime.Now.ToString("dd-MMM-yy");
                        arr[3] = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                        arr[4] = "";
                        arr[5] = "1";
                        ListViewItem itm = new ListViewItem(arr);
                        //kiem tra ra

                        listView_report.Invoke(new Action(() =>
                        {
                            int index = -1;
                            for (int i = 0; i < listView_report.Items.Count; i++)
                            {
                                if (listView_report.Items[i].SubItems[0].Text == name)
                                {
                                    index = i;
                                    break;
                                }
                            }
                            if (index == -1)
                            {
                                listView_report.Items.Add(itm);
                            }
                            else
                            {
                                listView_report.Items[index].SubItems[4].Text = DateTime.Now.Hour.ToString("00") + ":" + DateTime.Now.Minute.ToString("00");
                            }
                        }));
                    }
                    else
                    {
                        DateTime time = m_time_list[0];
                        String   s    = m_folder_unknow_Image + "/" + time.Year.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Month.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + time.Day.ToString();
                        if (!Directory.Exists(s))
                        {
                            Directory.CreateDirectory(s);
                        }
                        s += "/" + name + "_" + time.Hour.ToString("00") + time.Minute.ToString("00") + time.Second.ToString("00") + ".jpg";
                        m_bitmap_list[0].Save(s);
                        m_listView_Thumb.Invoke(new Action(() =>
                        {
                            Image img = Image.FromFile(s);
                            String s_ = "0";
                            imageList.Images.Add(s_, img);
                            //imageList.Images.Add()

                            ListViewItem lvitem = new ListViewItem();
                            lvitem.ImageIndex   = imageList.Images.Count - 1;
                            //lvitem.Text = name + ":" + confident.ToString();
                            lvitem.Text = name;
                            lvitem.Name = s;
                            if (listItemCur.Count > 8)
                            {
                                listItemCur.Dequeue();
                            }
                            listItemCur.Enqueue(lvitem);
                            m_listView_Thumb.Items.Clear();
                            var rsv = listItemCur.ToArray();
                            for (int i = rsv.Length - 1; i >= 0; i--)
                            {
                                m_listView_Thumb.Items.Insert(0, (ListViewItem)rsv[i]);
                            }
                            m_listView_Thumb.Refresh();
                        }));
                    }
                    m_time_list.RemoveAt(0);
                    m_bitmap_list.RemoveAt(0);
                }
            }
            catch (Exception ex)
            {
                updatedTracking = true;
            }
            updatedTracking = true;
            //}
            //bmp.Save("face.png");
            //bmp.Dispose();
        }
Ejemplo n.º 4
0
        public static DataTable getAll()
        {
            var lst = DAL_ATTENDANCE.getAll();

            return(BLL_ExtendList.ToDataTable(lst));
        }