Пример #1
0
        /*
         * Method Name: deleteRecord
         * Accessibility: private
         * Description == Method that deletes a record that possess a specific key via LINQ to SQL classes
         * (Arguments) -> return type == (empty) -> void
         * Precondition == none
         * Postcondition == none
         *
         */

        private void deleteRecord()
        {
            try
            {
                CSLabDBDataContext cs = new CSLabDBDataContext();

                CSLabStock stock = cs.CSLabStocks.Single(c => c.NCUTag == Convert.ToInt16(TextBoxRecordTag.Text.ToString()));

                cs.CSLabStocks.DeleteOnSubmit(stock);

                cs.SubmitChanges();

                foreach (TextBox c in tabControlMain.SelectedTab.Controls.OfType <TextBox>()) /*Clears Textbook After a CRUD operation*/
                {
                    c.Text = "";
                }//end for


                MessageBox.Show("Record Was Sucessfully Deleted", "Delete Status");
            }//end of try

            catch (Exception ex)
            {
                MessageBox.Show("An Error Occured in The Delete Query" + Environment.NewLine + ex.Message, "Error Report");
            }//end catch
        }
Пример #2
0
        /*
         * Method Name:  createRecord
         * Accessibility: private
         * Description ==  method to insert a new record in the SQL Server database via LINQ to SQL Classes.
         * (Arguments) -> return type ==  (empty) -> void
         * Precondition == none
         * Postcondition == none
         */

        private void createRecord()
        {
            try
            {
                CSLabDBDataContext cs = new CSLabDBDataContext();

                var stock = new CSLabStock
                {
                    NCUTag       = Convert.ToInt16(TextBoxNCUTag.Text.ToString()),
                    ItemType     = TextBoxItemType.Text.ToString(),
                    Quantity     = Convert.ToInt16(TextBoxQuantity.Text.ToString()),
                    Manufacturer = TextBoxManufacturer.Text.ToString(),
                    Model        = TextBoxModel.Text.ToString(),
                    SerialNum    = TextBoxSerial.Text.ToString(),
                    ServiceTag   = TextBoxServiceTag.Text.ToString(),
                    Location     = TextBoxLocation.Text.ToString(),
                    Status       = TextBoxStatus.Text.ToString(),
                    Notes        = TextBoxNotes.Text.ToString(),
                };


                cs.CSLabStocks.InsertOnSubmit(stock);
                cs.SubmitChanges();

                foreach (TextBox c in tabControlMain.SelectedTab.Controls.OfType <TextBox>()) /*Clears Textbook After a CRUD operation*/
                {
                    c.Text = "";
                }
                MessageBox.Show("Record Was Sucessfully Created", "Create Status");
            }//end of try

            catch (Exception ex)
            {
                MessageBox.Show("Record Was Unsuccessfully Created..." + Environment.NewLine + ex.Message, "Error Report");
            }//end catch
        }
 partial void DeleteCSLabStock(CSLabStock instance);
 partial void UpdateCSLabStock(CSLabStock instance);
 partial void InsertCSLabStock(CSLabStock instance);
Пример #6
0
        /*
         * Method Name: updateRecord
         * Accessibility: private
         * Description == Method that updates a record that possess a specific key via LINQ to SQL classes
         * (Arguments) -> return type == (empty) -> void
         * Precondition == none
         * Postcondition == none
         *
         */


        private void updateRecord()
        {
            try
            {
                CSLabDBDataContext cs = new CSLabDBDataContext();

                CSLabStock stock = cs.CSLabStocks.Single(c => c.NCUTag == Convert.ToInt16(TextBoxNCUTagUpdate.Text.ToString()));

                if (TextBoxItemTypeUpdate.Text.ToString() != "")
                {
                    stock.ItemType = TextBoxItemTypeUpdate.Text.ToString();
                }//end if


                if (TextBoxQuantityUpdate.Text.ToString() != "")
                {
                    stock.Quantity = Convert.ToInt16(TextBoxQuantityUpdate.Text.ToString());
                }//end if

                if (TextBoxManufacturerUpdate.Text.ToString() != "")
                {
                    stock.Manufacturer = TextBoxManufacturerUpdate.Text.ToString();
                }//end if


                if (TextBoxModelUpdate.Text.ToString() != "")
                {
                    stock.Model = TextBoxModelUpdate.Text.ToString();
                }//end if


                if (TextBoxSerialNumberUpdate.Text.ToString() != "")
                {
                    stock.SerialNum = TextBoxSerialNumberUpdate.Text.ToString();
                }//end if


                if (TextBoxServiceTagUpdate.Text.ToString() != "")
                {
                    stock.ServiceTag = TextBoxItemTypeUpdate.Text.ToString();
                }//end if


                if (TextBoxLocationUpdate.Text.ToString() != "")
                {
                    stock.Location = TextBoxServiceTagUpdate.Text.ToString();
                }//end if

                if (TextBoxStatusUpdate.Text.ToString() != "")
                {
                    stock.Status = TextBoxStatusUpdate.Text.ToString();
                }//end if


                if (TextBoxNotesUpdate.Text.ToString() != "")
                {
                    stock.Notes = TextBoxNotesUpdate.Text.ToString();
                }//end if

                cs.SubmitChanges();
                foreach (TextBox c in tabControlMain.SelectedTab.Controls.OfType <TextBox>())
                {
                    c.Text = "";
                }//end foreach

                MessageBox.Show("Record Was Sucessfully Updated", "Update Status");
            }//end of try

            catch (Exception ex)
            {
                MessageBox.Show("An Error Occured in The Upate Query" + Environment.NewLine + ex.Message, "Error Report");
            }//end catch
        }
 partial void DeleteCSLabStock(CSLabStock instance);
 partial void UpdateCSLabStock(CSLabStock instance);
 partial void InsertCSLabStock(CSLabStock instance);
Пример #10
0
        /*
          Method Name:  createRecord
          Accessibility: private
          Description ==  method to insert a new record in the SQL Server database via LINQ to SQL Classes.
          (Arguments) -> return type ==  (empty) -> void
          Precondition == none
          Postcondition == none
        */
        private void createRecord()
        {
            try
            {

                CSLabDBDataContext cs = new CSLabDBDataContext();

                var stock = new CSLabStock
                {
                    NCUTag = Convert.ToInt16(TextBoxNCUTag.Text.ToString()),
                    ItemType = TextBoxItemType.Text.ToString(),
                    Quantity = Convert.ToInt16(TextBoxQuantity.Text.ToString()),
                    Manufacturer = TextBoxManufacturer.Text.ToString(),
                    Model = TextBoxModel.Text.ToString(),
                    SerialNum = TextBoxSerial.Text.ToString(),
                    ServiceTag = TextBoxServiceTag.Text.ToString(),
                    Location = TextBoxLocation.Text.ToString(),
                    Status = TextBoxStatus.Text.ToString(),
                    Notes = TextBoxNotes.Text.ToString(),

                };

                cs.CSLabStocks.InsertOnSubmit(stock);
                cs.SubmitChanges();

                foreach (TextBox c in tabControlMain.SelectedTab.Controls.OfType<TextBox>()) /*Clears Textbook After a CRUD operation*/
                {
                    c.Text = "";
                }
                MessageBox.Show("Record Was Sucessfully Created", "Create Status");
            }//end of try

            catch (Exception ex)
            {

                MessageBox.Show("Record Was Unsuccessfully Created..." + Environment.NewLine + ex.Message, "Error Report");
            }//end catch
        }