This document contains code for an inventory management system. It includes modules for connecting to a database, handling user login and permissions, and inputting/managing product data. The login module verifies user credentials and sets permission levels. The product input module provides functions for inserting, updating, deleting and searching for product records in the database. It establishes the database connection and uses SQL commands to manage the data.
The document discusses three different ways to perform CRUD (create, read, update, delete) operations on a database using ADO.NET in Visual Basic.NET. It includes code examples showing how to connect to a SQL Server database, retrieve data from a table into a DataSet, display the data in a DataGridView, and search or filter the data. The examples demonstrate using DataAdapters, DataSets, DataViews and SqlDataReaders to connect to the database and perform queries to retrieve and manipulate the data.
This document contains code for a VB.Net application for a hospital patient admission system. It includes code for login authentication, user management, registration, payment, and treatment functions. The code handles tasks like connecting to a database, generating unique identifiers, performing queries, and updating/inserting records.
This document contains code for a sales system application in Visual Basic. It includes code for forms to manage clients, products, invoices and users. It allows adding, editing, deleting and searching records in databases. It also includes code to launch other applications like Word, Excel and Calculator from the main form.
This document contains C# code that defines a Form1 class with methods to connect to a database, retrieve and display data from tables, insert new records, and clear fields. It opens a database connection to retrieve data from two tables to populate drop-down lists. Buttons are used to insert new records, clear fields, and run a timer to move a label across the form.
This code defines a class that connects to a SQL database to perform CRUD operations on a student details table. It opens a connection, populates a dropdown with student IDs from the table. It allows updating, inserting, deleting and retrieving a student's details by ID, and displays the results in a grid view. Buttons trigger methods for each database operation like update, insert, delete, retrieve.
The document contains code for a web service class that connects to a MySQL database and provides various methods for retrieving, updating, and inserting user data. The methods include login authentication, retrieving user account information and transaction history, changing passwords, transferring funds between accounts, and getting the current account balance. The class connects to the database, executes SQL queries, and returns data to the caller.
This document discusses cross-platform support and push notifications in Windows Azure Mobile Services. It explains how to send push notifications to different device platforms including Windows Store, Windows Phone, iOS, and Android. It also discusses using service filters and delegating handlers to intercept requests and responses for custom processing like adding versioning information.
This document contains code for an inventory management system. It includes modules for connecting to a database, handling user login and permissions, and inputting/managing product data. The login module verifies user credentials and sets permission levels. The product input module provides functions for inserting, updating, deleting and searching for product records in the database. It establishes the database connection and uses SQL commands to manage the data.
The document discusses three different ways to perform CRUD (create, read, update, delete) operations on a database using ADO.NET in Visual Basic.NET. It includes code examples showing how to connect to a SQL Server database, retrieve data from a table into a DataSet, display the data in a DataGridView, and search or filter the data. The examples demonstrate using DataAdapters, DataSets, DataViews and SqlDataReaders to connect to the database and perform queries to retrieve and manipulate the data.
This document contains code for a VB.Net application for a hospital patient admission system. It includes code for login authentication, user management, registration, payment, and treatment functions. The code handles tasks like connecting to a database, generating unique identifiers, performing queries, and updating/inserting records.
This document contains code for a sales system application in Visual Basic. It includes code for forms to manage clients, products, invoices and users. It allows adding, editing, deleting and searching records in databases. It also includes code to launch other applications like Word, Excel and Calculator from the main form.
This document contains C# code that defines a Form1 class with methods to connect to a database, retrieve and display data from tables, insert new records, and clear fields. It opens a database connection to retrieve data from two tables to populate drop-down lists. Buttons are used to insert new records, clear fields, and run a timer to move a label across the form.
This code defines a class that connects to a SQL database to perform CRUD operations on a student details table. It opens a connection, populates a dropdown with student IDs from the table. It allows updating, inserting, deleting and retrieving a student's details by ID, and displays the results in a grid view. Buttons trigger methods for each database operation like update, insert, delete, retrieve.
The document contains code for a web service class that connects to a MySQL database and provides various methods for retrieving, updating, and inserting user data. The methods include login authentication, retrieving user account information and transaction history, changing passwords, transferring funds between accounts, and getting the current account balance. The class connects to the database, executes SQL queries, and returns data to the caller.
This document discusses cross-platform support and push notifications in Windows Azure Mobile Services. It explains how to send push notifications to different device platforms including Windows Store, Windows Phone, iOS, and Android. It also discusses using service filters and delegating handlers to intercept requests and responses for custom processing like adding versioning information.
This code connects to a database using an OleDbConnection, executes a SQL query to select all records from the product_type table using an OleDbCommand, fills a DataSet with the results and sets it as the data source for a DataGridView control, allowing the product data to be displayed in the UI.
This document discusses how to work with multiple tables in a relational database using a DataSet in Visual Basic. It covers setting up data adapters and command builders to fill the DataSet with data from different tables, displaying and editing data, adding and deleting rows, and establishing relationships between tables to link related data.
The Ring programming language version 1.3 book - Part 7 of 88Mahmoud Samir Fayed
Ring 1.3 includes improvements to RingQt classes, the Objects library, LibCurl, and other features. Better RingQt classes allow getting event information and enabling/disabling events. The updated Objects library manages GUI objects and provides a natural API for creating windows from classes. RingLibCurl adds functions wrapping LibCurl. Other enhancements include better support for calling methods from object attributes, displaying compiler warnings, and code quality improvements.
An Android operating system is an open source Linux-based OS for mobile devices. It includes application building blocks like activities, intents, broadcast receivers and services. To set up the Android development environment, developers need to install the Android SDK, Eclipse IDE, ADT plugin and create an Android virtual device. The document then provides instructions on creating an Android project in Eclipse, understanding the project structure and running an Android application.
The document provides examples for various methods that can be used to interact with and retrieve information from objects in a testing framework. It includes methods to activate, capture screenshots, click, close, drag and drop, exist, get and set properties, retrieve text, type, wait for properties, and more. The examples demonstrate how to use these methods to interact with dialog boxes, windows, and other objects.
This document contains C# code to:
1. Swap the values of two variables by passing them by reference to a swap method.
2. Calculate the square of a number by passing it by reference to a method that multiplies the number by itself.
3. Define a Decompose class to separate the integer and fractional parts of a floating point number.
This document contains code for a vehicle rental application. It includes code to connect to a database, retrieve and display rental records in a grid, add new rentals, and calculate rental prices based on vehicle type and duration. Functions are included to clear fields, disable/enable controls, and validate input when selecting vehicles or customers.
The Ring programming language version 1.7 book - Part 72 of 196Mahmoud Samir Fayed
This document describes a Ring-based notepad application with the following key features:
- It allows opening, saving, printing files and includes buttons for common editing functions like cut, copy, paste.
- The interface contains toolbars for file operations and menus for File, Edit, View, Help options. Shortcuts are also defined.
- Text editing functions like font selection, text coloring, search/replace are implemented through event handlers.
- The application stores settings like active file name, text/background colors, font and handles asking to save on close if needed.
Are the smartphone wars wearing your out? When asked to choose between Objective-C and Java do you answer “None of the Above”? Do you think app stores are so 1995? Then there is good news for you and it’s called the mobile web. This isn’t about trying to port iFart to the browser, and it’s definitely not about tweaking an existing website so it doesn’t look awful on your mom’s iPhone. It is about writing full featured, engaging applications on the web. This talk is all about how to create killer web apps using HTML5, CSS3, as well as some other not-so-standard technologies available on a wide variety of popular smartphones. We’re talking about multi-threaded, high performance apps that can track your movement or even take pictures of whatever you think is interesting.
This document describes a mobile authentication and key exchange protocol that uses nested one-time secrets. It contains modules for the user, VLR verification, HLR verification, key generation, and nested one-time secrets. The protocol uses lightweight public key cryptography and a challenge-response technique in two stages: an initial procedure and real execution stage. This allows for fast mutual authentication and agreement of a nested one-time secret while providing greater security and lower computational complexity than other wireless authentication schemes.
PyMongo is a Python driver for working with MongoDB and allows developers to connect to MongoDB from Python, interface with MongoDB databases and collections, and perform common operations like inserting, finding, updating, and deleting documents. It maps common SQL concepts like databases, tables, and rows to MongoDB concepts like databases, collections, and BSON documents. The document provides examples of basic PyMongo operations for connecting to a MongoDB server, getting and working with databases and collections, and performing CRUD operations on documents.
The document provides examples of how to perform various actions in QuickTest Professional (QTP) such as selecting items from a web list, setting values in a web edit, reading and writing data to text files, and using descriptive programming. Key examples include selecting the third item from a web list, setting the pincode value to "23" in a web edit, reading lines from one text file and writing them to another file, and setting the value "oshoworld" in the first web edit on a page using a descriptive program.
The document describes an example Java program that defines classes for a banking application including accounts, customers, and transactions. Key points:
1) It defines interfaces for interest rates and transactions that account classes can implement.
2) An abstract Account class and concrete SBAccount class that extends Account are defined.
3) A Customer class holds an SBAccount and allows transactions like deposit, withdraw, interest calculation.
4) A BankDemo class demonstrates creating a customer and performing sample transactions.
The Ring programming language version 1.8 book - Part 74 of 202Mahmoud Samir Fayed
This document describes a Ring-based notepad application with the following key features:
- It includes buttons and menu options for common file operations like new, open, save, print.
- The interface contains a toolbar and main window for the text editor area.
- Additional features allow for text formatting, search/replace, and setting the font and colors.
- The application stores the open file name and can check if the user wants to save changes when closing.
This document contains code for connecting to a database and querying data from tables to display in a list. It includes code to handle exceptions if the connection fails, query the "Orders" and "Inventory" tables to find items that are out of stock, query the "Orders", "Customers" and "Inventory" tables to display today's orders details including customer name, item details and total cost, and a function to verify if a database file exists before loading the form.
The document contains source code for a point of sale (POS) system with tables for products and transactions, and functions for loading products, adding items to a cart, generating transaction numbers, computing totals, and processing purchases. It includes interfaces for viewing and selecting products, building an order, and completing a sale with validation of inputs and updating of quantities.
The Ring programming language version 1.9 book - Part 78 of 210Mahmoud Samir Fayed
This document describes a simple notepad application developed using the RingQt GUI library. The application contains features like opening, saving, printing files as well as cut, copy, paste functionality. It allows changing font, text color and includes a find/replace feature. The main window contains toolbars for file operations and menus for file, edit, view and help. A text editor widget is used to display and edit text. Buttons are added to toolbars to trigger common operations like new, open, save etc.
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
The document describes the creation of a database in SQL Server to manage invoices and receipts. It includes tables for clients, employees, document headers, and document details. Stored procedures are created to insert data and a form is developed in Visual Studio .NET to manage documents. The form allows searching for clients and employees, adding product details, and printing reports using Crystal Reports.
This document contains code for an inventory management system. It includes modules for connecting to a database, handling user login and permissions, and inputting/managing product data. The login module verifies user credentials and sets permission levels. The product input module provides functions for inserting, updating, deleting and searching for product records in the database. It initializes forms and controls for data entry and management.
This document contains code for a Visual Basic .NET Windows forms application for a sales system. It includes code to manage clients, products, invoices and users through different forms. It allows layout of multiple document interface (MDI) forms in cascade, horizontal tile and vertical tile. It also includes code to launch external applications like calculator, Word and Excel.
This document provides information about an inventory management application created in VB.NET. It includes details on the login screen, main menu, stock record viewing and editing screens, size and color record screens, and supporting code. The application allows users to view, add, update and delete inventory stock records with attributes like quantity, product type, size, and color.
This code connects to a database using an OleDbConnection, executes a SQL query to select all records from the product_type table using an OleDbCommand, fills a DataSet with the results and sets it as the data source for a DataGridView control, allowing the product data to be displayed in the UI.
This document discusses how to work with multiple tables in a relational database using a DataSet in Visual Basic. It covers setting up data adapters and command builders to fill the DataSet with data from different tables, displaying and editing data, adding and deleting rows, and establishing relationships between tables to link related data.
The Ring programming language version 1.3 book - Part 7 of 88Mahmoud Samir Fayed
Ring 1.3 includes improvements to RingQt classes, the Objects library, LibCurl, and other features. Better RingQt classes allow getting event information and enabling/disabling events. The updated Objects library manages GUI objects and provides a natural API for creating windows from classes. RingLibCurl adds functions wrapping LibCurl. Other enhancements include better support for calling methods from object attributes, displaying compiler warnings, and code quality improvements.
An Android operating system is an open source Linux-based OS for mobile devices. It includes application building blocks like activities, intents, broadcast receivers and services. To set up the Android development environment, developers need to install the Android SDK, Eclipse IDE, ADT plugin and create an Android virtual device. The document then provides instructions on creating an Android project in Eclipse, understanding the project structure and running an Android application.
The document provides examples for various methods that can be used to interact with and retrieve information from objects in a testing framework. It includes methods to activate, capture screenshots, click, close, drag and drop, exist, get and set properties, retrieve text, type, wait for properties, and more. The examples demonstrate how to use these methods to interact with dialog boxes, windows, and other objects.
This document contains C# code to:
1. Swap the values of two variables by passing them by reference to a swap method.
2. Calculate the square of a number by passing it by reference to a method that multiplies the number by itself.
3. Define a Decompose class to separate the integer and fractional parts of a floating point number.
This document contains code for a vehicle rental application. It includes code to connect to a database, retrieve and display rental records in a grid, add new rentals, and calculate rental prices based on vehicle type and duration. Functions are included to clear fields, disable/enable controls, and validate input when selecting vehicles or customers.
The Ring programming language version 1.7 book - Part 72 of 196Mahmoud Samir Fayed
This document describes a Ring-based notepad application with the following key features:
- It allows opening, saving, printing files and includes buttons for common editing functions like cut, copy, paste.
- The interface contains toolbars for file operations and menus for File, Edit, View, Help options. Shortcuts are also defined.
- Text editing functions like font selection, text coloring, search/replace are implemented through event handlers.
- The application stores settings like active file name, text/background colors, font and handles asking to save on close if needed.
Are the smartphone wars wearing your out? When asked to choose between Objective-C and Java do you answer “None of the Above”? Do you think app stores are so 1995? Then there is good news for you and it’s called the mobile web. This isn’t about trying to port iFart to the browser, and it’s definitely not about tweaking an existing website so it doesn’t look awful on your mom’s iPhone. It is about writing full featured, engaging applications on the web. This talk is all about how to create killer web apps using HTML5, CSS3, as well as some other not-so-standard technologies available on a wide variety of popular smartphones. We’re talking about multi-threaded, high performance apps that can track your movement or even take pictures of whatever you think is interesting.
This document describes a mobile authentication and key exchange protocol that uses nested one-time secrets. It contains modules for the user, VLR verification, HLR verification, key generation, and nested one-time secrets. The protocol uses lightweight public key cryptography and a challenge-response technique in two stages: an initial procedure and real execution stage. This allows for fast mutual authentication and agreement of a nested one-time secret while providing greater security and lower computational complexity than other wireless authentication schemes.
PyMongo is a Python driver for working with MongoDB and allows developers to connect to MongoDB from Python, interface with MongoDB databases and collections, and perform common operations like inserting, finding, updating, and deleting documents. It maps common SQL concepts like databases, tables, and rows to MongoDB concepts like databases, collections, and BSON documents. The document provides examples of basic PyMongo operations for connecting to a MongoDB server, getting and working with databases and collections, and performing CRUD operations on documents.
The document provides examples of how to perform various actions in QuickTest Professional (QTP) such as selecting items from a web list, setting values in a web edit, reading and writing data to text files, and using descriptive programming. Key examples include selecting the third item from a web list, setting the pincode value to "23" in a web edit, reading lines from one text file and writing them to another file, and setting the value "oshoworld" in the first web edit on a page using a descriptive program.
The document describes an example Java program that defines classes for a banking application including accounts, customers, and transactions. Key points:
1) It defines interfaces for interest rates and transactions that account classes can implement.
2) An abstract Account class and concrete SBAccount class that extends Account are defined.
3) A Customer class holds an SBAccount and allows transactions like deposit, withdraw, interest calculation.
4) A BankDemo class demonstrates creating a customer and performing sample transactions.
The Ring programming language version 1.8 book - Part 74 of 202Mahmoud Samir Fayed
This document describes a Ring-based notepad application with the following key features:
- It includes buttons and menu options for common file operations like new, open, save, print.
- The interface contains a toolbar and main window for the text editor area.
- Additional features allow for text formatting, search/replace, and setting the font and colors.
- The application stores the open file name and can check if the user wants to save changes when closing.
This document contains code for connecting to a database and querying data from tables to display in a list. It includes code to handle exceptions if the connection fails, query the "Orders" and "Inventory" tables to find items that are out of stock, query the "Orders", "Customers" and "Inventory" tables to display today's orders details including customer name, item details and total cost, and a function to verify if a database file exists before loading the form.
The document contains source code for a point of sale (POS) system with tables for products and transactions, and functions for loading products, adding items to a cart, generating transaction numbers, computing totals, and processing purchases. It includes interfaces for viewing and selecting products, building an order, and completing a sale with validation of inputs and updating of quantities.
The Ring programming language version 1.9 book - Part 78 of 210Mahmoud Samir Fayed
This document describes a simple notepad application developed using the RingQt GUI library. The application contains features like opening, saving, printing files as well as cut, copy, paste functionality. It allows changing font, text color and includes a find/replace feature. The main window contains toolbars for file operations and menus for file, edit, view and help. A text editor widget is used to display and edit text. Buttons are added to toolbars to trigger common operations like new, open, save etc.
SISTEMA DE FACTURACION (Ejemplo desarrollado)Darwin Durand
The document describes the creation of a database in SQL Server to manage invoices and receipts. It includes tables for clients, employees, document headers, and document details. Stored procedures are created to insert data and a form is developed in Visual Studio .NET to manage documents. The form allows searching for clients and employees, adding product details, and printing reports using Crystal Reports.
This document contains code for an inventory management system. It includes modules for connecting to a database, handling user login and permissions, and inputting/managing product data. The login module verifies user credentials and sets permission levels. The product input module provides functions for inserting, updating, deleting and searching for product records in the database. It initializes forms and controls for data entry and management.
This document contains code for a Visual Basic .NET Windows forms application for a sales system. It includes code to manage clients, products, invoices and users through different forms. It allows layout of multiple document interface (MDI) forms in cascade, horizontal tile and vertical tile. It also includes code to launch external applications like calculator, Word and Excel.
This document provides information about an inventory management application created in VB.NET. It includes details on the login screen, main menu, stock record viewing and editing screens, size and color record screens, and supporting code. The application allows users to view, add, update and delete inventory stock records with attributes like quantity, product type, size, and color.
This document contains code for an application that allows users to add/update patient records in a database. It includes functions for connecting to the database, retrieving and populating dropdown lists of doctors and departments from tables, inserting/updating patient records, and navigating between forms to admit patients or view checkups.
The document is a Visual Basic program for a hotel reservation system. It allows users to enter a guest name, select a room type and number, and pick check-in and check-out dates. It then calculates the room rate, number of nights stayed, and any applicable discounts (0-75% off for long stays). The total payment due is displayed along with a record of the reservation added to several list boxes.
This document provides instructions for creating a simple book sales application in VB.Net. It describes setting up the database tables, designing the user interface forms, and includes example code for form functionality like loading and saving data. Tables are created for book types, books, transactions, and transaction details. Forms are designed for a main menu, managing book types and books, and processing sales transactions. Code examples show connecting to the database and querying/manipulating data. The goal is to demonstrate creating a basic working application with a database backend using VB.Net.
The document contains code snippets in VB.NET for various programming concepts like addition of two numbers, reversing a number, calculating factorial using a for loop, checking if a number is a palindrome, finding the greatest of three numbers, checking if a number is an Armstrong number, calculating the sum of digits, checking for a leap year, generating Fibonacci series, reversing a number, printing a number triangle, finding the maximum of two numbers, generating palindrome numbers, swapping two variables using a function, converting between Fahrenheit and Centigrade, swapping two variables without a third variable, summing array elements using a function, finding Armstrong numbers between 1 to 2000, inputting and printing array elements, adding array elements, using message boxes
The Ring programming language version 1.7 book - Part 41 of 196Mahmoud Samir Fayed
This document discusses using nested structures and object composition in Ring to enable declarative programming. It shows how to:
1. Create objects inside lists and add objects to lists.
2. Return objects and lists by reference from methods to avoid copies.
3. Execute a "BraceEnd()" method after accessing an object with braces {} to run cleanup code.
4. Build a declarative programming environment on top of Ring's object orientation features using nested structures, returning references, and BraceEnd() methods.
The document contains code snippets in Visual Basic for various programming tasks like:
1. Copying text from one text box to another
2. Clearing text from text boxes
3. Summarizing a number and reversing it
4. Calculating factorial of a number
5. Checking if a number is prime
6. Swapping numbers by value and reference
7. Checking case of a string and converting case
.Net Enterprise Services and their ImplementationsKashif Aleem
The document discusses .NET Enterprise Services and their implementation, including how they provide support for distributed transactions, security, object pooling, and other features. It provides an example of how transaction services can be used to ensure atomic updates across multiple database tables. Finally, it covers how queued components allow for asynchronous and disconnected method calls using Message Queuing to store and deliver messages.
The Ring programming language version 1.5 book - Part 8 of 31Mahmoud Samir Fayed
This document summarizes key classes and methods from the Ring web library (weblib.ring).
The Application class contains methods for encoding, decoding, cookies, and more. The Page class contains methods for generating common HTML elements and structures. Model classes like UsersModel manage data access and object relational mapping. Controller classes handle requests and coordinate the view and model.
The document contains source code and design documents for an inventory program. It includes use case diagrams, activity diagrams, collaboration diagrams, and component diagrams. It details the design of screens in VB6.0 and provides source code for connecting to a database, querying tables, inserting records, and updating stock quantities after purchases or sales. Screen designs and additional source code are presented for purchase and sales modules that also update the stock details after transactions.
This document contains code for a Visual Basic .NET application that connects to a SQL database. It includes code to query the database based on an inputted ID number, display the results, and enable editing of fields to allow adding a new record to the database. The code opens a SQL connection, executes a stored procedure to search the database based on an ID, loads the results into text boxes, and includes a method to enable editing of the fields in preparation for inserting a new record.
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
This document provides code examples and documentation for Ring's web library (weblib.ring). It describes classes and methods for generating HTML pages, forms, tables and other elements. This includes the Page class for adding common elements like text, headings, paragraphs etc., the Application class for handling requests, cookies and encoding, and classes representing various HTML elements like forms, inputs, images etc. It also provides an overview of how to create pages dynamically using View and Controller classes along with Model classes for database access.
The Ring programming language version 1.9 book - Part 53 of 210Mahmoud Samir Fayed
This document provides code examples and documentation for Ring's web application framework. It includes code for user authentication using a database, classes for database access and web controllers, and descriptions of the main classes and methods in the WebLib API for generating HTML pages and handling requests. The document covers key concepts like generating pages dynamically based on request parameters, working with databases using Model classes, and common tasks like cookies, file uploads, and URL encoding.
The document discusses .NET garbage collection and provides demonstrations of how it works. It begins with an introduction on why understanding garbage collection is important. It then demonstrates garbage collection concepts like generations and finalization through code examples. The document discusses optimizations the CLR performs as well as patterns that can impact memory usage, such as circular references, singletons, and caching objects. It concludes with best practices for memory management and references for further reading.
INSERCION DE REGISTROS DESDE VISUAL.NET A UNA BD DE SQL SERVERDarwin Durand
This document shows how to insert data into a database table using Visual Basic .NET. It creates a database called "ejercicio" and a table called "PRUEBA" with various columns. A module is created to handle the database connection. A form is created with textboxes and buttons to insert data. When the "btngrabar" button is clicked, a SQL insert statement is executed to add the data from the textboxes to the "PRUEBA" table.
The document contains 9 VB.Net programs with code examples and output. The programs cover topics like counting vowels in a string, checking if a number is even/odd/overflow, calculating compound interest, summing positive and negative numbers from user input, concatenating strings with message box, changing font style based on checkboxes, generating a student enrollment form with combo boxes, creating a dynamic user login form using a database, and implementing a multiple document interface with parent and child forms.
please code in c#- please note that im a complete beginner- northwind.docxAustinaGRPaigey
please code in c#.
please note that im a complete beginner.
northwind.mdf.
northwind_log.ldf
OrderDetailsMaintenance.zip
1. Include the two above files in the root of your OrderDetailsMaintenance project.
2. Make sure to mark them as "Content" and "Copy Always" or "Copy if newer" in the properties window of those two files.
3. Run the Scaffold-DbContext command to create a context class as well as a class to encapsulate the Orders objects from the associated table in the mdf file. Make sure to include the parameters for -Tables Customers (only worry about the attributes associated with the text boxes, you don't need to worry about any other rows from the table)
4. Once you have ran the command, include an app.config file and add a connection string element. Make sure to copy the connection string from your Context class to your app.config. Then edit your context to grab the connection string from the app.config (ConfigurationManager.ConnectionString["Northwind"].ConnectionString)
5. Code the Find button to Find the customer id and populate the details in the below text boxes.
1. If no order is found, display a message box.
6. Code the exit button
7. Code the Save button to update its attributes and call Update and SaveChanges() on that particular entity.
1. Note: If you close the program, reopen it, and search for the entity you recently updated. You may not see the changes depending on how you setup the mdf file in your project (because it copies a new version to the bin directory each time you run the program). So, if you don't see your changes, don't be alarmed.
============
HERE IS WHAT I HAVE SO FAR
frmCustomerMaintenance.cs
namespace OrderDetailsMaintenance
{
public partial class frmCustomerMaintenance : Form
{
public frmCustomerMaintenance()
{
InitializeComponent();
}
}
}
frmCustomerMaintenance.resx
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name".
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
Revolutionizing Visual Effects Mastering AI Face Swaps.pdfUndress Baby
The quest for the best AI face swap solution is marked by an amalgamation of technological prowess and artistic finesse, where cutting-edge algorithms seamlessly replace faces in images or videos with striking realism. Leveraging advanced deep learning techniques, the best AI face swap tools meticulously analyze facial features, lighting conditions, and expressions to execute flawless transformations, ensuring natural-looking results that blur the line between reality and illusion, captivating users with their ingenuity and sophistication.
Web:- https://undressbaby.com/
What is Augmented Reality Image Trackingpavan998932
Augmented Reality (AR) Image Tracking is a technology that enables AR applications to recognize and track images in the real world, overlaying digital content onto them. This enhances the user's interaction with their environment by providing additional information and interactive elements directly tied to physical images.
Takashi Kobayashi and Hironori Washizaki, "SWEBOK Guide and Future of SE Education," First International Symposium on the Future of Software Engineering (FUSE), June 3-6, 2024, Okinawa, Japan
What is Master Data Management by PiLog Groupaymanquadri279
PiLog Group's Master Data Record Manager (MDRM) is a sophisticated enterprise solution designed to ensure data accuracy, consistency, and governance across various business functions. MDRM integrates advanced data management technologies to cleanse, classify, and standardize master data, thereby enhancing data quality and operational efficiency.
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeAftab Hussain
Understanding variable roles in code has been found to be helpful by students
in learning programming -- could variable roles help deep neural models in
performing coding tasks? We do an exploratory study.
- These are slides of the talk given at InteNSE'23: The 1st International Workshop on Interpretability and Robustness in Neural Software Engineering, co-located with the 45th International Conference on Software Engineering, ICSE 2023, Melbourne Australia
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
8 Best Automated Android App Testing Tool and Framework in 2024.pdfkalichargn70th171
Regarding mobile operating systems, two major players dominate our thoughts: Android and iPhone. With Android leading the market, software development companies are focused on delivering apps compatible with this OS. Ensuring an app's functionality across various Android devices, OS versions, and hardware specifications is critical, making Android app testing essential.
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsPeter Muessig
The UI5 tooling is the development and build tooling of UI5. It is built in a modular and extensible way so that it can be easily extended by your needs. This session will showcase various tooling extensions which can boost your development experience by far so that you can really work offline, transpile your code in your project to use even newer versions of EcmaScript (than 2022 which is supported right now by the UI5 tooling), consume any npm package of your choice in your project, using different kind of proxies, and even stitching UI5 projects during development together to mimic your target environment.
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j
Dr. Jesús Barrasa, Head of Solutions Architecture for EMEA, Neo4j
Découvrez les dernières innovations de Neo4j, et notamment les dernières intégrations cloud et les améliorations produits qui font de Neo4j un choix essentiel pour les développeurs qui créent des applications avec des données interconnectées et de l’IA générative.
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppGoogle
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-fusion-buddy-review
AI Fusion Buddy Review: Key Features
✅Create Stunning AI App Suite Fully Powered By Google's Latest AI technology, Gemini
✅Use Gemini to Build high-converting Converting Sales Video Scripts, ad copies, Trending Articles, blogs, etc.100% unique!
✅Create Ultra-HD graphics with a single keyword or phrase that commands 10x eyeballs!
✅Fully automated AI articles bulk generation!
✅Auto-post or schedule stunning AI content across all your accounts at once—WordPress, Facebook, LinkedIn, Blogger, and more.
✅With one keyword or URL, generate complete websites, landing pages, and more…
✅Automatically create & sell AI content, graphics, websites, landing pages, & all that gets you paid non-stop 24*7.
✅Pre-built High-Converting 100+ website Templates and 2000+ graphic templates logos, banners, and thumbnail images in Trending Niches.
✅Say goodbye to wasting time logging into multiple Chat GPT & AI Apps once & for all!
✅Save over $5000 per year and kick out dependency on third parties completely!
✅Brand New App: Not available anywhere else!
✅ Beginner-friendly!
✅ZERO upfront cost or any extra expenses
✅Risk-Free: 30-Day Money-Back Guarantee!
✅Commercial License included!
See My Other Reviews Article:
(1) AI Genie Review: https://sumonreview.com/ai-genie-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
#AIFusionBuddyReview,
#AIFusionBuddyFeatures,
#AIFusionBuddyPricing,
#AIFusionBuddyProsandCons,
#AIFusionBuddyTutorial,
#AIFusionBuddyUserExperience
#AIFusionBuddyforBeginners,
#AIFusionBuddyBenefits,
#AIFusionBuddyComparison,
#AIFusionBuddyInstallation,
#AIFusionBuddyRefundPolicy,
#AIFusionBuddyDemo,
#AIFusionBuddyMaintenanceFees,
#AIFusionBuddyNewbieFriendly,
#WhatIsAIFusionBuddy?,
#HowDoesAIFusionBuddyWorks
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Vb Project ขั้นเทพ
1. 1
Imports System.Data.SqlClient
Public Class FrmSaleProduct
Private Sub tsbtnAdd_Click(sender As Object, e As EventArgs) Handles tsbtnAdd.Click
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim strSql As String
strSql = "SELECT TOP 1 BillID FROM tb_Sale ORDER BY BillID DESC"
Dim da As New SqlDataAdapter(strSql, conn)
Dim ds As New DataSet
da.Fill(ds, "Sale") 'นำค่ำ da ใส่ใน ds ชื่อ product555
If ds.Tables("Sale").Rows.Count = 0 Then
txtBillid.Text = DateTime.Now.ToString("yy-MM") + "-" + "0001"
Else
Dim oldBillID As String = ds.Tables("Sale").Rows(0).Item("BillID").ToString().Substring(6)
Dim newBillID As String = (Convert.ToInt32(oldBillID) + 1).ToString("0000")
txtBillid.Text = DateTime.Now.ToString("yy-MM") + "-" + newBillID
End If
2. 2
conn.Close()
dtpSaleDate.Enabled = True
txtCustomerId.Enabled = True
btnSelectCustomer.Enabled = True
txtProductId.Enabled = True
btnSelectProduct.Enabled = True
txtAmount.Enabled = True
btnAddProductSale.Enabled = True
tsbtnSave.Enabled = True
tsbtnAdd.Enabled = False
End Sub
Private Sub btnSelectCustomer_Click(sender As Object, e As EventArgs) Handles btnSelectCustomer.Click
dgvSelectCustomer.Visible = True
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'If conn.State = ConnectionState.Open Then MessageBox.Show("Connection OK")
Dim strSql As String
strSql = "SELECT CustomerId, Name FROM tb_Customers"
Dim da As New SqlDataAdapter(strSql, conn)
Dim ds As New DataSet
da.Fill(ds, "Customers")
dgvSelectCustomer.DataSource = ds.Tables("Customers")
conn.Close()
dgvSelectCustomer.Columns(0).HeaderText = "รหัสลูกค้ำ"
dgvSelectCustomer.Columns(1).HeaderText = "ชื่อลูกค้ำ"
dgvSelectCustomer.Columns(0).Width = 100
dgvSelectCustomer.Columns(1).Width = 150
End Sub
Private Sub txtCustomerId_KeyUp(sender As Object, e As KeyEventArgs) Handles txtCustomerId.KeyUp
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
3. 3
Dim strSql As String = "SELECT CustomerId, Name FROM tb_Customers Where CustomerID = '" + txtCustomerId.Text + "'"
Dim da As New SqlDataAdapter(strSql, conn)
Dim ds As New DataSet
da.Fill(ds, "Customers") 'นำค่ำ da ใส่ใน ds ชื่อ product555
If ds.Tables("Customers").Rows.Count = 0 Then
txtName.Text = ""
Else
txtName.Text = ds.Tables("Customers").Rows(0).Item("Name").ToString()
End If
conn.Close()
End Sub
Private Sub dgvSelectCustomer_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles
dgvSelectCustomer.CellMouseUp
If e.RowIndex < 0 Then
Exit Sub
End If
txtCustomerId.Text = dgvSelectCustomer.Rows(e.RowIndex).Cells(0).Value.ToString()
txtName.Text = dgvSelectCustomer.Rows(e.RowIndex).Cells(1).Value.ToString()
dgvSelectCustomer.Visible = False
End Sub
Private Sub txtProductId_KeyUp(sender As Object, e As KeyEventArgs) Handles txtProductId.KeyUp
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
Dim strSql As String = "SELECT * FROM tb_Products Where ProductID = '" + txtProductId.Text + "'"
Dim da As New SqlDataAdapter(strSql, conn)
Dim ds As New DataSet
da.Fill(ds, "Products") 'นำค่ำ da ใส่ใน ds ชื่อ product555
If ds.Tables("Products").Rows.Count = 0 Then
txtProductName.Text = ""
txtUnitsInstock.Text = ""
txtSalePrice.Text = ""
Else
txtProductName.Text = ds.Tables("Products").Rows(0).Item("ProductName").ToString()
txtUnitsInstock.Text = ds.Tables("Products").Rows(0).Item("UnitsInstock").ToString()
txtSalePrice.Text = ds.Tables("Products").Rows(0).Item("SalePrice").ToString()
End If
conn.Close()
End Sub
Private Sub btnSelectProduct_Click(sender As Object, e As EventArgs) Handles btnSelectProduct.Click
4. 4
dgvSelectProduct.Visible = True
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'If conn.State = ConnectionState.Open Then MessageBox.Show("Connection OK")
Dim strSql As String = "SELECT ProductID, ProductName, UnitsInstock, SalePrice FROM tb_Products"
Dim da As New SqlDataAdapter(strSql, conn)
Dim ds As New DataSet
da.Fill(ds, "Products")
dgvSelectProduct.DataSource = ds.Tables("Products")
conn.Close()
dgvSelectProduct.Columns(0).HeaderText = "รหัสสินค้ำ"
dgvSelectProduct.Columns(1).HeaderText = "ชื่อสินค้ำ"
dgvSelectProduct.Columns(2).HeaderText = "จำนวนในสต็อก"
dgvSelectProduct.Columns(3).HeaderText = "รำคำขำย"
dgvSelectProduct.Columns(0).Width = 100
dgvSelectProduct.Columns(1).Width = 150
dgvSelectProduct.Columns(2).Width = 120
dgvSelectProduct.Columns(3).Width = 100
End Sub
Private Sub dgvSelectProduct_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvSelectProduct.CellMouseUp
If e.RowIndex < 0 Then
Exit Sub
End If
txtProductId.Text = dgvSelectProduct.Rows(e.RowIndex).Cells(0).Value.ToString()
txtProductName.Text = dgvSelectProduct.Rows(e.RowIndex).Cells(1).Value.ToString()
txtUnitsInstock.Text = dgvSelectProduct.Rows(e.RowIndex).Cells(2).Value.ToString()
txtSalePrice.Text = dgvSelectProduct.Rows(e.RowIndex).Cells(3).Value.ToString()
dgvSelectProduct.Visible = False
End Sub
Private Sub btnAddProductSale_Click(sender As Object, e As EventArgs) Handles btnAddProductSale.Click
If txtProductName.Text = "" Then
MessageBox.Show("เลือกสินค้ำ")
ElseIf txtAmount.Text = "" Then
MessageBox.Show("กรุณำกรอกจำนวนที่ซื้อ")
ElseIf Convert.ToInt32(txtAmount.Text) > Convert.ToInt32(txtUnitsInstock.Text) Then
MessageBox.Show("จำนวนที่ซื้อมำกกว่ำ สินค้ำในสต็อก")
Else
Dim dgvRow As Integer = dgvSaleDetail.Rows.Count
5. 5
If dgvRow <> 0 Then
For i As Integer = 0 To dgvRow - 1
If dgvSaleDetail.Rows(i).Cells(0).Value.ToString() = txtProductId.Text Then
Dim quantity As Integer = Convert.ToInt32(txtAmount.Text) + Convert.ToInt32(dgvSaleDetail.Rows(i).Cells(3).Value)
If quantity > Convert.ToInt32(txtUnitsInstock.Text) Then
MessageBox.Show("จำนวนที่ซื้อมำกกว่ำ สินค้ำในสต็อก")
Else
dgvSaleDetail.Rows(i).Cells(3).Value = quantity
Dim saleUpdate As Double = quantity * Convert.ToDouble(txtSalePrice.Text)
dgvSaleDetail.Rows(i).Cells(4).Value = saleUpdate
Dim saleTotalUpdate = Convert.ToDouble(lblTotal.Text) + (Convert.ToInt32(txtAmount.Text) *
Convert.ToDouble(txtSalePrice.Text))
lblTotal.Text = saleTotalUpdate.ToString("#,##0.00")
End If
txtProductId.Clear()
txtUnitsInstock.Clear()
txtProductName.Clear()
txtSalePrice.Clear()
txtAmount.Clear()
Exit Sub
End If
Next
End If
Dim numRow = dgvSaleDetail.Rows.Add()
dgvSaleDetail.Rows(numRow).Cells(0).Value = txtProductId.Text
dgvSaleDetail.Rows(numRow).Cells(1).Value = txtProductName.Text
dgvSaleDetail.Rows(numRow).Cells(2).Value = txtSalePrice.Text
dgvSaleDetail.Rows(numRow).Cells(3).Value = txtAmount.Text
Dim salePrice As Double = Convert.ToInt32(txtAmount.Text) * Convert.ToDouble(txtSalePrice.Text)
dgvSaleDetail.Rows(numRow).Cells(4).Value = salePrice
Dim saleTotal As Double = Convert.ToDouble(lblTotal.Text) + salePrice
lblTotal.Text = saleTotal.ToString("#,##0.00")
txtProductId.Clear()
txtUnitsInstock.Clear()
txtProductName.Clear()
txtSalePrice.Clear()
txtAmount.Clear()
End If
End Sub
Private Sub dgvSaleDetail_CellMouseDoubleClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles
dgvSaleDetail.CellMouseDoubleClick
Dim rowSelect As Integer = e.RowIndex
6. 6
Dim total As Double = Convert.ToDouble(lblTotal.Text) - Convert.ToDouble(dgvSaleDetail.Rows(rowSelect).Cells(4).Value.ToString())
lblTotal.Text = total.ToString("#,##0.00")
dgvSaleDetail.Rows.RemoveAt(rowSelect)
End Sub
Private Sub tsbtnSave_Click(sender As Object, e As EventArgs) Handles tsbtnSave.Click
If txtName.Text = "" Then
MessageBox.Show("เลือกชื่อลูกค้ำด้วย")
ElseIf dgvSaleDetail.Rows.Count = 0 Then
MessageBox.Show("เลือกสินค้ำที่จะซื้อด้วย")
Else
Dim conn As SqlConnection
conn = New SqlConnection("Data Source = ISIN; Database=DBSale; integrated security=true")
If conn.State = ConnectionState.Open Then conn.Close()
conn.Open()
'If conn.State = ConnectionState.Open Then MessageBox.Show("Connection OK")
Dim cm As New SqlCommand
cm.Connection = conn
cm.CommandType = CommandType.Text
Dim strSql As String
strSql = "insert into tb_sale (billId, saleDate, customerId, total) values ('" + txtBillid.Text + "', '" +
dtpSaleDate.Value.Date.ToString("yyyy-MM-dd", New System.Globalization.CultureInfo("en-US")) + "', '" + txtCustomerId.Text + "', " +
lblTotal.Text + ")"
cm.CommandText = strSql
cm.ExecuteNonQuery()
MessageBox.Show("บันทึกเรียบร้อยแล้ว")
conn.Close()
End If
End Sub
End Class
Save File Dialog Confirm
Private Sub SaveButton_Click(sender As Object, e As EventArgs) Handles SaveButton.Click
SaveFileDialog1.DefaultExt = "*.rtf"
SaveFileDialog1.Filter = "RTF Files|*.rtf"
7. 7
SaveFileDialog1.CreatePrompt = True
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
RichTextBox1.SaveFile(SaveFileDialog1.FileName, RichTextBoxStreamType.RichText)
End If
End Sub
มินิโปรเจค
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
8. 8
Namespace WindowsFormsApplication1
Public Partial Class AddOrder
Inherits Form
Private btnText As String
Public Sub New(btnText As String)
InitializeComponent()
Me.btnText = btnText
End Sub
Private Sub loadDataToAdd()
Dim nt As Integer = Convert.ToInt16(btnText.Substring(7))
'sub x
Dim T00 As String = "T" + nt.ToString("00")
'1.ติดต่อฐำนข้อมูล
'string conStr = "server=Localhost;initial catalog=DBBarBQ;integrated security=true";
Dim conStr As String = "server=Localhost ;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2.คำสั่ง SQL BillID,TableID,SaleDate,AmountChild,AmountAdult,Total,Fined,AmountFined,Status
'tb_xxxx1 a left join tb_xxxx2 b on a.BillID=b.BillID
9. 9
Dim strSql As String = (Convert.ToString("select * " + " from tb_Sale S left join tb_saledetail SD on S.BillID=SD.BillID" +
" where S.status = 'Yes' and S.TableID = '") & T00) + "'"
'สมมติ T01 มี ทำ ถ้ำไม่มี ไม่ทำ
'3.สั่งให้ SQl ทำงำน
Dim cmd As New SqlCommand(strSql, connectDB)
'ทำงำน
Dim dr As SqlDataReader = cmd.ExecuteReader()
'สั่งให้ทำงำน + ดึงค่ำที่ได้มำ
'3.1 ทำอะไรก็แล้วแต่
If dr.Read() Then
txtBill.Text = dr("BillID").ToString()
txtChild.Text = dr("AmountChild").ToString()
txtAdult.Text = dr("AmountAdult").ToString()
txtAmount.Text = dr("AmountFined").ToString()
End If
'4.
connectDB.Close()
'###################################### dgvBev #######################################//
If connectDB.State = ConnectionState.Closed Then
connectDB.Open()
End If
If True Then
'1.ติดต่อฐำนข้อมูล
'string conStr = "server=Localhost;initial catalog=DBBarBQ;integrated security=true";
'string conStr2 = "server=Localhost ;initial catalog=DBBarBQ;integrated security=true";
'SqlConnection connectDB2 = new SqlConnection(conStr2);
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
10. 10
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2.คำสั่ง SQL BillID,TableID,SaleDate,AmountChild,AmountAdult,Total,Fined,AmountFined,Status
'2.คำสั่ง SQL BeveragesID ,BeveragesName ,SalePrice ,Cost ,UnitStock
Dim strSqlBev As String = "select BeveragesID, BeveragesName , SalePrice , UnitStock from tb_Beverages"
'คำสั่ง
'3.สั่งให้ SQl ทำงำน
Dim cmd2 As New SqlCommand(strSqlBev, connectDB)
'ทำงำน
Dim dr2 As SqlDataReader = cmd2.ExecuteReader()
'สั่งให้ทำงำน + ดึงค่ำที่ได้มำ
'3.1 ทำอะไรก็แล้วแต่ เอำไปใส่ใน DataGridview Bevproduct
'connectDB.Close();
While dr2.Read()
'กรณีมีข้อมูล
'MessageBox.Show(dr2["BeveragesID"].ToString());
'เพิ่มแถวใน GV พร้อมกับกำหนดตัวแปร เก็บหมำยเลขแถว
Dim numRow As Integer = dgvBev.Rows.Add()
'numRow = numRow;
'3.1 product
dgvBev.Rows(numRow).Cells(0).Value = dr2("BeveragesID").ToString()
dgvBev.Rows(numRow).Cells(1).Value = dr2("BeveragesName").ToString()
dgvBev.Rows(numRow).Cells(2).Value = dr2("UnitStock").ToString()
dgvBev.Rows(numRow).Cells(3).Value = dr2("SalePrice").ToString()
'txtProductId.Text = dr2["BeveragesID"].ToString();
11. 11
numRow = numRow + 1
End While
'DataTable dt2 = new DataTable();
'dt2.Load(dr2);//เก็บสิ่งที่ได้มำ
'dgvAddBev.DataSource = dt2;//เอำสิ่งที่เก็บใส่ DataGridView
connectDB.Close()
End If
'###################################### dgvAddBev #######################################//
If connectDB.State = ConnectionState.Closed Then
connectDB.Open()
End If
If True Then
'MessageBox.Show("Op1");
'1.ติดต่อฐำนข้อมูล
'string conStr = "server=Localhost;initial catalog=DBBarBQ;integrated security=true";
'string conStr2 = "server=Localhost ;initial catalog=DBBarBQ;integrated security=true";
'SqlConnection connectDB2 = new SqlConnection(conStr2);
'if (connectDB.State == ConnectionState.Closed) connectDB.Open();
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
12. 12
Return
End Try
'2.คำสั่ง SQL BillID,TableID,SaleDate,AmountChild,AmountAdult,Total,Fined,AmountFined,Status
'2.คำสั่ง SQL BeveragesID ,BeveragesName ,SalePrice ,Cost ,UnitStock
Dim strSqlAddBev As String = (Convert.ToString("select * " + " from tb_SaleDetail SD left join tb_Beverages
Bev on SD.BeveragesID=Bev.BeveragesID " + " left join tb_Sale S on SD.BillID=S.BillID " + " where
SD.BeveragesID=Bev.BeveragesID " + " and S.status = 'Yes' and S.TableID = '") & T00) + "'"
'3.สั่งให้ SQl ทำงำน
Dim cmd3 As New SqlCommand(strSqlAddBev, connectDB)
'ทำงำน
Dim dr3 As SqlDataReader = cmd3.ExecuteReader()
'สั่งให้ทำงำน + ดึงค่ำที่ได้มำ
'3.1 ทำอะไรก็แล้วแต่ เอำไปใส่ใน DataGridview Bevproduct
While dr3.Read()
'กรณีมีข้อมูล
'MessageBox.Show(dr3["BeveragesID"].ToString()+"Before");
'เพิ่มแถวใน GV พร้อมกับกำหนดตัวแปร เก็บหมำยเลขแถว
Dim numRow As Integer = dgvAddBev.Rows.Add()
'numRow = numRow;
'3.1 product
dgvAddBev.Rows(numRow).Cells(0).Value = dr3("BeveragesID").ToString()
dgvAddBev.Rows(numRow).Cells(1).Value = dr3("BeveragesName").ToString()
dgvAddBev.Rows(numRow).Cells(2).Value = dr3("UnitStock").ToString()
dgvAddBev.Rows(numRow).Cells(3).Value = dr3("SalePrice").ToString()
'txtProductId.Text = dr2["BeveragesID"].ToString();
numRow = numRow + 1
End While
'
13. 13
' DataTable dt = new DataTable();
' dt.Load(dr3);//เก็บสิ่งที่ได้มำ
' int dtnum = dt.Rows.Count;
' MessageBox.Show(dtnum.ToString());
' if (dtnum > 0)
' {
' dataGridView1.Enabled = true;
' dataGridView1.Visible = true;
' }
' else
' {
' dataGridView1.Enabled = false;
' dataGridView1.Visible = false;
' }
' dataGridView1.DataSource = dt;//เอำสิ่งที่เก็บใส่ DataGridView
' dataGridView1.Columns[0].Width = 100;
' dataGridView1.Columns[1].Width = 250;
' dataGridView1.Columns[2].Width = 150;
' dataGridView1.Columns[3].Width = 150;
' dataGridView1.Columns[4].Width = 150;
'
connectDB.Close()
End If
End Sub
Private Sub AddOrder_Load(sender As Object, e As EventArgs)
lblTableX.Text = btnText
'โตะที่ x
14. 14
loadDataToAdd()
End Sub
Private Sub dgvBev_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs)
If e.RowIndex = -1 Then
Return
End If
txtBevID.Text = dgvBev.Rows(e.RowIndex).Cells(0).Value.ToString()
txtBevName.Text = dgvBev.Rows(e.RowIndex).Cells(1).Value.ToString()
txtAmount.Enabled = True
txtAmount.Focus()
btnAddProductSale.Enabled = True
btnDelete.Enabled = True
End Sub
Private Sub tsbtnHome_Click(sender As Object, e As EventArgs)
AddOrder.ActiveForm.Close()
End Sub
Private Sub chkChild_CheckedChanged(sender As Object, e As EventArgs)
15. 15
If chkChild.Checked Then
txtChild.Enabled = True
txtChild.Focus()
Else
txtChild.Enabled = False
txtChild.Focus()
End If
End Sub
Private Sub chkAdult_CheckedChanged(sender As Object, e As EventArgs)
If chkAdult.Checked Then
txtAdult.Enabled = True
txtAdult.Focus()
Else
txtAdult.Enabled = False
txtAdult.Focus()
End If
End Sub
Private Sub txtChild_KeyPress(sender As Object, e As KeyPressEventArgs)
End Sub
Private Sub txtAdult_KeyPress(sender As Object, e As KeyPressEventArgs)
End Sub
Private Sub btnAddProductSale_Click(sender As Object, e As EventArgs)
End Sub
16. 16
Private Sub tsbtnHome_Click_1(sender As Object, e As EventArgs)
Dim ManageBv As New ManageBv()
Me.Close()
ManageBv.Show()
End Sub
Private Sub tsbtnManageBv_Click(sender As Object, e As EventArgs)
Dim ManageBv As New ManageBv()
Me.Close()
ManageBv.Show()
End Sub
Private Sub tsbtnPricePeople_Click(sender As Object, e As EventArgs)
Dim PricePeople As New PricePeople()
Me.Close()
PricePeople.Show()
End Sub
Private Sub tsbtnReportEarn_Click(sender As Object, e As EventArgs)
Dim ReportEarn As New ReportEarn()
Me.Close()
ReportEarn.Show()
End Sub
Private Sub btnSaveOrder_Click(sender As Object, e As EventArgs)
End Sub
Private Sub btnCancelOrder_Click(sender As Object, e As EventArgs)
17. 17
End Sub
' private void txtChild_TextChanged(object sender, EventArgs e)
' {
' int number;
' if (!Int32.TryParse(txtChild.Text, out number))
' {
' MessageBox.Show("ข้อมูลของคุณต้องเป็นตัวเลขจำนวนเต็มเท่ำนั้น", "ตรวจสอบตัวเลข", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
' }
' }
Private Sub txtChild_KeyPress_1(sender As Object, e As KeyPressEventArgs)
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso (e.KeyChar <> "."C) Then
e.Handled = True
End If
' only allow one decimal point
If (e.KeyChar = "."C) AndAlso (TryCast(sender, TextBox).Text.IndexOf("."C) > -1) Then
e.Handled = True
End If
End Sub
Private Sub chkFined_CheckedChanged(sender As Object, e As EventArgs)
If chkFined.Checked Then
txtAmountFined.Enabled = True
txtAmountFined.Focus()
Else
txtAmountFined.Enabled = False
txtAmountFined.Focus()
End If
18. 18
End Sub
Private Sub txtChild_KeyPress_2(sender As Object, e As KeyPressEventArgs)
If Not Char.IsControl(e.KeyChar) AndAlso Not Char.IsDigit(e.KeyChar) AndAlso (e.KeyChar <> "."C) Then
e.Handled = True
End If
' only allow one decimal point
If (e.KeyChar = "."C) AndAlso (TryCast(sender, TextBox).Text.IndexOf("."C) > -1) Then
e.Handled = True
End If
End Sub
Private Sub dgvBev_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)
End Sub
End Class
End Namespace
Manage BV
Imports System.Data.SqlClient
Public Class ManagBv
Dim flag As String
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs)
Me.Hide()
Main.Show()
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs)
Me.Hide()
'addOrder.Show()
End Sub
Private Sub ManagBv_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If True Then
19. 19
'1.ติดต่อฐำนข้อมูล
'string conStr = "server=ASUS-PCSqlExpress;initial catalog=DBBarBQ;integrated security=true";
Dim conStr As String = "server=ISIN;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2.คำสั่ง SQL BeveragesID , BeveragesName , SalePrice , Cost , UnitStock
Dim strSql As String = "select BeveragesID, BeveragesName , Cost , SalePrice , UnitStock from tb_Beverages"
'คำสั่ง
'3.สั่งให้ SQl ทำงำน
Dim cmd As New SqlCommand(strSql, connectDB)
'ทำงำน
Dim dr As SqlDataReader = cmd.ExecuteReader()
'สั่งให้ทำงำน + ดึงค่ำที่ได้มำ
'3.1 ทำอะไรก็แล้วแต่
Dim dt As New DataTable()
dt.Load(dr)
'เก็บสิ่งที่ได้มำ
dgvEditProduct.DataSource = dt
'เอำสิ่งที่เก็บใส่ DataGridView
connectDB.Close()
dgvEditProduct.Columns(0).HeaderText = "เลขที่สินค้ำ"
'กำหนดชื่อหัวColum
dgvEditProduct.Columns(1).HeaderText = "ชื่อเครื่องดื่ม"
dgvEditProduct.Columns(2).HeaderText = "รำคำทุน"
dgvEditProduct.Columns(3).HeaderText = "รำคำขำย"
dgvEditProduct.Columns(4).HeaderText = "จำนวนในสต็อก"
dgvEditProduct.Columns(0).Width = 100
dgvEditProduct.Columns(1).Width = 200
dgvEditProduct.Columns(2).Width = 100
dgvEditProduct.Columns(3).Width = 100
dgvEditProduct.Columns(4).Width = 120
End If
End Sub
Private Sub btnCancle_Click(sender As Object, e As EventArgs) Handles btnCancle.Click
If True Then
btnAdd.Enabled = True
btnCancle.Enabled = False
btnSave.Enabled = False
20. 20
btnEdit.Enabled = False
btnDelete.Enabled = False
txtEditProductName.Enabled = False
txtEditStock.Enabled = False
txtEditCost.Enabled = False
txtEditPrice.Enabled = False
txtEditSearch.Focus()
txtEditProductId.Clear()
txtEditProductName.Text = "กรอกรำยละเอียด"
txtEditStock.Text = "กรอกรำยละเอียด"
txtEditCost.Text = "กรอกรำยละเอียด"
txtEditPrice.Text = "กรอกรำยละเอียด"
txtEditSearch.Text = "กรอกรำยละเอียด"
loadDateToDgvEditProducts()
End If
End Sub
Private Sub dgvEditProduct_CellMouseUp(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvEditProduct.CellMouseUp
If True Then
If e.RowIndex = -1 Then
Return
End If
txtEditProductId.Text = dgvEditProduct.Rows(e.RowIndex).Cells("BeveragesID").Value.ToString()
txtEditProductName.Text = dgvEditProduct.Rows(e.RowIndex).Cells("BeveragesName").Value.ToString()
txtEditStock.Text = dgvEditProduct.Rows(e.RowIndex).Cells("UnitStock").Value.ToString()
txtEditCost.Text = dgvEditProduct.Rows(e.RowIndex).Cells("Cost").Value.ToString()
txtEditPrice.Text = dgvEditProduct.Rows(e.RowIndex).Cells("SalePrice").Value.ToString()
txtEditStock.Focus()
btnAdd.Enabled = False
btnCancle.Enabled = True
btnEdit.Enabled = True
btnDelete.Enabled = True
End If
End Sub
Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click
If True Then
flag = "Add"
txtEditStock.Clear()
txtEditPrice.Clear()
txtEditProductName.Clear()
txtEditProductId.Clear()
txtEditCost.Clear()
21. 21
btnAdd.Enabled = False
btnCancle.Enabled = True
btnSave.Enabled = True
txtEditProductName.Enabled = True
txtEditProductName.Focus()
txtEditStock.Enabled = True
txtEditCost.Enabled = True
txtEditPrice.Enabled = True
'1.ติดต่อฐำนข้อมูล
Dim conStr As String = "server=ISIN;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2.คำสั่ง SQL
Dim strSql As String = "select top 1 BeveragesID from tb_Beverages order by BeveragesID DESC"
'3.สั่งให้ SQl ทำงำน
Dim cmd As New SqlCommand(strSql, connectDB)
Dim dr As SqlDataReader = cmd.ExecuteReader()
'3.1 ทำอะไรก็แล้วแต่
If dr.Read() Then
'กรณีที่มีรหัสอยู่แล้ว
Dim oldwaID As String = dr("BeveragesID").ToString()
Dim newWaId As Integer = Convert.ToInt16(oldwaID.Substring(3)) + 1
'oldwaID เอำมำsub
txtEditProductId.Text = "wa" + newWaId.ToString("000")
Else
'กรณีที่ไม่มีรหัสสินค้ำเครื่องดื่ม
txtEditProductId.Text = "wa001"
End If
'4.ยกเลิกติดต่อ
connectDB.Close()
End If
End Sub
22. 22
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
If txtEditProductName.Text = "" Then
MessageBox.Show("กรุณำกรอกชื่อสินค้ำ/เครื่องดื่ม")
ElseIf txtEditStock.Text = "" Then
MessageBox.Show("กรุณำกรอกจำนวนสต๊อก")
ElseIf txtEditCost.Text = "" Then
MessageBox.Show("กรุณำกรอกรำคำทุน")
ElseIf txtEditPrice.Text = "" Then
MessageBox.Show("กรุณำกรอกรำคำขำย")
ElseIf flag = "Add" Then
'MessageBox.Show("add");
'1.ติดต่อฐำนข้อมูล
Dim conStr As String = "server=ISIN;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2. Sql statement BeveragesID, BeveragesName , Cost , SalePrice , UnitStock
Dim strSql As [String] = "Insert into tb_Beverages (BeveragesID,BeveragesName,Cost,SalePrice,UnitStock)values(" + "'" +
txtEditProductId.Text + "'" + ",'" + txtEditProductName.Text + "'" + ",'" + txtEditStock.Text + "'" + ",'" + txtEditCost.Text + "'" + ",'" +
txtEditPrice.Text + "'" + ")"
'3. สั่ง Sql statement ทำงำน
Dim cmd As New SqlCommand(strSql, connectDB)
cmd.ExecuteNonQuery()
'3.1 ทำอะไรก็แล้วแต่
MessageBox.Show("บันทึกหน้ำจอเรียบร้อยแล้ว")
'4. Disconnect
connectDB.Close()
btnCancle.PerformClick()
End If
End Sub
Private Sub btnEdit_Click(sender As Object, e As EventArgs) Handles btnEdit.Click
flag = "update"
btnEdit.Enabled = False
btnDelete.Enabled = False
btnSave.Enabled = True
txtEditProductName.Enabled = True
txtEditProductName.Focus()
23. 23
txtEditStock.Enabled = True
txtEditCost.Enabled = True
txtEditPrice.Enabled = True
End Sub
Private Sub loadDateToDgvEditProducts()
End Sub
Private Sub ToolStripButton1_Click_1(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
Me.Hide()
Main.Show()
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
Me.Hide()
End Sub
Private Sub ToolStripButton4_Click(sender As Object, e As EventArgs) Handles ToolStripButton4.Click
Me.Hide()
PricePeople.Show()
End Sub
Private Sub ToolStripButton5_Click_1(sender As Object, e As EventArgs) Handles ToolStripButton5.Click
Me.Hide()
ReportEarn.Show()
End Sub
Private Sub txtEditStock_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtEditStock.KeyPress
If e.KeyChar.ToString = "." And txtEditStock.Text.Contains(".") Then
e.Handled = True
Exit Sub
End If
Dim regex As String = "^[0-9.rntbs]+$"
Dim r As New System.Text.RegularExpressions.Regex(regex)
If r.IsMatch(e.KeyChar.ToString()) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtEditCost_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtEditCost.KeyPress
If e.KeyChar.ToString = "." And txtEditCost.Text.Contains(".") Then
e.Handled = True
Exit Sub
End If
24. 24
Dim regex As String = "^[0-9.rntbs]+$"
Dim r As New System.Text.RegularExpressions.Regex(regex)
If r.IsMatch(e.KeyChar.ToString()) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub txtEditPrice_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtEditPrice.KeyPress
If e.KeyChar.ToString = "." And txtEditPrice.Text.Contains(".") Then
e.Handled = True
Exit Sub
End If
Dim regex As String = "^[0-9.rntbs]+$"
Dim r As New System.Text.RegularExpressions.Regex(regex)
If r.IsMatch(e.KeyChar.ToString()) Then
e.Handled = False
Else
e.Handled = True
End If
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click
MessageBox.Show("ยืนยันกำรลบ")
btnDelete.Enabled = False
btnCancle.Enabled = True
If MessageBox.Show("ต้องกำรลบหรือไม่", "ยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
'1.ติดต่อฐำนข้อมูล
'string conStr = "server=ASUS-PCSqlExpress;initial catalog=DBBarBQ;integrated security=true";
Dim conStr As String = "server=ISIN;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่ำน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
Dim strSql As String = "delete from tb_Beverages where BeveragesID = '" + txtEditProductId.Text + "'"
Dim cmd As New SqlCommand(strSql, connectDB)
Dim dr As SqlDataReader = cmd.ExecuteReader()
25. 25
MessageBox.Show("ลบรำยกำรเรียบร้อยแล้ว")
'4. Disconnect
connectDB.Close()
btnDelete.Enabled = False
btnCancle.Enabled = True
btnDelete.Enabled = False
btnCancle.Enabled = True
dgvEditProduct.Refresh()
End If
End Sub
End Class
Public Class PricePeople
Private Sub btnEdit_Click(sender As Object, e As EventArgs)
txtAdult.Enabled = True
End Sub
Private Sub btnEdit2_Click(sender As Object, e As EventArgs)
txtChild.Enabled = True
End Sub
Private Sub loadDataToPricePeople()
'1.ติดต่อฐานข้อมูล
Dim conStr As String = "server=Localhost;initial catalog=DBBarBQ;integrated security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่าน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'2.คาสั่ง SQL (DateEdit,Child,Adult)
Dim strSql As String = "select top 1 Child, Adult , DateEdit from tb_PricePerson order by
DateEdit desc"
'คาสั่ง
'3.สั่งให้ SQl ทางาน
Dim cmd As New SqlCommand(strSql, connectDB)
'ทางาน
Dim dr As SqlDataReader = cmd.ExecuteReader()
'สั่งให้ทางาน + ดึงค่าที่ได้มา
'3.1 ทาอะไรก็แล้วแต่
If dr.Read() Then
txtAdult.Text = dr("Child").ToString()
txtChild.Text = dr("Adult").ToString()
26. 26
Dim dateDr As String = dr("DateEdit").ToString()
dateDr = dateDr.Substring(0, 9)
'lblDateNowPrice.Text = DateTime.Now.ToString("dd MMMM yyyy", New
System.Globalization.CultureInfo("th-TH"))
End If
'4.ปิด
connectDB.Close()
txtChild.Enabled = False
txtAdult.Enabled = False
dtpEdit.Enabled = False
End Sub
Private Sub PricePeople_Load(sender As Object, e As EventArgs) Handles MyBase.Load
loadDataToPricePeople()
txtAdult.Enabled = False
txtChild.Enabled = False
End Sub
Private Sub btnEditDateFinish_Click(sender As Object, e As EventArgs)
dtpEdit.Enabled = True
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles
ToolStripButton1.Click
Me.Hide()
Main.Show()
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles
ToolStripButton2.Click
Me.Hide()
AddOrder.Show()
End Sub
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles
ToolStripButton3.Click
Me.Hide()
ManagBv.Show()
End Sub
Private Sub ToolStripButton5_Click(sender As Object, e As EventArgs) Handles
ToolStripButton5.Click
Me.Hide()
ReportEarn.Show()
End Sub
Private Sub btnSavePricePeople_Click(sender As Object, e As EventArgs) Handles
btnSavePricePeople.Click
'MessageBox.Show(txtAdult.Text);
If Convert.ToInt16(txtAdult.Text) > 999 Then
MessageBox.Show("กรุณาระบุค่าบุฟเฟ่ต์ไม่เกิน 999 บาท")
txtAdult.Focus()
ElseIf Convert.ToInt16(txtChild.Text) > 999 Then
MessageBox.Show("กรุณาระบุค่าบุฟเฟ่ต์ไม่เกิน 999 บาท")
27. 27
txtChild.Focus()
Else
'1.ติดต่อฐานข้อมูล
'string conStr = "server=ASUS-PCSqlExpress;initial catalog=DBBarBQ;integrated
security=true";
Dim conStr As String = "server=Localhost;initial catalog=DBBarBQ;integrated
security=true"
Dim connectDB As New SqlConnection(conStr)
If connectDB.State = ConnectionState.Open Then
connectDB.Close()
End If
Try
'MessageBox.Show("โอเคผ่าน");
connectDB.Open()
Catch ex As Exception
MessageBox.Show("can't Database open." + ex.Message)
Return
End Try
'String dateS = dtpFinish.Value.Date.ToShortDateString();
Dim dateEdit As String = DateTime.Now.ToString("yyyy-MM-dd " + "hh:mm:ss.fff")
Dim YYYYF As String = (Convert.ToInt16(dtpEdit.Value.[Date].ToString("yyyy")) -
543).ToString("0000")
'String dateF = dtpEdit.Value.Date.ToString(YYYYF + "-MM-dd " + "hh:mm:ss.fff");
Dim yyyy As Integer = Convert.ToInt16(dtpEdit.Value.[Date].ToString("yyyy"))
Dim MM As Integer = Convert.ToInt16(dtpEdit.Value.[Date].ToString("MM"))
Dim dd As Integer = Convert.ToInt16(dtpEdit.Value.[Date].ToString("dd"))
'MessageBox.Show(a.ToString() + b.ToString());
'yyyyF<S
'MMF<S
'ddF<S
If yyyy < Convert.ToInt16(DateTime.Now.ToString("yyyy")) Then
MessageBox.Show("กรุณาตรวจสอบปี")
ElseIf yyyy = Convert.ToInt16(DateTime.Now.ToString("yyyy")) AndAlso MM <
Convert.ToInt16(DateTime.Now.ToString("MM")) Then
MessageBox.Show("กรุณาตรวจสอบเดือน")
ElseIf yyyy = Convert.ToInt16(DateTime.Now.ToString("yyyy")) AndAlso MM =
Convert.ToInt16(DateTime.Now.ToString("MM")) AndAlso dd <
Convert.ToInt16(DateTime.Now.ToString("dd")) Then
MessageBox.Show("กรุณาตรวจสอบวัน")
Else
'2. Sql statement //ลงตาราง tb_PricePerson (DateStart,Child,Adult,Datefinish)
Dim strSql As [String] = (Convert.ToString("Insert into tb_PricePerson
(DateEdit,Adult,Child)values(" + " '") & dateEdit) + "'" + ",'" + txtChild.Text + "'" + ",'" +
txtAdult.Text + "'" + ")"
'3. สั่ง Sql statement ทางาน
Dim cmd As New SqlCommand(strSql, connectDB)
cmd.ExecuteNonQuery()
'3.1
MessageBox.Show("บันทึกหน้าจอเรียบร้อยแล้ว")
End If
'4.close DB
connectDB.Close()
loadDataToPricePeople()
End If
28. 28
End Sub
'MsgBox(txtAdult.Text & " " & txtChild.Text & " " & dtpFinish.Text)
'If True Then
' '1.ติดต่อฐานข้อมูล
' 'string conStr = "server=ISIN;initial catalog=DBBarBQ;integrated security=true";
' Dim conStr As String = "server=Localhost;initial catalog=DBBarBQ;integrated
security=true"
' Dim connectDB As New SqlConnection(conStr)
' If connectDB.State = ConnectionState.Open Then
' connectDB.Close()
' End If
' Try
' 'MessageBox.Show("โอเคผ่าน");
' connectDB.Open()
' Catch ex As Exception
' MessageBox.Show("can't Database open." + ex.Message)
' Return
' End Try
' 'string dateS = dtpFinish.Value.Date.ToShortDateString();
' Dim dateS As String = DateTime.Now.ToString("yyyy-MM-dd " + "hh:mm:ss.fff")
' Dim YYYYF As String = (Convert.ToInt16(dtpFinish.Value.[Date].ToString("yyyy")) -
543).ToString("0000")
' Dim dateF As String = dtpFinish.Value.[Date].ToString((YYYYF & Convert.ToString("-MM-dd
")) + "hh:mm:ss.fff")
' Dim yyyy As Integer = Convert.ToInt16(dtpFinish.Value.[Date].ToString("yyyy"))
' Dim MM As Integer = Convert.ToInt16(dtpFinish.Value.[Date].ToString("MM"))
' Dim dd As Integer = Convert.ToInt16(dtpFinish.Value.[Date].ToString("dd"))
' 'MessageBox.Show(a.ToString() + b.ToString());
' 'yyyyF<S
' 'MMF<S
' 'ddF<S
' If yyyy < Convert.ToInt16(DateTime.Now.ToString("yyyy")) Then
' MessageBox.Show("กรุณาตรวจสอบปี")
' ElseIf yyyy = Convert.ToInt16(DateTime.Now.ToString("yyyy")) AndAlso MM <
Convert.ToInt16(DateTime.Now.ToString("MM")) Then
' MessageBox.Show("กรุณาตรวจสอบเดือน")
' ElseIf yyyy = Convert.ToInt16(DateTime.Now.ToString("yyyy")) AndAlso MM =
Convert.ToInt16(DateTime.Now.ToString("MM")) AndAlso dd <
Convert.ToInt16(DateTime.Now.ToString("dd")) Then
' MessageBox.Show("กรุณาตรวจสอบวัน")
' Else
' '2. Sql statement //ลงตาราง tb_PricePerson (DateStart,Child,Adult,Datefinish)
' '+ ",'" + txtAdult.Text + "'"
' '+ ", 2558-09-04 00:00:00 "
' Dim strSql As [String] = (Convert.ToString((Convert.ToString("Insert into
tb_PricePerson (DateStart,Adult,Child,Datefinish)values(" + " '") & dateS) + "'" + ",'" +
txtAdult.Text + "'" + ",'" + txtChild.Text + "'" + ",'") & dateF) + "'" + ")"
' '3. สั่ง Sql statement ทางาน
' Dim cmd As New SqlCommand(strSql, connectDB)
' cmd.ExecuteNonQuery()
' '3.1
29. 29
' MessageBox.Show("บันทึกหน้าจอเรียบร้อยแล้ว")
' End If
' '4.close DB
' connectDB.Close()
' loadDataToPricePeople()
'End If
Private Sub btnEditAdult_Click(sender As Object, e As EventArgs)
txtAdult.Enabled = True
txtAdult.Focus()
End Sub
Private Sub btnEditChild_Click(sender As Object, e As EventArgs)
txtChild.Enabled = True
txtChild.Focus()
End Sub
Private Sub Label6_Click(sender As Object, e As EventArgs) Handles Label6.Click
End Sub
Private Sub btnEditDateFinish_Click_1(sender As Object, e As EventArgs) Handles
btnEditDateFinish.Click
txtAdult.Enabled = True
txtAdult.Focus()
txtChild.Enabled = True
dtpEdit.Enabled = True
End Sub
Private Sub txtAdult_KeyDown(sender As Object, e As KeyEventArgs) Handles txtAdult.KeyDown
If e.KeyCode = Keys.Enter Then
txtChild.Focus()
End If
End Sub
Private Sub txtChild_KeyDown(sender As Object, e As KeyEventArgs) Handles txtChild.KeyDown
If e.KeyCode = Keys.Enter Then
dtpEdit.Focus()
End If
End Sub
End Class
30. 30
โค๊ด combobox ดึงข้อมูลออกมำ จำก Db
Dim strConnString As String
strConnString = "Server=localhost;User Id=root; Password=root; Database=mydatabase; Pooling=false"
objConn = New MySqlConnection(strConnString)
objConn.Open()
Dim sqlGeo As String = "SELECT geo_name FROM geography"
Dim daGeo As New MySqlDataAdapter(sqlGeo, con)
Dim dtGeo As New DataTable
daGeo.Fill(dtGeo)
With cmbGeo
.DataSource = dtGeo
.DisplayMember = dtGeo.Columns.Item("geo_name").ColumnName
End With
ต้องกำร ให้ลบแถวที่เรำเลือกไว้ ลบ โดย ใช้ปุ่ม del ปกติ ให้มีข้อควำมเตือนและสำมำรถลบได้ปกตำมที่ defalut
niras srihemthong:
Private Sub DataGridView1_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles DataGridView1.KeyDown
Dim CurRow As Integer
CurRow = Me.DataGridView1.CurrentRow.Index
If e.KeyCode = Keys.Delete Then
If Me.DataGridView1.Rows.Count <> 1 Then
Dim Result As MsgBoxResult
Result = MessageBox.Show("ต้องกำรลบข้อมูลแถวนี้หรือไม่", "ยืนยัน", MessageBoxButtons.YesNo, _
MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
31. 31
If Result = MsgBoxResult.Yes Then
Me.DataGridView1.Rows.RemoveAt(CurRow)
End If
End If
End If
End Sub
ผมว่ำผูกข้อมูลโดยกำรเขียนโค้ดจะดีกว่ำในกรณีต้องกำร refresh ข้อมูลใหม่บ่อยหรือมีกำรใช้งำนร่วมกันหลำย ๆ ฟอร์ม ถ้ำจะอธิบำยก็คงต้องเริ่มตั้งแต่กำร เขียนโค้ดในกำรผูก
ข้อมูลตั้งแต่เริ่มแรกเลยไม่ยำกครับลองแกะดูครับ ผมก็อำศัยวิธีเดียวกับคุณนั้นแหละ เพรำะว่ำหนังสือไทยไม่มีเลย ก็ต้องไปหำอ่ำนตำมเว็บเมืองนอก
ผมจะเขียนแบบนี้ครับ
Imports System.Data.OleDb 'เรียกใช้เฟรมเวิร์ก
Public Class form1
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Windows.Forms.Application.StartupPath & "databaseMyDataBase.mdb;Jet OLEDB:Database Password=1234;"
'กำหนด พำร์ทของฐำนข้อมูลครับ ในที่นี้เป็นฐำนข้อมูล Access ชื่อว่ำ MyDataBase.mdb password 1234 ถ้ำมีกำรตั้ง password ใน access คำสั่ง StartupPath เป็น
คำสั่งระบุว่ำ ฐำนข้อมูลนี้อยู่ภำยในโฟลเดอร์เดียวกันกับโปรแกรม และอยู่ภำยใน ซับโฟล์เดอร์ ที่ชื่อว่ำ database
Dim Conn As New OleDbConnection(strConn) ' เรียกใช้คำสั่ง ติดต่อฐำนข้อมูล
Dim ds As New DataSet 'กำหนดตัวแปรเป็นแบบดำต้ำเซ็ท ตัวแปรนี้แหละครับจะเป็นตัว refresh ข้อมูล
Private Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim StrSql As String
StrSql = "SELECT * FROM MyTable " 'คำสั่ง SQL
Dim da As OleDbDataAdapter 'ตัวแปรนี้ก็คือ DataAdapter ที่คุณใช้ใน Tool ครับ
da = New OleDbDataAdapter(StrSql, Conn) 'เก็บข้อมูลจำกกำรเรียกใช้คำสั่ง SQL เข้ำมำใน DataAdapter
da.Fill(ds, "MyData") 'นำเข้ำมูล จำก DataAdapter มำเก็บไว้ ในดำต้ำเซ็ทที่ชื่อ ds ครับ ds เป็นดำต้ำเซ็ทที่ใช้ในกำรพักข้อมูลก่อนส่งเข้ำไปแสดงที่ดำต้ำกริด
Mydata เป็นชื่อที่ตั้งเพื่อสื่อควำมหมำยแทนข้อมูลในดำต้ำเซ็ทครับ
Me.DataGridView1.DataSource = ds.Tables("MyData") 'นำข้อมูลที่ได้มำแสดงที่ดำต้ำกริดครับ
End Sub
32. 32
End Class
ต่อไปก็จะเป็นกำร รีเฟรชข้อมูลครับ
ใช้คำสั่งนี้
If ds.Tables.Contains("MyData") Then 'ก็จะตรวจสอบ ข้อมูลค้ำงอยู่ใน ดำต้ำเซ็ทไหม ถ้ำมีค้ำงอยู่ใน รีมูฟ ออกก่อน
ds.Tables.Remove("MyData")
End If
ก็เป็นกำรตัดกำรผูกข้อมูลกับฐำนข้อมูล ถ้ำจะมีกำรดึงข้อมูลขึ้นมำอีกก็ทำตำมโค้ดข้ำงบนเหมือนเดิม คุณต้องทำควำมเข้ำใจกับ ตัวแปร ds หรือ ดำต้ำเซ็ทก่อนนะครับ ดำต้ำเซ็ท
เป็นตำรำงข้อมูลในรูปแบบ temporary ดูง่ำย ๆ เหมือนไฟล์เอ็กเซลที่เก็บไว้ในหน่วยควำมจำ ดำต้ำเซ็ทสำมำรถมีได้หลำยตำรำงเหมือนกับเอ็กเซลก็สำมำรถมีได้หลำย sheet คุณ
สำมำรถ fill เข้ำดำต้ำเซ็ทได้หลำยตำรำงก็ได้ เช่น da.Fill(ds, "MyData") หรือ da.Fill(ds, "MyData1 ") , da.Fill(ds, "MyDataN") จำก da หรือ DataAdapter ตัว
เดียวกันได้
Public Class frmMain
'By http://www.thaicreate.com (mr.win)'
Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
Me.Hide()
Dim f As New frmHome
f.Show()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
If MessageBox.Show("Are you sure to exit?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
Application.Exit()
End If
End Sub
End Class
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Data.SqlTypes
33. 33
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Public Class frmHome
'By http://www.thaicreate.com (mr.win)'
Private Sub frmHome_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
BindDataGrid()
End Sub
Private Sub BindDataGrid()
Dim myConnection As SqlCeConnection
Dim dt As New DataTable
Dim Adapter As SqlCeDataAdapter
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) + "Database1.sdf;"))
myConnection = New SqlCeConnection("Data Source=C:WindowsFormsApplicationWindowsFormsApplicationDatabase1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "SELECT [id], [name], [email] FROM [mytable]"
myCommand.CommandType = CommandType.Text
Adapter = New SqlCeDataAdapter(myCommand)
Adapter.Fill(dt)
myConnection.Close()
Me.dgName.DataSource = dt
Me.dgName.Columns.Clear()
34. 34
Dim column As DataGridViewTextBoxColumn
column = New DataGridViewTextBoxColumn()
column.DataPropertyName = "id"
column.HeaderText = "ID"
column.Width = 50
Me.dgName.Columns.Add(column)
column = New DataGridViewTextBoxColumn()
column.DataPropertyName = "name"
column.HeaderText = "Name"
column.Width = 100
Me.dgName.Columns.Add(column)
column = New DataGridViewTextBoxColumn()
column.DataPropertyName = "email"
column.HeaderText = "Email"
column.Width = 150
Me.dgName.Columns.Add(column)
dt = Nothing
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Me.Hide()
Dim f As New frmAdd
f.Show()
End Sub
35. 35
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
Me.Hide()
Dim f As New frmEdit()
f._strID = Me.dgName(0, Me.dgName.CurrentCell.RowIndex).Value.ToString()
f.Show()
End Sub
Private Sub btnDel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDel.Click
If MessageBox.Show("Are you sure to delete?", "Confirm.", MessageBoxButtons.YesNo, MessageBoxIcon.Question,
MessageBoxDefaultButton.Button1) = DialogResult.Yes Then
Dim strID As String = Me.dgName(0, Me.dgName.CurrentCell.RowIndex).Value.ToString()
Dim myConnection As SqlCeConnection
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) + "Database1.sdf;"))
myConnection = New SqlCeConnection("Data Source=C:WindowsFormsApplicationWindowsFormsApplicationDatabase1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "DELETE FROM [mytable] WHERE id = '" & strID & "'"
myCommand.CommandType = CommandType.Text
myCommand.ExecuteNonQuery()
myConnection.Close()
MessageBox.Show("Delete Successfully")
BindDataGrid()
End If
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Hide()
Dim f As New frmMain
36. 36
f.Show()
End Sub
End Class
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Data.SqlTypes
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Public Class frmAdd
'By http://www.thaicreate.com (mr.win)'
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If Me.txtName.Text = "" Then
MessageBox.Show("Please input (Name)")
Me.txtName.Focus()
Exit Sub
End If
If Me.txtEmail.Text = "" Then
MessageBox.Show("Please input (Email)")
Me.txtEmail.Focus()
Exit Sub
End If
Dim myConnection As SqlCeConnection
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) + "Database1.sdf;"))
37. 37
myConnection = New SqlCeConnection("Data Source=C:WindowsFormsApplicationWindowsFormsApplicationDatabase1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "INSERT INTO [mytable] ([name], [email]) VALUES " & _
" ('" & Me.txtName.Text & "','" & Me.txtEmail.Text & "' ) "
myCommand.CommandType = CommandType.Text
myCommand.ExecuteNonQuery()
myConnection.Close()
MessageBox.Show("Save Successfully.")
Me.Hide()
Dim f As New frmHome
f.Show()
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Hide()
Dim f As New frmHome
f.Show()
End Sub
End Class
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Data.SqlTypes
Imports System.Drawing
Imports System.ComponentModel
Imports System.Windows.Forms
Public Class frmEdit
38. 38
'By http://www.thaicreate.com (mr.win)'
Dim strID As String = ""
Public Property _strID() As String
Get
Return strID
End Get
Set(ByVal value As String)
strID = value
End Set
End Property
Private Sub frmEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myConnection As SqlCeConnection
Dim dt As New DataTable
Dim Adapter As SqlCeDataAdapter
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) + "Database1.sdf;"))
myConnection = New SqlCeConnection("Data Source=C:WindowsFormsApplicationWindowsFormsApplicationDatabase1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "SELECT [id], [name], [email] FROM [mytable] WHERE id = '" & strID & "' "
myCommand.CommandType = CommandType.Text
Adapter = New SqlCeDataAdapter(myCommand)
Adapter.Fill(dt)
myConnection.Close()
If dt.Rows.Count > 0 Then
Me.txtName.Text = dt.Rows(0)("name")
39. 39
Me.txtEmail.Text = dt.Rows(0)("email")
End If
dt = Nothing
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
If Me.txtName.Text = "" Then
MessageBox.Show("Please input (Name)")
Me.txtName.Focus()
Exit Sub
End If
If Me.txtEmail.Text = "" Then
MessageBox.Show("Please input (Email)")
Me.txtEmail.Focus()
Exit Sub
End If
Dim myConnection As SqlCeConnection
'myConnection = New SqlCeConnection("Data Source =" + (System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase ) + "Database1.sdf;"))
myConnection = New SqlCeConnection("Data Source=C:WindowsFormsApplicationWindowsFormsApplicationDatabase1.sdf;")
myConnection.Open()
Dim myCommand As SqlCeCommand = myConnection.CreateCommand()
myCommand.CommandText = "UPDATE [mytable] SET " & _
" [name] = '" & Me.txtName.Text & "', [email] = '" & Me.txtEmail.Text & "' " & _
" WHERE id = '" & strID & "' "
myCommand.CommandType = CommandType.Text
myCommand.ExecuteNonQuery()