Страница: 1 | 2 | 3 | 4 |
|
Вопрос: ListView, Highlight строку
|
Добавлено: 01.09.10 22:40
|
|
Номер ответа: 17 Автор ответа:
Вопросов: 1 Ответов: 26
|
Профиль | | #17
|
Добавлено: 03.09.10 15:18
|
Imports System.Data
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.IO
Module modDogLicense
Public connString As String = "ata Source=SqlSrvSqlSrv; Initial Catalog=DogLicense; Integrated Security=SSPI;"
 im QueryDCL As String
Public connDCL As New SqlConnection(connString)
Public connOwner As New SqlConnection(connString)
Public connAdapter As New SqlDataAdapter(QueryDCL, connDCL)
Public dsDCL As New DataSet
Public drRow As DataRow
Public drRowDogs As DataRow
Public drRowVac As DataRow
Public indRowNumber As Integer
Public SqlCommand As New SqlCommand
Public AddMode As Boolean
Public ClientID As String = ""
Public ClientTable As String
Public DataBase As String
Public DogID As String
Public DogsTable As String
Public EditMode As Boolean
Public Order As String
Public OwnerInd As Int16
Public OwnersTable As String
Public SqlStatement As String
Public VaccinationTable As String
Public VacID As Integer
Sub Main()
 ataBase = "Live"
OwnersTable = "CLDogOwners"
 ogsTable = "CLDogs"
VaccinationTable = "CLVaccination"
SqlCommand.Connection = connDCL
connDCL.Open()
End Sub
Public Class frmDCLMain
Private Sub DogLicensesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DogLicensesToolStripMenuItem.Click
frmDogsAndCats.ShowDialog()
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub frmDCLMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Main()
End Sub
Public Class frmDogsAndCats
 im litem As ListViewItem
 im expired As String = "0"
 im SelDog As Int16
 im SqlStatementSecur As String
 im VacInd As Integer
Private Sub frmDogsAndCats_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ClientID = "030018"
Enable_Owner(False)
 isplayOwner()
End Sub
Sub DisplayOwner()
SqlStatement = "Select * from " & OwnersTable & " Where clientid = '" & ClientID & "'"
connAdapter.SelectCommand.CommandText = SqlStatement
If Not dsDCL.Tables("SelectedOwner" Is Nothing Then
dsDCL.Tables("SelectedOwner".Clear()
End If
connAdapter.SelectCommand.CommandType = CommandType.Text
connAdapter.Fill(dsDCL, "SelectedOwner"
drRow = dsDCL.Tables("SelectedOwner".Rows(0)
txtClientID_pgeOwners.Text = ClientID
txtOwner_pgeOwners.Text = Trim(drRow.Item("Customer" & " "
Customer = txtOwner_pgeOwners.Text
txtAddr_pgeOwners.Text = Trim(drRow.Item("Address1" & " "
txtAddr2_pgeOwners.Text = Trim(drRow.Item("Address2" & " "
txtCity.Text = Trim(drRow.Item("city" & " "
txtZIP.Text = Trim(drRow.Item("zip" & " "
cmbState.Text = Trim(drRow.Item("state" & " "
txtPhone1.Text = Trim(drRow.Item("phone1" & " "
txtPhone2.Text = Trim(drRow.Item("phone2" & " "
If Not Trim(drRow.Item("paiddtd".ToString & " " = "" Then
If Not CDate(Trim(drRow.Item("paiddtd".ToString & " ") = #1/1/1990# Then
txtPaidDate.Text = drRow.Item("paiddtd"
Else
txtPaidDate.Text = ""
End If
txtPaidDate.Text = ""
End If
rtbComments.Text = Trim(drRow.Item("comments" & " "
CityStateZIP = Trim(txtCity.Text) & ", " & cmbState.Text & " " & txtZIP.Text
cmdPrior.Enabled = True
cmdFirst.Enabled = True
cmdNext.Enabled = True
cmdLast.Enabled = True
BeginOfFile = False
EndOfFile = False
If OwnerInd = dsDCL.Tables("ogOwners".Rows.Count - 1 Then
cmdNext.Enabled = False
cmdLast.Enabled = False
EndOfFile = True
End If
If OwnerInd = 0 Then
cmdPrior.Enabled = False
cmdFirst.Enabled = False
BeginOfFile = True
End If
If Order = "Name" Then
cmdOrder.Text = "SWITCH TO ORDER BY CLIENT ID"
Else
cmdOrder.Text = "SWITCH TO ORDER BY CLIENT NAME"
End If
pgfDogsInfo.SelectedIndex = 0
pgeOwners.Select()
End Sub
Sub DisplayDogs()
SqlStatement = "Select * from " & DogsTable & " Where clientid = '" & ClientID & "'"
SqlStatement &= " Order By Dog_ID"
connAdapter.SelectCommand.CommandText = SqlStatement
If Not dsDCL.Tables("SelectedDogs" Is Nothing Then
dsDCL.Tables("SelectedDogs".Clear()
End If
connAdapter.SelectCommand.CommandType = CommandType.Text
connAdapter.Fill(dsDCL, "SelectedDogs"
lsvDogs.Items.Clear()
If dsDCL.Tables("SelectedDogs".Rows.Count = 0 Then
litem = lsvDogs.Items.Add(" "
litem.SubItems.Add("No Dogs On File For This Owner"
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
SelDog = 0
Else
 im rowcount As Int16 = dsDCL.Tables("SelectedDogs".Rows.Count
 im rowi As Int16 = 0
For Each drRowDogs In dsDCL.Tables("SelectedDogs".Rows
litem = lsvDogs.Items.Add(drRowDogs.Item("og_ID")
litem.SubItems.Add(drRowDogs.Item("FullName")
litem.SubItems.Add(drRowDogs.Item("Breed")
litem.SubItems.Add(drRowDogs.Item("Gender")
litem.SubItems.Add(drRowDogs.Item("og_Color")
litem.SubItems.Add(drRowDogs.Item("Birthday".ToString)
litem.SubItems.Add(drRowDogs.Item("Species")
litem.SubItems.Add(drRowDogs.Item("Weight")
litem.SubItems.Add(drRowDogs.Item("eprived")
litem.SubItems.Add(drRowDogs.Item("Reason")
Next
If AddMode = True Then
SelDog = rowcount - 1
ElseIf EditMode = False Then
SelDog = 0
End If
End If
txtClientID_pgeDogs.Text = txtClientID_pgeOwners.Text
txtOwner_pgeDogs.Text = txtOwner_pgeOwners.Text
txtAddr_pgeDogs.Text = txtAddr_pgeOwners.Text
txtAddr2_pgeDogs.Text = txtAddr2_pgeOwners.Text
lsvDogs.Items(SelDog).ListView.Select()
lsvDogs.Items(SelDog).Selected = True
End Sub
Sub DisplayVaccination(ByVal VacID_Ind As Integer)
SqlStatement = "Select * from " & VaccinationTable & " Where clientid = '" & ClientID
SqlStatement &= "' AND dog_id = '" & DogID & "' Order By ClientID, Dog_ID, vacdate, expdate, vacid"
connAdapter.SelectCommand.CommandText = SqlStatement
If Not dsDCL.Tables("VaccinationTable" Is Nothing Then
dsDCL.Tables("VaccinationTable".Clear()
End If
connAdapter.SelectCommand.CommandType = CommandType.Text
connAdapter.Fill(dsDCL, "VaccinationTable"
lsvTags.Items.Clear()
VacInd = 0
If dsDCL.Tables("VaccinationTable".Rows.Count = 0 Then
litem = lsvTags.Items.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add("No Vaccinations On File For This Dog/Cat"
litem.SubItems.Add(0)
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(" "
litem.SubItems.Add(0)
Else
 im test_str As Date
 im test_decimal As Decimal = 0.0
 im rowcount As Int16 = dsDCL.Tables("VaccinationTable".Rows.Count
 im rowi As Int16 = 0
 im i As Int16 = 0
For Each drRow In dsDCL.Tables("VaccinationTable".Rows
litem = lsvTags.Items.Add(drRow.Item("TagNumber")
test_str = drRow.Item("VacDate"
litem.SubItems.Add(test_str.ToShortDateString)
test_str = drRow.Item("ExpDate"
litem.SubItems.Add(test_str.ToShortDateString)
litem.SubItems.Add(drRow.Item("ChargeType")
litem.SubItems.Add(drRow.Item("Amount".ToString)
litem.SubItems.Add(drRow.Item("ClinicName")
litem.SubItems.Add(Trim(drRow.Item("License" & " ")
litem.SubItems.Add(drRow.Item("For_Year")
If Trim(drRow.Item("ueDate".ToString & " " = "" Then
litem.SubItems.Add(" "
Else
test_str = drRow.Item("ueDate"
litem.SubItems.Add(test_str.ToShortDateString)
End If
litem.SubItems.Add(drRow.Item("LetterSent")
litem.SubItems.Add(Trim(drRow.Item("walkin" & " ")
test_str = drRow.Item("PayDate"
litem.SubItems.Add(test_str.ToShortDateString)
litem.SubItems.Add(Trim(drRow.Item("Purchased" & " ")
litem.SubItems.Add(Trim(drRow.Item("Cashier" & " ")
For rowi = 0 To PaymentArray.Length - 1
If Trim(drRow.Item("PayType" & " " = PaymentArray(rowi).PmntCode Then
Exit For
End If
Next
If rowi = PaymentArray.Length Or PaymentArray(rowi).PmntCode = "" Then
litem.SubItems.Add(" "
Else
litem.SubItems.Add(Trim(PaymentArray(rowi).PmntName))
End If
litem.SubItems.Add(Trim(drRow.Item("Check_no" & " ")
litem.SubItems.Add(Trim(drRow.Item("Expired" & " ")
litem.SubItems.Add(drRow.Item("VacID".ToString)
If VacID_Ind > 0 And VacID_Ind = drRow.Item("VacID" Then
VacInd = i
End If
i += 1
Next
If AddMode = True Then
VacInd = rowcount - 1
End If
End If
txtClientID_pgeVaccination.Text = txtClientID_pgeOwners.Text
txtOwner_pgeVaccination.Text = txtOwner_pgeOwners.Text
txtAddr_pgeVaccination.Text = txtAddr_pgeOwners.Text
txtAddr2_pgeVaccination.Text = txtAddr2_pgeOwners.Text
txtDogID_pgeVaccination.Text = txtDogID_pgeDogs.Text
txtDogName_pgeVaccination.Text = txtDogName_pgeDogs.Text
txtBreed_pgeVaccination.Text = txtBreed_pgeDogs.Text
lsvTags.Items(VacInd).ListView.Select()
lsvTags.Items(VacInd).Selected = True
End Sub
Private Sub pgfDogsInfo_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles pgfDogsInfo.Selected
Select Case e.TabPageIndex
Case Is = 1
If AddMode = True Or EditMode = True Then
Enable_Dogs(True)
Else
Enable_Dogs(False)
End If
 isplayDogs()
Case Is = 2
If AddMode = True Or EditMode = True Then
Enable_Vaccination(True)
Else
Enable_Vaccination(False)
End If
 isplayVaccination(0)
End Select
End Sub
Private Sub lsvDogs_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles lsvDogs.ItemSelectionChanged
 im birthday_str As String
 im birthday As String
 im birthday_date As Date
If e.IsSelected = True Then
SelDog = e.ItemIndex
If dsDCL.Tables("SelectedDogs".Rows.Count = 0 Then
 ogID = ""
txtDogID_pgeDogs.Text = ""
txtDogName_pgeDogs.Text = ""
txtBreed_pgeDogs.Text = ""
txtSex.Text = ""
txtColor.Text = ""
cmbSpecies.SelectedIndex = -1
txtWeight.Text = ""
mtbBirthday.Text = ""
txtReason.Text = ""
chkRemoved.Checked = False
Else
 ogID = lsvDogs.Items(e.ItemIndex).Text
txtDogID_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).Text
txtDogName_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).SubItems(1).Text
txtBreed_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).SubItems(2).Text
txtSex.Text = lsvDogs.Items(e.ItemIndex).SubItems(3).Text
txtColor.Text = lsvDogs.Items(e.ItemIndex).SubItems(4).Text
cmbSpecies.Text = lsvDogs.Items(e.ItemIndex).SubItems(6).Text
txtWeight.Text = lsvDogs.Items(e.ItemIndex).SubItems(7).Text
birthday = lsvDogs.Items(e.ItemIndex).SubItems(5).Text
If Not Trim(birthday) = "" Then
birthday_date = CDate(birthday)
If Not birthday_date = #1/1/1900# Then
birthday = birthday_date.ToShortDateString
birthday_str = Mid(birthday, 1, Len(birthday) - 5)
Select Case Len(birthday_str)
Case 3
birthday_str = "0" & Mid(birthday_str, 1, 1) & "0" & Mid(birthday_str, 3, 1)
Case 4
If Mid(birthday_str, 2, 1) = "/" Then
birthday_str = "0" & Mid(birthday_str, 1, 1) & Mid(birthday_str, 3, 2)
Else
birthday_str = Mid(birthday_str, 1, 2) & "0" & Mid(birthday_str, 4, 1)
End If
Case 5
birthday_str = Mid(birthday_str, 1, 2) & Mid(birthday_str, 4, 2)
End Select
birthday = birthday_str & Mid(birthday, Len(birthday) - 3, 4)
mtbBirthday.Text = birthday
Else
mtbBirthday.Text = ""
End If
End If
txtReason.Text = lsvDogs.Items(e.ItemIndex).SubItems(9).Text
chkRemoved.Checked = IIf(lsvDogs.Items(e.ItemIndex).SubItems(8).Text = "Y", True, False)
End If
End If
End Sub
Private Sub lsvTags_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles lsvTags.ItemSelectionChanged
 im i As Int16
 im DateToStr As String
 im DateToStr1 As String
If e.IsSelected = True Then
VacInd = e.ItemIndex
If dsDCL.Tables("VaccinationTable".Rows.Count = 0 Then
txtTagNumber.Text = ""
cmbClinics.SelectedIndex = -1
mtbVacDate.Text = ""
mtbExpDate.Text = ""
mtbDueDate.Text = ""
mtbPayDate.Text = ""
cmbChargeType.SelectedIndex = -1
txtChargeAmount.Text = ""
chkLetterSent.Checked = False
chkWalkIn.Checked = False
txtYear.Text = ""
txtLicense.Text = ""
cmbPurchased.SelectedIndex = -1
txtCashier.Text = ""
cmbPmntType.SelectedIndex = -1
txtCheckNo.Text = ""
expired = "0"
VacID = 0
Else
txtTagNumber.Text = lsvTags.Items(e.ItemIndex).Text
If Trim(lsvTags.Items(e.ItemIndex).SubItems(5).Text) = "" Then
cmbClinics.SelectedIndex = -1
Else
cmbClinics.Text = lsvTags.Items(e.ItemIndex).SubItems(5).Text
End If
VacDate = CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text.ToString)
If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text) = #1/1/1900# Then
 ateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text).ToShortDateString
 ateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
Select Case Len(DateToStr1)
Case 3
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
Case 4
If Mid(DateToStr1, 2, 1) = "/" Then
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
Else
 ateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
End If
Case 5
 ateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
End Select
 ateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
mtbVacDate.Text = DateToStr
Else
mtbVacDate.Text = ""
End If
ExpDate = CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text.ToString)
If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text) = #1/1/1900# Then
 ateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text).ToShortDateString
 ateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
Select Case Len(DateToStr1)
Case 3
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
Case 4
If Mid(DateToStr1, 2, 1) = "/" Then
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
Else
 ateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
End If
Case 5
 ateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
End Select
 ateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
mtbExpDate.Text = DateToStr
Else
mtbExpDate.Text = ""
End If
If Not Trim(lsvTags.Items(e.ItemIndex).SubItems(8).Text) = "" Then
If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(8).Text) = #1/1/1900# Then
 ateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(8).Text).ToShortDateString
 ateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
Select Case Len(DateToStr1)
Case 3
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
Case 4
If Mid(DateToStr1, 2, 1) = "/" Then
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
Else
 ateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
End If
Case 5
 ateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
End Select
 ateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
mtbDueDate.Text = DateToStr
Else
mtbDueDate.Text = ""
End If
Else
mtbDueDate.Text = ""
End If
If Not Trim(lsvTags.Items(e.ItemIndex).SubItems(11).Text) = "" Then
If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(11).Text) = #1/1/1900# Then
 ateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(11).Text).ToShortDateString
 ateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
Select Case Len(DateToStr1)
Case 3
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
Case 4
If Mid(DateToStr1, 2, 1) = "/" Then
 ateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
Else
 ateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
End If
Case 5
 ateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
End Select
 ateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
mtbPayDate.Text = DateToStr
Else
mtbPayDate.Text = ""
End If
Else
mtbPayDate.Text = ""
End If
If Trim(lsvTags.Items(e.ItemIndex).SubItems(3).Text) = "" Then
cmbChargeType.SelectedIndex = -1
Else
cmbChargeType.Text = lsvTags.Items(e.ItemIndex).SubItems(3).Text
End If
txtChargeAmount.Text = lsvTags.Items(e.ItemIndex).SubItems(4).Text
chkLetterSent.Checked = IIf(lsvTags.Items(e.ItemIndex).SubItems(9).Text = "Y", True, False)
chkWalkIn.Checked = IIf(lsvTags.Items(e.ItemIndex).SubItems(10).Text = "Y", True, False)
txtYear.Text = lsvTags.Items(e.ItemIndex).SubItems(7).Text
txtLicense.Text = lsvTags.Items(e.ItemIndex).SubItems(6).Text
If Trim(lsvTags.Items(e.ItemIndex).SubItems(12).Text) = "" Then
cmbPurchased.SelectedIndex = -1
Else
cmbPurchased.Text = lsvTags.Items(e.ItemIndex).SubItems(12).Text
End If
txtCashier.Text = lsvTags.Items(e.ItemIndex).SubItems(13).Text
For i = 0 To PaymentArray.Length - 1
If Trim(PaymentArray(i).PmntName) = lsvTags.Items(e.ItemIndex).SubItems(14).Text Then
Exit For
End If
Next
If i = PaymentArray.Length Then
cmbPmntType.SelectedIndex = -1
Else
cmbPmntType.SelectedIndex = i
End If
txtCheckNo.Text = lsvTags.Items(e.ItemIndex).SubItems(15).Text
expired = lsvTags.Items(e.ItemIndex).SubItems(16).Text
If Not expired = "0" Then
lblExpired.Visible = True
If expired = "1" Then
lblExpired.Text = "THIS VACCINATION EXPIRED BASED ON VACCINATION DATE"
Else
lblExpired.Text = "THIS VACCINATION EXPIRED DUE TO NEW VACCINATION ADDED"
End If
Else
lblExpired.Visible = False
End If
VacID = CInt(lsvTags.Items(e.ItemIndex).SubItems(17).Text)
End If
End If
End Sub
Sub Enable_Owner(ByVal Switch As Boolean)
btnFind.Enabled = Not Switch
btnExit.Enabled = Not Switch
cmbState.Enabled = Switch
cmdFirst.Enabled = Not (Switch Or BeginOfFile)
cmdPrior.Enabled = Not (Switch Or BeginOfFile)
cmdNext.Enabled = Not (Switch Or EndOfFile)
cmdLast.Enabled = Not (Switch Or EndOfFile)
cmdOrder.Enabled = Not Switch
cmdDeleteOwner.Enabled = Not Switch
rtbComments.Enabled = Switch
txtAddr_pgeOwners.Enabled = Switch
txtAddr2_pgeOwners.Enabled = Switch
txtCity.Enabled = Switch
txtOwner_pgeOwners.Enabled = Switch
txtPhone1.Enabled = Switch
txtPhone2.Enabled = Switch
txtZIP.Enabled = Switch
End Sub
Sub Enable_Dogs(ByVal Switch As Boolean)
btnExit.Enabled = Not Switch
btnFind.Enabled = Not Switch
chkRemoved.Enabled = Switch
cmbSpecies.Enabled = Switch
cmdDeleteDog.Enabled = Not Switch
cmdReassign.Enabled = Not Switch
cmdUpdateID.Enabled = Not Switch
mtbBirthday.Enabled = Switch
txtBreed_pgeDogs.Enabled = Switch
txtColor.Enabled = Switch
txtDogName_pgeDogs.Enabled = Switch
txtReason.Enabled = Switch
txtSex.Enabled = Switch
txtWeight.Enabled = Switch
lsvDogs.Enabled = Not Switch
End Sub
Sub Enable_Vaccination(ByVal Switch As Boolean)
 im VacExpDates As Boolean = False
If AddMode = True Or UserLevel = 3 Then
VacExpDates = True
End If
btnExit.Enabled = Not Switch
btnFind.Enabled = Not Switch
chkWalkIn.Enabled = Switch
cmbChargeType.Enabled = Switch
cmbClinics.Enabled = Switch
cmbPmntType.Enabled = Switch
cmbPurchased.Enabled = Switch
cmdCopyVaccination.Enabled = Not Switch
cmdDeleteVac.Enabled = Not Switch
cmdPrint.Enabled = Not Switch
cmdPrintAppl.Enabled = Not Switch
cmdRedirect.Enabled = Not Switch
cmdRemoveExpired.Enabled = Not Switch And (UserLevel = 3)
txtCashier.Enabled = Switch
txtCheckNo.Enabled = Switch
mtbExpDate.Enabled = Switch And VacExpDates
txtLicense.Enabled = Switch
mtbPayDate.Enabled = Switch
txtTagNumber.Enabled = Switch
mtbVacDate.Enabled = Switch And VacExpDates
lsvTags.Enabled = Not Switch
End Sub
Imports System.Data
Imports System.Data.OleDb
Public Class frmDCLSelectOwner
 im ColNumber As Int16
 im OldInd As Int16
 im results As SqlClient.SqlDataReader
 im FindRow As DataRow
Private Sub frmDCLSelectOwner_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FindLastID()
OldInd = OwnerInd
Order = "Name"
 isplayAll()
txtFindOwner.Text = ""
txtFindOwner.Focus()
End Sub
Sub DisplayAll()
 im OrderField As String = IIf(Order = "Name", "Customer", "ClientID"
connAdapter.SelectCommand.CommandText = "Select Customer, ClientID from " & OwnersTable & " Order By " & OrderField
If Not dsDCL.Tables("ogOwners" Is Nothing Then
dsDCL.Tables("ogOwners".Clear()
End If
connAdapter.Fill(dsDCL, "ogOwners"
 ataGridView1.DataSource = dsDCL.Tables("ogOwners"
 ataGridView1.Columns(0).Width = 300
End Sub
Private Sub btnContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnContinue.Click
SelectID(DataGridView1.CurrentCell.RowIndex)
End Sub
Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
SelectID(OldInd)
End Sub
Private Sub DataGridView1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.ColumnHeaderMouseClick
If e.ColumnIndex = 0 Then
Order = "Name"
 isplayAll()
Else
Order = "ID"
 isplayAll()
End If
ColNumber = e.ColumnIndex
txtFindOwner.Text = ""
txtFindOwner.Focus()
End Sub
Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.DoubleClick
SelectID(DataGridView1.CurrentCell.RowIndex)
End Sub
Private Sub DataGridView1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress
If e.KeyChar = ChrW(Keys.Back) Then
indRowNumber = 0
Else
txtFindOwner.Text &= txtFindOwner.Text & e.KeyChar
End If
End Sub
Private Sub DataGridView1_RowLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
End Sub
Private Sub txtFindOwner_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtFindOwner.KeyPress
If e.KeyChar = ChrW(Keys.Back) Then
indRowNumber = 0
End If
If e.KeyChar = ChrW(Keys.Return) Then
SelectID(DataGridView1.CurrentCell.RowIndex)
End If
End Sub
Private Sub txtFindOwner_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtFindOwner.MouseClick
If Len(txtFindOwner.Text) = 0 Then
indRowNumber = 0
End If
End Sub
Private Sub txtFindOwner_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFindOwner.TextChanged
 im blnfound As Boolean = False
 im i As Integer = 0
 im datastring As String = ""
If Len(Trim(txtFindOwner.Text)) = 0 Then
Exit Sub
End If
While indRowNumber <= DataGridView1.Rows.Count - 1
datastring = DataGridView1.Rows(indRowNumber).Cells(ColNumber).Value
If UCase(Mid(datastring, 1, Len(txtFindOwner.Text))) = UCase(txtFindOwner.Text) Then
Customer = DataGridView1.Rows(indRowNumber).Cells(0).Value
ClientID = DataGridView1.Rows(indRowNumber).Cells(1).Value
OwnerInd = indRowNumber
 ataGridView1.Rows(indRowNumber).Selected = True
 ataGridView1.CurrentCell = DataGridView1.Rows(indRowNumber).Cells(ColNumber)
blnfound = True
Exit While
End If
indRowNumber += 1
End While
If blnfound = False Then
MsgBox("Owners Name " & StrConv(txtFindOwner.Text, VbStrConv.ProperCase) & " Not On File"
indRowNumber = 0
txtFindOwner.Text = Mid(txtFindOwner.Text, 1, Len(txtFindOwner.Text) - 1)
Else
OwnerInd = indRowNumber
End If
End Sub
Sub SelectID(ByVal NewInd)
OwnerInd = NewInd
indRowNumber = OwnerInd
Customer = DataGridView1.Rows(indRowNumber).Cells(0).Value
ClientID = DataGridView1.Rows(indRowNumber).Cells(1).Value
Me.Close()
End Sub
End Class
Ответить
|
Номер ответа: 18 Автор ответа:
Вопросов: 1 Ответов: 26
|
Профиль | | #18
|
Добавлено: 03.09.10 15:22
|
- Imports System.Data
- Imports System.Data.OleDb
- Imports System.Data.SqlClient
- Imports System.IO
-
- Module modDogLicense
- Public connString As String = "Data Source=SqlSrvSqlSrv; Initial Catalog=DogLicense; Integrated Security=SSPI;"
- Dim QueryDCL As String
- Public connDCL As New SqlConnection(connString)
- Public connOwner As New SqlConnection(connString)
- Public connAdapter As New SqlDataAdapter(QueryDCL, connDCL)
- Public dsDCL As New DataSet
- Public drRow As DataRow
- Public drRowDogs As DataRow
- Public drRowVac As DataRow
- Public indRowNumber As Integer
- Public SqlCommand As New SqlCommand
- Public AddMode As Boolean
- Public ClientID As String = ""
- Public ClientTable As String
- Public DataBase As String
- Public DogID As String
- Public DogsTable As String
- Public EditMode As Boolean
- Public Order As String
- Public OwnerInd As Int16
- Public OwnersTable As String
- Public SqlStatement As String
- Public VaccinationTable As String
- Public VacID As Integer
-
- Sub Main()
- DataBase = "Live"
- OwnersTable = "DCLDogOwners"
- DogsTable = "DCLDogs"
- VaccinationTable = "DCLVaccination"
- SqlCommand.Connection = connDCL
- connDCL.Open()
- End Sub
-
- Public Class frmDCLMain
-
- Private Sub DogLicensesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DogLicensesToolStripMenuItem.Click
- frmDogsAndCats.ShowDialog()
- End Sub
-
- Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click
- Me.Close()
- End Sub
-
- Private Sub frmDCLMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- Main()
- End Sub
-
- Public Class frmDogsAndCats
- Dim litem As ListViewItem
- Dim expired As String = "0"
- Dim SelDog As Int16
- Dim SqlStatementSecur As String
- Dim VacInd As Integer
-
- Private Sub frmDogsAndCats_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- ClientID = "030018"
- Enable_Owner(False)
- DisplayOwner()
- End Sub
-
- Sub DisplayOwner()
- SqlStatement = "Select * from " & OwnersTable & " Where clientid = '" & ClientID & "'"
- connAdapter.SelectCommand.CommandText = SqlStatement
- If Not dsDCL.Tables("SelectedOwner") Is Nothing Then
- dsDCL.Tables("SelectedOwner").Clear()
- End If
- connAdapter.SelectCommand.CommandType = CommandType.Text
- connAdapter.Fill(dsDCL, "SelectedOwner")
- drRow = dsDCL.Tables("SelectedOwner").Rows(0)
- txtClientID_pgeOwners.Text = ClientID
- txtOwner_pgeOwners.Text = Trim(drRow.Item("Customer") & " ")
- Customer = txtOwner_pgeOwners.Text
- txtAddr_pgeOwners.Text = Trim(drRow.Item("Address1") & " ")
- txtAddr2_pgeOwners.Text = Trim(drRow.Item("Address2") & " ")
- txtCity.Text = Trim(drRow.Item("city") & " ")
- txtZIP.Text = Trim(drRow.Item("zip") & " ")
- cmbState.Text = Trim(drRow.Item("state") & " ")
- txtPhone1.Text = Trim(drRow.Item("phone1") & " ")
- txtPhone2.Text = Trim(drRow.Item("phone2") & " ")
- If Not Trim(drRow.Item("paiddtd").ToString & " ") = "" Then
- If Not CDate(Trim(drRow.Item("paiddtd").ToString & " ")) = #1/1/1990# Then
- txtPaidDate.Text = drRow.Item("paiddtd")
- Else
- txtPaidDate.Text = ""
- End If
- txtPaidDate.Text = ""
- End If
- rtbComments.Text = Trim(drRow.Item("comments") & " ")
- CityStateZIP = Trim(txtCity.Text) & ", " & cmbState.Text & " " & txtZIP.Text
- cmdPrior.Enabled = True
- cmdFirst.Enabled = True
- cmdNext.Enabled = True
- cmdLast.Enabled = True
- BeginOfFile = False
- EndOfFile = False
- If OwnerInd = dsDCL.Tables("DogOwners").Rows.Count - 1 Then
- cmdNext.Enabled = False
- cmdLast.Enabled = False
- EndOfFile = True
- End If
- If OwnerInd = 0 Then
- cmdPrior.Enabled = False
- cmdFirst.Enabled = False
- BeginOfFile = True
- End If
- If Order = "Name" Then
- cmdOrder.Text = "SWITCH TO ORDER BY CLIENT ID"
- Else
- cmdOrder.Text = "SWITCH TO ORDER BY CLIENT NAME"
- End If
- pgfDogsInfo.SelectedIndex = 0
- pgeOwners.Select()
- End Sub
-
- Sub DisplayDogs()
- SqlStatement = "Select * from " & DogsTable & " Where clientid = '" & ClientID & "'"
- SqlStatement &= " Order By Dog_ID"
- connAdapter.SelectCommand.CommandText = SqlStatement
- If Not dsDCL.Tables("SelectedDogs") Is Nothing Then
- dsDCL.Tables("SelectedDogs").Clear()
- End If
- connAdapter.SelectCommand.CommandType = CommandType.Text
- connAdapter.Fill(dsDCL, "SelectedDogs")
- lsvDogs.Items.Clear()
- If dsDCL.Tables("SelectedDogs").Rows.Count = 0 Then
- litem = lsvDogs.Items.Add(" ")
- litem.SubItems.Add("No Dogs On File For This Owner")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- SelDog = 0
- Else
- Dim rowcount As Int16 = dsDCL.Tables("SelectedDogs").Rows.Count
- Dim rowi As Int16 = 0
- For Each drRowDogs In dsDCL.Tables("SelectedDogs").Rows
- litem = lsvDogs.Items.Add(drRowDogs.Item("Dog_ID"))
- litem.SubItems.Add(drRowDogs.Item("FullName"))
- litem.SubItems.Add(drRowDogs.Item("Breed"))
- litem.SubItems.Add(drRowDogs.Item("Gender"))
- litem.SubItems.Add(drRowDogs.Item("Dog_Color"))
- litem.SubItems.Add(drRowDogs.Item("Birthday").ToString)
- litem.SubItems.Add(drRowDogs.Item("Species"))
- litem.SubItems.Add(drRowDogs.Item("Weight"))
- litem.SubItems.Add(drRowDogs.Item("Deprived"))
- litem.SubItems.Add(drRowDogs.Item("Reason"))
- Next
- If AddMode = True Then
- SelDog = rowcount - 1
- ElseIf EditMode = False Then
- SelDog = 0
- End If
- End If
- txtClientID_pgeDogs.Text = txtClientID_pgeOwners.Text
- txtOwner_pgeDogs.Text = txtOwner_pgeOwners.Text
- txtAddr_pgeDogs.Text = txtAddr_pgeOwners.Text
- txtAddr2_pgeDogs.Text = txtAddr2_pgeOwners.Text
- lsvDogs.Items(SelDog).ListView.Select()
- lsvDogs.Items(SelDog).Selected = True
- End Sub
-
- Sub DisplayVaccination(ByVal VacID_Ind As Integer)
- SqlStatement = "Select * from " & VaccinationTable & " Where clientid = '" & ClientID
- SqlStatement &= "' AND dog_id = '" & DogID & "' Order By ClientID, Dog_ID, vacdate, expdate, vacid"
- connAdapter.SelectCommand.CommandText = SqlStatement
- If Not dsDCL.Tables("VaccinationTable") Is Nothing Then
- dsDCL.Tables("VaccinationTable").Clear()
- End If
- connAdapter.SelectCommand.CommandType = CommandType.Text
- connAdapter.Fill(dsDCL, "VaccinationTable")
- lsvTags.Items.Clear()
- VacInd = 0
- If dsDCL.Tables("VaccinationTable").Rows.Count = 0 Then
- litem = lsvTags.Items.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add("No Vaccinations On File For This Dog/Cat")
- litem.SubItems.Add(0)
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(" ")
- litem.SubItems.Add(0)
- Else
- Dim test_str As Date
- Dim test_decimal As Decimal = 0.0
- Dim rowcount As Int16 = dsDCL.Tables("VaccinationTable").Rows.Count
- Dim rowi As Int16 = 0
- Dim i As Int16 = 0
- For Each drRow In dsDCL.Tables("VaccinationTable").Rows
- litem = lsvTags.Items.Add(drRow.Item("TagNumber"))
- test_str = drRow.Item("VacDate")
- litem.SubItems.Add(test_str.ToShortDateString)
- test_str = drRow.Item("ExpDate")
- litem.SubItems.Add(test_str.ToShortDateString)
- litem.SubItems.Add(drRow.Item("ChargeType"))
- litem.SubItems.Add(drRow.Item("Amount").ToString)
- litem.SubItems.Add(drRow.Item("ClinicName"))
- litem.SubItems.Add(Trim(drRow.Item("License") & " "))
- litem.SubItems.Add(drRow.Item("For_Year"))
- If Trim(drRow.Item("DueDate").ToString & " ") = "" Then
- litem.SubItems.Add(" ")
- Else
- test_str = drRow.Item("DueDate")
- litem.SubItems.Add(test_str.ToShortDateString)
- End If
- litem.SubItems.Add(drRow.Item("LetterSent"))
- litem.SubItems.Add(Trim(drRow.Item("walkin") & " "))
- test_str = drRow.Item("PayDate")
- litem.SubItems.Add(test_str.ToShortDateString)
- litem.SubItems.Add(Trim(drRow.Item("Purchased") & " "))
- litem.SubItems.Add(Trim(drRow.Item("Cashier") & " "))
- For rowi = 0 To PaymentArray.Length - 1
- If Trim(drRow.Item("PayType") & " ") = PaymentArray(rowi).PmntCode Then
- Exit For
- End If
- Next
- If rowi = PaymentArray.Length Or PaymentArray(rowi).PmntCode = "" Then
- litem.SubItems.Add(" ")
- Else
- litem.SubItems.Add(Trim(PaymentArray(rowi).PmntName))
- End If
- litem.SubItems.Add(Trim(drRow.Item("Check_no") & " "))
- litem.SubItems.Add(Trim(drRow.Item("Expired") & " "))
- litem.SubItems.Add(drRow.Item("VacID").ToString)
- If VacID_Ind > 0 And VacID_Ind = drRow.Item("VacID") Then
- VacInd = i
- End If
- i += 1
- Next
- If AddMode = True Then
- VacInd = rowcount - 1
- End If
- End If
- txtClientID_pgeVaccination.Text = txtClientID_pgeOwners.Text
- txtOwner_pgeVaccination.Text = txtOwner_pgeOwners.Text
- txtAddr_pgeVaccination.Text = txtAddr_pgeOwners.Text
- txtAddr2_pgeVaccination.Text = txtAddr2_pgeOwners.Text
- txtDogID_pgeVaccination.Text = txtDogID_pgeDogs.Text
- txtDogName_pgeVaccination.Text = txtDogName_pgeDogs.Text
- txtBreed_pgeVaccination.Text = txtBreed_pgeDogs.Text
- lsvTags.Items(VacInd).ListView.Select()
- lsvTags.Items(VacInd).Selected = True
- End Sub
-
- Private Sub pgfDogsInfo_Selected(ByVal sender As Object, ByVal e As System.Windows.Forms.TabControlEventArgs) Handles pgfDogsInfo.Selected
- Select Case e.TabPageIndex
- Case Is = 1
- If AddMode = True Or EditMode = True Then
- Enable_Dogs(True)
- Else
- Enable_Dogs(False)
- End If
- DisplayDogs()
- Case Is = 2
- If AddMode = True Or EditMode = True Then
- Enable_Vaccination(True)
- Else
- Enable_Vaccination(False)
- End If
- DisplayVaccination(0)
- End Select
- End Sub
-
- Private Sub lsvDogs_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles lsvDogs.ItemSelectionChanged
- Dim birthday_str As String
- Dim birthday As String
- Dim birthday_date As Date
- If e.IsSelected = True Then
- SelDog = e.ItemIndex
- If dsDCL.Tables("SelectedDogs").Rows.Count = 0 Then
- DogID = ""
- txtDogID_pgeDogs.Text = ""
- txtDogName_pgeDogs.Text = ""
- txtBreed_pgeDogs.Text = ""
- txtSex.Text = ""
- txtColor.Text = ""
- cmbSpecies.SelectedIndex = -1
- txtWeight.Text = ""
- mtbBirthday.Text = ""
- txtReason.Text = ""
- chkRemoved.Checked = False
- Else
- DogID = lsvDogs.Items(e.ItemIndex).Text
- txtDogID_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).Text
- txtDogName_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).SubItems(1).Text
- txtBreed_pgeDogs.Text = lsvDogs.Items(e.ItemIndex).SubItems(2).Text
- txtSex.Text = lsvDogs.Items(e.ItemIndex).SubItems(3).Text
- txtColor.Text = lsvDogs.Items(e.ItemIndex).SubItems(4).Text
- cmbSpecies.Text = lsvDogs.Items(e.ItemIndex).SubItems(6).Text
- txtWeight.Text = lsvDogs.Items(e.ItemIndex).SubItems(7).Text
- birthday = lsvDogs.Items(e.ItemIndex).SubItems(5).Text
- If Not Trim(birthday) = "" Then
- birthday_date = CDate(birthday)
- If Not birthday_date = #1/1/1900# Then
- birthday = birthday_date.ToShortDateString
- birthday_str = Mid(birthday, 1, Len(birthday) - 5)
- Select Case Len(birthday_str)
- Case 3
- birthday_str = "0" & Mid(birthday_str, 1, 1) & "0" & Mid(birthday_str, 3, 1)
- Case 4
- If Mid(birthday_str, 2, 1) = "/" Then
- birthday_str = "0" & Mid(birthday_str, 1, 1) & Mid(birthday_str, 3, 2)
- Else
- birthday_str = Mid(birthday_str, 1, 2) & "0" & Mid(birthday_str, 4, 1)
- End If
- Case 5
- birthday_str = Mid(birthday_str, 1, 2) & Mid(birthday_str, 4, 2)
- End Select
- birthday = birthday_str & Mid(birthday, Len(birthday) - 3, 4)
- mtbBirthday.Text = birthday
- Else
- mtbBirthday.Text = ""
- End If
- End If
- txtReason.Text = lsvDogs.Items(e.ItemIndex).SubItems(9).Text
- chkRemoved.Checked = IIf(lsvDogs.Items(e.ItemIndex).SubItems(8).Text = "Y", True, False)
- End If
- End If
- End Sub
-
- Private Sub lsvTags_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles lsvTags.ItemSelectionChanged
- Dim i As Int16
- Dim DateToStr As String
- Dim DateToStr1 As String
- If e.IsSelected = True Then
- VacInd = e.ItemIndex
- If dsDCL.Tables("VaccinationTable").Rows.Count = 0 Then
- txtTagNumber.Text = ""
- cmbClinics.SelectedIndex = -1
- mtbVacDate.Text = ""
- mtbExpDate.Text = ""
- mtbDueDate.Text = ""
- mtbPayDate.Text = ""
- cmbChargeType.SelectedIndex = -1
- txtChargeAmount.Text = ""
- chkLetterSent.Checked = False
- chkWalkIn.Checked = False
- txtYear.Text = ""
- txtLicense.Text = ""
- cmbPurchased.SelectedIndex = -1
- txtCashier.Text = ""
- cmbPmntType.SelectedIndex = -1
- txtCheckNo.Text = ""
- expired = "0"
- VacID = 0
- Else
- txtTagNumber.Text = lsvTags.Items(e.ItemIndex).Text
- If Trim(lsvTags.Items(e.ItemIndex).SubItems(5).Text) = "" Then
- cmbClinics.SelectedIndex = -1
- Else
- cmbClinics.Text = lsvTags.Items(e.ItemIndex).SubItems(5).Text
- End If
- VacDate = CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text.ToString)
- If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text) = #1/1/1900# Then
- DateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(1).Text).ToShortDateString
- DateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
- Select Case Len(DateToStr1)
- Case 3
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
- Case 4
- If Mid(DateToStr1, 2, 1) = "/" Then
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
- Else
- DateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
- End If
- Case 5
- DateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
- End Select
- DateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
- mtbVacDate.Text = DateToStr
- Else
- mtbVacDate.Text = ""
- End If
- ExpDate = CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text.ToString)
- If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text) = #1/1/1900# Then
- DateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(2).Text).ToShortDateString
- DateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
- Select Case Len(DateToStr1)
- Case 3
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
- Case 4
- If Mid(DateToStr1, 2, 1) = "/" Then
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
- Else
- DateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
- End If
- Case 5
- DateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
- End Select
- DateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
- mtbExpDate.Text = DateToStr
- Else
- mtbExpDate.Text = ""
- End If
- If Not Trim(lsvTags.Items(e.ItemIndex).SubItems(8).Text) = "" Then
- If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(8).Text) = #1/1/1900# Then
- DateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(8).Text).ToShortDateString
- DateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
- Select Case Len(DateToStr1)
- Case 3
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
- Case 4
- If Mid(DateToStr1, 2, 1) = "/" Then
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
- Else
- DateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
- End If
- Case 5
- DateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
- End Select
- DateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
- mtbDueDate.Text = DateToStr
- Else
- mtbDueDate.Text = ""
- End If
- Else
- mtbDueDate.Text = ""
- End If
- If Not Trim(lsvTags.Items(e.ItemIndex).SubItems(11).Text) = "" Then
- If Not CDate(lsvTags.Items(e.ItemIndex).SubItems(11).Text) = #1/1/1900# Then
- DateToStr = CDate(lsvTags.Items(e.ItemIndex).SubItems(11).Text).ToShortDateString
- DateToStr1 = Mid(DateToStr, 1, Len(DateToStr) - 5)
- Select Case Len(DateToStr1)
- Case 3
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & "0" & Mid(DateToStr1, 3, 1)
- Case 4
- If Mid(DateToStr1, 2, 1) = "/" Then
- DateToStr1 = "0" & Mid(DateToStr1, 1, 1) & Mid(DateToStr1, 3, 2)
- Else
- DateToStr1 = Mid(DateToStr1, 1, 2) & "0" & Mid(DateToStr1, 4, 1)
- End If
- Case 5
- DateToStr1 = Mid(DateToStr1, 1, 2) & Mid(DateToStr1, 4, 2)
- End Select
- DateToStr = DateToStr1 & Mid(DateToStr, Len(DateToStr) - 3, 4)
- mtbPayDate.Text = DateToStr
- Else
- mtbPayDate.Text = ""
- End If
- Else
- mtbPayDate.Text = ""
- End If
- If Trim(lsvTags.Items(e.ItemIndex).SubItems(3).Text) = "" Then
- cmbChargeType.SelectedIndex = -1
- Else
- cmbChargeType.Text = lsvTags.Items(e.ItemIndex).SubItems(3).Text
- End If
- txtChargeAmount.Text = lsvTags.Items(e.ItemIndex).SubItems(4).Text
- chkLetterSent.Checked = IIf(lsvTags.Items(e.ItemIndex).SubItems(9).Text = "Y", True, False)
- chkWalkIn.Checked = IIf(lsvTags.Items(e.ItemIndex).SubItems(10).Text = "Y", True, False)
- txtYear.Text = lsvTags.Items(e.ItemIndex).SubItems(7).Text
- txtLicense.Text = lsvTags.Items(e.ItemIndex).SubItems(6).Text
- If Trim(lsvTags.Items(e.ItemIndex).SubItems(12).Text) = "" Then
- cmbPurchased.SelectedIndex = -1
- Else
- cmbPurchased.Text = lsvTags.Items(e.ItemIndex).SubItems(12).Text
- End If
- txtCashier.Text = lsvTags.Items(e.ItemIndex).SubItems(13).Text
- For i = 0 To PaymentArray.Length - 1
- If Trim(PaymentArray(i).PmntName) = lsvTags.Items(e.ItemIndex).SubItems(14).Text Then
- Exit For
- End If
- Next
- If i = PaymentArray.Length Then
- cmbPmntType.SelectedIndex = -1
- Else
- cmbPmntType.SelectedIndex = i
- End If
- txtCheckNo.Text = lsvTags.Items(e.ItemIndex).SubItems(15).Text
- expired = lsvTags.Items(e.ItemIndex).SubItems(16).Text
- If Not expired = "0" Then
- lblExpired.Visible = True
- If expired = "1" Then
- lblExpired.Text = "THIS VACCINATION EXPIRED BASED ON VACCINATION DATE"
- Else
- lblExpired.Text = "THIS VACCINATION EXPIRED DUE TO NEW VACCINATION ADDED"
- End If
- Else
- lblExpired.Visible = False
- End If
- VacID = CInt(lsvTags.Items(e.ItemIndex).SubItems(17).Text)
- End If
- End If
- End Sub
-
- Sub Enable_Owner(ByVal Switch As Boolean)
- btnFind.Enabled = Not Switch
- btnExit.Enabled = Not Switch
- cmbState.Enabled = Switch
- cmdFirst.Enabled = Not (Switch Or BeginOfFile)
- cmdPrior.Enabled = Not (Switch Or BeginOfFile)
- cmdNext.Enabled = Not (Switch Or EndOfFile)
- cmdLast.Enabled = Not (Switch Or EndOfFile)
- cmdOrder.Enabled = Not Switch
- cmdDeleteOwner.Enabled = Not Switch
- rtbComments.Enabled = Switch
- txtAddr_pgeOwners.Enabled = Switch
- txtAddr2_pgeOwners.Enabled = Switch
- txtCity.Enabled = Switch
- txtOwner_pgeOwners.Enabled = Switch
- txtPhone1.Enabled = Switch
- txtPhone2.Enabled = Switch
- txtZIP.Enabled = Switch
- End Sub
-
- Sub Enable_Dogs(ByVal Switch As Boolean)
- btnExit.Enabled = Not Switch
- btnFind.Enabled = Not Switch
- chkRemoved.Enabled = Switch
- cmbSpecies.Enabled = Switch
- cmdDeleteDog.Enabled = Not Switch
- cmdReassign.Enabled = Not Switch
- cmdUpdateID.Enabled = Not Switch
- mtbBirthday.Enabled = Switch
- txtBreed_pgeDogs.Enabled = Switch
- txtColor.Enabled = Switch
- txtDogName_pgeDogs.Enabled = Switch
- txtReason.Enabled = Switch
- txtSex.Enabled = Switch
- txtWeight.Enabled = Switch
- lsvDogs.Enabled = Not Switch
- End Sub
-
- Sub Enable_Vaccination(ByVal Switch As Boolean)
- Dim VacExpDates As Boolean = False
- If AddMode = True Or UserLevel = 3 Then
- VacExpDates = True
- End If
- btnExit.Enabled = Not Switch
- btnFind.Enabled = Not Switch
- chkWalkIn.Enabled = Switch
- cmbChargeType.Enabled = Switch
- cmbClinics.Enabled = Switch
- cmbPmntType.Enabled = Switch
- cmbPurchased.Enabled = Switch
- cmdCopyVaccination.Enabled = Not Switch
- cmdDeleteVac.Enabled = Not Switch
- cmdPrint.Enabled = Not Switch
- cmdPrintAppl.Enabled = Not Switch
- cmdRedirect.Enabled = Not Switch
- cmdRemoveExpired.Enabled = Not Switch And (UserLevel = 3)
- txtCashier.Enabled = Switch
- txtCheckNo.Enabled = Switch
- mtbExpDate.Enabled = Switch And VacExpDates
- txtLicense.Enabled = Switch
- mtbPayDate.Enabled = Switch
- txtTagNumber.Enabled = Switch
- mtbVacDate.Enabled = Switch And VacExpDates
- lsvTags.Enabled = Not Switch
- End Sub
-
- Imports System.Data
- Imports System.Data.OleDb
- Public Class frmDCLSelectOwner
- Dim ColNumber As Int16
- Dim OldInd As Int16
- Dim results As SqlClient.SqlDataReader
- Dim FindRow As DataRow
-
- Private Sub frmDCLSelectOwner_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- FindLastID()
- OldInd = OwnerInd
- Order = "Name"
- DisplayAll()
- txtFindOwner.Text = ""
- txtFindOwner.Focus()
- End Sub
-
- Sub DisplayAll()
- Dim OrderField As String = IIf(Order = "Name", "Customer", "ClientID")
- connAdapter.SelectCommand.CommandText = "Select Customer, ClientID from " & OwnersTable & " Order By " & OrderField
- If Not dsDCL.Tables("DogOwners") Is Nothing Then
- dsDCL.Tables("DogOwners").Clear()
- End If
- connAdapter.Fill(dsDCL, "DogOwners")
- DataGridView1.DataSource = dsDCL.Tables("DogOwners")
- DataGridView1.Columns(0).Width = 300
- End Sub
-
- Private Sub btnContinue_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnContinue.Click
- SelectID(DataGridView1.CurrentCell.RowIndex)
- End Sub
- Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
- SelectID(OldInd)
- End Sub
-
- Private Sub DataGridView1_ColumnHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.ColumnHeaderMouseClick
- If e.ColumnIndex = 0 Then
- Order = "Name"
- DisplayAll()
- Else
- Order = "ID"
- DisplayAll()
- End If
- ColNumber = e.ColumnIndex
- txtFindOwner.Text = ""
- txtFindOwner.Focus()
- End Sub
-
- Private Sub DataGridView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.DoubleClick
- SelectID(DataGridView1.CurrentCell.RowIndex)
- End Sub
-
- Private Sub DataGridView1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DataGridView1.KeyPress
- If e.KeyChar = ChrW(Keys.Back) Then
- indRowNumber = 0
- Else
- txtFindOwner.Text &= txtFindOwner.Text & e.KeyChar
- End If
- End Sub
-
- Private Sub DataGridView1_RowLeave(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.RowLeave
- End Sub
-
- Private Sub txtFindOwner_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtFindOwner.KeyPress
- If e.KeyChar = ChrW(Keys.Back) Then
- indRowNumber = 0
- End If
- If e.KeyChar = ChrW(Keys.Return) Then
- SelectID(DataGridView1.CurrentCell.RowIndex)
- End If
- End Sub
-
- Private Sub txtFindOwner_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtFindOwner.MouseClick
- If Len(txtFindOwner.Text) = 0 Then
- indRowNumber = 0
- End If
- End Sub
-
- Private Sub txtFindOwner_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtFindOwner.TextChanged
- Dim blnfound As Boolean = False
- Dim i As Integer = 0
- Dim datastring As String = ""
-
- If Len(Trim(txtFindOwner.Text)) = 0 Then
- Exit Sub
- End If
- While indRowNumber <= DataGridView1.Rows.Count - 1
- datastring = DataGridView1.Rows(indRowNumber).Cells(ColNumber).Value
- If UCase(Mid(datastring, 1, Len(txtFindOwner.Text))) = UCase(txtFindOwner.Text) Then
- Customer = DataGridView1.Rows(indRowNumber).Cells(0).Value
- ClientID = DataGridView1.Rows(indRowNumber).Cells(1).Value
- OwnerInd = indRowNumber
- DataGridView1.Rows(indRowNumber).Selected = True
- DataGridView1.CurrentCell = DataGridView1.Rows(indRowNumber).Cells(ColNumber)
- blnfound = True
- Exit While
- End If
- indRowNumber += 1
- End While
- If blnfound = False Then
- MsgBox("Owners Name " & StrConv(txtFindOwner.Text, VbStrConv.ProperCase) & " Not On File")
- indRowNumber = 0
- txtFindOwner.Text = Mid(txtFindOwner.Text, 1, Len(txtFindOwner.Text) - 1)
- Else
- OwnerInd = indRowNumber
- End If
- End Sub
-
- Sub SelectID(ByVal NewInd)
- OwnerInd = NewInd
- indRowNumber = OwnerInd
- Customer = DataGridView1.Rows(indRowNumber).Cells(0).Value
- ClientID = DataGridView1.Rows(indRowNumber).Cells(1).Value
- Me.Close()
- End Sub
- End Class
Ответить
|
Номер ответа: 24 Автор ответа: EROS
Вопросов: 58 Ответов: 4255
|
Профиль | | #24
|
Добавлено: 08.09.10 20:57
|
Iosif, чтоб однозначно понять в чем проблема надо иметь ваш код и подробное описание проблемы. Код, который вы выложили, слишком громозд и избыточен и вовсе не приспособлен для поиска проблемы без источника данных.. Вам предлагали создать тестовый проект, кинуть на форму ваш TabControl, создать вкладки, раскидать по ним ListView , заполнить их тестовыми/виртуальными данными (без использования БД) по 2-3 строчки и попытаться воспроизвести вашу проблему. При наличии таковой опубликовать этот проект на любом файловом хостинге и тут, на форуме, опубликовать ссылку на этот проект с описанием действий которые я, или кто то другой, должен проделать чтобы получить вашу проблему. Поймите правильно, из преложенного вами кода нам ничего не понять.. он не отражает суть проблемы.
Ответить
|
Страница: 1 | 2 | 3 | 4 |
Поиск по форуму