// добавление private void button_Add_Click(object sender, EventArgs e) { object selectedDoc = DocSelectComboBox.SelectedItem; if (selectedDoc.ToString() is "Квитанция") { RecieptConstructorWindow RecConst = new RecieptConstructorWindow(); RecConst.docList = bList; RecConst.serviceToUse = serviceToUse; RecConst.Show(); } else if (selectedDoc.ToString() is "Счет") { BillConstructorWindow BillConst = new BillConstructorWindow(); BillConst.docList = bList; BillConst.serviceToUse = serviceToUse; BillConst.Show(); } else if (selectedDoc.ToString() is "Накладная") { InvoiceConstructorWindow InvConst = new InvoiceConstructorWindow(); InvConst.docList = bList; InvConst.serviceToUse = serviceToUse; InvConst.Show(); } }
// редактирование private void DataGirdViewDocumentsTable_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { string currentDocId = DataGridViewDocumentsTable.CurrentRow.Cells[0].Value.ToString(); Document currentDoc = bList.First(doc => doc.DocId == currentDocId); if (currentDoc != null) { if (currentDoc is Reciept) { RecieptConstructorWindow RecConst = new RecieptConstructorWindow(); RecConst.reciept = (Reciept)currentDoc; RecConst.docList = bList; RecConst.toEdit = true; RecConst.serviceToUse = serviceToUse; RecConst.Show(); } else if (currentDoc is Bill) { BillConstructorWindow BillConst = new BillConstructorWindow(); BillConst.bill = (Bill)currentDoc; BillConst.docList = bList; BillConst.toEdit = true; BillConst.serviceToUse = serviceToUse; BillConst.Show(); } else if (currentDoc is Invoice) { InvoiceConstructorWindow InvConst = new InvoiceConstructorWindow(); InvConst.invoice = (Invoice)currentDoc; InvConst.docList = bList; InvConst.toEdit = true; InvConst.serviceToUse = serviceToUse; InvConst.Show(); } } }