public async Task Delete(Guid id)
        {
            using (MUEContext db = new MUEContext())
            {
                SettlementSheet SettlementSheet = await GetEntity(id);

                db.Entry(SettlementSheet).State = EntityState.Deleted;
                db.SettlementSheets.Remove(SettlementSheet);
                await db.SaveChangesAsync();
            }
        }
Example #2
0
        private void okBtn_Click(object sender, EventArgs e)
        {
            if (checkFields())
            {
                ConnectionClass.startTransaction();
                if (filter == null)
                {
                    settleSheetSet.deleteSheetsFilteredTransaction(new SettlementSheetFilter(datePck.Value, ((Department)departCbx.SelectedItem).id));
                    for (int i = 0; i < dataGridSheet.Rows.Count - 1; i++)
                    {
                        SettlementSheet newEntity = new SettlementSheet(((Employee)dataGridSheet["employee", i].Value).id, ((Settlement)dataGridSheet["settle_type", i].Value).id, datePck.Value, Convert.ToDouble(dataGridSheet["value", i].Value), ((Department)departCbx.SelectedItem).id);

                        settleSheetSet.addEntityTransaction(newEntity);
                    }
                }
                else
                {
                    settleSheetSet.deleteSheetsFilteredTransaction(filter);

                    for (int i = 0; i < dataGridSheet.Rows.Count - 1; i++)
                    {
                        SettlementSheet newEntity = new SettlementSheet(((Employee)dataGridSheet["employee", i].Value).id, ((Settlement)dataGridSheet["settle_type", i].Value).id, datePck.Value, Convert.ToDouble(dataGridSheet["value", i].Value), ((Department)departCbx.SelectedItem).id);

                        settleSheetSet.addEntityTransaction(newEntity);
                    }
                }

                if (!noMinus())
                {
                    ConnectionClass.finishTransaction(true);
                }
                else
                {
                    ConnectionClass.finishTransaction(false);
                    if (filter == null)
                    {
                        MessageBox.Show("Ведомость добавлена");
                    }
                    else
                    {
                        MessageBox.Show("Ведомость отредактирована");
                    }
                    Close();
                }
            }
            else
            {
            }
        }