Exemplo n.º 1
0
        public List <sms_emp_attendance> get_all_attendance_by_date(DateTime dt)
        {
            List <sms_emp_attendance> att_list = new List <sms_emp_attendance>();

            try
            {
                using (MySqlConnection con = new MySqlConnection(ConnectionString.con_string))
                {
                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        cmd.CommandText = "SELECT * FROM sms_emp_attendance as att inner join sms_emp as emp on att.emp_id=emp.id where Date(att.date_time)=@date order by att.date_time DESC";
                        cmd.Connection  = con;
                        cmd.Parameters.Add("@date", MySqlDbType.Date).Value = dt;
                        //cmd.CommandType = System.Data.CommandType.StoredProcedure;

                        con.Open();

                        MySqlDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            sms_emp_attendance att = new sms_emp_attendance()
                            {
                                id           = Convert.ToInt32(reader["id"]),
                                emp_id       = Convert.ToInt32(reader["emp_id"]),
                                mode         = reader["mode"].ToString(),
                                date_time    = Convert.ToDateTime(reader["date_time"]),
                                emp_login_id = Convert.ToInt32(reader["emp_login_id"]),
                                image        = (byte[])reader["image"],
                                emp_name     = reader["emp_name"].ToString(),
                                created_by   = reader["created_by"].ToString(),
                            };
                            att_list.Add(att);
                        }
                    }
                }
            }
            catch (Exception ex)
            { throw ex; }
            return(att_list);
        }
Exemplo n.º 2
0
        public int insert_thumb_attendance(sms_emp_attendance attendance)
        {
            int i = 0;

            try
            {
                using (MySqlConnection con = new MySqlConnection(ConnectionString.con_string))
                {
                    con.Open();


                    using (MySqlCommand cmd = new MySqlCommand())
                    {
                        cmd.CommandText = "INSERT INTO sms_emp_attendance(emp_id, mode,created_by, emp_login_id, date_time) Values(@emp_id, @mode,@created_by, @emp_login_id, @date_time)";
                        cmd.Connection  = con;

                        cmd.Parameters.Add("@emp_id", MySqlDbType.Int32).Value       = attendance.emp_id;
                        cmd.Parameters.Add("@mode", MySqlDbType.VarChar).Value       = attendance.mode;
                        cmd.Parameters.Add("@created_by", MySqlDbType.VarChar).Value = attendance.created_by;
                        cmd.Parameters.Add("@emp_login_id", MySqlDbType.Int32).Value = attendance.emp_login_id;
                        cmd.Parameters.Add("@date_time", MySqlDbType.DateTime).Value = attendance.date_time;


                        i = Convert.ToInt32(cmd.ExecuteNonQuery());
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(i);
        }
Exemplo n.º 3
0
        void fp_OnCapture(bool ActionResult, object ATemplate)
        {
            try
            {
                mode = "";
                bool check = false;
                if (ActionResult)
                {
                    aTemplate       = new object();
                    aTemplate       = ATemplate;
                    aTemplateString = fp.GetTemplateAsString();

                    foreach (var item in thumb_enroll_list)
                    {
                        check           = false;
                        pTemplateString = Convert.ToBase64String(item.template);
                        if (fp.VerFingerFromStr(pTemplateString, aTemplateString, true, true))
                        {
                            employee_att_details_GBs.DataContext = null;
                            //fill object
                            attendance_obj        = new sms_emp_attendance();
                            attendance_obj.emp_id = item.emp_id;
                            if (empDAL.get_last_attendance_mode(item.emp_id) == "checkin")
                            {
                                mode      = "checkout";
                                mode_text = "You Are Out";
                            }
                            else
                            {
                                mode      = "checkin";
                                mode_text = "You Are In";
                            }

                            attendance_obj.mode         = mode;
                            attendance_obj.emp_login_id = 0;
                            attendance_obj.date_time    = DateTime.Now;
                            attendance_obj.created_by   = "Tahir";

                            if (empDAL.insert_thumb_attendance(attendance_obj) > 0)
                            {
                                employee_att_details_GBs.DataContext = emp_list.Where(x => x.id == item.emp_id.ToString()).First();
                                mode_text_TB.Text     = mode_text;
                                check                 = true;
                                error_grid.Visibility = Visibility.Collapsed;
                                load_emp_att_history();
                                break;
                            }
                        }
                    }
                    if (check == false)
                    {
                        employee_att_details_GBs.DataContext = null;
                        error_grid.Visibility  = Visibility.Visible;
                        error_grid.DataContext = "Not Verified Please Try Again";
                        mode_text_TB.Text      = "";
                    }
                }
                else
                {
                    MessageBox.Show("Capture Failed");
                }
            }catch (Exception ex)
            { MessageBox.Show(ex.Message); }
        }