Exemple #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Contracts contract = new Contracts();
                contract.con_cl_ID = cl_id;
                contract.con_o_ID  = (int)dataGridView1.CurrentRow.Cells["oIDDataGridViewTextBoxColumn"].Value;
                contract.con_sum   = (int)numericUpDownSum.Value;
                int ID;
                if ((from con in ctx.Contracts
                     select con.con_ID).Count() == 0)
                {
                    ID = 0;
                }
                else
                {
                    ID = (from con in ctx.Contracts
                          select con.con_ID).Max();
                }
                contract.con_ID           = (int)ID + 1;
                contract.con_signing_date = DateTime.Now;
                contract.con_finish_date  = dateTimePickerFinish.Value;

                ctx.Contracts.Add(contract);
                ctx.SaveChanges();

                this.Dispose();
            }
            catch (Exception)
            {
                MessageBox.Show("Something`s gone wrong!");
            }
        }
Exemple #2
0
 private void buttonContractsDelete_Click(object sender, EventArgs e)
 {
     try
     {
         contractsBindingSource.RemoveCurrent();
         ctx.SaveChanges();
     }
     catch (Exception)
     {
         MessageBox.Show("Deleting error");
     }
 }
Exemple #3
0
 private void buttonBanksSave_Click(object sender, EventArgs e)
 {
     ctx.SaveChanges();
 }