Exemplo n.º 1
0
 public ShiduchActivity()
 {
     reminder = new ReminderActivity();
 }
        private void btn_Click(object sender, EventArgs e)
        {
            //או שלא בחרו עדיין שידוך
            //או שזה פעילות חדשה ובחרו את אינדקס אפס שזה ריק
            //
            if ((sender as Button) == btnSaveOpenB && (
                    txtSearchShiduch.SelectedIndex < 0 || txtSearchShiduch.SelectedIndex == 0 && newActivity && !thisSideB))
            {
                //אם רוצים לפתוח פעילות כאשר הצד השני לא נבחר אז לא לתת
                // את זה כי זה יכול לעשות הרבה בעיות
                MessageBox.Show("לא נבחר צד ב'");
            }
            else if (radOther.Checked && txtOther.Text.Length <= 0)
            {
                MessageBox.Show("נא לפרט על אופי הפעילות", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtOther.Focus();
            }
            else if (!radDate.Checked && !radProposal.Checked && !radOther.Checked && !radDetails.Checked)
            {
                MessageBox.Show("נא לבחור פעולה", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                radProposal.Focus();
            }
            else
            {
                Activity          = new ShiduchActivity();
                Activity.Date     = DateTime.Parse(txtDate.Text);
                Activity.PeopleId = MyPeople.ID;
                Activity.Action   = radProposal.Checked ? 0
                    : radDate.Checked ? 1 : radDetails.Checked ? 2 : 3;
                if (Shiduch != null && (txtSearchShiduch.SelectedIndex > 0 || updateActivity || thisSideB || isNew_Active_From_Complete_Active))
                {
                    Activity.IdSideB = Shiduch.ID;
                }
                else if (radDetails.Checked || radOther.Checked) //אם זה רק ברור אז אין צורך בצד ב'
                {
                    Activity.IdSideB = -1;
                }
                else
                {
                    MessageBox.Show("נא לבחור את ההצעה", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtSearchShiduch.Focus();
                    return;
                }
                Activity.Status = radIncare.Checked ? 0
                     : radComplete.Checked ? 1 : 2;
                Activity.NotesSummary = txtNotesSummary.Text;
                if (Activity.Action == 3)
                {
                    Activity.NotesSummary = txtOther.Text + "^^^" + txtNotesSummary.Text;
                }
                Activity.reminder.IdUser = int.Parse(
                    (txtReminderInCare.SelectedItem as KeyValueClass).Value.ToString());
                Activity.reminder.Date = txtDateReminder.Value;
                Activity.UserId        = Activity.reminder.IdUser;

                if (newActivity)
                {
                    try
                    {
                        Activity.Id = ShiduchActivity.insertActivity(Activity);
                        ReminderActivity.InsertReminder(Activity);
                    }
                    catch { }
                }
                else if (updateActivity)
                {
                    Activity.Id     = ShiduchActivity.Id;
                    Activity.UserId = ShiduchActivity.UserId;
                    try
                    {
                        ShiduchActivity.updateActivity(Activity);

                        //if (OpenReminder&&txtDateReminder.Value == ShiduchActivity.reminder.Date)
                        //    Activity.reminder.Done = true;
                        if (Activity.Status == (int)ShiduchActivity.ActionStatus.inCare)
                        {
                            Activity.reminder.Done = false;
                        }
                        else
                        {
                            Activity.reminder.Done = true;
                        }
                        ReminderActivity.UpdateReminder(Activity);
                        MessageBox.Show("עודכן בהצלחה");
                    }
                    catch (Exception ex)
                    {
                    }
                }
                if ((sender as Button) == btnSaveOpenB)
                {
                    OpenSideB = true;
                }
                else if (Activity.Status == (int)ShiduchActivity.ActionStatus.completed &&
                         MessageBox.Show("האם ברצונך לפתוח פעילות חדשה?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    OpenNewActivity = true;
                }
                save = true;
                //foreach (Form frm in Application.OpenForms)
                //{
                //    if (frm.GetType() == typeof(MainForm))
                //    {
                //        (frm as MainForm).LoadReminder();
                //    }
                //}

                Close();
            }
        }