Пример #1
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (txtRCusID.Text == "" || txtRVideoCode.Text == "")
     {
         MessageBox.Show("There is no customer or video in the system", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             IssueTran newtrans = new IssueTran();
             newtrans.CustomerID       = txtCusID.Text;
             newtrans.VideoCode        = Convert.ToInt16(txtVideoCode.Text);
             newtrans.DateIssue        = dtpIssue.Value;
             newtrans.DateDue          = dtpDue.Value;
             newtrans.DateActualReturn = null;
             newtrans.RentalStatus     = "IN";
             newtrans.Remarks          = textBox1.Text;
             ctx.IssueTrans.Add(newtrans);
             ctx.SaveChanges();
             MessageBox.Show("Transaction Completed", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ResetTextBox();
         }
         catch
         {
             MessageBox.Show("Error Occurred! Try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             ResetTextBox();
         }
     }
 }