在下刚刚接触.net,在单位实习, 拿着前面师兄得例子作教程,负责作一个办公自动化程序的功能拓展。从控件的使用开始学习,半个月的时间写出了一个页面。我觉的我的模仿能力很好,编程的思想都是在看动别人程序的基础上模仿的,或者用自己在学校学的C语言的思想,再就是考程序员时学到的一些东西;但在写这个页面的过程中我发现了自己在程序流程控制方面的不足,还有就是对类认识的浅显, 函数调用、变量范围控制的基本功也很差,写程序没有一个总的框架,只是想到什么写什么。用到什么看什么方面的内容,只是在有类似例子的情况下才能快速的深入学习一下,没有一个系统的学习计划。很快就大学毕业了,希望自己有质的提高。
希望高手指教:我在这个阶段怎样学习才能快速的成为一个好的程序员。从个人的发展情空间来看,我应该学什么呢。办公自动化程序的发展前景如何?
谢谢!
QQ:5478740
MSN:[email protected]
(由于长度限制,删除了部分代码) '----------------------------------------------------------------------------------------------------------------- '页面初始代码 '----------------------------------------------------------------------------------------------------------------- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then SqlConnection1.Open()
receivedeptid = Convert.ToString("dsgd1111ads") userid = Convert.ToDouble("af00000sra") username = Convert.ToString("1111").Trim '-------------------------------------------------------------------------------- ddl_year.Items.Add(Convert.ToString(Today().Year - 2)) ddl_year.Items.Add(Convert.ToString(Today().Year - 1)) ddl_year.Items.Add(Convert.ToString(Today().Year)) ddl_year.Items.Add(Convert.ToString(Today().Year + 1)) ddl_year.SelectedIndex = -1 ddl_year.Items.FindByValue(Convert.ToString(Today().Year)).Selected = True BINDGRID() Btn_reg.Enabled = False BindTree() Else Response.Write("<script language=javascript>function init(){document.Form1.page_pos.value = " + Request("page_pos") + "; window.scrollBy(0,document.Form1.page_pos.value); }window.onload=init;</script>") End If End Sub
'--------------------------------------------------------------------- '绑定公文表 '--------------------------------------------------------------------- Private Function BINDGRID() receivedeptid = Convert.ToString("00550000") Dim tpCnt As Integer With New DocumentSystem() tmpDPR = .getDocuArchiveInfo(receivedeptid, Convert.ToString(ddl_year.SelectedItem.Value), "WAIT") End With If tmpDPR.Tables(0).Rows.Count > 0 Then 'Btn_reg.Enabled = True L_tips.Text = "" tpCnt = tmpDPR.Tables(0).Rows.Count \ DG_DPR.PageSize If tmpDPR.Tables(0).Rows.Count Mod DG_DPR.PageSize > 0 Then tpCnt = tpCnt + 1 End If If tpCnt < DG_DPR.PageCount Then If DG_DPR.CurrentPageIndex > tpCnt - 1 Then DG_DPR.CurrentPageIndex = tpCnt - 1 End If End If Else Btn_reg.Enabled = False L_tips.Visible = True L_tips.Text = "现在没有要归档得公文!" End If DG_DPR.DataSource = tmpDPR DG_DPR.DataBind() If tmpDPR.Tables(DocuPublishRegData.DocuPublishReg_TABLE).Rows.Count = 0 Then L_pagecount.Text = "共0页!" IB_first.Visible = False IB_PRE.Visible = False IB_NEXT.Visible = False IB_last.Visible = False Label5.Visible = False TB_pageno.Visible = False Label7.Visible = False IB_first.Enabled = False IB_PRE.Enabled = False IB_NEXT.Enabled = False IB_last.Enabled = False Else IB_first.Visible = True IB_PRE.Visible = True IB_NEXT.Visible = True IB_last.Visible = True Label5.Visible = True TB_pageno.Visible = True Label7.Visible = True IB_first.Enabled = True IB_PRE.Enabled = True IB_NEXT.Enabled = True IB_last.Enabled = True L_pagecount.Text = "第" + Convert.ToString(DG_DPR.CurrentPageIndex + 1) + "页!共" + Convert.ToString(DG_DPR.PageCount) + "页!" If DG_DPR.CurrentPageIndex + 1 = DG_DPR.PageCount Then IB_NEXT.Enabled = False IB_last.Enabled = False End If If DG_DPR.CurrentPageIndex + 1 = 1 Then IB_PRE.Enabled = False IB_first.Enabled = False End If TB_pageno.Text = Convert.ToString(DG_DPR.CurrentPageIndex + 1) End If TB_archive.Text = "" Ddl_Archive.SelectedIndex = -1 End Function
'---------------------------------------------------------------------------------------------------------------- '归档按钮点击触发事件 '---------------------------------------------------------------------------------------------------------------- Private Sub Btn_reg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_reg.Click
Dim i As Integer Dim j As Integer
If Lb_archivevalue.Text = "" Or Lb_archivevalue.Text <> Convert.ToString(Ddl_Archive.SelectedItem.Value) Then '必须初始化对象?
Lb_archivename.Text = "归档不成功,请先选择档案库及案卷!!" Lb_archivename.Visible = True Else Lb_archivename.Visible = False If DG_DPR.Items.Count > 0 Then Dim checkdocuselected As Boolean checkdocuselected = False For i = DG_DPR.Items.Count - 1 To 0 Step -1 Dim tmpDocuid As Double = Convert.ToDouble(DG_DPR.Items(i).Cells(4).Text) Dim deptid As String = Trim(DG_DPR.Items(i).Cells(3).Text) Dim myRemoveCmd As CheckBox = CType(DG_DPR.Items(i).FindControl("cb_dj"), CheckBox) If myRemoveCmd.Checked Then checkdocuselected = True Dim data As DocumentsData With New DocumentSystem() data = .GetDocumentByDocuID(Convert.ToString(tmpDocuid)) End With
'将公文信息(除正文、附件)插入档案系统数据库 '--------------------------------------------- Dim aaa As String Dim bbb As String Dim wid Dim b1 As String Dim a1 As String Dim a2 As String Dim a3 As String Dim a4 As String Dim a5 As String Dim a6 As String Dim a7 As String Dim a8 As String Dim a9 As String Dim a10 As String
b1 = Convert.ToString(Lb_filetablename.Text).Trim a1 = Guid.NewGuid.ToString a2 = Convert.ToString(Lb_archivevalue.Text).Trim a3 = Convert.ToString(data.Tables(0).Rows(0).Item("docutt")).Trim a4 = Convert.ToString(data.Tables(0).Rows(0).Item("keyword")).Trim a5 = Convert.ToString(data.Tables(0).Rows(0).Item("docusigner")).Trim a6 = Convert.ToString(data.Tables(0).Rows(0).Item("writedate")).Trim a7 = Convert.ToString(data.Tables(0).Rows(0).Item("dispatchyear")).Trim a8 = Convert.ToString(data.Tables(0).Rows(0).Item("dispatchdeptname")).Trim() a9 = "正文" a10 = Trim(DG_DPR.Items(i).Cells(1).Text) SqlInsertCommand1.CommandText = "INSERT INTO " & b1 & _ " (guid,relations,subject,mainword,duteman,FileDate,Years,FileComeUnit,TextField,FileNum,flags)" & _ " values ('" & a1 & "','" & a2 & "','" & a3 & "','" & a4 & "','" & a5 & "','" & a6 & "','" & a7 & "','" & a8 & "','" & a9 & "','" & a10 & "',2)"
SqlConnection1.Open() SqlInsertCommand1.ExecuteNonQuery() SqlConnection1.Close()
'确定路径并判断文件夹是否存在 '-------------------------------------------------------- Dim address As String Dim address1 As String address = Lb_filetablename.Text address1 = Convert.ToString(Session("file_save")) address1 = address1 & address If IO.Directory.Exists(address1) = False Then IO.Directory.CreateDirectory(address1) Else End If
'输出公文正文 '------------------------------------------------------- Dim byteData As Byte() byteData = CType(data.Tables(0).Rows(0).Item("docucontent"), Byte()) Dim byteDataSize As Long = byteData.Length Dim filename As String filename = Convert.ToString(data.Tables(0).Rows(0).Item("docutitle")) & Convert.ToString(data.Tables(0).Rows(0).Item("FILETYPE")) Dim fsDoc As FileStream fsDoc = New FileStream(address1 & "\" & filename, FileMode.Create, FileAccess.Write) fsDoc.Write(byteData, 0, byteDataSize) fsDoc.Close()
'输出公文附件 '------------------------------------------------------- Dim data1 As DOCUATTACHData With New DocumentSystem() data1 = .getDocuAttachByDocuid(Convert.ToString(tmpDocuid)) End With Dim aid As String If data1.Tables(0).Rows.Count > 0 Then aid = Convert.ToString(data1.Tables(0).Rows(0).Item("aid")) Dim tmpdocuattachData As DOCUATTACHData With New DocumentSystem() tmpdocuattachData = .getDocuAttachContentByAid(Convert.ToDouble(aid)) End With If tmpdocuattachData.Tables(0).Rows.Count > 0 Then
Dim fname As String For j = 0 To tmpdocuattachData.Tables(0).Rows.Count - 1 byteData = CType(tmpdocuattachData.Tables(0).Rows(j).Item("acontent"), Byte()) byteDataSize = byteData.Length fname = address1 & "\" & Trim(Convert.ToString(tmpdocuattachData.Tables(0).Rows(j).Item("filename"))) fsDoc = New FileStream(fname, FileMode.Create, FileAccess.Write) fsDoc.Write(byteData, 0, byteDataSize) fsDoc.Close() Next End If End If
'修改公文归档状态 '---------------------------------------------------------------------------------------------- Dim dacuphasedata As DocumentPhaseData With New DocumentPhaseSystem() dacuphasedata = .GetDocumentPhaseInfo(Convert.ToDouble(tmpDocuid), "WAIT", "DPGD") End With Dim phasedataid As DocumentPhaseData With New DocumentPhaseSystem() If dacuphasedata.Tables(0).Rows.Count > 0 Then phasedataid = .GetPhaseBySequenceID(Convert.ToDouble(dacuphasedata.Tables(0).Rows(0).Item("sequenceid"))) phasedataid.Tables(0).Rows(0).Item(phasedataid.CurrentStatus_FIELD) = "OVER" phasedataid.Tables(0).Rows(0).Item(phasedataid.HandlerID_FIELD) = Convert.ToDouble(Session("userid")) phasedataid.Tables(0).Rows(0).Item(phasedataid.Handler_FIELD) = Convert.ToString(Session("username"))
' phasedataid.Tables(0).Rows(0).Item(phasedataid.CurrentStatus_FIELD) = "WAIT" ' phasedataid.Tables(0).Rows(0).Item(phasedataid.HandlerID_FIELD) = System.DBNull.Value 'Convert.ToDouble(Session("userid")) ' phasedataid.Tables(0).Rows(0).Item(phasedataid.Handler_FIELD) = System.DBNull.Value 'Convert.ToString(Session("username")) End If End With Dim updata As Boolean With New DocumentPhaseSystem() updata = .updateDocumentPhase(phasedataid) If updata = True Then Lb_archivename.Text = "归档成功!" Lb_archivename.Visible = True End If End With End If Next If checkdocuselected = False Then Lb_archivename.Text = "归档不成功,请先选择要归档的公文!" Lb_archivename.Visible = True End If
End If
End If BINDGRID() End Sub
'---------------------------------------------------------------------------------------------------------------- '绑定树结点 '----------------------------------------------------------------------------------------------------------------
'--------------------------------------------------------------------- 'TreeView1触发事件 '--------------------------------------------------------------------- Private Sub TreeView1_SelectedIndexChange(ByVal sender As System.Object, ByVal e As Microsoft.Web.UI.WebControls.TreeViewSelectEventArgs) Handles TreeView1.SelectedIndexChange Btn_reg.Enabled = True Lb_tablename.Text = Convert.ToString(TreeView1.GetNodeFromIndex(e.NewNode).NodeData).Trim Dim aaa As String '参数“Length”必须大于或等于零!!! aaa = Convert.ToString(Lb_tablename.Text).Trim Dim bbb As Integer bbb = aaa.Length() If bbb >= 2 Then Lb_filetablename.Text = "F_" & Right(aaa, bbb - 2) Lb_filetablename.Text = Convert.ToString(Lb_filetablename.Text).Trim Else Lb_tablename.Text = "" End If Lb_archivename.Visible = False bindarchive("", Convert.ToString(Lb_tablename.Text)) End Sub
'-------------------------------------------------------------------------------------------------------------------- '给Ddl_Archive下拉列表框绑定案卷数据 '-------------------------------------------------------------------------------------------------------------------- Private Function bindarchive(ByVal serch As String, ByVal tablename As String) Ddl_Archive.Items.Clear() Dim cataitem1 As New ListItem() cataitem1.Text = "" cataitem1.Value = "" Ddl_Archive.Items.Add(cataitem1) Ddl_Archive.SelectedIndex = -1 If tablename <> "" Then Try SqlDataAdapter1.SelectCommand.CommandText = " SELECT subject ,guid FROM " & tablename & " where subject like '%" & serch & "%' ORDER BY subject" SqlDataAdapter1.Fill(DataSet11, "Sys_UserTable7") If DataSet11.Tables("sys_userTable7").Rows.Count > 0 Then Dim i As Integer For i = 0 To DataSet11.Tables("Sys_UserTable7").Rows.Count - 1 Dim cataitem As New ListItem() cataitem.Text = Convert.ToString(DataSet11.Tables("Sys_UserTable7").Rows(i).Item("subject")) cataitem.Value = Convert.ToString(DataSet11.Tables("Sys_UserTable7").Rows(i).Item("guid")) Ddl_Archive.Items.Add(cataitem) Ddl_Archive.SelectedIndex = -1 Next DataSet11.Tables("Sys_UserTable7").Clear() End If Catch End Try End If End Function
'--------------------------------------------------------------------- '“查询案卷”按钮点击触发事件 '--------------------------------------------------------------------- Private Sub bt_archiveserch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bt_archiveserch.Click bindarchive(Convert.ToString(TB_archive.Text).Trim, Convert.ToString(Lb_tablename.Text).Trim) Lb_archivename.Visible = False End Sub
'-------------------------------------------------------------------------------------------------------------------------- '(下拉列表框)案卷改变触发事件 '-------------------------------------------------------------------------------------------------------------------------- Private Sub Ddl_Archive_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ddl_Archive.SelectedIndexChanged Lb_archivevalue.Text = Convert.ToString(Ddl_Archive().SelectedItem().Value()).Trim Lb_archivename.Visible = False Btn_reg.Enabled = True End Sub
'--------------------------------------------------------------------- '改变年份下拉列表框触发事件 '--------------------------------------------------------------------- Private Sub ddl_year_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ddl_year.SelectedIndexChanged BINDGRID() End Sub End Class
End Namespace

|