Example #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Record record = new Record();

            if (txtFullName.Text.Length > 0)
            {
                record.FullName = txtFullName.Text;
            }
            else
            {
                MessageBox.Show("You have to insert Name");
            }
            if (txtDocNumber.Text.Length > 0)
            {
                record.Document = txtDocNumber.Text;
            }
            else
            {
                MessageBox.Show("You have to insert document number");
            }
            record.Aim    = txtAim.Text;
            record.InTime = DateTime.Now;
            using (var context = new VisitorsContext())
            {
                context.Records.Add(record);
                context.SaveChanges();
            }
            this.Close();
        }
 private void btnUnregistSubmit_Click(object sender, EventArgs e)
 {
     using (var context = new VisitorsContext())
     {
         try
         {
             var result = context.Records.FirstOrDefault(r => r.Document == txtUnregistDocNum.Text);
             result.OutTime = DateTime.Now;
             context.SaveChanges();
             this.Close();
         }
         catch (Exception)
         {
             MessageBox.Show("No such visitor");
         }
     }
 }