Exemplo n.º 1
0
        private static IOEMDevice Return(NpgsqlDataReader lect)
        {
            IOEMDevice bean = new IOEMDevice();

            try
            {
                bean.id               = Convert.ToInt32(lect["id"].ToString());
                bean.iMachineNumber   = Convert.ToInt32(lect["machine"].ToString());
                bean.idwSEnrollNumber = Convert.ToInt32(lect["employe"].ToString());
                bean.idwVerifyMode    = Convert.ToInt32(lect["verify_mode"].ToString());
                bean.idwInOutMode     = Convert.ToInt32(lect["in_out_mode"].ToString());
                bean.idwWorkCode      = Convert.ToInt32(lect["work_code"].ToString());
                bean.idwReserved      = Convert.ToInt32(lect["reserved"].ToString());
                bean.pointeuse        = new Pointeuse(Convert.ToInt32(lect["pointeuse"].ToString()));
                bean.date_action      = (DateTime)((lect["date_action"] != null) ? (!lect["date_action"].ToString().Trim().Equals("") ? lect["date_action"] : DateTime.Now) : DateTime.Now);
                bean.time_action      = (DateTime)((lect["time_action"] != null) ? (!lect["time_action"].ToString().Trim().Equals("") ? lect["time_action"] : DateTime.Now) : DateTime.Now);
                bean.date_time_action = (DateTime)((lect["date_time_action"] != null) ? (!lect["date_time_action"].ToString().Trim().Equals("") ? lect["date_time_action"] : DateTime.Now) : DateTime.Now);
                bean.idwYear          = Convert.ToInt32(bean.date_action.ToString("yyyy"));
                bean.idwMonth         = Convert.ToInt32(bean.date_action.ToString("MM"));
                bean.idwDay           = Convert.ToInt32(bean.date_action.ToString("dd"));
                bean.idwHour          = Convert.ToInt32(bean.time_action.ToString("HH"));
                bean.idwMinute        = Convert.ToInt32(bean.time_action.ToString("mm"));
                bean.idwSecond        = Convert.ToInt32(bean.time_action.ToString("ss"));
            }
            catch (Exception ex)
            {
                Messages.Exception("IOEMDeviceDAO (Return)", ex);
            }
            return(bean);
        }
Exemplo n.º 2
0
        public static void SaveCsv(string fileName, IOEMDevice iO)
        {
            try
            {
                // Write sample data to CSV file
                using (CsvFileWriter writer = new CsvFileWriter(fileName, true, Encoding.UTF8))
                {
                    List <string> row = new List <string>();
                    row.Add(iO.iMachineNumber.ToString());
                    row.Add(iO.idwSEnrollNumber.ToString());
                    row.Add(iO.idwVerifyMode.ToString());
                    row.Add(iO.idwInOutMode.ToString());
                    row.Add(iO.idwWorkCode.ToString());
                    row.Add(iO.idwReserved.ToString());
                    row.Add(iO.date_action.ToString("dd-MM-yyyy"));
                    row.Add(iO.time_action.ToString("HH:mm:ss"));
                    row.Add(iO.date_time_action.ToString("dd-MM-yyyy HH:mm:ss"));
                    row.Add(iO.pointeuse.Id.ToString());

                    writer.WriteRow(row);
                }
            }
            catch (Exception ex)
            {
                Utils.Exception(ex);
            }
        }
Exemplo n.º 3
0
        public static IOEMDevice getOne(Pointeuse pointeuse, Employe employe, DateTime date, string adresse)
        {
            IOEMDevice       result  = new IOEMDevice();
            NpgsqlConnection connect = new Connexion().Connection(adresse);

            try
            {
                string           query = "SELECT * FROM yvs_grh_ioem_device WHERE date_time_action = '" + date + "' AND employe =" + employe.Id + " AND pointeuse =" + pointeuse.Id;
                NpgsqlCommand    Lcmd  = new NpgsqlCommand(query, connect);
                NpgsqlDataReader lect  = Lcmd.ExecuteReader();
                if (lect.HasRows)
                {
                    while (lect.Read())
                    {
                        result = Return(lect);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Messages.Exception("IOEMDeviceDAO (getOne)", ex);
                return(result);
            }
            finally
            {
                Connexion.Close(connect);
            }
            return(result);
        }
Exemplo n.º 4
0
 public Dial_View_No_Insert(Employe employe, IOEMDevice current)
 {
     InitializeComponent();
     Configuration.Load(this);
     object_presence = new ObjectThread(dgv_presence);
     object_pointage = new ObjectThread(dgv_pointage);
     this.employe    = employe;
     this.current    = current;
 }
Exemplo n.º 5
0
 public static void WriteCsv(string fileName, IOEMDevice iO)
 {
     if (!File.Exists(fileName))
     {
         SaveCsv(fileName, iO);
     }
     else
     {
         UpdateCsv(fileName, iO);
     }
 }
Exemplo n.º 6
0
 public static bool Insert(IOEMDevice bean, string adresse)
 {
     try
     {
         return(IOEMDeviceDAO.getInsert(bean, adresse));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemplo n.º 7
0
        private void Dial_Insert_Pointage_Load(object sender, EventArgs e)
        {
            if (parent != null)
            {
                string adresse = Constantes.SOCIETE.AdresseIp;

                IOEMDevice current = parent.currentPointage;
                employe            = EmployeBLL.OneById(current.idwSEnrollNumber);
                txt_id.Text        = employe.Id.ToString();
                txt_matricule.Text = employe.Matricule;
                txt_noms.Text      = employe.NomPrenom;
                txt_poste.Text     = employe.Poste.Poste.Intitule;
                try
                {
                    current_time       = new DateTime(current.idwYear, current.idwMonth, current.idwDay, current.idwHour, current.idwMinute, current.idwSecond);
                    dtp_decalage.Value = current_time;
                    time_decalage      = current_time;
                    Presence presence = Fonctions.GetPresence(employe, current_time, true, adresse);
                    if (presence != null ? presence.Id > 0 : false)
                    {
                        dtp_date_debut.Value  = presence.DateDebut;
                        dtp_date_fin.Value    = presence.DateFinPrevu;
                        dtp_heure_debut.Value = presence.HeureDebut;
                        dtp_heure_fin.Value   = presence.HeureFinPrevu;
                        box_fich_exit.Image   = global::ZK_Lymytz.Properties.Resources.vu;
                    }
                    else
                    {
                        Planning planning = Fonctions.GetPlanning(employe, new DateTime(current_time.Year, current_time.Month, current_time.Day, 0, 0, 0), adresse);
                        dtp_date_debut.Value  = planning.DateDebut;
                        dtp_date_fin.Value    = planning.DateFin;
                        dtp_heure_debut.Value = planning.HeureDebut;
                        dtp_heure_fin.Value   = planning.HeureFin;
                    }
                }
                catch (Exception ex) { }
                this.Text += " [" + current_time.ToShortTimeString() + "]";
            }
            else
            {
                this.Dispose();
            }
        }
Exemplo n.º 8
0
        public static bool getInsert(IOEMDevice bean, string adresse)
        {
            NpgsqlConnection connect = new Connexion().Connection(adresse);

            try
            {
                string query = "INSERT INTO yvs_grh_ioem_device(machine, employe, verify_mode, in_out_mode, work_code, reserved, date_action, time_action, date_time_action, pointeuse, author) " +
                               " VALUES (" + bean.iMachineNumber + "," + bean.idwSEnrollNumber + ", " + bean.idwVerifyMode + ", " + bean.idwInOutMode + ", " + bean.idwWorkCode + ", " + bean.idwReserved + ", '" + bean.date_action + "', '" + bean.time_action.ToString("HH:mm:ss") + "', '" + bean.date_time_action + "', " + bean.pointeuse.Id + ", " + (Constantes.USERS.Author > 0 ? Constantes.USERS.Author.ToString() : "null") + ")";
                NpgsqlCommand cmd = new NpgsqlCommand(query, connect);
                cmd.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                Messages.Exception("IOEMDeviceDAO (getInsert)", ex);
                return(false);
            }
            finally
            {
                Connexion.Close(connect);
            }
        }
Exemplo n.º 9
0
        public static void UpdateCsv(string fileName, IOEMDevice iO)
        {
            try
            {
                // Write sample data to CSV file
                FileInfo file = new FileInfo(fileName);
                if (file.Length == 8192)
                {
                    string destination = file.DirectoryName + Constantes.FILE_SEPARATOR + file.Name.Replace(file.Extension, "") + "_" + DateTime.Now.ToShortDateString().Replace("/", "-") + file.Extension;
                    file.MoveTo(destination);
                    SaveCsv(fileName, iO);
                }
                else
                {
                    using (CsvFileWriter writer = new CsvFileWriter(fileName, true, Encoding.UTF8))
                    {
                        List <string> row = new List <string>();
                        row.Add(iO.iMachineNumber.ToString());
                        row.Add(iO.idwSEnrollNumber.ToString());
                        row.Add(iO.idwVerifyMode.ToString());
                        row.Add(iO.idwInOutMode.ToString());
                        row.Add(iO.idwWorkCode.ToString());
                        row.Add(iO.idwReserved.ToString());
                        row.Add(iO.date_action.ToString("dd-MM-yyyy"));
                        row.Add(iO.time_action.ToString("HH:mm:ss"));
                        row.Add(iO.date_time_action.ToString("dd-MM-yyyy HH:mm:ss"));
                        row.Add(iO.pointeuse.Id.ToString());

                        writer.WriteRow(row);
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.Exception(ex);
            }
        }
Exemplo n.º 10
0
 public Dial_Update_Action(IOEMDevice current)
     : this()
 {
     this.current = current;
 }
Exemplo n.º 11
0
        public static void WriteCsv(IOEMDevice iO)
        {
            string fileName = TOOLS.Chemins.CheminDatabase() + "LogRecord.csv";

            WriteCsv(fileName, iO);
        }
Exemplo n.º 12
0
        public static List <IOEMDevice> ReadCsv(string fileName)
        {
            try
            {
                if (!File.Exists(fileName))
                {
                    return(new List <IOEMDevice>());
                }

                List <IOEMDevice> l = new List <IOEMDevice>();
                // Read sample data from CSV file
                using (CsvFileReader reader = new CsvFileReader(fileName))
                {
                    List <string> row = new List <string>();
                    while (reader.ReadRow(row))
                    {
                        int        i = 0;
                        IOEMDevice e = new IOEMDevice(Convert.ToInt32(row.Count > 0 ? row[i++] : "0"));
                        if (row.Count == 10)//Chargement de la version 2 du fichier
                        {
                            e.idwSEnrollNumber = Convert.ToInt32(row.Count > 1 ? row[i++] : "0");
                            e.idwVerifyMode    = Convert.ToInt32(row.Count > 2 ? row[i++] : "0");
                            e.idwInOutMode     = Convert.ToInt32(row.Count > 3 ? row[i++] : "0");
                            e.idwWorkCode      = Convert.ToInt32(row.Count > 4 ? row[i++] : "0");
                            e.idwReserved      = Convert.ToInt32(row.Count > 5 ? row[i++] : "0");
                            e.date_action      = row.Count > 6 ? Convert.ToDateTime(row[i++]) : DateTime.Now;
                            e.time_action      = row.Count > 7 ? Convert.ToDateTime(row[i++]) : DateTime.Now;;
                            e.date_time_action = row.Count > 8 ? Convert.ToDateTime(row[i++]) : DateTime.Now;;
                            e.pointeuse        = new Pointeuse(Convert.ToInt32(row.Count > 9 ? row[i++] : "0"));
                            e.idwYear          = Convert.ToInt32(e.date_action.ToString("yyyy"));
                            e.idwMonth         = Convert.ToInt32(e.date_action.ToString("MM"));
                            e.idwDay           = Convert.ToInt32(e.date_action.ToString("dd"));
                            e.idwHour          = Convert.ToInt32(e.time_action.ToString("HH"));
                            e.idwMinute        = Convert.ToInt32(e.time_action.ToString("mm"));
                            e.idwSecond        = Convert.ToInt32(e.time_action.ToString("ss"));
                        }
                        else//Chargement de la version 1 du fichier
                        {
                            e.idwTMachineNumber = Convert.ToInt32(row.Count > 1 ? row[i++] : "0");
                            e.idwSEnrollNumber  = Convert.ToInt32(row.Count > 2 ? row[i++] : "0");
                            e.iParams4          = Convert.ToInt32(row.Count > 3 ? row[i++] : "0");
                            e.iParams1          = Convert.ToInt32(row.Count > 4 ? row[i++] : "0");
                            e.iParams2          = Convert.ToInt32(row.Count > 5 ? row[i++] : "0");
                            e.idwManipulation   = Convert.ToInt32(row.Count > 6 ? row[i++] : "0");
                            e.iParams3          = Convert.ToInt32(row.Count > 7 ? row[i++] : "0");
                            e.idwYear           = Convert.ToInt32(row.Count > 8 ? row[i++] : "0");
                            e.idwMonth          = Convert.ToInt32(row.Count > 9 ? row[i++] : "0");
                            e.idwDay            = Convert.ToInt32(row.Count > 10 ? row[i++] : "0");
                            e.idwHour           = Convert.ToInt32(row.Count > 11 ? row[i++] : "0");
                            e.idwMinute         = Convert.ToInt32(row.Count > 12 ? row[i++] : "0");
                            e.idwSecond         = Convert.ToInt32(row.Count > 13 ? row[i++] : "0");
                            e.date_action       = new DateTime(e.idwYear, e.idwMonth, e.idwDay, 0, 0, 0);
                            e.time_action       = new DateTime(e.idwYear, e.idwMonth, e.idwDay, e.idwHour, e.idwMinute, 0);
                            e.date_time_action  = new DateTime(e.idwYear, e.idwMonth, e.idwDay, e.idwHour, e.idwMinute, 0);
                        }
                        l.Add(e);
                        Constantes.LoadPatience(false);
                    }
                }
                return(l);
            }
            catch (Exception ex)
            {
                Utils.Exception(ex);
            }
            return(new List <IOEMDevice>());
        }