CMFly.Web.Operation.dll 我们用vs2005这个版本生成出来
首先先是搞代码,包的调用以后再说可以看一下
namespace WanH
Public Class RQHandle
inherits System.Web.UI.Page
'==================声明开始==================
'以下代码在各个页面中统一调用,请不要修改
Private mo_logon As TApplogon = nothing '登陆对象
'==================声明结束==================
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DeBUGgerStepThrough()> Private Sub InitializeComponent()
End Sub
'注意: 以下占位符声明是 Web 窗体设计器所必需的。
'不要删除或移动它。
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: 此方法调用是 Web 窗体设计器所必需的
'不要使用代码编辑器修改它。
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load
'以下代码在各个页面中统一调用,请不要修改
On Error GoTo l_Err
'该函数参数为本窗口对象
mo_logon = New TApplogon(Me,"",TApplogon.enumApplogonFlag.logonOnModuleadmin,True,TApplogon.enumrecordtype.NotRecordLog,"")
'==================声明结束==================
'在此处放置初始化页的用户代码
Dim lo_XML As New System.Xml.Xmldocument,ls_Result As String
lo_XML.Load(Request.inputStream)
Select Case lo_XML.documentElement.GetAttribute("Handle")
Case "ExcelinRQG0050" '钢板信息
ls_Result = ExcelinRQG0050(lo_XML.documentElement)
Case "ExcelinRQG0060" '焊缝信息
ls_Result = ExcelinRQG0060(lo_XML.documentElement)
End Select
'记录日志
mo_logon.logon.SysError.RecordLog(Typename(Me),"Handle:" & lo_XML.documentElement.GetAttribute("Handle"))
lo_XML = nothing
'==================声明开始==================
'以下代码在各个页面中统一调用,请不要修改
mo_logon.ClearUp()
mo_logon = nothing
Response.Write(ls_Result)
Return
l_Err:
If mo_logon Is nothing Then mo_logon = New TApplogon(Me,CShort(0))
mo_logon.ErrorMsgToWeb(Err.Number,Err.Description,Typename(Me) & "::Page_Load() Event")
mo_logon = nothing
'==================声明结束==================
End Sub
'执行时间很长的大行的SQL语句的时候调用,比如存储过程
Private Function UpdateBigDate(ByVal ao_Node As System.Xml.XmlElement) As String
On Error GoTo ls_err
Dim ls_sql As String = ao_Node.GetAttribute("ls_sql")
Dim ls_Connet As String = ao_Node.GetAttribute("ls_Connet")
Dim lo_sqlHandle As TsqlHandle
Dim lo_sqlComm As New sqlClIEnt.sqlCommand
If ls_Connet = "" Then
lo_sqlHandle = mo_logon.logon.AppsqlHandle
Else
lo_sqlHandle = mo_logon.logon.GetothersqlHandle(ls_Connet)
End If
lo_sqlComm.CommandTimeout = 1000
lo_sqlComm.Connection = lo_sqlHandle.Connection
lo_sqlComm.CommandText = ls_sql
lo_sqlComm.ExecuteNonquery()
lo_sqlComm.dispose()
lo_sqlComm = nothing
Return "<Root Value=""1"" ResultValue=""成功"" />"
ls_err:
lo_sqlComm.dispose()
lo_sqlComm = nothing
Return "<Root Value=""0"" ResultValue=""失败,请与管理员联系"" />"
End Function
'钢板信息导入
Private Function ExcelinRQG0050(ByVal ao_Node As System.Xml.XmlElement) As String
On Error GoTo ls_err
'基础定义
Dim ls_sql As String,lo_sqlHandle As TsqlHandle
Dim ls_file As String = mo_logon.logon.GetParameterValue("NET_TEMP_DATA_PATH") & ao_Node.GetAttribute("Excelfile")
Dim lo_Excel As New Excel.Application
Dim lo_Workbook As Excel.Workbook = lo_Excel.Workbooks.Open(ls_file)
Dim lo_sheet As Excel.Worksheet = lo_Workbook.Sheets(1)
lo_sqlHandle = mo_logon.logon.GetothersqlHandle("CQG_DATAColL")
'需求定义
Dim ls_TypeID As Integer,ls_PBNum As String,ls_MBNum As String,ls_MBLNum As String,ls_Len As Double,ls_WI As Double,ls_Hou As Double
Dim ls_FJBack As String,ls_createuserID As Integer,ls_createusername As String,ls_CreateDate As DateTime
Dim ls_ParentID As Integer,ls_IsCheck As String,ls_JLRemake As String
Dim ls_QualityInspector As String,ls_YZRemake As String
Dim ls_Num As Integer,ls_sql1 As String,ls_Num01 As Integer,ls_Value01 As String,ls_PID As String
ls_ParentID = ao_Node.GetAttribute("ParentID")
If lo_sheet.Cells(2,1).value = "钢板编号" And lo_sheet.Cells(2,2).value = "钢板位置" And lo_sheet.Cells(2,3).value = "母板炉批号" And lo_sheet.Cells(2,4).value = "母板编号" And lo_sheet.Cells(2,5).value = "长" And lo_sheet.Cells(2,6).value = "宽" And lo_sheet.Cells(2,7).value = "板厚" And lo_sheet.Cells(2,8).value = "复检记录" Then ls_PID = "1"
'随机查看是否为正确模板
If ls_PID <> "1" Then
Call ExitExcelin(lo_Excel,lo_Workbook,lo_sheet,ls_file)
Return "<Root Value=""0"" ResultValue=""导入失败,请确认导入模板,谢谢!"" />"
Exit Function
End If
'这里就是导入了
ls_Num = 0
For i As Integer = 3 To lo_sheet.Rows.Count
If Isdbnull(lo_sheet.Cells(i,1).value) Or CStr(lo_sheet.Cells(i,1).value) = "" Then
'============出现空的=============
ls_Num = ls_Num + 1
If ls_Num > 2 Then
Exit For
End If
Else
'列值
'钢板编号不为空
If CStr(lo_sheet.Cells(i,1).value) = "" Then
Call gcExcel(lo_Excel,lo_sheet)
Return "<Root Value=""0"" ResultValue=""导入第" & i & "行时失败,钢板编号不能为空!"" />"
Exit Function
Else
ls_PBNum = CStr(lo_sheet.Cells(i,1).value)
End If
'钢板位置不为空
If CStr(lo_sheet.Cells(i,2).value) = "" Then
Call gcExcel(lo_Excel,钢板位置不能为空!"" />"
Exit Function
Else
Select Case Replace(Replace(lo_sheet.Cells(i,2).value," ","")," ","")
Case "外罐底板"
ls_TypeID = 1
Case "外罐壁板"
ls_TypeID = 2
Case "穹顶"
ls_TypeID = 3
Case "内罐底板"
ls_TypeID = 4
Case "内罐壁板"
ls_TypeID = 5
Case "内罐浮顶"
ls_TypeID = 6
End Select
End If
ls_MBNum = CStr(lo_sheet.Cells(i,3).value)
ls_MBLNum = CStr(lo_sheet.Cells(i,4).value)
ls_Len = CStr(lo_sheet.Cells(i,5).value)
ls_WI = CStr(lo_sheet.Cells(i,6).value)
ls_Hou = CStr(lo_sheet.Cells(i,7).value)
ls_FJBack = CStr(lo_sheet.Cells(i,8).value)
ls_createuserID = mo_logon.logon.UserID
ls_createusername = mo_logon.logon.Username
ls_IsCheck = ""
ls_JLRemake = " "
ls_QualityInspector = " "
ls_YZRemake = " "
'数据重复
ls_sql1 = "Select Count(*) from G0050 where PBNum ='" & ls_PBNum & "' and TypeID = " & ls_TypeID & ""
ls_Num01 = lo_sqlHandle.GetValueBysql(ls_sql1)
If ls_Num01 > 0 Then
ls_Value01 = ls_Value01 & "---第" & i & "行数据重复,请检查" & Chr(13) + Chr(10)
Return "<Root Value=""1"" ResultValue=""导入失败" & ls_Value01 & """ />"
Exit Function
End If
'开始插入
ls_sql = "INSERT INTO G0050 (PBNum,TypeID,MBNum,MBLNum,Len,WI,Hou,FJBack,IsCheck,JLRemake,QualityInspector,YZRemake,ParentID,createuserID,createusername,CreateDate) values ("
ls_sql = ls_sql & "'" & ls_PBNum & "'," & ls_TypeID & ",'" & ls_MBNum & "','" & ls_MBLNum & "'," & ls_Len & "," & ls_WI & "," & ls_Hou & ",'" & ls_FJBack & "','" & ls_IsCheck & "','" & ls_JLRemake & "','" & ls_QualityInspector & "','" & ls_YZRemake & "','" & ls_ParentID & "','" & ls_createuserID & "','" & ls_createusername & "'," & "GetDate())"
Call lo_sqlHandle.Updatesql(ls_sql)
'sql调试的时候拷贝出来检查他的准确性
End If
Next
'退出Excel,并且释放调用的COM资源
lo_Excel.displayAlerts = False
lo_Workbook.Save()
lo_Excel.displayAlerts = True
lo_Workbook.Close()
lo_Excel.Quit()
ReleaseComObject(lo_sheet)
ReleaseComObject(lo_Workbook)
ReleaseComObject(lo_Excel)
lo_Excel = nothing : lo_Workbook = nothing : lo_sheet = nothing
'删除上传的Excel
Call System.IO.file.Delete(ls_file)
System.GC.Collect()
Return "<Root Value=""1"" ResultValue=""导入成功"" />"
ls_err:
lo_Excel.displayAlerts = False
lo_Workbook.Save()
lo_Excel.displayAlerts = True
lo_Workbook.Close()
lo_Excel.Quit()
ReleaseComObject(lo_sheet)
ReleaseComObject(lo_Workbook)
ReleaseComObject(lo_Excel)
lo_Excel = nothing : lo_Workbook = nothing : lo_sheet = nothing
'删除上传的Excel
Call System.IO.file.Delete(ls_file)
System.GC.Collect()
Return "<Root Value=""0"" ResultValue=err.Description />"
End Function
' 当然最重要的是excel的那些东西,不经常接触,比较陌生
'退出Excel,并且释放调用的COM资源
Private Function ExitExcelin(ByVal lo_Excel As Excel.Application,ByVal lo_Workbook As Excel.Workbook,ByVal lo_sheet As Excel.Worksheet,ByVal ls_file As String) As String
lo_Excel.displayAlerts = False
lo_Workbook.Save()
lo_Excel.displayAlerts = True
lo_Workbook.Close()
lo_Excel.Quit()
ReleaseComObject(lo_sheet)
ReleaseComObject(lo_Workbook)
ReleaseComObject(lo_Excel)
lo_Excel = nothing : lo_Workbook = nothing : lo_sheet = nothing
'删除上传的Excel
Call System.IO.file.Delete(ls_file)
System.GC.Collect()
End Function
其实东西就是这些了
附件是代码
这个东西就这样了,不要深究
总结以上是内存溢出为你收集整理的OBPS开发平台――导入功能vb代码解析全部内容,希望文章能够帮你解决OBPS开发平台――导入功能vb代码解析所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)