Exemple #1
0
        private void Btn_Activities_Add_Click(object sender, EventArgs e)
        {
            Activity_Service eys = new Activity_Service();

            if (!Btn_Activities_Delete.Visible)
            {
                try
                {
                    eys.InsertActivity(Txt_Activities_Name.Text, Txt_Activities_Location.Text, (Dtp_Activities_DatePart.Value.Date + Dtp_Activities_TimePart.Value.TimeOfDay), Txt_Activities_Description.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                try
                {
                    eys.UpdateActivity(Convert.ToInt32(Txt_Activities_Id.Text), Txt_Activities_Name.Text, Txt_Activities_Location.Text, (Dtp_Activities_DatePart.Value.Date + Dtp_Activities_TimePart.Value.TimeOfDay), Txt_Activities_Description.Text);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            Btn_Activities_Add.Text       = "Add";
            Btn_Activities_Delete.Visible = false;

            showPanel("Activities");
        }
Exemple #2
0
        private void btnAddActivity_Click(object sender, EventArgs e)
        {
            SomerenLogic.Activity_Service activity_Service = new Activity_Service();

            // check for empty fields
            if (String.IsNullOrEmpty(txtAddActivityId.Text) || String.IsNullOrEmpty(txtAddDescription.Text))
            {
                MessageBox.Show("Field(s) empty!");
                return; // when a field is empty, display message and return
            }

            // get all values from the textboxes
            int    id          = int.Parse(txtAddActivityId.Text);
            string description = txtAddDescription.Text;

            // insert the activity, reference to service layer
            activity_Service.InsertActivity(id, description);
        }