Example #1
0
        private void btnWorkerList_Click(object sender, EventArgs e)
        {
            WorkerListForm workerList = new WorkerListForm();

            workerList.ShowDialog();
        }
Example #2
0
        private void OpenForm(object sender, EventArgs e)
        {
            var btn  = (Button)sender;
            var text = btn.Text;

            CatelogForm form = null;

            if (Application.OpenForms.OfType <CatelogForm>().Count() != 0)
            {
                form = Application.OpenForms.OfType <CatelogForm>().LastOrDefault();
            }
            if (form != null)
            {
                var gbo = form.pnlFill;
                form.Skip = true;
                gbo.Controls.Clear();

                if (text == "Worker")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <WorkerListForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <WorkerListForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new WorkerListForm()
                            {
                                TopLevel    = false,
                                Dock        = DockStyle.Fill,
                                AutoScroll  = true,
                                CatelogForm = form
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new WorkerListForm()
                        {
                            TopLevel    = false,
                            Dock        = DockStyle.Fill,
                            AutoScroll  = true,
                            CatelogForm = form
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Category")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <Category>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <Category>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                        }
                        var selectionForm = new Category()
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new Category()
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Patient")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <PatientListForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <PatientListForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new PatientListForm()
                            {
                                TopLevel    = false,
                                Dock        = DockStyle.Fill,
                                AutoScroll  = true,
                                Account     = _account,
                                CatelogForm = form
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}

                    else
                    {
                        var selectionForm = new PatientListForm()
                        {
                            TopLevel    = false,
                            Dock        = DockStyle.Fill,
                            AutoScroll  = true,
                            Account     = _account,
                            CatelogForm = form
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "CheckIn")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <CheckInsForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <CheckInsForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new CheckInsForm
                            {
                                TopLevel   = false,
                                Dock       = DockStyle.Fill,
                                AutoScroll = true
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new CheckInsForm
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Sample")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <SamplesForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <SamplesForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new SamplesForm()
                            {
                                TopLevel   = false,
                                Dock       = DockStyle.Fill,
                                AutoScroll = true,
                                Account    = _account
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new SamplesForm()
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true,
                            Account    = _account
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Management")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <Managements>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <Managements>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new Managements()
                            {
                                TopLevel   = false,
                                Dock       = DockStyle.Fill,
                                AutoScroll = true
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new Managements()
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Medical")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <MedicalsForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <MedicalsForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            gbo.Controls.Add(firstOrDefault);
                            firstOrDefault.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new MedicalsForm()
                        {
                            TopLevel    = false,
                            Dock        = DockStyle.Fill,
                            AutoScroll  = true,
                            Account     = _account,
                            CatelogForm = form
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "WaitingList")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <WaitingForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <WaitingForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new WaitingForm()
                            {
                                TopLevel    = false,
                                Dock        = DockStyle.Fill,
                                AutoScroll  = true,
                                Account     = _account,
                                CatelogForm = form
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new WaitingForm()
                        {
                            TopLevel    = false,
                            Dock        = DockStyle.Fill,
                            AutoScroll  = true,
                            Account     = _account,
                            CatelogForm = form
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
                if (text == "Report")
                {
                    if (Application.OpenForms.OfType <HistorysForm>().Count() != 0)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <HistorysForm>().LastOrDefault();
                        if (firstOrDefault != null)
                        {
                            if (firstOrDefault.NewMedical || firstOrDefault.Editing)
                            {
                                var result = MessageBox.Show(@"Do you really want to leave this? leaving this document will delete all your current work.", @"Leave", MessageBoxButtons.YesNo);
                                if (result == DialogResult.No)
                                {
                                    gbo.Controls.Add(firstOrDefault);
                                    firstOrDefault.CatelogForm.Skip = false;
                                    firstOrDefault.Show();
                                    return;
                                }
                                if (result == DialogResult.Yes)
                                {
                                    firstOrDefault.Close();
                                }
                            }
                        }
                    }
                    if (Application.OpenForms.OfType <WaitingForm>().Count() == 1)
                    {
                        var firstOrDefault = Application.OpenForms.OfType <WaitingForm>().FirstOrDefault();
                        if (firstOrDefault != null)
                        {
                            firstOrDefault.Close();
                            var selectionForm = new Report()
                            {
                                TopLevel   = false,
                                Dock       = DockStyle.Fill,
                                AutoScroll = true,
                            };
                            gbo.Controls.Add(selectionForm);
                            selectionForm.Show();
                        }
                    }
                    //if (Application.OpenForms.OfType<MedicalsForm>().Count() == 1)
                    //{
                    //    var firstOrDefault = Application.OpenForms.OfType<MedicalsForm>().FirstOrDefault();
                    //    if (firstOrDefault != null)
                    //    {
                    //        firstOrDefault.Clear();
                    //        firstOrDefault.Close();
                    //    }
                    //}
                    else
                    {
                        var selectionForm = new Report()
                        {
                            TopLevel   = false,
                            Dock       = DockStyle.Fill,
                            AutoScroll = true,
                        };
                        gbo.Controls.Add(selectionForm);
                        selectionForm.Show();
                    }
                }
            }
        }