コード例 #1
0
ファイル: Register.cs プロジェクト: Puit/TimeBank
        private void addPersonButtonClick(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nameTextBox.Text) ||
                String.IsNullOrEmpty(passwordTextBox.Text) ||
                String.IsNullOrEmpty(emailTextBox.Text) ||
                String.IsNullOrEmpty(phoneTextBox.Text))
            {
                MessageBox.Show("All the parameters must be filled");
            }
            else
            {
                if (ManageDB.checkIfMailExist(emailTextBox.Text))
                {
                    MessageBox.Show("The mail is already registered.");
                }
                else
                {
                    Person person = new Person();
                    person.userName = nameTextBox.Text;
                    person.password = passwordTextBox.Text;
                    person.email    = emailTextBox.Text;
                    person.phone    = phoneTextBox.Text;
                    person.hours    = 5;
                    ManageDB.addPerson(person);

                    this.Close();
                }
            }
        }
コード例 #2
0
 private void getAllLists()
 {
     hoursLabel.Text     = "Total hours: " + ManageDB.myPerson.hours;
     consumedActivities  = ManageDB.getMyConsumedActivities();
     publishedActivities = ManageDB.getMyPublishedActivities();
     doneActivities      = ManageDB.getMyDoneActivities();
     fillListBoxWithActivities(consumedListBox, consumedActivities);
     fillListBoxWithActivities(publishedListBox, publishedActivities);
     fillListBoxWithActivities(doneListBox, doneActivities);
 }
コード例 #3
0
ファイル: Home.cs プロジェクト: Puit/TimeBank
        private void fillActivitiesListBox()
        {
            hoursLabel.Text = "Total hours: " + ManageDB.myPerson.hours;
            activitiesListBox.Items.Clear();
            offeredActivities = ManageDB.getPublishedActivities();
            foreach (Activity a in offeredActivities)
            {
                String professional = ManageDB.findPerson(a.userProducer).userName;
                String item         = "Professional: " + professional + "; Description: " + a.activityName;

                activitiesListBox.Items.Add(item);
            }
        }
コード例 #4
0
        private void publishedListBox_MouseClick(object sender, MouseEventArgs e)
        {
            Activity     currentActivity = publishedActivities[publishedListBox.SelectedIndex];
            DialogResult result;

            result = MessageBox.Show(publishedListBox.SelectedItem.ToString(),
                                     "Do you want to delete " + ManageDB.findPerson(currentActivity.userProducer).userName + "?",
                                     MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                ManageDB.removeActivity(currentActivity);
            }

            getAllLists();
        }
コード例 #5
0
ファイル: Home.cs プロジェクト: Puit/TimeBank
        private void activitiesListBox_MouseClick(object sender, MouseEventArgs e)
        {
            Activity     currentActivity = offeredActivities[activitiesListBox.SelectedIndex];
            DialogResult result;

            result = MessageBox.Show(activitiesListBox.SelectedItem.ToString(),
                                     "Do you want to contract " + ManageDB.findPerson(currentActivity.userProducer).userName + "?",
                                     MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                if (!ManageDB.transferHours(currentActivity))
                {
                    MessageBox.Show("Currently you don't have enough hours, please work a little bit harder...", "You don't have enough hours.", MessageBoxButtons.OK);
                }
            }
            fillActivitiesListBox();
        }
コード例 #6
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            string mail        = mailTextBox.Text;
            string password    = passwordTextBox.Text;
            string message     = "";
            bool   showMessage = true;

            try
            {
                switch (ManageDB.checkLogin(mail, password))
                {
                case loginOptions.CORRECT:
                    showMessage = false;
                    break;

                case loginOptions.PASSWORD_ERROR:
                    message = "WRONG PASSWORD";
                    break;

                case loginOptions.EMAIL_ERROR:
                    message = "WRONG EMAIL";
                    break;

                default:
                    message = "SOMETHING IS WRONG";
                    break;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception: ", exception.Message);
            }
            if (showMessage)
            {
                MessageBox.Show(message);
            }
            else
            {
                this.Hide();
                Home home = new Home();
                home.ShowDialog();

                this.Close();
            }
        }
コード例 #7
0
        private void fillListBoxWithActivities(ListBox listBox, List <Activity> activityList)
        {
            listBox.Items.Clear();
            foreach (Activity a in activityList)
            {
                Person producer = ManageDB.findPerson(a.userProducer);
                Person consumer = ManageDB.findPerson(a.userConsumer);

                String item = "";
                if (producer.userId != ManageDB.myPerson.userId)
                {
                    item = item + "Producer: " + producer.userName;
                }
                if (consumer.userId != ManageDB.myPerson.userId)
                {
                    item = item + " Consumer: " + consumer.userName;
                }

                item = item + " Description: " + a.activityName;

                listBox.Items.Add(item);
            }
        }
コード例 #8
0
ファイル: Home.cs プロジェクト: Puit/TimeBank
        private void addActivityButton_Click(object sender, EventArgs e)
        {
            String   description = descriptionTextBox.Text;
            Activity myActivity  = new Activity();

            myActivity.activityName = description;
            myActivity.hours        = 1;
            myActivity.userProducer = ManageDB.myPerson.userId;
            myActivity.userConsumer = ManageDB.myPerson.userId;
            myActivity.activityDate = DateTime.Now;
            String message;

            if (String.IsNullOrEmpty(description))
            {
                message = "You must write something in the description.";
            }
            else
            {
                ManageDB.addActivity(myActivity);
                message = "The activity has been published. Check your profile to see it.";
            }
            MessageBox.Show(message, "", MessageBoxButtons.OK);
        }