Пример #1
0
 /// <summary>
 /// Gets the current jobs from the database
 /// </summary>
 /// <returns></returns>
 private List <JobsTbl> GetJobsFromDB()
 {
     using (LinqToOlgaDBDataContext con = new LinqToOlgaDBDataContext())
     {
         // get all jobs from the database
         return(con.JobsTbls.ToList());
     }
 }
Пример #2
0
        private void LoadJob(int JobID)
        {
            // clear the list of current selected job (if one)
            richTextBoxJobDetails.Text = "";
            // create connection to our database
            using (LinqToOlgaDBDataContext con = new LinqToOlgaDBDataContext())
            {
                // SQL query using linq that will find a job in the database that maches the select JobID
                var getTheJob = from a in con.JobsTbls
                                where a.JobID == JobID
                                select a;


                JobDetails jon = new JobDetails()
                {
                    JobFromDB = getTheJob.First()
                };

                richTextBoxJobDetails.Text = jon.ToString();
            }
        }
Пример #3
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a connection to our database
                // when using a 'using' statement all resources are automatically disposed after the statement
                using (LinqToOlgaDBDataContext con = new LinqToOlgaDBDataContext())
                {
                    // create a new row in database
                    JobsTbl newJob = new JobsTbl();
                    // set the date from the time picker
                    newJob.Date = dateTimePicker1.Value;
                    // get the batch number from the text box on the form
                    newJob.BatchNumber = int.Parse(textBoxBatchNo.Text);
                    // get job number from main form
                    newJob.JobNumber = (int)
                                       JobNumberNUD.Value;
                    newJob.JobIssue     = textBoxJobIssue.Text;
                    newJob.SMIssue      = textBoxSMIssue.Text;
                    newJob.PasteType    = textBoxPasteType.Text;
                    newJob.PCBSide      = textBoxPCBSide.Text;
                    newJob.TypeOf1stOff = textBoxTypeOf1stOff.Text;
                    newJob.ChangeNotes  = int.Parse(textBoxCnNo.Text);
                    newJob.CCP          = int.Parse(textBoxCppNo.Text);
                    newJob.ERMN         = int.Parse(textBoxErmnNo.Text);
                    newJob.LineNo       = int.Parse(textBoxLineNo.Text);

                    // take the row we just made and when i call con.submitChanges() insert into db
                    con.JobsTbls.InsertOnSubmit(newJob);
                    // submits chnages to db
                    con.SubmitChanges();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }