public void Fill() { TA_DE.FillBy(DS_Master.DE); TA_CLIENT.Fill(DS_Master.CLIENT); TA_CHAMBRE.Fill(DS_Master.CHAMBRE); TA_RESERVATION.Fill(DS_Master.RESERVATION); }
public bool Delete() { bool hasDepartB = hasDepart(ds_master.ARRIVE[BS_ARRIVE.Position]["IdArrive"].ToString()); bool hasTrxB = hasTrx(ds_master.ARRIVE[BS_ARRIVE.Position]["IdArrive"].ToString()); if (!hasDepartB && !hasTrxB) { DialogResult result = MessageBox.Show("Do you want to delete the arrive?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: DataRowView De = (DataRowView)BS_CHAMBRE[BS_CHAMBRE.Find("NoCham", ds_master.ARRIVE[BS_ARRIVE.Position]["NoCham"])]; DTR_De = De.Row; DTR_De.BeginEdit(); DTR_De["Attribuee"] = false; DTR_De.EndEdit(); BS_ARRIVE.RemoveCurrent(); TA_ARRIVE.Update(ds_master.ARRIVE); TA_DE.Update(ds_master.DE); if (BS_ARRIVE.Count == 0) { Link_All(false); ic_arrive.WipeInformation(); ir_arrive.WipeInformation(); } Sync_ForeignTables(); MessageBox.Show("Deletion successful"); return(true); case DialogResult.No: return(false); default: return(false); } } else { MessageBox.Show("Can't delete an arrive with a " + (hasDepartB ? (hasTrxB ? "depart and a transaction" : "depart") : "transaction"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }
public bool Save() { if (!CheckErrors()) { ic_Reserv.ResetErrors(); lc_reserv.ResetErrors(); TA_RESERVATION.Update(DS_Master.RESERVATION); try { TA_DE.Update(DS_Master.DE); return(true); } catch (Exception e) { MessageBox.Show(e.Message); } } return(false); }
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(); }
public bool Save() { bool hasErrors = CheckSaveErrors(); if (State == States.ADD || State == States.EDIT) { if (!hasErrors) { DialogResult result = MessageBox.Show("Do you want to save the information?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); switch (result) { case DialogResult.Yes: try { DTR_Arrive.EndEdit(); DTR_De.EndEdit(); TA_ARRIVE.Update(ds_master.ARRIVE); TA_DE.Update(ds_master.DE); Link_All(true); this.TA_RESERVATION.FillByARRIVE(this.ds_master.RESERVATION); Sync_ForeignTables(); } catch (Exception e) { hasErrors = true; MessageBox.Show(e.Message); } return(true); case DialogResult.No: return(false); default: return(false); } } } return(!hasErrors); }
private void AjustDe(bool attribuee) { if (DateTime.Today < ir_departs.DTP_Fin.Value) { Object[] pk = new object[2]; pk[0] = DTR_Depart["IdReser"]; pk[1] = DTR_Depart["NoCham"]; DataRow DTR_De = dS_Master.Tables["DE"].Rows.Find(pk); if (DTR_De != null) { DTR_De.BeginEdit(); DTR_De["Attribuee"] = attribuee; DTR_De.EndEdit(); try { TA_DE.Update(dS_Master.DE); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void NewReserv() { TA_DE.FillBy(DS_Master.DE); TA_BK_CHAMBRE.Fill(DS_Master.BK_CHAMBRE); BS_RESERVATION.Position = BS_RESERVATION.Count - 1; BS_BK_CHAMBRE.Position = BS_BK_CHAMBRE.Count - 1; DS_Master.RESERVATION.Columns["IdReser"].AutoIncrementSeed = (int)DS_Master.RESERVATION.Rows[BS_RESERVATION.Position]["IdReser"] + 1; DTR_RESERV = DS_Master.Tables["Reservation"].NewRow(); DTR_RESERV["IdReser"] = (int)DS_Master.RESERVATION.Columns["IdReser"].AutoIncrementSeed; DTR_RESERV["IdCli"] = -1; DTR_RESERV["DateReser"] = DateTime.Today; DTR_RESERV["DateDebut"] = DateTime.Today; DTR_RESERV["DateFin"] = DateTime.Today.AddDays(3); DS_Master.Tables["Reservation"].Rows.Add(DTR_RESERV); BS_RESERVATION.Position = BS_RESERVATION.Count - 1; Link_All(false); Link_Reservation(true); EmptyFields(); }
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); }