(drBooksort.Item(0))
EndWhile
Me.cboBook_sort.DataSource=myarr
CatchexAsException
MessageBox.Show(ex.Message)
Me.Close()
Finally
cnLib2004.Close()
EndTry
EndFunction
PrivateSubToolBar1_Butt(ByValsenderAsSystem.Object,ByValeAsSystem.Windows.Forms.ToolBarButtEventArgs)HandlesToolBar1.Butt
Ife.ButtonIsMe.tbtnQueryThen
search()
ElseIfe.ButtonIsMe.tbtnExitThen
Me.Close()
ElseIfe.ButtonIsMe.tbtnResetThen
frmClear()
ElseIfe.ButtonIsMe.tbtnExcelThen
excel()
ElseIfe.ButtonIsMe.tbtnPrintThen
print()
EndIf
EndSub
PrivateSubfrmClear()
Dimp1AsControl
DimuAsNewLabel
ForEachp1InMe.Panel2.Controls
IfNotp1.GetTypeIsu.GetTypeThen
p1.Text=""
EndIf
Next
Me.cboBook_sort.Text=""
Me.radAllBook.Checked=True
Me.dtpBook_pubdate.Value="1990-1-1"
Me.txtBook_code.Focus()
Me.dbgBookList.DataSource=Nothing
EndSub
Subexcel()
DimtableAuAsDataTable
tableAu=CType(Me.dbg.DataSource,DataTable)
IftableAuIsNothingThen
MessageBox.Show("没有任何记录可以导出!","error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
ExitSub
EndIf
DimmyfrmAsNewfrmShowProgress
myfrm.Show("正在建立excel对象...")
Try
DimexlAsNewMicrosoft.Office.Interop.Excel.ApplicationClass
DimworkbookAsMicrosoft.Office.Interop.Excel.Workbook
DimsheetAsMicrosoft.Office.Interop.Excel.Worksheet
workbook=CType(exl.Workbooks.Add(),Microsoft.Office.Interop.Excel.Workbook)
sheet=CType(workbook.Sheets(1),Microsoft.Office.Interop.Excel.Worksheet)
Dimmycount,mycolumnAsInt16
WithtableAu
myfrm.setMsg("正在导出数据,请等待......")
Formycount=0To.Rows.Count-1
Formycolumn=0To.Columns.Count-1
Withsheet
.Cells(mycount+2,mycolumn+1)=tableAu.Rows(mycount).Item(mycolumn)
EndWith
Next
'MsgBox(CType(mycount/.Rows.Count*100,Int16))
myfrm.setProgress(CType(mycount/.Rows.Count*100,Int16))
Next
myfrm.setMsg("正在设定excel表头格式...")
Formycolumn=0To.Columns.Count-1
exl.Workbooks(1).Worksheets(1).cells(1,mycolumn+1)=.Columns(mycolumn).ColumnName
exl.Workbooks(1).Worksheets(1).cells(1,mycolumn+1).Font.Bold=True
Next
EndWith
myfrm.setProgress(100)
myfrm.Close()
'workbook.SaveAs(myfile)
sheet.Application.Visible=True
'exl.Quit()
CatchexAsException
MessageBox.Show("导出失败!","fail",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
myfrm.Close()
EndTry
EndSub
PrivateSubprint()
DimtableAuAsDataTable
tableAu=CType(Me.dbgBookList.DataSource,DataTable)
IftableAuIsNothingThen
MessageBox.Show("没有任何记录可以导出!","error",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
ExitSub
EndIf
Dimmyfrm2AsNewfrmStatus
myfrm2.Show("正在导出报表...")
DimmyfrmAsNewfrmShowReport
DimrtdAsNewcrtBook
rtd.SetDataSource(tableAu)
myfrm.Text="报表输出窗口..."
myfrm.rpt.ReportSource=rtd
myfrm.rpt.DisplayGroupTree=False
myfrm2.Close()
myfrm.ShowDialog()
EndSub
EndClass
登陆窗体代码frmLogin.vb
PublicClassfrmLogin
InheritsSystem.Windows.Forms.Form
PublicIsLogSuccessAsBoolean
PublicstrLogUserAsString
#Region"Windows窗体设计器生成的代码"
此处略......
#EndRegion
PrivateSubfrmLogin_Load(ByValsenderAsObject,ByValeAsSystem.EventArgs)HandlesMyBase.Load
IsLogSuccess=False
EndSub
PrivateSubbtnLogin_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesbtnLogin.Click
IsLogSuccess=validateLogin(Me.txtUser.Text.Trim,Me.txtPwd.Text.Trim)
IfIsLogSuccess=TrueThen
strLogUser=Me.txtUser.Text.Trim
Me.Close()
Else
MessageBox.Show("密码错误!","请重新登陆!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
EndIf
EndSub
PrivateSubbtnExit_Click(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesbtnExit.Click
Me.Close()
EndSub
PrivateSubPanel1_Paint(ByValsenderAsSystem.Object,ByValeAsSystem.Windows.Forms.PaintEventArgs)HandlesPanel1.Paint
DimgrbrushAsDrawing2D.LinearGradientBrush
grbrush=NewDrawing2D.LinearGradientBrush(NewPoint(0,0),_
NewPoint(sender.Width,sender.Height),Color.DarkSlateGray,Color.White)
sender.CreateGraphics.FillRectangle(grbrush,NewRectangle(0,0,sender.Width,sender.Height))
EndSub
EndClass
将数据服务器信息序列化为xml文件的类
ImportsSystem.Xml.Serialization
ImportsSystem.IO
ImportsSystem.Collections
PublicClassCsetCnInfo
StructureCnInfo
PublicserverAsString
PublicdatabaseAsString
PublicuidAsString
PublicpasswordAsString
EndStructure
PrivatemCC(4)AsString
PublicFunctionsetCnTofile()
DimmcnAsCnInfo
mcn.server=mCC(0)
mcn.database=mCC(1)
mcn.uid=mCC(2)
mcn.password=mCC(3)
DimxmlSAsNewXmlSerializer(GetType(CnInfo))
DimtxtwtAsTextWriter=NewStreamWriter("cninfo.xml")
xmlS.Serialize(txtwt,mCn)
txtwt.Close()
EndFunction
PublicFunctionGetCnFromfile()AsString
DimmcnAsCnInfo
DimxmlsAsNewXmlSerializer(GetType(CnInfo))
DimtxtwtAsTextReader=NewStreamReader("cninfo.xml")
Try
mcn=xmls.Deserialize(txtwt)
mCC(0)=mcn.server
mCC(1)=mcn.database
mCC(2)=mcn.uid
mCC(3)=mcn.password
CatchexAsException
Throwex
Finally
txtwt.Close()
EndTry
ReturnreturnCnstr()
EndFunction
PublicFunctionreturnCnstr()AsString
Return"server="+mCC(0)+";database="_
+mCC(1)+";uid="+mCC(2)+";pwd="+mCC(3)
EndFunction
PublicPropertycnstr()AsString()
Get
ReturnmCC
EndGet
Set(ByValValueAsString())
Value.CopyTo(mCC,0)
EndSet
EndProperty
PublicSubNew()
EndSub
EndClass
验证登陆的函数
PublicFunctionvalidateLogin(ByValuidAsString,ByValpwdAsString)AsBoolean
DimIsCorrectAsBoolean=False
DimcnmyAsNewSqlConnection(cnstr)
DimcmdAsNewSqlCommand
Withcmd
.Connection=cnmy
.CommandType=CommandType.Text
.CommandText="selectcount(*)frommanagerwhereMan_id=@Man_idandMan_pwd=@Man_pwd"
EndWith
DimmMan_idAsNewSqlParameter("@Man_id",SqlDbType.NVarChar,50)
DimmMan_pwdAsNewSqlParameter("@Man_pwd",SqlDbType.NVarChar,12)
Withcmd.Parameters
.Add(mMan_id)
.Add(mMan_pwd)
EndWith
mMan_id.Value=uid
mMan_pwd.Value=pwd
Try
cnmy.Open()
Ifcmd.ExecuteScalar=1Then
IsCorrect=True
EndIf
CatchexAsException
MessageBox.Show("登陆验证时数据库发生错误"+vbCrLf+ex.Message,_
"err
上一篇:
ASP_net010电子购物商城系统+论文(论文和程序)
下一篇:
医学论文英语标题写作的修辞原则