Exemplo n.º 1
0
        public VideoLookupScreen()
        {
            InitializeComponent();
            // linq query
            context = new DafestyEntities();
            var q = from x in context.Movies select x;

            // display in datagridview
            VideoDataGridView.DataSource = q.ToList();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Submits the Issue with RentalStatus "in".
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            if (CustomerIDTextBox.Text != "" &&
                VideoCodeTextBox.Text != "")
            {
                string   cid       = CustomerIDTextBox.Text;
                string   vcode     = VideoCodeTextBox.Text;
                DateTime issuedate = IssueDateTimePicker.Value;
                DateTime duedate   = DueDateTimePicker.Value;
                string   remarks   = RemarksTextBox.Text;

                // create LINQ Query with CustomerIDTextBox, VideoCodeTextBox, IssueDateTimePicker, DueDateTimePicker

                // instantiate context
                DafestyEntities context = new DafestyEntities();

                // Since you're not displaying information, you don't need a query obj

                // create new tran
                IssueTran t = new IssueTran();
                t.CustomerID = cid;
                t.VideoCode  = Convert.ToInt16(vcode);
                t.DateIssue  = issuedate;
                t.DateDue    = duedate;
                if (remarks != "")
                {
                    t.Remarks = remarks;
                }
                t.RentalStatus = "in";

                context.IssueTrans.Add(t);
                context.SaveChanges();

                MessageBox.Show("Issue Submitted");
            }
            else
            {
                toolStripStatusLabel1.Text = "Please enter Customer ID and Video Code.";
            }
        }