Commit 7ee4276b authored by Xavier de Blas's avatar Xavier de Blas

Added personAddMultiple (now we can create 10 persons at once) (closes task: 270)

parent 04b9f927
CHANGELOG:
19 aug 2005
Added personAddMultiple (now we can create 10 persons at once) (closes task: 270)
18 aug 2005
Add run type and run interval type (closes task: 282)
......
No preview for this file type
This diff is collapsed.
......@@ -109,7 +109,8 @@ public class ChronoJump
[Widget] Gtk.MenuItem menuitem_export_csv;
[Widget] Gtk.MenuItem menuitem_export_xml;
[Widget] Gtk.MenuItem menuitem_recuperate_person;
[Widget] Gtk.MenuItem create_person;
[Widget] Gtk.MenuItem menuitem_person_add_single;
[Widget] Gtk.MenuItem menuitem_person_add_multiple;
[Widget] Gtk.MenuItem menuitem_edit_session;
[Widget] Gtk.MenuItem menuitem_delete_session;
[Widget] Gtk.MenuItem menuitem_recuperate_persons_from_session;
......@@ -204,6 +205,7 @@ public class ChronoJump
SessionLoadWindow sessionLoadWin;
PersonRecuperateWindow personRecuperateWin;
PersonAddWindow personAddWin;
PersonAddMultipleWindow personAddMultipleWin;
PersonModifyWindow personModifyWin;
JumpsMoreWindow jumpsMoreWin;
JumpsRjMoreWindow jumpsRjMoreWin;
......@@ -1002,18 +1004,33 @@ public class ChronoJump
sensitiveGuiYesPerson();
}
private void on_create_person_activate (object o, EventArgs args) {
Console.WriteLine("nuevo suj.");
private void on_person_add_single_activate (object o, EventArgs args) {
personAddWin = PersonAddWindow.Show(app1, currentSession.UniqueID);
personAddWin.Button_accept.Clicked += new EventHandler(on_new_person_accepted);
personAddWin.Button_accept.Clicked += new EventHandler(on_person_add_single_accepted);
}
private void on_new_person_accepted (object o, EventArgs args) {
private void on_person_add_single_accepted (object o, EventArgs args) {
if (personAddWin.CurrentPerson != null)
{
currentPerson = personAddWin.CurrentPerson;
updateComboSujetoCurrent();
sensitiveGuiYesPerson();
appbar2.Push( "Successfully added " + currentPerson.Name );
}
}
private void on_person_add_multiple_activate (object o, EventArgs args) {
personAddMultipleWin = PersonAddMultipleWindow.Show(app1, currentSession.UniqueID);
personAddMultipleWin.Button_accept.Clicked += new EventHandler(on_person_add_multiple_accepted);
}
private void on_person_add_multiple_accepted (object o, EventArgs args) {
if (personAddMultipleWin.CurrentPerson != null)
{
currentPerson = personAddMultipleWin.CurrentPerson;
updateComboSujetoCurrent();
sensitiveGuiYesPerson();
appbar2.Push( "Successfully added " + personAddMultipleWin.PersonsCreatedCount + " persons" );
}
}
......@@ -2182,7 +2199,8 @@ public class ChronoJump
menuitem_export_xml.Sensitive = false;
menuitem_recuperate_person.Sensitive = false;
menuitem_recuperate_persons_from_session.Sensitive = false;
create_person.Sensitive = false;
menuitem_person_add_single.Sensitive = false;
menuitem_person_add_multiple.Sensitive = false;
combo_person_current.Sensitive = false;
menuitem_edit_session.Sensitive = false;
menuitem_delete_session.Sensitive = false;
......@@ -2220,7 +2238,8 @@ public class ChronoJump
menuitem_export_xml.Sensitive = false; //it's not coded yet
menuitem_recuperate_person.Sensitive = true;
menuitem_recuperate_persons_from_session.Sensitive = true;
create_person.Sensitive = true;
menuitem_person_add_single.Sensitive = true;
menuitem_person_add_multiple.Sensitive = true;
menuitem_edit_session.Sensitive = true;
menuitem_delete_session.Sensitive = true;
menu_persons.Sensitive = true;
......
......@@ -469,3 +469,223 @@ public class PersonModifyWindow
}
}
//new persons multiple (10)
public class PersonAddMultipleWindow {
[Widget] Gtk.Window person_add_multiple;
[Widget] Gtk.Entry entry1;
[Widget] Gtk.Entry entry2;
[Widget] Gtk.Entry entry3;
[Widget] Gtk.Entry entry4;
[Widget] Gtk.Entry entry5;
[Widget] Gtk.Entry entry6;
[Widget] Gtk.Entry entry7;
[Widget] Gtk.Entry entry8;
[Widget] Gtk.Entry entry9;
[Widget] Gtk.Entry entry10;
[Widget] Gtk.RadioButton r_1_m;
[Widget] Gtk.RadioButton r_1_f;
[Widget] Gtk.RadioButton r_2_m;
[Widget] Gtk.RadioButton r_2_f;
[Widget] Gtk.RadioButton r_3_m;
[Widget] Gtk.RadioButton r_3_f;
[Widget] Gtk.RadioButton r_4_m;
[Widget] Gtk.RadioButton r_4_f;
[Widget] Gtk.RadioButton r_5_m;
[Widget] Gtk.RadioButton r_5_f;
[Widget] Gtk.RadioButton r_6_m;
[Widget] Gtk.RadioButton r_6_f;
[Widget] Gtk.RadioButton r_7_m;
[Widget] Gtk.RadioButton r_7_f;
[Widget] Gtk.RadioButton r_8_m;
[Widget] Gtk.RadioButton r_8_f;
[Widget] Gtk.RadioButton r_9_m;
[Widget] Gtk.RadioButton r_9_f;
[Widget] Gtk.RadioButton r_10_m;
[Widget] Gtk.RadioButton r_10_f;
[Widget] Gtk.SpinButton spinbutton1;
[Widget] Gtk.SpinButton spinbutton2;
[Widget] Gtk.SpinButton spinbutton3;
[Widget] Gtk.SpinButton spinbutton4;
[Widget] Gtk.SpinButton spinbutton5;
[Widget] Gtk.SpinButton spinbutton6;
[Widget] Gtk.SpinButton spinbutton7;
[Widget] Gtk.SpinButton spinbutton8;
[Widget] Gtk.SpinButton spinbutton9;
[Widget] Gtk.SpinButton spinbutton10;
[Widget] Gtk.Button button_accept;
static PersonAddMultipleWindow PersonAddMultipleWindowBox;
Gtk.Window parent;
ErrorWindow errorWin;
private Person currentPerson;
int sessionID;
int personsCreatedCount;
string errorExistsString;
string errorWeightString;
PersonAddMultipleWindow (Gtk.Window parent, int sessionID) {
Glade.XML gladeXML = Glade.XML.FromAssembly ("chronojump.glade", "person_add_multiple", null);
gladeXML.Autoconnect(this);
this.parent = parent;
this.sessionID = sessionID;
}
static public PersonAddMultipleWindow Show (Gtk.Window parent, int sessionID)
{
if (PersonAddMultipleWindowBox == null) {
PersonAddMultipleWindowBox = new PersonAddMultipleWindow (parent, sessionID);
}
PersonAddMultipleWindowBox.person_add_multiple.Show ();
return PersonAddMultipleWindowBox;
}
void on_button_cancel_clicked (object o, EventArgs args)
{
PersonAddMultipleWindowBox.person_add_multiple.Hide();
PersonAddMultipleWindowBox = null;
}
void on_delete_event (object o, EventArgs args)
{
PersonAddMultipleWindowBox.person_add_multiple.Hide();
PersonAddMultipleWindowBox = null;
}
void on_button_accept_clicked (object o, EventArgs args)
{
errorExistsString = "";
errorWeightString = "";
personsCreatedCount = 0;
int count = 1;
checkEntries(count++, entry1.Text.ToString(), (int) spinbutton1.Value);
checkEntries(count++, entry2.Text.ToString(), (int) spinbutton2.Value);
checkEntries(count++, entry3.Text.ToString(), (int) spinbutton3.Value);
checkEntries(count++, entry4.Text.ToString(), (int) spinbutton4.Value);
checkEntries(count++, entry5.Text.ToString(), (int) spinbutton5.Value);
checkEntries(count++, entry6.Text.ToString(), (int) spinbutton6.Value);
checkEntries(count++, entry7.Text.ToString(), (int) spinbutton7.Value);
checkEntries(count++, entry8.Text.ToString(), (int) spinbutton8.Value);
checkEntries(count++, entry9.Text.ToString(), (int) spinbutton9.Value);
checkEntries(count++, entry10.Text.ToString(), (int) spinbutton10.Value);
string combinedErrorString = "";
combinedErrorString = readErrorStrings();
if (combinedErrorString.Length > 0) {
errorWin = ErrorWindow.Show(person_add_multiple, combinedErrorString);
} else {
prepareAllNonBlankRows();
PersonAddMultipleWindowBox.person_add_multiple.Hide();
PersonAddMultipleWindowBox = null;
}
}
void checkEntries(int count, string name, int weight) {
if(name.Length > 0) {
bool personExists = SqlitePersonSession.PersonExists (Util.RemoveTilde(name));
if(personExists) {
errorExistsString += "[" + count + "] " + name + "\n";
}
if(weight == 0) {
errorWeightString += "[" + count + "] " + name + "\n";
}
}
}
string readErrorStrings() {
if (errorExistsString.Length > 0) {
errorExistsString = "ERROR This person(s) exists in the database:\n" + errorExistsString;
}
if (errorWeightString.Length > 0) {
errorWeightString = "\nERROR weight of this person(s) cannot be 0:\n" + errorWeightString;
}
return errorExistsString + errorWeightString;
}
//inserts all the rows where name is not blank
//all this names doesn't match with other in the database, and the weights are > 0 ( checked in checkEntries() )
void prepareAllNonBlankRows()
{
//the last is the first for having the first value inserted as currentPerson
if( entry10.Text.ToString().Length > 0 ) {
insertPerson (entry10.Text.ToString(), r_10_m.Active, (int) spinbutton10.Value);
}
if( entry9.Text.ToString().Length > 0 ) {
insertPerson (entry9.Text.ToString(), r_9_m.Active, (int) spinbutton9.Value);
}
if( entry8.Text.ToString().Length > 0 ) {
insertPerson (entry8.Text.ToString(), r_8_m.Active, (int) spinbutton8.Value);
}
if( entry7.Text.ToString().Length > 0 ) {
insertPerson (entry7.Text.ToString(), r_7_m.Active, (int) spinbutton7.Value);
}
if( entry6.Text.ToString().Length > 0 ) {
insertPerson (entry6.Text.ToString(), r_6_m.Active, (int) spinbutton6.Value);
}
if( entry5.Text.ToString().Length > 0 ) {
insertPerson (entry5.Text.ToString(), r_5_m.Active, (int) spinbutton5.Value);
}
if( entry4.Text.ToString().Length > 0 ) {
insertPerson (entry4.Text.ToString(), r_4_m.Active, (int) spinbutton4.Value);
}
if( entry3.Text.ToString().Length > 0 ) {
insertPerson (entry3.Text.ToString(), r_3_m.Active, (int) spinbutton3.Value);
}
if( entry2.Text.ToString().Length > 0 ) {
insertPerson (entry2.Text.ToString(), r_2_m.Active, (int) spinbutton2.Value);
}
if( entry1.Text.ToString().Length > 0 ) {
insertPerson (entry1.Text.ToString(), r_1_m.Active, (int) spinbutton1.Value);
}
}
void insertPerson (string name, bool male, int weight)
{
string sex = "F";
if(male) { sex = "M"; }
currentPerson = new Person ( name, sex, "0/0/1900",
0, weight, //height, weight
"", sessionID //description, sessionID
);
personsCreatedCount ++;
}
public Button Button_accept
{
set {
button_accept = value;
}
get {
return button_accept;
}
}
public int PersonsCreatedCount
{
get { return personsCreatedCount; }
}
public Person CurrentPerson
{
get {
return currentPerson;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment