Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
Dim objcommand As New SqlCommand
objcommand.Connection = objconnection
'objconnection.Open()
objcommand.CommandText = "Insert into dept_mas (dept_code,dept_name) values (@dept_code,@dept_name)"
objcommand.Parameters.AddWithValue("@dept_code", cbodept.Text)
'go_button.Enabled = True
'objcommand.Parameters.AddWithValue("@dept_name", txtdeptname.Text)
objcommand.Parameters.AddWithValue("@dept_name", Combdeptname.Text)
'If txtdeptname.Text = "" Then
If Combdeptname.Text = "" Then
btnnew.Enabled = False
Combdeptname.Enabled = True
Combdeptname.Focus()
MessageBox.Show("You must enter the departement name.", " Departement Name Entry Error", _
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
Try
Dim ans As MsgBoxResult
ans = MsgBox("record Saved ", +MsgBoxStyle.Question, "Save confirmation")
Button1.Focus()
Combdeptname.Enabled = False
objconnection.Open()
objcommand.ExecuteNonQuery()
enable_disabledeptmas(False)
StatusStrip1.Items(0).Text = " Department Name Record Saved"
btnnew.Enabled = True
btnsave.Enabled = True
Catch SqlExceptionErr As SqlException
MessageBox.Show(SqlExceptionErr.Message)
End Try
objconnection.Close()
End If
If Combdeptname.Text = "" Then
ErrorProvider1.SetError(Combdeptname, "Cannot leave textbox blank")
Else
ErrorProvider1.SetError(Combdeptname, "")
End If
'btnsave.Enabled = False
Combdeptname.Enabled = True
txtedit.Enabled = True
btnupdate.Enabled = False
End Sub
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder

New Topic/Question
Reply




MultiQuote



|