}//Busca la ley para retornarla public void DeleteLaw(string Lawname) { Ley tempLey = new Ley("", ""); this.rentLaws(Lawname, ref tempLey);//Para poder convertir el nombre al objeto ley //ciclo para que todos los parlamentarios que tienen la ley la regresen antes de eliminarla for (int i = 0; i < Congress.Length; i++) { //Ciclo para que en un parlamentario se busque si tiene la ley for (int j = 0; j < Congress[i].LeyesEnAlquiler.Length; j++) { //si alguna de sus leyes coincide con el nombre, se devuelve if (Lawname == Congress[i].LeyesEnAlquiler[j].returnName()) { Congress[i].DevolverLey(tempLey); } } //este ciclo es para buscar en los asesores a ver si alguno la tiene for (int k = 0; k < 8; k++) { //entra al parlamentario donde estan los asesores, entra a los asesores donde estan //sus leyes prestadas, entra a las leyes para comparar... for (int j = 0; j < Congress[i].Asesores[k].LeyesEnAlquiler.Length; j++) { if (Lawname == Congress[i].Asesores[k].LeyesEnAlquiler[j].returnName()) { Congress[i].Asesores[k].DevolverLey(tempLey); } } } tempLey = null; GoathemalaLaws[ReturnNumberOfLaw(Lawname)] = null; this.ArreglarLeyes(); } }
}//Renta una ley private void RentLaws_Return_Buttom_Click(object sender, EventArgs e) { Ley A = new Ley("", ""); Goathemala.returnLaws(RentLaws_ReturnLaw_Combobox.Text, ref A); if (Act_Work == "Parlamentario") { TempPar.DevolverLey(A); RentLaws_ReturnLaw_Combobox.Items.Clear(); for (int i = 0; i < TempPar.LeyesEnAlquiler.Length; i++) { RentLaws_ReturnLaw_Combobox.Items.Add(TempPar.LeyesEnAlquiler[i].returnName()); } } else { TempAse.DevolverLey(A); RentLaws_ReturnLaw_Combobox.Items.Clear(); for (int i = 0; i < TempAse.LeyesEnAlquiler.Length; i++) { RentLaws_ReturnLaw_Combobox.Items.Add(TempAse.LeyesEnAlquiler[i].returnName()); } } RentLaws_ReturnLaw_Combobox.SelectedIndex = -1; }
}//Agranda el arreglo 1 tamaño y guarda la nueva public void DevolverLey(Ley A) { for (int i = 0; i < LeyesEnAlquiler.Length; i++) { if (A.returnName() == LeyesEnAlquiler[i].returnName()) { LeyesEnAlquiler[i] = null; } } this.ArreglarLeyes(); }//Elimina la ley alquilada
}//Busca la ley para prestarla public void returnLaws(string _name, ref Ley A) { for (int i = 0; i < GoathemalaLaws.Length; i++) { if ((_name == GoathemalaLaws[i].returnName()) && (GoathemalaLaws[i].Copies > 0)) { GoathemalaLaws[i].Copies++; A = GoathemalaLaws[i]; } } }//Busca la ley para retornarla
//---------------------------DeleteLaws--------------------------------------- //---------------------------Rent/Return_Laws--------------------------------------- private void RentLaws_Rent_Buttom_Click(object sender, EventArgs e) { Ley A = new Ley("", ""); Goathemala.rentLaws(RentLaws_ChooseLaw_Combobox.Text, ref A); if (A.returnName() != "") { if (Act_Work == "Parlamentario") { if (TempPar.Yalatiene(RentLaws_ChooseLaw_Combobox.Text) == false) { TempPar.AlquilarLey(A); } else { MessageBox.Show("Usted ya tiene esta ley alquilada"); } } else { if (TempAse.Yalatiene(RentLaws_ChooseLaw_Combobox.Text) == false) { TempAse.AlquilarLey(A); } else { MessageBox.Show("Usted ya tiene esta ley alquilada"); } } } else { MessageBox.Show("Debe de seleccionar una ley"); } RentLaws_ReturnLaw_Combobox.Items.Clear(); //Se vuelven a llenar los combo box. if (Act_Work == "Parlamentario") { for (int i = 0; i < TempPar.LeyesEnAlquiler.Length; i++) { RentLaws_ReturnLaw_Combobox.Items.Add(TempPar.LeyesEnAlquiler[i].returnName()); } } else { for (int i = 0; i < TempAse.LeyesEnAlquiler.Length; i++) { RentLaws_ReturnLaw_Combobox.Items.Add(TempAse.LeyesEnAlquiler[i].returnName()); } } RentLaws_ChooseLaw_Combobox.SelectedIndex = -1; }//Renta una ley
//---------------------------SeeLaws--------------------------------------- //---------------------------CreateLaws--------------------------------------- private void CreateLaws_Create_Buttom_Click(object sender, EventArgs e) { if (CreateLaws_Name_txt.Text != "" && CreateLaws_Description_txt.Text != "") { Ley newLey = new Ley(CreateLaws_Name_txt.Text, CreateLaws_Description_txt.Text); Goathemala.addLaw(newLey); newLey = null; CreateLaws_Name_txt.Text = ""; CreateLaws_Description_txt.Text = ""; } else { MessageBox.Show("Ingrese un nombre o una descripcion"); } }//Crea una nueva ley
}//retorna la posicion de la ley en el arreglo oficial public void rentLaws(string _name, ref Ley A) { for (int i = 0; i < GoathemalaLaws.Length; i++) { if ((_name == GoathemalaLaws[i].returnName())) { if ((GoathemalaLaws[i].Copies > 0)) { GoathemalaLaws[i].Copies--; A = GoathemalaLaws[i]; } else { System.Windows.Forms.MessageBox.Show("Lo sentimos, actualmente no hay copias disponibles"); } } } }//Busca la ley para prestarla
}//Borra la Informacion de un Asesor //Laws public void AlquilarLey(Ley A) { Array.Resize(ref LeyesEnAlquiler, (LeyesEnAlquiler.Length + 1)); LeyesEnAlquiler[LeyesEnAlquiler.Length - 1] = A; }//Agranda el arreglo 1 tamaño y guarda la nueva
//Laws public void addLaw(Ley _NewLey) { Array.Resize(ref GoathemalaLaws, (GoathemalaLaws.Length + 1)); GoathemalaLaws[GoathemalaLaws.Length - 1] = _NewLey; }//Añade una nueva ley en el congreso