private void btnDelete_Click(object sender, EventArgs e)
        {
            if (m_candidatesBindingSource.Count > 0)
            {
                MessageBox.Show("You can not delete this opening till You remove all candidates connected to this position", "HunterCV", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("Are You sure to permanently delete this opening from database ?", "HunterCV", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                button1.Enabled   = false;
                button2.Enabled   = false;
                btnDelete.Enabled = false;

                try
                {
                    BackgroundWorker worker = new BackgroundWorker();

                    worker.RunWorkerCompleted += (senders, es) =>
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = false);

                        CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, r =>
                        {
                            m_region.Positions.Remove(m_position);
                        });

                        Form form = MainRegion.GetForm(typeof(PositionsForm));

                        if (form is PositionsForm)
                        {
                            CrossThreadUtility.InvokeControlAction <PositionsForm>(((PositionsForm)form), f => f.DoSearch(-1));
                        }

                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                    };

                    worker.DoWork += (senders, es) =>
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = true);

                        //remove from service
                        ServiceHelper.Delete(m_position);
                    };

                    worker.RunWorkerAsync();
                }
                catch (HttpRequestException)
                {
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool blValidTitle = ValidateTitle();

            if (!blValidTitle)
            {
                return;
            }

            panelWait.Visible = true;
            button1.Enabled   = false;

            this.m_position.PositionAreas = GetNodesPath(tvAreas.Nodes, null);

            //exists
            if (!m_position.IsNew)
            {
                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                    CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                };

                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Update(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
            else
            {
                //new

                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    if (es.Error != null)
                    {
                        if (es.Error is LicenseException)
                        {
                            CrossThreadUtility.InvokeControlAction <Form>(this, f =>
                            {
                                MessageBox.Show(this, "Sorry, but this license type does not allow more entities of those types", "HunterCV", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                f.Close();
                            });
                        }
                    }
                    else
                    {
                        m_position.IsNew = false;

                        CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                        Form form = MainRegion.GetForm(typeof(PositionsForm));

                        if (form is PositionsForm)
                        {
                            CrossThreadUtility.InvokeControlAction <PositionsForm>(((PositionsForm)form), f => f.DoSearch(-1));
                        }


                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                    }
                };



                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Add(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
        }