예제 #1
0
        private void Search_Click(object sender, EventArgs e)
        {
            using (var db = new FacturationEntities())
            {
                IQueryable <Eau> elecs = db.Eaux;
                var countOfAll         = elecs.Count();
                if (textBoxRechNpo.Text != "")
                {
                    elecs = elecs.Where(el => el.NPolice == textBoxRechNpo.Text);
                }
                else if (textBoxRechNcomp.Text != "")
                {
                    elecs = elecs.Where(el => el.NCompteur == textBoxRechNcomp.Text);
                }
                else if (textBoxRechRef.Text != "")
                {
                    elecs = elecs.Where(el => el.Reference == textBoxRechRef.Text);
                }
                else if (textBoxRechAdress.Text != "")
                {
                    elecs = elecs.Where(el => el.Adresse.Contains(textBoxRechAdress.Text) || el.Adresse.StartsWith(textBoxRechAdress.Text));
                }

                if (elecs.Count() > 0 && elecs.Count() < countOfAll)
                {
                    FillDataGridView(elecs);
                }
                else
                {
                    MessageBox.Show("Aucun resultat trouvé!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         FillDataGridView(db.Eaux);
     }
 }
예제 #3
0
 private void ReleveEauOuElec_Load(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         comboBoxNpolice.DataSource = db.Eaux.Select(ea => ea.NPolice).ToList();
         comboBoxNpolice.AutoCompleteCustomSource.AddRange(db.Eaux.Select(ea => ea.NPolice).ToArray());
         InitFields();
     }
 }
예제 #4
0
 private void textBoxRechNpo_TextChanged(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         IQueryable <Eau> elecs = db.Eaux;
         elecs = elecs.Where(el => el.NPolice == textBoxRechNpo.Text);
         FillDataGridView(elecs.Count() > 0 ? elecs : db.Eaux);
     }
 }
예제 #5
0
 private void ReleveElec_Load(object sender, EventArgs e)
 {
     // Remplissage des numeros de Police
     using (var db = new FacturationEntities())
     {
         comboBoxNpolice.DataSource = db.Electricites.Select(ea => ea.NPolice).ToList();
         comboBoxNpolice.AutoCompleteCustomSource.AddRange(db.Electricites.Select(ea => ea.NPolice).ToArray());
         InitFields();
     }
 }
예제 #6
0
        private void confirm_Click(object sender, EventArgs e)
        {
            //if (textBoxAnnee.Text != "" && comboBoxTrimestre.Text != "" && textBoxNewIndex.Text != "" && textBoxPrevIndex.Text != "" && comboBoxNpolice.Text != "" && textBoxAdress.Text != "" && textBoxNCompt.Text != "" )
            //{
            //    if (MessageBox.Show("Voulez vous vraiment confirmer!", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            //    {
            //        if (textBoxMotif.Text == "")
            //            dataGridView1.Rows.Add(comboBoxNpolice.Text, textBoxAdress.Text, textBoxAnnee.Text, comboBoxTrimestre.Text, textBoxNewIndex.Text, textBoxPrevIndex.Text, textBoxConsommation.Text, textBoxNetPayer.Text);
            //        else
            //            dataGridView1.Rows.Add(comboBoxNpolice.Text, textBoxAdress.Text, textBoxAnnee.Text, comboBoxTrimestre.Text, textBoxNewIndex.Text, textBoxPrevIndex.Text, textBoxConsommation.Text, textBoxNetPayer.Text, textBoxMotif.Text);
            //    }
            //}

            //else
            //    MessageBox.Show("Veuillez remplir tous les champs!", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
            var All_Ok = true;

            foreach (Control control in Controls.OfType <TextBox>())
            {
                if (control.Text == "")
                {
                    All_Ok = false;
                    break;
                }
            }

            if (comboBoxTrimestre.Text == "" || (textBoxMotif.Visible && textBoxMotif.Text == ""))
            {
                All_Ok = false;
            }

            if (!All_Ok)
            {
                ErrorMbox("Veuiller remplir tous les champs!");
            }

            else if (MessageBox.Show("Voulez vous vraiment confirmer!", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                using (var db = new FacturationEntities())
                {
                    db.RelveeEaux.Add(new RelveeEau
                    {
                        Eau_NPolice = comboBoxNpolice.Text,
                        Annee       = short.Parse(textBoxAnnee.Text),
                        Trimestre   = int.Parse(comboBoxTrimestre.Text),
                        NIndex      = int.Parse(textBoxNewIndex.Text),
                        PIndex      = int.Parse(textBoxPrevIndex.Text),
                        NPayer      = float.Parse(textBoxNetPayer.Text),
                        Rapport     = textBoxMotif.Visible ? textBoxMotif.Text : null
                    });
                    db.SaveChanges();
                }
                comboBoxNpolice_SelectedIndexChanged(sender, e);
            }
        }
예제 #7
0
 private void FormTelecommunication_Load(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         comboBoxEtat.DataSource    = db.Etats.ToList();
         comboBoxEtat.DisplayMember = "NomEtat";
         comboBoxEtat.ValueMember   = "id";
         comboBoxType.DataSource    = db.TypeTelecommunications.ToList();
         comboBoxType.DisplayMember = "NomTypeTelecommunication";
         comboBoxType.ValueMember   = "id";
     }
 }
예제 #8
0
 private void FormEau_Load(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         comboBoxEtat.DataSource    = db.Etats.ToList();
         comboBoxEtat.DisplayMember = "NomEtat";
         comboBoxEtat.ValueMember   = "id";
         comboBoxType.DataSource    = db.TypeEaux.ToList();
         comboBoxType.DisplayMember = "NomTypeEau";
         comboBoxType.ValueMember   = "id";
         FillDataGridView(db.Eaux);
     }
 }
예제 #9
0
 private void dellete_Click(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         var eau = db.Eaux.SingleOrDefault(ea => ea.NPolice == textBoxPolice.Text);
         if (eau == null)
         {
             return;
         }
         db.Eaux.Remove(eau);
         db.SaveChanges();
     }
 }
예제 #10
0
 private void del_Click(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         var Telecommunication = db.TeleCommunications.SingleOrDefault(ea => ea.NPolice == textBoxPolice.Text);
         if (Telecommunication == null)
         {
             return;
         }
         db.TeleCommunications.Remove(Telecommunication);
         db.SaveChanges();
     }
 }
예제 #11
0
        // Modifier un Eau
        private void edit_Click(object sender, EventArgs e)
        {
            using (var db = new FacturationEntities())
            {
                var eau = db.Eaux.SingleOrDefault(ea => ea.NPolice == textBoxPolice.Text);

                eau.Etat_id    = (int)comboBoxEtat.SelectedValue;
                eau.TypeEau_id = (int)comboBoxType.SelectedValue;
                eau.Annee      = short.Parse(textBoxAnnee.Text);

                db.SaveChanges();
                FillDataGridView(db.Eaux);
            }
        }
예제 #12
0
        private void edit_Click(object sender, EventArgs e)
        {
            using (var db = new FacturationEntities())
            {
                var Telecommunication = db.TeleCommunications.SingleOrDefault(ea => ea.NPolice == textBoxPolice.Text);

                Telecommunication.Etat = db.Etats.Single(et => et.id == (int)comboBoxEtat.SelectedValue);
                Telecommunication.TypeTelecommunication = db.TypeTelecommunications.Single(te => te.id == (int)comboBoxType.SelectedValue);
                Telecommunication.Tel     = textBoxTel.Text;
                Telecommunication.Date    = dateTimePickerTelecom.Value;
                Telecommunication.MD      = textBoxMD.Text;
                Telecommunication.Adresse = textBoxAdresse.Text;
                Telecommunication.Montant = short.Parse(textBoxPrice.Text);
                Telecommunication.Forfait = int.Parse(textBoxForfait.Text);
                db.SaveChanges();
            }
        }
예제 #13
0
        private void comboBoxNpolice_SelectedIndexChanged(object sender, EventArgs e)
        {
            using (var db = new FacturationEntities())
            {
                var npolice = comboBoxNpolice.SelectedValue.ToString();

                var eau = db.Eaux.Single(ea => ea.NPolice == npolice);
                textBoxAdress.Text = eau.Adresse;
                textBoxNCompt.Text = eau.NCompteur.ToString();
                InitFields();
                dataGridView1.Rows.Clear();
                foreach (var rel in eau.RelveeEaux)
                {
                    dataGridView1.Rows.Add(eau.NPolice, eau.Adresse, eau.Annee, rel.Trimestre, rel.NIndex, rel.PIndex, rel.NIndex - rel.PIndex, rel.NPayer, rel.Rapport);
                }
            }
        }
예제 #14
0
        private void edit_Click(object sender, EventArgs e)
        {
            using (var db = new FacturationEntities())
            {
                var eau = db.Eaux.SingleOrDefault(ea => ea.NPolice == textBoxPolice.Text);

                eau.Etat      = db.Etats.Single(et => et.id == (int)comboBoxEtat.SelectedValue);
                eau.TypeEau   = db.TypeEaux.Single(te => te.id == (int)comboBoxType.SelectedValue);
                eau.NCompteur = textBoxNcompteur.Text;
                eau.Tel       = textBoxTeli.Text;
                eau.Date      = dateTimePickerElec.Value;
                eau.Reference = textBoxReference.Text;
                eau.Adresse   = textBoxAdresse.Text;
                eau.Annee     = short.Parse(textBoxAnnee.Text);

                db.SaveChanges();
            }
        }
예제 #15
0
        private void FormElec_Load(object sender, EventArgs e)
        {//Remplissage des Comboboxs
            using (var db = new FacturationEntities())
            {
                comboBoxEtat.DataSource    = db.Etats.ToList();
                comboBoxEtat.DisplayMember = "NomEtat";
                comboBoxEtat.ValueMember   = "id";
                comboBoxType.DataSource    = db.TypeElectricites.ToList();
                comboBoxType.DisplayMember = "NomTypeElec";
                comboBoxType.ValueMember   = "id";

                //Remplissage de dataGridView
                FillDataGridView(db.Eaux);

                textBoxRechNpo.AutoCompleteCustomSource.AddRange(db.Electricites.Select(el => el.NPolice).ToArray());
                textBoxRechAdress.AutoCompleteCustomSource.AddRange(db.Electricites.Select(el => el.Adresse).ToArray());
            }
        }
예제 #16
0
 private void add_Click(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         db.TeleCommunications.Add(new TeleCommunication
         {
             NPolice = textBoxPolice.Text,
             Etat    = db.Etats.Single(et => et.id == (int)comboBoxEtat.SelectedValue),
             TypeTelecommunication = db.TypeTelecommunications.Single(te => te.id == (int)comboBoxType.SelectedValue),
             Tel     = textBoxTel.Text,
             Date    = dateTimePickerTelecom.Value,
             MD      = textBoxMD.Text,
             Adresse = textBoxAdresse.Text,
             Forfait = int.Parse(textBoxForfait.Text),
             Montant = double.Parse(textBoxPrice.Text)
         });
         db.SaveChanges();
     }
 }
예제 #17
0
 //Ajouter
 private void add_Click(object sender, EventArgs e)
 {
     using (var db = new FacturationEntities())
     {
         db.Eaux.Add(new Eau
         {
             NPolice   = textBoxPolice.Text,
             Etat      = db.Etats.Single(et => et.id == (int)comboBoxEtat.SelectedValue),
             TypeEau   = db.TypeEaux.Single(te => te.id == (int)comboBoxType.SelectedValue),
             NCompteur = textBoxNcompteur.Text,
             Tel       = textBoxTeli.Text,
             Date      = dateTimePickerElec.Value,
             Reference = textBoxReference.Text,
             Adresse   = textBoxAdresse.Text,
             Annee     = short.Parse(textBoxAnnee.Text)
         });
         db.SaveChanges();
     }
 }
예제 #18
0
        private void InitFields()
        {
            using (var db = new FacturationEntities())
            {
                // l'année
                textBoxAnnee.Text = DateTime.Today.Year.ToString();
                // L'index précèdent
                var rel = db.RelveeEaux.Where(r => r.Eau_NPolice == comboBoxNpolice.Text).OrderByDescending(r => r.Id).FirstOrDefault();
                textBoxPrevIndex.Text = rel != null?rel.NIndex.ToString() : "0";

                // Trimmestre
                comboBoxTrimestre.Items.Clear();
                for (int i = 0; i < 4; i++)
                {
                    comboBoxTrimestre.Items.Add(i + 1);
                }
                comboBoxTrimestre.Text = "1";
                if (rel == null)
                {
                    return;
                }
                comboBoxTrimestre.Text = rel.Trimestre != 4 ? (++rel.Trimestre).ToString() : "1";
            }
        }