private void CreateButton_Click(object sender, EventArgs e) { int iCorrespondentID = -1; if (RecipientCheckBox.Checked) { iCorrespondentID = Convert.ToInt32(RecipientComboBox.SelectedValue); } if (iCorrespondentID == 0) { InfiniumTips.ShowTip(this, 50, 85, "Выберите получателя", 2000); return; } if (AttachmentsDataTable.Rows.Count == 0) { InfiniumTips.ShowTip(this, 50, 85, "Не выбраны файлы", 2000); return; } int iCurrentUploadedFile = 0; bool Ok = false; InfiniumDocuments.FM.bStopTransfer = 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 = AttachmentsDataTable.Rows.Count; int DocumentType = Convert.ToInt32(DocumentsTypeComboBox.SelectedValue); string Description = DescriptionTextBox.Text; int DocumentState = Convert.ToInt32(DocumentsStatesComboBox.SelectedValue); int FactoryID = Convert.ToInt32(FactoryTypesComboBox.SelectedValue); if (DocumentType == 0) { InfiniumTips.ShowTip(this, 50, 85, "Выберите тип документа", 2000); return; } RecipientsDataTable.Clear(); foreach (InfiniumDocumentsSelectUserItem Item in RecipientsList.Items) { if (Item.Checked) { DataRow NewRow = RecipientsDataTable.NewRow(); NewRow["UserID"] = Item.UserID; RecipientsDataTable.Rows.Add(NewRow); } } Thread T; if (!bEdit) { T = new Thread(delegate() { Ok = InfiniumDocuments.AddOuterDocument(DocumentType, Security.GetCurrentDate(), Security.CurrentUserID, iCorrespondentID, RecipientsDataTable, Description, RegNumberTextBox.Text, DocumentState, AttachmentsDataTable, ref iCurrentUploadedFile, FactoryID); }); T.Start(); } else { T = new Thread(delegate() { Ok = InfiniumDocuments.EditOuterDocument(OuterDocumentID, DocumentType, Security.CurrentUserID, iCorrespondentID, RecipientsDataTable, Description, RegNumberTextBox.Text, DocumentState, AttachmentsDataTable, ref iCurrentUploadedFile, FactoryID); }); 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) { InfiniumDocuments.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); } FormEvent = eClose; AnimateTimer.Enabled = true; } } FormEvent = eClose; AnimateTimer.Enabled = true; }
private void ClientsSaveButton_Click(object sender, EventArgs e) { if (ClientNameTextBox.Text.Length == 0) { Infinium.LightMessageBox.Show(ref TopForm, false, "Введены не все данные: Клиент!", "Сохранение клиента"); return; } if (CityTextBox.Text.Length == 0) { Infinium.LightMessageBox.Show(ref TopForm, false, "Введены не все данные Город!", "Сохранение клиента"); return; } string UNN = tbUNN.Text; string Name = ClientNameTextBox.Text; int CountryID = Convert.ToInt32(cbCountry.SelectedValue); int ClientGroupID = Convert.ToInt32(cbClientGroups.SelectedValue); string City = CityTextBox.Text; string Site = SiteTextBox.Text; string Email = EmailTextBox.Text; int ManagerID = Convert.ToInt32(cbManager.SelectedValue); int NonStandard = Convert.ToInt32(NonStandardComboBox.SelectedIndex); decimal PriceGroup = Convert.ToDecimal(tbPriceGroup.Text); int DelayOfPayment = 0; bool Enabled = cbClientEnable.Checked; if (tbDelayOfPayment.Text.Length > 0) { DelayOfPayment = Convert.ToInt32(tbDelayOfPayment.Text); } if (Clients.NewClient == true) { InfiniumFiles InfiniumFiles = new InfiniumFiles(); InfiniumFiles.CreateClientFolders(ClientNameTextBox.Text); Clients.AddClient(Name, CountryID, City, ClientGroupID, Site, Email, ManagerID, UNN, NonStandard, PriceGroup, DelayOfPayment, Enabled); Clients.SaveShopAddresses(); } else { Clients.SaveClient(Name, CountryID, City, ClientGroupID, Site, Email, ManagerID, UNN, NonStandard, PriceGroup, DelayOfPayment, Enabled, ClientID); Clients.SaveShopAddresses(); } if (OldManagerID != ManagerID && ManagerID != 0) { bool OKCancel = Infinium.LightMessageBox.Show(ref TopForm, true, "У клиента поменялся менеджер. Уведомить клиента письмом на почту?", "Уведомлению клиенту"); if (OKCancel) { string result = string.Empty; result = Clients.NotifyClient(Email, ManagerID); InfiniumTips.ShowTip(this, 50, 85, result, 2500); } } ClientNameTextBox.Text = string.Empty; CityTextBox.Text = string.Empty; EmailTextBox.Text = string.Empty; SiteTextBox.Text = string.Empty; tbUNN.Text = string.Empty; FormEvent = eClose; AnimateTimer.Enabled = true; }