private void dialog_DialogEvent(object source, DialogEventArgs e) { var dialog = e.Dialog as Dialogs.AddDBDocDialog; if (dialog != null) { switch (dialog.DialogResult) { case DialogResult.Yes: case DialogResult.Retry: case DialogResult.OK: { Console.Write("Document: " + dialog.DocID.ToString() + " Image: " + dialog.ImageID.ToString()); int docID = dialog.DocID; int imageID = dialog.ImageID; if (docID == 0 || imageID == 0) { return; } bool work = dialog.DialogResult != DialogResult.Yes; if (work && dialog.AddToWork) { Console.WriteLine("{0}: Add to Work", DateTime.Now.ToString("HH:mm:ss fff")); Environment.WorkDocData.AddDocToEmployee(docID, Environment.CurEmp.ID); } Console.WriteLine("{0}: event", DateTime.Now.ToString("HH:mm:ss fff")); var doc = new DocumentSavedEventArgs(docID, imageID, work && dialog.GotoDoc, work && dialog.CreateEForm, dialog.CreateSlaveEForm); Console.WriteLine("{0}: Send Message", DateTime.Now.ToString("HH:mm:ss fff")); if (work && dialog.SendMessage && !dialog.CreateSlaveEForm) { var senddialog = new Dialogs.SendMessageDialog(dialog.DocID, GetStringToSave(), !dialog.AddToWork) { Owner = docControl.ParentForm }; senddialog.DialogEvent += SendMessageAfterSave_DialogEvent; senddialog.Show(); } else { Console.WriteLine("{0}: link", DateTime.Now.ToString("HH:mm:ss fff")); docControl.OnLinkDoc(docID); } Console.WriteLine("{0}: Save event", DateTime.Now.ToString("HH:mm:ss fff")); OnDocumentSaved(doc); } break; } } }
private void SendFromChild(int docID) { if (childDocIDs.Count > 0) { Console.WriteLine("{0}: Start link form", DateTime.Now.ToString("HH:mm:ss fff")); if (!Environment.DocLinksData.CheckDocLinkExists(docID, childDocIDs[0])) { Environment.DocLinksData.AddDocLink(docID, childDocIDs[0]); } Console.WriteLine("{0}: Parent: {1}, Child: {2}", DateTime.Now.ToString("HH:mm:ss fff"), docID, childDocIDs[0]); childDocIDs.RemoveAt(0); SendFromChild(docID); } else { if (sendMail) { Console.WriteLine("{0}: Send Message", DateTime.Now.ToString("HH:mm:ss fff")); var senddialog = new Dialogs.SendMessageDialog(docID, sendString, force); senddialog.DialogEvent += SendMessageAfterSave_DialogEvent; senddialog.Show(); } } }
private void AddSign(SignType sign) { try { if (!OnAddingDocSign()) { return; } if (_droppedDown) { CollapsePanel(true); } bool sendMessage = sign == SignType.firstSign || Environment.UserSettings.MessageOnEndSign; Employee employee4 = Environment.CurEmp; List <Employee> employees = Environment.ReplacementEmployeeData.GetReplacementEmployees(); if (employees.Count > 1 || sign != SignType.firstSign) { var dlg = new Select.SelectSignEmployeeDialog(employees, sign); if (dlg.ShowDialog() != DialogResult.OK) { return; } employee4 = dlg.Employee4; sendMessage = dlg.SendMessage; } byte singT = Convert.ToByte(sign); int? кодПодписиДокумента; bool isImage = _imgId.HasValue; if (isImage ? Environment.DocSignatureData.AddSign(_docId, _imgId.Value, Environment.CurEmp.ID, employee4.ID, singT, out кодПодписиДокумента) : Environment.DocSignatureData.AddSign(_docId, Environment.CurEmp.ID, employee4.ID, singT, out кодПодписиДокумента)) { LoadDocInfo(_docId, _imgId); if (кодПодписиДокумента != null) // успешно подписали { UndoSign(кодПодписиДокумента.Value, _docId, isImage, (isImage ? _imgId.Value : (int?)null), employee4.ID, singT); } if (sendMessage) { string str = Environment.SignTextData.GetSignMessageText( Environment.DocData.GetDocIntField(Environment.DocData.DocTypeIDField, _docId), singT, Environment.CurCultureInfo.TwoLetterISOLanguageName); if (string.IsNullOrEmpty(str)) { switch (sign) { case SignType.firstSign: str = "Документ подписан"; break; case SignType.finalSign: str = "Работа завершена"; break; case SignType.cancelSign: str = "Изображение аннулировано"; break; } } foreach (int empID in Environment.EmpData.GetCurrentEmployeeIDs()) { Environment.WorkDocData.MarkAsRead(empID, _docId); } var smd = new Dialogs.SendMessageDialog(_docId, str) { Check = true }; // не правильная реализация события smd.FormClosed += smd_FormClosed; smd.Show(); } else { OnAddedDocSign(); } } } catch (Exception ex) { Data.Env.WriteToLog(ex); Error.ErrorShower.OnShowError(null, ex.Message, ""); } }