15,911,524 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 8576839 (Top 1 by date)
Member 8576839
4-Feb-12 5:57am
View
Private Sub btnsav_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsav.Click
If txtcode.Text = "" Then
MessageBox.Show("Enter the Material Code", "Code", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtcode.Focus()
Exit Sub
End If
If txtname.Text = "" Then
MessageBox.Show("Enter the Material Name", "Name", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtname.Focus()
Exit Sub
End If
If txtunit.Text = "" Then
MessageBox.Show("Enter the Unit", "Unit", MessageBoxButtons.OK, MessageBoxIcon.Information)
txtunit.Focus()
Exit Sub
End If
Try
If Mode = "New" Then
If MessageBox.Show("Are you sure to store the values.!!!", "New Material", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.No Then Exit Sub
flag = cn.executeQuery(" insert into tbl_Mat_Master values ('" & txtcode.Text & "','" & txtname.Text & "','" & txtunit.Text & "') ")
If flag = True Then
MessageBox.Show("Record Inserted Successfully", "Raw Material", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
MessageBox.Show("Unable to Save Record", "Raw Material", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
ElseIf Mode = "Edit" Then
If MessageBox.Show("Are You want to Edit the record", "Edit", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.No Then Exit Sub
flag = cn.executeQuery(" UPDATE tbl_mat_master SET Mat_Name= '" & txtname.Text & "', Unit = '" & txtunit.Text & "' WHERE Mat_Code= '" & txtcode.Text & "' ")
If flag = True Then
MessageBox.Show("Record Updated Successfully", "Raw Material", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End If
Catch ex As Exception
cn.DisplayErrorDialog(ex)
cn.WriteToErrorLog(ex.Message, ex.StackTrace, "Error")
End Try
End Sub
it is my save button coding i use MSSql 2008 and Microsoft visual studio 2010