Beispiel #1
0
 public bool Save()
 {
     if (State == States.ADD)
     {
         if (IsConfirmerParValide())
         {
             DTR_Depart.BeginEdit();
             DTR_Depart["ConfirmerPar"] = ir_departs.tb_confirmerPar.Text;
             DTR_Depart.EndEdit();
             try
             {
                 TA_DEPART.Update(dS_Master.DEPART);
                 AjustDe(false);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
                 return(false);
             }
             TA_ARRIVE.Fill(dS_Master.ARRIVE);
             Sync_ForeignTables();
             ir_departs.tb_confirmerPar.ResetText();
             return(true);
         }
         else
         {
             ir_departs.tb_confirmerPar.Focus();
             return(false);
         }
     }
     return(false);
 }
Beispiel #2
0
        public bool Delete()
        {
            TA_DEPART.FillByToDel(dS_Master.DEPART, DateTime.Today.ToString());
            if (dS_Master.Tables["DEPART"].Rows.Count <= 0)
            {
                MessageBox.Show("Aucun depart n'est disponible pour être supprimer");
                TA_DEPART.FillByDEPART(dS_Master.DEPART);
                return(false);
            }
            BS_DEPART.DataSource = dS_Master;
            BS_DEPART.DataMember = "DEPART";
            PrjEq01_Application.List_Forms.LF_Depart lf_depart = new PrjEq01_Application.List_Forms.LF_Depart(BS_DEPART);
            if (lf_depart.ShowDialog() == DialogResult.Cancel)
            {
                TA_DEPART.FillByDEPART(dS_Master.DEPART);
                BS_DEPART.DataSource = BS_RESERVATION;
                BS_DEPART.DataMember = "DEPART_FK_IdReser";
                return(false);
            }
            DialogResult result = MessageBox.Show("Êtes-vous certains de vouloir supprimer ce départ?", "Supprimer", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            switch (result)
            {
            case DialogResult.Yes:
                DeleteDepart();
                break;

            case DialogResult.No:
                break;
            }
            TA_DEPART.FillByDEPART(dS_Master.DEPART);
            BS_DEPART.DataSource = BS_RESERVATION;
            BS_DEPART.DataMember = "DEPART_FK_IdReser";
            return(true);
        }
Beispiel #3
0
 private void DeleteDepart()
 {
     DTR_Depart            = dS_Master.Tables["DEPART"].NewRow();
     DTR_Depart["IdReser"] = dS_Master.Tables["DEPART"].Rows[BS_DEPART.Position]["IdReser"];
     DTR_Depart["NoCham"]  = dS_Master.Tables["DEPART"].Rows[BS_DEPART.Position]["NoCham"];
     BS_DEPART.RemoveCurrent();
     BS_DEPART.MoveFirst();
     try
     {
         TA_DEPART.Update(dS_Master.DEPART);
         AjustDe(false);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     DTR_Depart.Delete();
 }
Beispiel #4
0
        public void Fill()
        {
            string idArrive = null;

            if (BS_ARRIVE.Position >= 0)
            {
                try
                {
                    idArrive = dS_Master.Tables["ARRIVE"].Rows[BS_ARRIVE.Position]["IdArrive"].ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            if (State == States.ADD)
            {
                TA_ARRIVE.FillBy(this.dS_Master.ARRIVE, DateTime.Today.ToString());
            }
            else
            {
                TA_ARRIVE.Fill(this.dS_Master.ARRIVE);
            }
            TA_CLIENT.Fill(this.dS_Master.CLIENT);
            TA_RESERVATION.Fill(this.dS_Master.RESERVATION);
            TA_DE.Fill(this.dS_Master.DE);
            if (State == States.CONSULT)
            {
                TA_DEPART.FillByDEPART(this.dS_Master.DEPART);
            }
            if (BS_ARRIVE != null && idArrive != null)
            {
                BS_ARRIVE.Position = BS_ARRIVE.Find("IdArrive", idArrive);
            }
            else
            {
                BS_ARRIVE.Position = 0;
            }
            Sync_ForeignTables();
        }
Beispiel #5
0
        public bool Delete()
        {
            TA_TRX.Fill(DS_Master.TRX);
            TA_ARRIVE.Fill(DS_Master.ARRIVE);
            TA_DEPART.Fill(DS_Master.DEPART);

            DTR_RESERV = DS_Master.Tables["RESERVATION"].Rows[BS_RESERVATION.Position];
            int i = DTR_RESERV.GetChildRows("ARRIVE_FK_IdReser").Length;
            int j = DTR_RESERV.GetChildRows("DEPART_FK_IdReser").Length;

            // Pré-conditions
            if (i != 0 && j != i)
            {
                MessageBox.Show("Le nombre d'arrivés n'est pas compatible avec le nombre de départs associés à cette réservation", "Impossible de suprimer");
                return(false);
            }

            if (ir_Reserv.DTP_Fin.Value.AddDays(2) < DateTime.Today)
            {
                MessageBox.Show("Une réservation doit rester dans la base de donnée au moins 2 jours après sa date de fin.", "Impossible de suprimer");
                return(false);
            }

            // Post-conditions
            foreach (DataRow DTR in DTR_RESERV.GetChildRows("TRX_FK_IdReser"))
            {
                DTR["IdReser"] = DBNull.Value;
            }

            foreach (DataRow DTR in DTR_RESERV.GetChildRows("DE_FK_IdReser"))
            {
                DTR.Delete();
            }

            foreach (DataRow DTR in DTR_RESERV.GetChildRows("DEPART_FK_IdReser"))
            {
                DTR.Delete();
            }

            foreach (DataRow DTR in DTR_RESERV.GetChildRows("ARRIVE_FK_IdReser"))
            {
                DTR.Delete();
            }

            DTR_RESERV.Delete();

            try
            {
                TA_TRX.Update(DS_Master.TRX);
                TA_DE.Update(DS_Master.DE);
                TA_ARRIVE.Update(DS_Master.ARRIVE);
                TA_DEPART.Update(DS_Master.DEPART);
                TA_RESERVATION.Update(DS_Master.RESERVATION);

                Sync_ForeignTables();

                MessageBox.Show("Reservation supprimé avec succès.", "Succès");
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }

            return(false);
        }