private void btnCreate_Click(object sender, EventArgs e) { docHead.DocType = TENDER; //Заявка docHead.DocumentDate = dtpDateDoc.Value; if (chkParentDocument.Checked) { docHead.DocumentParent = int.Parse(txtParentDocNum.Text); } docHead.RPInfo = (int)cmbRP.SelectedValue; if (docHead.DocumentNumber == 0) { MessageBox.Show("Возникла ошибка при создании документа.\nНеверный номер документа.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { IForecastDocument document = ForecastDocumentFactory.CreateDocument(docHead, Data); if (document == null) { throw new Exception(); } Doc = document as ForecastDocument; string message = "Документ № " + document.Head.DocumentNumber.ToString() + " успешно создан.\nПерейти к редактированию?"; if (MessageBox.Show(message, "Информация", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { this.DialogResult = DialogResult.Yes; } } catch (Exception exception) { ErrorMsgBox.Show("Ошибка", "Возникла ошибка при создании документа.\n" + exception.Message, exception.ToString()); } this.Dispose(); }
public CreateTender(IGlobalValues data, int parent) { InitializeComponent(); Data = data; ForecastDocument doc = ForecastDocument.LoadDocument(parent, Data.ActiveSchema + ".ForecastDocumentHead", Data.ActiveSchema + ".ForecastDocumentBody", Data.ConnectionString); parentDoc = doc.Head; }
private void btnEdit_Click(object sender, EventArgs e) { if (gridForecastDocuments.SelectedRows.Count > 0) { try { int docid = (int)gridForecastDocuments.SelectedRows[0].Cells["DocumentID"].Value; ForecastDocument document = ForecastDocumentFactory.LoadDocument(docid, GlobalValues.Instance); FormTender edit = new FormTender(document, GlobalValues.Instance); edit.Show(); } catch (Exception exc) { ErrorMsgBox.Show("Ошибка", "Ошибка редактирования документа\r\n" + exc.Message, exc.ToString()); return; } } }
private void btnDeleteTender_Click(object sender, EventArgs e) { if (gridForecastDocuments.SelectedRows.Count > 0) { try { int docid = (int)gridForecastDocuments.SelectedRows[0].Cells["DocumentID"].Value; ForecastDocument document = ForecastDocumentFactory.LoadDocument(docid, GlobalValues.Instance); if (MessageBox.Show("Вы хотите удалить документ № " + docid.ToString(), "Предупреждение", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (document.DeleteDocument()) { MessageBox.Show("Документ № " + docid.ToString() + " удалён."); } } } catch (Exception exc) { ErrorMsgBox.Show("Ошибка", "Ошибка удаления документа\r\n" + exc.Message, exc.ToString()); return; } } }
public static ForecastDocument LoadDocument(int docnum, IGlobalValues data) { return(ForecastDocument.LoadDocument(docnum, data.ActiveSchema + ".ForecastDocumentHead", data.ActiveSchema + ".ForecastDocumentBody", data.ConnectionString)); }
public static ForecastDocument CreateDocument(ForecastDocumentHead head, IGlobalValues data) { return(ForecastDocument.CreateDocument(head, data.ActiveSchema + ".ForecastDocumentHead", data.ActiveSchema + ".ForecastDocumentBody", data.ConnectionString)); }