Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult res;
                res = MessageBox.Show("Voulez vous supprimer cet enregisteremet", "Supprimer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == DialogResult.Yes)
                {
                    PersonnelMat = GridViewPersonnel.SelectedRows[0].Cells[0].Value.ToString();
                    PERSONNEL personnel = entity.PERSONNEL.Single(p => p.MAT == PersonnelMat);

                    //  personnel.SOCIETE.;
                    entity.SaveChanges();
                    entity.PERSONNEL.Remove(personnel);
                    entity.SaveChanges();


                    RemplirGrid();
                }
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string imgpath = img.ImageLocation;



                FileStream   fs      = new FileStream((string)imgpath, FileMode.Open, FileAccess.Read);
                BinaryReader br      = new BinaryReader(fs);
                FileInfo     fi      = new FileInfo((string)imgpath);
                byte[]       imgdata = br.ReadBytes((int)fi.Length);
                fs.Close();
                br.Close();
                SOCIETE societe = entity.SOCIETE.FirstOrDefault(S => S.CODE_S.Equals((decimal)comboBox1.SelectedValue));
                SHIFT   shift   = entity.SHIFT.FirstOrDefault(S => S.CODE == (decimal)comboBox2.SelectedValue);


                PERSONNEL p = new PERSONNEL
                {
                    MAT        = tb1.Text,
                    NOM        = tb2.Text,
                    PRENOM     = tb3.Text,
                    TEL        = tb4.Text,
                    ADR_P      = tb5.Text,
                    VILLE_P    = tb6.Text,
                    POSTE      = tb7.Text,
                    DATE_EMB   = dt.Value,
                    SALAIRE    = Convert.ToDecimal(tb8.Text),
                    PHOTO      = imgdata,
                    CODE_S     = societe.CODE_S,
                    SHIFT      = shift,
                    SOCIETE    = societe,
                    IDEMPRIENT = emprientID
                };

                entity.PERSONNEL.Add(p);
                entity.SaveChanges();
                ajout.ForeColor = Color.Green;
                MessageFormtOK MessageFormtOK = new MessageFormtOK("ajout avec success");
                var            result         = MessageFormtOK.ShowDialog();

                this.Close();
            }//Try end
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
Example #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            string imgpath = img.ImageLocation;

            // int salaire = 0;

            try
            {
                if (imgpath != null)
                {
                    FileStream   fs = new FileStream((string)imgpath, FileMode.Open, FileAccess.Read);
                    BinaryReader br = new BinaryReader(fs);
                    FileInfo     fi = new FileInfo((string)imgpath);
                    imgdata = br.ReadBytes((int)fi.Length);
                    fs.Close();
                    br.Close();
                }

                PERSONNEL personnel = entity.PERSONNEL.FirstOrDefault(per => per.MAT == PersonnelMat);
                personnel.MAT      = tb1.Text;
                personnel.NOM      = tb2.Text;
                personnel.PRENOM   = tb3.Text;
                personnel.TEL      = tb4.Text;
                personnel.ADR_P    = tb5.Text;
                personnel.VILLE_P  = tb6.Text;
                personnel.POSTE    = tb7.Text;
                personnel.DATE_EMB = dt.Value;
                personnel.SALAIRE  = Convert.ToDecimal(tb8.Text);
                personnel.PHOTO    = imgdata;


                entity.SaveChanges();
                // ajout.ForeColor = Color.Green;


                // Vide_le_Champs();
                this.Close();
                //var dialogresult = MessageBox.Show("ajout avec success");
            }//Try end
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
Example #4
0
        public Form3(string PersonnelMat)
        {
            this.PersonnelMat = PersonnelMat;
            InitializeComponent();

            try
            {
                PERSONNEL p = entity.PERSONNEL.FirstOrDefault(per => per.MAT == PersonnelMat);
                tb1.Text = p.MAT;
                tb2.Text = p.NOM;
                tb3.Text = p.PRENOM;
                tb4.Text = p.TEL;
                tb5.Text = p.ADR_P;
                tb6.Text = p.VILLE_P;
                tb7.Text = p.POSTE;
                dt.Value = p.DATE_EMB.Value;
                tb8.Text = p.SALAIRE.ToString();
                imgdata  = p.PHOTO;
                MemoryStream ms = new MemoryStream(imgdata);
                img.Image = Image.FromStream(ms);

                comboBox1.DataSource    = entity.SOCIETE.ToList();
                comboBox1.DisplayMember = "NOM_S";
                comboBox1.ValueMember   = "CODE_S";
                comboBox1.SelectedValue = p.CODE_S;
                comboBox2.DataSource    = entity.SHIFT.ToList();
                comboBox2.DisplayMember = "LIBELLE";
                comboBox2.ValueMember   = "CODE";
                comboBox1.SelectedValue = p.SHIFT.CODE;
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }
Example #5
0
        public static void matching()
        {
            initialiser();

            while (!StopBits)
            {
                while (!outPut.Contains("Found ID "))
                {
                    //Console.Write(".");
                }
                outPut = "";
                while (idEmprient == "" || idEmprient == "\n")
                {
                    idEmprient = port.ReadExisting();
                }

                // while(!outPut.Contains("operation terminé"))
                Console.Write(idEmprient);
                decimal id;

                if (Decimal.TryParse(idEmprient, out id))
                {
                    Console.WriteLine(id);
                    idEmprient = "";


                    DbEntities entity     = new DbEntities();
                    MACHINE    machine    = entity.MACHINE.Where(m => m.ID_M == 21).FirstOrDefault();
                    PERSONNEL  p          = entity.PERSONNEL.FirstOrDefault(per => per.IDEMPRIENT == id);
                    DateTime   Datenow    = DateTime.Now;
                    DateTime   Datedebut  = (DateTime)p.SHIFT.DATEDDEBUT;
                    DateTime   Datedefin  = (DateTime)p.SHIFT.DATEDFIN;
                    DateTime   Heuredebut = (DateTime)p.SHIFT.HEUREDEBUT;
                    DateTime   Heuredefin = (DateTime)p.SHIFT.HEUREFIN;
                    //DateTime heuredebutpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREDEBUT;
                    //DateTime heuredefinpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREFIN;
                    if (Datedebut.CompareTo(Datenow) <= 0 && Datedefin.CompareTo(Datenow) >= 0 && Heuredebut.TimeOfDay.CompareTo(Datenow.TimeOfDay) <= 0 && Heuredefin.TimeOfDay.CompareTo(Datenow.TimeOfDay) >= 0)
                    {
                        var count = entity.POINTAGE.Where(point => point.MAT.Equals(p.MAT)).Count();
                        if (count % 2 == 0)
                        {
                            sens = "Entrée";
                        }
                        else
                        {
                            sens = "Sortie";
                        }
                        port.Write("1");
                        POINTAGE Pointage = new POINTAGE
                        {
                            MAT       = p.MAT,
                            DATE_P    = Datenow,
                            ID_M      = machine.ID_M,
                            SENS      = sens,
                            PERSONNEL = p,
                            MACHINE   = machine
                        };
                        entity.POINTAGE.Add(Pointage);
                        entity.SaveChanges();


                        Console.Write("okkkkk" + Datedebut + " <=" + Datenow + " >= " + Datedefin);
                    }
                    else
                    {
                        port.Write("2"); Console.Write("not okkkkk" + Datedebut + " >" + Datenow + " >= " + Datedefin);
                    }
                }
                else
                {
                    port.Write("2");  Console.WriteLine("Unable to parse '{0}'.", idEmprient);
                }

                //StopBits = true;
            }
        }
Example #6
0
        public static void matching()
        {
            try
            {
                initialiser();

                while (!StopBits)
                {
                    while (!outPut.Contains("Found ID "))
                    {
                        //Console.Write(".");
                    }
                    outPut = "";
                    while (idEmprient == "" || idEmprient == "\n")
                    {
                        idEmprient = port.ReadExisting();
                    }

                    // while(!outPut.Contains("operation terminé"))
                    Console.Write(idEmprient);
                    decimal id;

                    if (Decimal.TryParse(idEmprient, out id))
                    {
                        Console.WriteLine(id);
                        idEmprient = "";


                        DbEntities entity     = new DbEntities();
                        MACHINE    machine    = entity.MACHINE.Where(m => m.ID_M == 21).FirstOrDefault();
                        PERSONNEL  p          = entity.PERSONNEL.FirstOrDefault(per => per.IDEMPRIENT == id);
                        DateTime   Datenow    = DateTime.Now;
                        DateTime   Datedebut  = (DateTime)p.SHIFT.DATEDDEBUT;
                        DateTime   Datedefin  = (DateTime)p.SHIFT.DATEDFIN;
                        DateTime   Heuredebut = (DateTime)p.SHIFT.HEUREDEBUT;
                        DateTime   Heuredefin = (DateTime)p.SHIFT.HEUREFIN;
                        //DateTime heuredebutpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREDEBUT;
                        //DateTime heuredefinpause = (DateTime)p.SHIFT.FirstOrDefault().HEUREFIN;
                        if (Datedebut.CompareTo(Datenow) <= 0 && Datedefin.CompareTo(Datenow) >= 0 && Heuredebut.TimeOfDay.CompareTo(Datenow.TimeOfDay) <= 0 && Heuredefin.TimeOfDay.CompareTo(Datenow.TimeOfDay) >= 0)
                        {
                            var count = entity.POINTAGE.Where(point => point.MAT.Equals(p.MAT)).Count();
                            if (count % 2 == 0)
                            {
                                sens = "Entrée";
                            }
                            else
                            {
                                sens = "Sortie";
                            }
                            port.Write("1");
                            POINTAGE Pointage = new POINTAGE
                            {
                                MAT       = p.MAT,
                                DATE_P    = Datenow,
                                ID_M      = machine.ID_M,
                                SENS      = sens,
                                PERSONNEL = p,
                                MACHINE   = machine
                            };
                            entity.POINTAGE.Add(Pointage);
                            entity.SaveChanges();

                            if (sens == "Entrée")
                            {
                                NotificationPointageForm MessageFormt = new NotificationPointageForm("Entrée enregitré pour : " + p.NOM + " " + p.PRENOM + " le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());
                                MessageFormt.ShowDialog();
                            }
                            else
                            {
                                NotificationPointageForm MessageFormt = new NotificationPointageForm("Sortie enregisté pour : " + p.NOM + " " + p.PRENOM + "le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());
                                MessageFormt.ShowDialog();
                            }
                        }
                        else
                        {
                            port.Write("2");
                            MessageFormError MessageForm = new MessageFormError("Access refusé pour : " + p.NOM + " " + p.PRENOM + "le " + Datenow.ToShortDateString() + " à " + Datenow.ToShortTimeString());

                            MessageForm.ShowDialog();
                        }
                    }
                    else
                    {
                        port.Write("2"); Console.WriteLine("Unable to parse '{0}'.", idEmprient);
                    }

                    //StopBits = true;
                }
            }
            catch (Exception ex)
            {
                MessageFormError MessageForm = new MessageFormError(ex.Message.ToString());
                var result = MessageForm.ShowDialog();
            }
        }