private void OKDateButton_Click(object sender, EventArgs e)
        {
            //if (HeaderTextEdit.Text.Length < 1 || HeaderTextEdit.Text.Length > 1024)
            //    return;

            bool N = false;

            foreach (DataRow Row in LightNews.ClientsSelectDataTable.Rows)
            {
                if (Convert.ToBoolean(Row["Check"]) == true)
                {
                    N = true;
                    break;
                }
            }

            if (!cbNewsToSite.Checked)
            {
                if (N == false)
                {
                    InfiniumTips.ShowTip(this, 50, 93, "Не выбраны клиенты", 3000);
                    return;
                }
            }

            if (BodyTextEdit.Text.Length < 1)
            {
                InfiniumTips.ShowTip(this, 50, 93, "Не введено содержание", 3000);
                return;
            }

            if (iNewsIDEdit == -1)
            {
                if (!cbNewsToSite.Checked)
                {
                    foreach (DataRow Row in LightNews.ClientsSelectDataTable.Rows)
                    {
                        if (Convert.ToBoolean(Row["Check"]) == false)
                        {
                            continue;
                        }

                        DateTime Date = new DateTime();

                        LoadLabel.Text           = "Создание новости...";
                        OKNewsButton.Enabled     = false;
                        CancelNewsButton.Enabled = false;
                        AttachmentsGrid.ReadOnly = true;
                        BodyTextEdit.Enabled     = false;
                        AttachButton.Enabled     = false;
                        DetachButton.Enabled     = false;
                        HeaderTextEdit.Enabled   = false;

                        Application.DoEvents();

                        if (Convert.ToInt32(Row["UserTypeID"]) == 0) //новость для клиентов
                        {
                            Date = LightNews.AddNews(Security.CurrentUserID, 0, HeaderTextEdit.Text, BodyTextEdit.Text, Convert.ToInt32(Row["ID"]), 2);
                        }
                        if (Convert.ToInt32(Row["UserTypeID"]) == 1) //новость для менеджеров
                        {
                            Date = LightNews.AddNews(Security.CurrentUserID, 0, HeaderTextEdit.Text, BodyTextEdit.Text, Convert.ToInt32(Row["ID"]), 3);
                        }

                        bool Ok = false;

                        bStopTransfer = false;
                        LightNews.FM.bStopTransfer = false;

                        if (AttachmentsBindingSource.Count > 0)
                        {
                            LoadLabel.Visible   = true;
                            ProgressBar.Visible = true;
                            //LoadLabel.Text = "Загрузка прикрепленых файлов...";
                            LoadTimer.Enabled = true;
                            CancelLoadingFilesButton.Visible = true;

                            Application.DoEvents();

                            int LastUploadedFile    = 0;
                            int CurrentUploadedFile = 0;
                            int TotalFilesCount     = AttachmentsDataTable.Rows.Count;

                            Thread T = new Thread(delegate() { Ok = LightNews.Attach(AttachmentsDataTable, Date, ref CurrentUploadedFile, Convert.ToInt32(Row["ID"])); });
                            T.Start();

                            this.Activate();
                            Application.DoEvents();

                            while (T.IsAlive)
                            {
                                T.Join(50);
                                Application.DoEvents();

                                if (CurrentUploadedFile != LastUploadedFile)
                                {
                                    LoadLabel.Text   = "Загрузка прикрепленых файлов(" + CurrentUploadedFile.ToString() + " из " + TotalFilesCount.ToString() + ")";
                                    LastUploadedFile = CurrentUploadedFile;
                                }

                                if (bStopTransfer)
                                {
                                    LightNews.FM.bStopTransfer = true;
                                    bStopTransfer       = false;
                                    LoadTimer.Enabled   = false;
                                    ProgressBar.Visible = false;
                                    LoadLabel.Text      = "Отмена загрузки файлов...";
                                    DownloadLabel.Text  = "";
                                    SpeedLabel.Text     = "";
                                    PercentsLabel.Text  = "";
                                    CancelLoadingFilesButton.Visible = false;

                                    Application.DoEvents();

                                    while (T.IsAlive)
                                    {
                                        Thread.Sleep(50);
                                    }

                                    LightNews.RemoveAttachments(LightNews.GetNewsIDByDateTime(Date));

                                    FormEvent            = eClose;
                                    AnimateTimer.Enabled = true;
                                }
                            }

                            LoadTimer.Enabled = false;

                            if (!Ok)
                            {
                                MessageBox.Show("Один или несколько файлов не были найдены или отсутствовал доступ");
                                return;
                            }
                        }

                        LightNews.ClearPending(Date, Convert.ToInt32(Row["ID"]));

                        if (Convert.ToInt32(Row["UserTypeID"]) == 0) //для клиентов
                        {
                            LightNews.AddSubscribeForNews(Date, 2, Convert.ToInt32(Row["ID"]));
                        }
                        if (Convert.ToInt32(Row["UserTypeID"]) == 1) //для менеджеров
                        {
                            LightNews.AddSubscribeForNews(Date, 3, Convert.ToInt32(Row["ID"]));
                        }
                    }
                }
                else
                {
                    DateTime Date = new DateTime();

                    LoadLabel.Text           = "Создание новости...";
                    OKNewsButton.Enabled     = false;
                    CancelNewsButton.Enabled = false;
                    AttachmentsGrid.ReadOnly = true;
                    BodyTextEdit.Enabled     = false;
                    AttachButton.Enabled     = false;
                    DetachButton.Enabled     = false;
                    HeaderTextEdit.Enabled   = false;

                    Application.DoEvents();

                    Date = LightNews.AddNews(Security.CurrentUserID, 0, HeaderTextEdit.Text, BodyTextEdit.Text, -1, -1);

                    LightNews.ClearPending(Date, -1);

                    LightNews.AddSubscribeForNews(Date, -1, -1);
                }
            }
            else
            {
                LoadLabel.Text           = "Обновление новости...";
                OKNewsButton.Enabled     = false;
                CancelNewsButton.Enabled = false;
                AttachmentsGrid.ReadOnly = true;
                BodyTextEdit.Enabled     = false;
                AttachButton.Enabled     = false;
                DetachButton.Enabled     = false;
                HeaderTextEdit.Enabled   = false;

                Application.DoEvents();

                LightNews.EditNews(iNewsIDEdit, Security.CurrentUserID, 0, HeaderTextEdit.Text, BodyTextEdit.Text, -1, DateTime);


                if (AttachsCount > 0 || AttachmentsBindingSource.Count > 0)
                {
                    bool Ok = false;


                    LoadLabel.Visible   = true;
                    ProgressBar.Visible = true;
                    //LoadLabel.Text = "Загрузка прикрепленых файлов...";
                    LoadTimer.Enabled = true;
                    CancelLoadingFilesButton.Visible = true;

                    Application.DoEvents();

                    int LastUploadedFile    = 0;
                    int CurrentUploadedFile = 0;
                    int TotalFilesCount     = 0;

                    Thread T = new Thread(delegate() { Ok = LightNews.EditAttachments(iNewsIDEdit, AttachmentsDataTable, ref CurrentUploadedFile, ref TotalFilesCount); });
                    T.Start();

                    this.Activate();
                    Application.DoEvents();


                    while (T.IsAlive)
                    {
                        T.Join(50);
                        Application.DoEvents();

                        if (CurrentUploadedFile != LastUploadedFile)
                        {
                            LoadLabel.Text   = "Загрузка прикрепленых файлов(" + CurrentUploadedFile.ToString() + " из " + TotalFilesCount.ToString() + ")";
                            LastUploadedFile = CurrentUploadedFile;
                        }

                        if (bStopTransfer)
                        {
                            LightNews.FM.bStopTransfer = true;
                            bStopTransfer       = false;
                            LoadTimer.Enabled   = false;
                            ProgressBar.Visible = false;
                            LoadLabel.Text      = "Отмена загрузки файлов...";
                            DownloadLabel.Text  = "";
                            SpeedLabel.Text     = "";
                            PercentsLabel.Text  = "";
                            CancelLoadingFilesButton.Visible = false;

                            Application.DoEvents();

                            while (T.IsAlive)
                            {
                                Thread.Sleep(50);
                            }

                            LightNews.RemoveCurrentAttachments(LightNews.GetNewsIDByDateTime(DateTime), AttachmentsDataTable);

                            FormEvent            = eClose;
                            AnimateTimer.Enabled = true;
                        }
                    }

                    LoadTimer.Enabled = false;



                    if (!Ok)
                    {
                        MessageBox.Show("Один или несколько файлов не были найдены или отсутствовал доступ");
                    }
                }
            }

            FormEvent            = eClose;
            AnimateTimer.Enabled = true;
        }