源代码参考
源代码清单
附录:主要窗体的源代码:1:订房信息窗体的源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc As ADODB.RecordsetPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer)Dim mrcc As ADODB.RecordsetDim intCount As IntegerDim MsgText As StringIf gintBmode = 1 ThenIf Index = 0 ThentxtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "' and putup <> '是'"Set mrcc = ExecuteSQL(txtSQL, MsgText)For intCount = 1 To 3cboItem(intCount).ClearcboItem(intCount).AddItem mrcc.Fields(intCount)cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = mrcc.Fields(5)mrcc.CloseEnd IfEnd IfEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And cmdSave.Enabled ThenIf MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then'保存Call cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc As ADODB.RecordsetDim MsgText As StringFor intCount = 0 To 3If Trim(txtItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "顾客姓名"Case 1sMeg = "身份证号码"Case 2sMeg = "折扣"Case 3sMeg = "入住时间"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountFor intCount = 0 To 3If Trim(cboItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "客房编号"Case 1sMeg = "客房种类"Case 2sMeg = "客房位置"Case 3sMeg = "客房单价"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告"cboItem(intCount).SetFocusExit SubEnd IfNext intCountIf IsDate(txtItem(2)) ThentxtItem(2) = Format(txtItem(2), "yyyy-mm-dd")ElseMsgBox "入库时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"txtItem(2).SetFocusExit SubEnd IfFor intCount = 1 To 3 Step 2If Not IsNumeric(txtItem(intCount)) ThenMsgBox "请输入数字", vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountIf gintBmode = 2 ThentxtSQL = "delete from bookin where bookno = '" & Trim(txtNo) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)End IftxtSQL = "select * from bookin"Set mrcc = ExecuteSQL(txtSQL, MsgText)mrcc.AddNewmrcc.Fields(0) = txtNoFor intCount = 0 To 1mrcc.Fields(intCount + 1) = txtItem(intCount)Next intCountmrcc.Fields(3) = cboItem(0)For intCount = 2 To 4mrcc.Fields(intCount + 2) = txtItem(intCount)Next intCountmrcc.Fields(8) = 0mrcc.Updatemrcc.ClosetxtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not mrcc.EOF Thenmrcc!putup = "y"End Ifmrcc.Updatemrcc.CloseIf gintBmode = 1 ThenMsgBox "添加订房信息成功!", vbOKOnly + vbExclamation, "添加订房消息"Unload MeIf flagBedit ThenUnload frmBookinEnd IffrmBookin.txtSQL = "select bookno,customname,customID,roomno,indate,discount,inmemo from bookin where ammount = '0'"frmBookin.ShowElseMsgBox "修改订房信息成功!", vbOKOnly + vbExclamation, "修改订房消息"Unload MeIf flagBedit ThenUnload frmBookinEnd IffrmBookin.txtSQL = "select bookno,customname,customID,roomno,indate,discount,inmemo from bookin where ammount = '0'"frmBookin.ShowEnd IfEnd SubPrivate Sub Form_Load()Dim sSql As StringDim intCount As IntegerDim MsgText As StringIf flagSedit ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenFor intCount = 0 To 3cboItem(intCount).AddItem mrc.Fields(intCount)cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = mrc.Fields(5)End Ifmrc.ClosetxtNo = GetRkno()gintBmode = 1ElseIf gintBmode = 1 ThenMe.Caption = Me.Caption & "添加"'初始化客房信息txtSQL = "select DISTINCT roomNO from rooms where putup <> 'y'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenDo While Not mrc.EOFcboItem(0).AddItem Trim(mrc.Fields(0))mrc.MoveNextLoopElseMsgBox "请先进行客房登记!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrc.ClosetxtNo = GetRknoElseIf gintBmode = 2 ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenWith mrctxtNo = !booknoFor intCount = 0 To 1If Not IsNull(.Fields(intCount + 1)) ThentxtItem(intCount) = .Fields(intCount + 1)End IfNext intCountcboItem(0).AddItem !roomnocboItem(0).ListIndex = 0For intCount = 2 To 4If Not IsNull(.Fields(intCount + 2)) ThentxtItem(intCount) = .Fields(intCount + 2)End IfNext intCountEnd WithEnd Ifmrc.CloseMe.Caption = Me.Caption & "修改"txtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenFor intCount = 1 To 3cboItem(intCount).AddItem mrc.Fields(intCount)cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = mrc.Fields(5)End Ifmrc.CloseEnd IfmblChange = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)gintBmode = 0End SubPrivate Sub txtItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End SubPrivate Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd Sub2:订房信息查询窗体源代码:Option Explicit'用于传递查询块Private Sub chkItem_Click(Index As Integer)If Index = 2 ThencboYear(0).SetFocusElsetxtItem(Index).SetFocusEnd IfEnd SubPrivate Sub cmdExit_Click()Me.HideEnd SubPrivate Sub cmdOK_Click()Dim dBeginDate As StringDim sQSql As StringIf chkItem(0).Value = vbChecked ThensQSql = " customname = '" & Trim(txtItem(0) & " ") & "'"End IfIf chkItem(1).Value = vbChecked ThenIf Trim(sQSql & " ") = "" ThensQSql = " roomno ='" & Trim(txtItem(1) & " ") & "'"ElsesQSql = sQSql & " and roomno ='" & Trim(txtItem(1) & " ") & "'"End IfEnd IfIf chkItem(2).Value = vbChecked ThendBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")If Trim(sQSql & " ") = "" ThensQSql = " indate ='" & dBeginDate & "'"ElsesQSql = sQSql & " and indate ='" & dBeginDate & "'"End IfEnd IfIf Trim(sQSql) = "" ThenMsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告"Exit SubElseIf flagBedit ThenUnload frmBookinEnd IffrmBookin.txtSQL = "selectbookno,customname,customID,roomno,indate,discount,inmemo from bookin where ammount = '0' and " & sQSqlfrmBookin.ShowEnd IfMe.HideEnd SubPrivate Sub Form_Load()Dim i As IntegerDim j As IntegerDim sSql As StringDim txtSQL As StringDim MsgText As StringDim mrc As ADODB.RecordsettxtSQL = "select distinct datepart(yy,indate) from bookin where ammount = '0' "Set mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenWith mrcDo While Not .EOFcboYear(0).AddItem .Fields(0).MoveNextLoopEnd WithcboYear(0).ListIndex = 0For j = 1 To 12cboMonth(0).AddItem jNext jcboMonth(0).Text = Month(Now())For j = 1 To 31cboDay.AddItem jNext jcboDay.Text = Day(Now())ElsecmdOk.Enabled = FalseEnd Ifmrc.CloseEnd SubPrivate Sub lblitem_Click(Index As Integer)chkItem(Index).Value = vbCheckedEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End Sub3:订房信息列表窗体源代码:Option ExplicitPublic txtSQL As StringDim mrc As ADODB.RecordsetDim MsgText As StringPrivate Sub Form_Load()ShowTitleShowDataflagBedit = TrueEnd SubPrivate Sub Form_Resize()If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then '边界处理If Me.ScaleHeight < 10 * lblTitle.Height ThenExit SubEnd IfIf Me.ScaleWidth < lblTitle.Width + lblTitle.Width / 2 ThenExit SubEnd If'控制控件的位置lblTitle.Top = lblTitle.HeightlblTitle.Left = (Me.Width - lblTitle.Width) / 2msgList.Top = lblTitle.Top + lblTitle.Height + lblTitle.Height / 2msgList.Width = Me.ScaleWidth - 200msgList.Left = Me.ScaleLeft + 100msgList.Height = Me.ScaleHeight - msgList.Top - 200 End IfEnd SubPublic Sub FormClose()Unload MeEnd Sub'删除记录Private Sub Form_Unload(Cancel As Integer)flagBedit = FalsegintBmode = 0End Sub'显示Grid的内容Private Sub ShowData()Dim j As IntegerDim i As IntegerSet mrc = ExecuteSQL(txtSQL, MsgText)With msgList.Rows = 1Do While Not mrc.EOF.Rows = .Rows + 1For i = 1 To mrc.Fields.CountSelect Case mrc.Fields(i - 1).TypeCase adDBDate.TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")Case Else.TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""End SelectNext imrc.MoveNextLoopEnd Withmrc.CloseEnd Sub'显示Grid表头Private Sub ShowTitle()Dim i As IntegerWith msgList.Cols = 8.TextMatrix(0, 1) = "".TextMatrix(0, 2) = "顾客姓名".TextMatrix(0, 3) = "身份证号码".TextMatrix(0, 4) = "房间编号".TextMatrix(0, 5) = "入住日期".TextMatrix(0, 6) = "折扣".TextMatrix(0, 7) = "备注"'固定表头.FixedRows = 1'设置各列的对齐方式For i = 0 To 7.ColAlignment(i) = 0Next i'表头项居中.FillStyle = flexFillRepeat.Col = 0.Row = 0.RowSel = 1.ColSel = .Cols - 1.CellAlignment = 4'设置单元大小.ColWidth(0) = 300.ColWidth(1) = 0.ColWidth(2) = 1000.ColWidth(3) = 2000.ColWidth(4) = 2000.ColWidth(5) = 1000.ColWidth(6) = 1000.ColWidth(7) = 600.Row = 1End WithEnd SubPrivate Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) '右键弹出If Button = 2 And Shift = 0 ThenPopupMenu fMainForm.menuBookinEnd IfEnd Sub4:结算信息窗体源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc As ADODB.RecordsetPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer)Dim sSql As StringDim MsgText As StringDim mrcc As ADODB.RecordsetDim intCount As IntegerIf gintCmode = 1 Then'初始化员工名称和IDIf Index = 0 ThencboItem(1).Enabled = TruecboItem(2).Enabled = TruecboItem(3).Enabled = TruecboItem(1).ClearcboItem(2).ClearcboItem(3).CleartxtSQL = "select roomNO,roomtype,roomposition,roomprice from rooms where roomNO ='" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not mrcc.EOF ThencboItem(1).AddItem mrcc!roomtypecboItem(2).AddItem mrcc!roompositioncboItem(3).AddItem mrcc!roompricecboItem(1).Enabled = FalsecboItem(2).Enabled = FalsecboItem(3).Enabled = FalsecboItem(1).ListIndex = 0cboItem(2).ListIndex = 0cboItem(3).ListIndex = 0cmdSave.Enabled = TrueElseMsgBox "没有订房信息!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrcc.ClosetxtSQL = "select * from bookin where ammount = '0' and roomno = '" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not mrcc.EOF ThentxtNo = mrcc!booknotxtItem(0) = mrcc!customnametxtItem(1) = mrcc!customIDtxtItem(2) = mrcc!indatetxtItem(3) = mrcc!discounttxtItem(5) = mrcc!inmemoFor intCount = 0 To 3txtItem(intCount).Enabled = FalseNext intCountEnd Ifmrcc.CloseEnd IfEnd IfExit SubEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And cmdSave.Enabled ThenIf MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then'保存Call cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc As ADODB.RecordsetDim MsgText As StringDim bYear As IntegerDim eYear As IntegerDim bDays As IntegerDim eDays As IntegerDim aDays As IntegerDim amMount As DoubleIf Trim(txtItem(4) & " ") = "" ThenMsgBox sMeg, vbOKOnly + vbExclamation, "警告"txtItem(4).SetFocusExit SubEnd IfIf IsDate(txtItem(4)) ThentxtItem(4) = Format(txtItem(4), "yyyy-mm-dd")ElseMsgBox "入库时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"txtItem(4).SetFocusExit SubEnd If'再加入新记录txtSQL = "select * from bookin where bookno = '" & Trim(txtNo) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)mrcc.Fields(6) = txtItem(5)mrcc.Fields(7) = txtItem(4)bYear = DatePart("yyyy", txtItem(2))eYear = DatePart("yyyy", txtItem(4))bDays = DatePart("y", txtItem(2))eDays = DatePart("y", txtItem(4))If bYear = eYear ThenaDays = eDays - bDaysElseaDays = (eYear - bYear - 1) * 365 + (365 - bDays) + eDaysEnd Ifmrcc.Fields(8) = aDays * Trim(cboItem(3)) * Trim(txtItem(3)) / 100amMount = aDays * Trim(cboItem(3)) * Trim(txtItem(3)) / 100mrcc.Updatemrcc.ClosetxtSQL = "select * from rooms where roomNO = '" & cboItem(0) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not mrcc.EOF Thenmrcc!putup = " "End Ifmrcc.Updatemrcc.CloseIf gintCmode = 1 ThenUnload MemblChange = FalseMsgBox "金额为" & amMount & "元,结算完毕!", vbOKOnly + vbExclamation, "添加结算信息"If flagCedit ThenUnload frmCheckoutEnd IffrmCheckout.txtSQL = "select * from bookin where ammount <> '0'"frmCheckout.ShowElseIf gintCmode = 2 ThenMsgBox "金额为" & amMount & "元,结算信息修改完毕!", vbOKOnly + vbExclamation, "修改结算信息"Unload MeIf flagCedit ThenUnload frmCheckoutEnd IffrmCheckout.txtSQL = "select * from bookin where ammount <> '0'"frmCheckout.ShowEnd IfEnd SubPrivate Sub Form_Load()Dim sSql As StringDim intCount As IntegerDim MsgText As StringIf gintCmode = 1 ThenMe.Caption = Me.Caption & "添加"'初始化物资名称txtSQL = "select DISTINCT roomno from bookin where ammount = '0'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenDo While Not mrc.EOFcboItem(0).AddItem Trim(mrc!roomno)mrc.MoveNextLoopElseMsgBox "没有顾客入住!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrc.CloseElseIf gintCmode = 2 ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenWith mrctxtNo = mrc.Fields(0)For intCount = 0 To 1txtItem(intCount) = .Fields(intCount + 1)Next intCountcboItem(0).AddItem .Fields(3)cboItem(0).ListIndex = 0For intCount = 2 To 3If Not IsNull(.Fields(intCount + 2)) ThentxtItem(intCount) = .Fields(intCount + 2)End IfNext intCounttxtItem(5) = .Fields(6)txtItem(4) = .Fields(7)End WithEnd Ifmrc.ClosetxtSQL = "select * from rooms where roomNO = '" & cboItem(0) & "'" Set mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenWith mrcFor intCount = 1 To 3cboItem(intCount).AddItem .Fields(intCount)cboItem(intCount).ListIndex = 0Next intCountEnd WithEnd Ifmrc.CloseFor intCount = 0 To 3txtItem(intCount).Enabled = FalseNext intCountMe.Caption = Me.Caption & "修改"End IfmblChange = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)gintCmode = 0End SubPrivate Sub txtItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End SubPrivate Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd Sub5:结算信息查询窗体源代码:Option Explicit'用于传递查询块Private Sub chkItem_Click(Index As Integer)If Index = 2 ThencboYear(0).SetFocusElsetxtItem(Index).SetFocusEnd IfEnd SubPrivate Sub cmdExit_Click()Me.HideEnd SubPrivate Sub cmdOK_Click()Dim dBeginDate As StringDim sQSql As StringIf chkItem(0).Value = vbChecked ThensQSql = " customname = '" & Trim(txtItem(0) & " ") & "'"End IfIf chkItem(1).Value = vbChecked ThenIf Trim(sQSql & " ") = "" ThensQSql = " roomno ='" & Trim(txtItem(1) & " ") & "'"ElsesQSql = sQSql & " and roomno ='" & Trim(txtItem(1) & " ") & "'"End IfEnd IfIf chkItem(2).Value = vbChecked ThendBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")If Trim(sQSql & " ") = "" ThensQSql = " indate ='" & dBeginDate & "'"ElsesQSql = sQSql & " and indate ='" & dBeginDate & "'"End IfEnd IfIf Trim(sQSql) = "" ThenMsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告"Exit SubElseIf flagBedit ThenUnload frmCheckoutEnd IffrmCheckout.txtSQL = "select * from bookin where ammount <> '0' and " & sQSqlfrmCheckout.ShowEnd IfMe.HideEnd SubPrivate Sub Form_Load()Dim i As IntegerDim j As IntegerDim sSql As StringDim txtSQL As StringDim MsgText As StringDim mrc As ADODB.RecordsettxtSQL = "select distinct datepart(yy,indate) from bookin where ammount <> '0'"Set mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenWith mrcDo While Not .EOFcboYear(0).AddItem .Fields(0).MoveNextLoopEnd WithcboYear(0).ListIndex = 0For j = 1 To 12cboMonth(0).AddItem jNext jcboMonth(0).Text = Month(Now())For j = 1 To 31cboDay.AddItem jNext jcboDay.Text = Day(Now())ElsecmdOk.Enabled = FalseEnd Ifmrc.CloseEnd SubPrivate Sub lblitem_Click(Index As Integer)chkItem(Index).Value = vbCheckedEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End Sub6:结算信息列表窗体源代码:Option ExplicitPublic txtSQL As StringDim mrc As ADODB.RecordsetDim MsgText As StringPrivate Sub Form_Load()ShowTitleShowDataflagCedit = TrueEnd SubPrivate Sub Form_Resize()If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then '边界处理If Me.ScaleHeight < 10 * lblTitle.Height ThenExit SubEnd IfIf Me.ScaleWidth < lblTitle.Width + lblTitle.Width / 2 ThenExit SubEnd If'控制控件的位置lblTitle.Top = lblTitle.HeightlblTitle.Left = (Me.Width - lblTitle.Width) / 2msgList.Top = lblTitle.Top + lblTitle.Height + lblTitle.Height / 2msgList.Width = Me.ScaleWidth - 200msgList.Left = Me.ScaleLeft + 100msgList.Height = Me.ScaleHeight - msgList.Top - 200 End IfEnd SubPublic Sub FormClose()Unload MeEnd SubPrivate Sub Form_Unload(Cancel As Integer)flagCedit = FalsegintCmode = 0End Sub'显示Grid的内容Private Sub ShowData()Dim j As IntegerDim i As IntegerSet mrc = ExecuteSQL(txtSQL, MsgText)With msgList.Rows = 1Do While Not mrc.EOF.Rows = .Rows + 1For i = 1 To mrc.Fields.CountSelect Case mrc.Fields(i - 1).TypeCase adDBDate.TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")Case Else.TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""End SelectNext imrc.MoveNextLoopEnd Withmrc.CloseEnd Sub'显示Grid表头Private Sub ShowTitle()Dim i As IntegerWith msgList.Cols = 10.TextMatrix(0, 1) = "".TextMatrix(0, 2) = "顾客姓名".TextMatrix(0, 3) = "身份证号码".TextMatrix(0, 4) = "房间编号".TextMatrix(0, 5) = "入住日期".TextMatrix(0, 6) = "折扣".TextMatrix(0, 7) = "备注信息".TextMatrix(0, 8) = "结算日期".TextMatrix(0, 9) = "金额"'固定表头.FixedRows = 1'设置各列的对齐方式For i = 0 To 9.ColAlignment(i) = 0Next i'表头项居中.FillStyle = flexFillRepeat.Col = 0.Row = 0.RowSel = 1.ColSel = .Cols - 1.CellAlignment = 4'设置单元大小.ColWidth(0) = 300.ColWidth(1) = 0.ColWidth(2) = 1000.ColWidth(3) = 2000.ColWidth(4) = 2000.ColWidth(5) = 2000.ColWidth(6) = 2000.ColWidth(7) = 2000.ColWidth(8) = 2000.ColWidth(9) = 1000.Row = 1End WithEnd SubPrivate Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) '右键弹出If Button = 2 And Shift = 0 ThenPopupMenu fMainForm.menuCheckoutEnd IfEnd Sub7:客房信息窗体源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc As ADODB.RecordsetPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer)Dim sSql As StringDim MsgText As StringDim mrcc As ADODB.Recordset'初始化员工名称和IDIf Index = 0 ThentxtSQL = "select typename,price from roomtype where typename='" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not mrcc.EOF ThentxtItem(2) = mrcc!pricecmdSave.Enabled = TrueElseMsgBox "请先建立客房标准!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrcc.CloseEnd IfExit SubEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And cmdSave.Enabled ThenIf MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then'保存Call cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc As ADODB.RecordsetDim MsgText As StringFor intCount = 0 To 3If Trim(txtItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "客房编号"Case 1sMeg = "客房位置"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountIf gintRmode = 1 ThentxtSQL = "select * from rooms where roomNO='" & Trim(txtItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)If mrc.EOF = False ThenMsgBox "已经存在此客房编号的记录!", vbOKOnly + vbExclamation, "警告"txtItem(0).SetFocusExit SubEnd Ifmrc.CloseEnd IfIf gintRmode = 2 Then'先删除已有记录txtSQL = "delete from rooms where roomNO='" & Trim(txtItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)End If'再加入新记录txtSQL = "select * from rooms"Set mrc = ExecuteSQL(txtSQL, MsgText)mrc.AddNewmrc.Fields(0) = Trim(txtItem(0))mrc.Fields(1) = Trim(cboItem(0))For intCount = 1 To 2If Trim(txtItem(intCount) & " ") = "" Thenmrc.Fields(intCount + 1) = NullElsemrc.Fields(intCount + 1) = Trim(txtItem(intCount))End IfNext intCountmrc.Fields(4) = " "mrc.Fields(5) = Trim(txtItem(3))mrc.Updatemrc.CloseIf gintRmode = 1 ThenFor intCount = 0 To 3txtItem(intCount) = ""Next intCountmblChange = FalseIf flagRedit ThenUnload frmRoomfrmRoom.txtSQL = "select * from rooms"frmRoom.ShowEnd IfElseIf gintRmode = 2 ThenUnload MeIf flagRedit ThenUnload frmRoomEnd IffrmRoom.txtSQL = "select * from rooms"frmRoom.ShowEnd IfEnd SubPrivate Sub Form_Load()Dim sSql As StringDim intCount As IntegerDim MsgText As StringDim mrcc As ADODB.RecordsetIf gintRmode = 1 ThenMe.Caption = Me.Caption & "添加"'初始化物资名称txtSQL = "select DISTINCT typename from roomtype"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenDo While Not mrc.EOFcboItem(0).AddItem Trim(mrc.Fields(0))mrc.MoveNextLoopcboItem(0).ListIndex = 0ElseMsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrc.CloseElseIf gintRmode = 2 ThenSet mrcc = ExecuteSQL(txtSQL, MsgText)If mrcc.EOF = False ThenWith mrcctxtItem(0) = .Fields(0)For intCount = 1 To 2If Not IsNull(.Fields(intCount + 1)) ThentxtItem(intCount) = .Fields(intCount + 1)End IfNext intCounttxtItem(3) = .Fields(5)txtSQL = "select DISTINCT typename from roomtype"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not mrc.EOF ThenDo While Not mrc.EOFcboItem(0).AddItem Trim(mrc.Fields(0))mrc.MoveNextLoopcboItem(0).ListIndex = 0ElseMsgBox "请先进行客房标准设置!", vbOKOnly + vbExclamation, "警告"cmdSave.Enabled = FalseExit SubEnd Ifmrc.CloseEnd WithEnd Ifmrcc.CloseMe.Caption = Me.Caption & "修改"End IfmblChange = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)gintRmode = 0End SubPrivate Sub txtItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End SubPrivate Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) EnterToTab KeyCodeEnd Sub8:客房信息查询窗体源代码:Option Explicit'用于传递查询块。
247个python 案例 源码
Python作为一种高级编程语言,被广泛应用于数据分析、人工智能、Web开发等领域。
通过阅读Python案例源码,我们可以深入了解Python的语法、特性和应用方式。
在本文中,我们将共享247个Python案例源码,希望能够帮助大家更好地理解Python编程。
一、Python语法基础1. Hello World```pythonprint("Hello World")```2. 变量赋值```pythonname = "张三"age = 18```3. 条件语句```pythonif x > 0:print("x是正数")else:print("x是负数或零")```4. 循环语句```pythonfor i in range(5):print(i)```5. 函数定义```pythondef add(x, y):return x + y```6. 列表操作```pythonnumbers = [1, 2, 3, 4, 5]```7. 字典操作```pythonperson = {'name': '张三', 'age': 18}```8. 字符串操作```pythons = "Hello, World"```9. 文件操作```pythonwith open('file.txt', 'r') as f: content = f.read()```10. 异常处理```pythontry:x = 1 / 0except ZeroDivisionError: print("除零错误")```二、数据分析与处理11. 数据读取```pythonimport pandas as pddata = pd.read_csv('data.csv') ```12. 数据清理```pythondata.dropna()```13. 数据筛选```pythondata[data['age'] > 30]```14. 数据聚合```pythondata.groupby('sex').mean() ```15. 数据可视化```pythonimport matplotlib.pyplot as pltplt.plot(data['x'], data['y'])```三、Web开发16. Flask框架搭建```pythonfrom flask import Flaskapp = Flask(__name__)app.route('/')def index():return "Hello, World!"if __name__ == '__m本人n__':app.run()```17. Django框架搭建```pythonfrom django.shortcuts import renderfrom django.网络协议 import HttpResponsedef index(request):return HttpResponse("Hello, World!")```18. 数据库操作```pythonimport sqlite3conn = sqlite3.connect('test.db')```19. 模板引擎```pythonrender_template('index.html', name=name) ```20. 表单处理```pythonif request.method == 'POST':process_form_data()```四、人工智能21. 机器学习```pythonfrom sklearn import svm model = svm.SVC()```22. 深度学习```pythonimport torchmodel = torch.nn.Sequential() ```23. 自然语言处理```pythonimport nltknltk.download('punkt')```24. 图像处理```pythonimport cv2image = cv2.imread('image.jpg')25. 语音处理```pythonimport speech_recognition as srr = sr.Recognizer()with sr.Microphone() as source:audio = r.listen(source)```五、网络编程26. TCP服务器```pythonimport socketserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ```27. TCP客户端```pythonclient = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client.connect(('127.0.0.1', 8888))28. UDP服务器```pythonserver = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) server.bind(('127.0.0.1', 9999))```29. UDP客户端```pythonclient = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) client.sendto(b'hello', ('127.0.0.1', 9999))```30. HTTP请求```pythonimport requestsresponse = requests.get('xxx```六、系统管理31. 文件操作```pythonimport osos.mkdir('test')```32. 进程管理```pythonimport subprocessresult = subprocess.run(['ls', '-l'], stdout=subprocess.PIPE) ```33. 网络配置```pythonimport netifacesnetifaces.interfaces()```34. 日志记录```pythonimport logginglogging.basicConfig(filename='example.log',level=logging.DEBUG)```35. 定时任务```pythonimport scheduleschedule.every().day.at("10:30").do(job)```七、其他实用工具36. 数据加密```pythonimport hashlibhashlib.md5('xxx'.encode('utf-8')).hexdigest() ```37. 数据压缩```pythonimport zlibcompressed_data = zlibpress('Hello, World') ```38. 数据解压```pythonoriginal_data = zlib.dpresspressed_data)```39. 日期时间处理```pythonimport datetimedt = datetime.datetime.now()```40. 邮件发送```pythonimport smtplibserver = smtplib.SMTP('smtp.example', 25)```八、总结通过阅读以上247个Python案例源码,我们不仅可以加深对Python 编程语言的理解,还可以学习到Python在不同领域的应用方式。
C语言代码大全
------------------------------------------------------------------------摘自宋鲁生程序设计大赛乘法口诀表#include <stdio.h>#include <conio.h>void main(void){int i,j,x,y;clrscr();printf("\n\n * * * 乘法口诀表* * * \n\n");x=9;y=5;for(i=1;i<=9;i++){gotoxy(x,y);printf("%2d ",i);x+=3;}x=7;y=6;for(i=1;i<=9;i++){gotoxy(x,y);printf("%2d ",i);y++;}x=9;y= 6;for(i=1;i<=9;i++){for(j=1;j<=9;j++){gotoxy(x,y);printf("%2d ",i*j);y++;}y-=9;x+=3;}printf("\n\n");}用一维数组统计学生成绩#include <stdio.h>void main(){char SelectKey,CreditMoney,DebitMoney;while(1){do{clrscr();puts("=========================");puts("| Please select key: |");puts("| 1. Quary |");puts("| 2. Credit |");puts("| 3. Debit |");puts("| 4. Return |");puts("=========================");SelectKey = getch();}while( SelectKey!='1' && SelectKey!='2' && SelectKey!='3' &&SelectKey!='4' );switch(SelectKey){case '1':clrscr();puts("================================");puts("| Your balance is $1000. |");puts("| Press any key to return... |");puts("================================");getch();break;case '2':do{clrscr();puts("==================================");puts("| Please select Credit money: |");puts("| 1. $50 |");puts("| 2. $100 |");puts("| 3. Return |");puts("==================================");CreditMoney = getch();}while( CreditMoney!='1' && CreditMoney!='2' && CreditMoney!='3' );switch(CreditMoney){case '1':clrscr();puts("=========================================");puts("| Your Credit money is $50,Thank you! |");puts("| Press any key to return... |");puts("=========================================");getch();break;case '2':clrscr();puts("==========================================");puts("| Your Credit money is $100,Thank you! |");puts("| Press any key to return... |");puts("==========================================");getch();break;case '3':break;}break;case '3':do{clrscr();puts("====================================");puts("| Please select Debit money: |");puts("| 1. $50 |");puts("| 2. $100 |");puts("| 3. $500 |");puts("| 4. $1000 |");puts("| 5. Return |");puts("====================================");DebitMoney = getch();}while( DebitMoney!='1' && DebitMoney!='2' && DebitMoney!='3' &&DebitMoney!='4' && DebitMoney!='5' );switch(DebitMoney){case '1':clrscr();puts("===========================================");puts("| Your Debit money is $50,Thank you! |");puts("| Press any key to return... |");puts("===========================================");getch();break;case '2':clrscr();puts("===========================================");puts("| Your Debit money is $100,Thank you! |");puts("| Press any key to return... |");puts("===========================================");getch();break;case '3':clrscr();puts("===========================================");puts("| Your Debit money is $500,Thank you! |");puts("| Press any key to return... |");puts("===========================================");getch();break;case '4':clrscr();puts("===========================================");puts("| Your Debit money is $1000,Thank you! |");puts("| Press any key to return... |");puts("===========================================");getch();break;case '5':break;}break;case '4':clrscr();puts("================================");puts("| Thank you for your using! |");puts("| Good bye! |");puts("================================");return;}}模拟ATM(自动柜员机)界面#include <stdio.h> void main(){int Password=0,Number=0,price=58,i=0;while( Password != 1234 ){if( i >= 3 )return;i++;puts("Please input Password: ");scanf("%d",&Password);}i=0;while( Number!=price ){do{puts("Please input a number between 1 and 100: ");scanf("%d",&Number);printf("Your input number is %d\n",Number);}while( !(Number>=1 && Number<=100) );if( Number >= 90 ){printf("Too Bigger! Press any key to try again!\n");}else if( Number >= 70 && Number < 90 ){printf("Bigger!\n");}else if( Number >= 1 && Number <= 30 ){printf("Too Small! Press any key to try again!\n");}else if( Number > 30 && Number <= 50 ){printf("Small! Press any key to try again!\n");}else{if( Number == price ){printf("OK! You are right! Bye Bye!\n");}else if( Number < price ){printf("Sorry,Only a little smaller! Press any key to try again!\n");}else if( Number > price ){printf(" Sorry, Only a little bigger! Press any key to try again!\n");}getch();}}用二维数组实现矩阵转置/* 用二维数组实现矩阵的转置*/#include <stdio.h>#define ROW 3#define COL 4main(){int matrixA[ROW][COL],matrixB[COL][ROW];int i,j; clrscr();printf("Enter elements of the matrixA,");printf("%d*%d:\n",ROW,COL);for( i=0; i<ROW; i++ ){for( j=0; j<COL; j++ ){scanf("%d",&matrixA[i][j]);}}for( i=0; i<ROW; i++ ){for( j=0; j<COL; j++ ){matrixB[j][i] = matrixA[i][j];}}printf("MatrixB,");printf("%d*%d:\n",COL,ROW);for( i=0; i<COL; i++ ){for( j=0; j<ROW; j++ ){printf("%8d",matrixB[i][j]);}printf("\n");}printf("\n Press Any Key to Quit... \n");getch();}求解二维数组的最大/最小元素#define MAXN 20int a[MAXN][MAXN];main(){int min, /* 存储最小值*/max; /* 存储最大值*/int row,col,n;clrscr();printf("Please input the order of the matrix:\n");/* 输入方阵的阶次*/ scanf("%d",&n);printf("Please input the elements of the matrix,\n from a[0][0] to a[%d][%d]:\n",n-1,n-1);for(row=0;row<n;row++)for(col=0;col<n;col++)scanf("%d",&a[row][col]);for(min=a[0][0],row=0;row<n;row++){/* 从每行选出最大数*/for(max=a[row][0],col=1;col<n;col++)/*从row行选出最大数*/if(max<a[row][col])max=a[row][col];if(min>max)/* 保存至row行的最小数*/min=max;}printf("The minimum of maximum number is %d\n",min);for(max=a[0][0],row=0;row<n;row++){/* 每行选出最小数*/for(min=a[row][0],col=1;col<n;col++)/* 从row行选出最小数*/ if(min>a[row][col])min=a[row][col];if(max<min)/*保存至row行的最大数*/max=min;}printf("The maximum of minimum numbers is %d\n",max);printf("\nPress any key to quit...\n");getch();}利用数组求前n个质数#define N 50main(){int primes[N];int pc,m,k; clrscr();printf("\n The first %d prime numbers are:\n",N);primes[0]=2;/*2是第一个质数*/pc =1;/*已有第一个质数*/m =3;/*被测试的数从3开始*/while(pc<N){/*调整m使它为下一个质数*/k=0;while(primes[k]*primes[k]<=m)if(m%primes[k]==0){/*m是合数*/m+=2;/*让m取下一个奇数*/k=1;/*不必用primes[0]=2去测试m,所以k从一开始*/}elsek++;/*继续用下一个质数去测试*/primes[pc++]=m;m+=2;/*除2外,其余质数均是奇数*/}/*输出primes[0]至primes[pc-1]*/for(k=0;k<pc;k++)printf("%4d",primes[k]);printf("\n\n Press any key to quit...\n ");getch();}编制万年历#include "stdio.h"long int f(int year,int month){/*f(年,月)=年-1,如月<3;否则,f(年,月)=年*/if(month<3) return year-1;else return year;} long int g(int month){/*g(月)=月+13,如月<3;否则,g(月)=月+1*/if(month<3) return month+13;else return month+1;} long int n(int year,int month,int day){/*N=1461*f(年、月)/4+153*g(月)/5+日*/return 1461L*f(year,month)/4+153L*g(month)/5+day;} int w(int year,int month,int day){/*w=(N-621049)%7(0<=w<7)*/return(int)((n(year,month,day)%7-621049L%7+7)%7);} int date[12][6][7];int day_tbl[ ][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};main(){int sw,leap,i,j,k,wd,day;int year;/*年*/char title[]="SUN MON TUE WED THU FRI SAT";clrscr();printf("Please input the year whose calendar you want to know: ");/*输入年*/scanf("%d%*c",&year);/*输入年份值和掠过值后的回车*/sw=w(year,1,1);leap=year%4==0&&year%100||year%400==0;/*判闰年*/for(i=0;i<12;i++)for(j=0;j<6;j++)for(k=0;k<7;k++)date[i][j][k]=0;/*日期表置0*/for(i=0;i<12;i++)/*一年十二个月*/for(wd=0,day=1;day<=day_tbl[leap][i];day++){/*将第i+1月的日期填入日期表*/date[i][wd][sw]=day;sw=++sw%7;/*每星期七天,以0至6计数*/if(sw==0) wd++;/*日期表每七天一行,星期天开始新的一行*/} printf("\n|==================The Calendar of Year %d=====================|\n|",year);for(i=0;i<6;i++){/*先测算第i+1月和第i+7月的最大星期数*/for(wd=0,k=0;k<7;k++)/*日期表的第六行有日期,则wd!=0*/wd+=date[i][5][k]+date[i+6][5][k];wd=wd?6:5;printf("%2d %s %2d %s |\n|",i+1,title,i+7,title);for(j=0;j<wd;j++){printf(" ");/*输出四个空白符*//*左栏为第i+1月,右栏为第i+7月*/for(k=0;k<7;k++)if(date[i][j][k])printf("%4d",date[i][j][k]);else printf(" ");printf(" ");/*输出十个空白符*/for(k=0;k<7;k++)if(date[i+6][j][k])printf("%4d",date[i+6][j][k]);else printf(" ");printf(" |\n|");}/*scanf("%*c");/*键入回车输出下一个月的日历*/}puts("=================================================================|") ;puts("\n Press any key to quit...");getch();}对数组元素排序rest(int a[], int n){int i,low,high,t; for(i=0,low=0,high=n-1;i<=high;) {if(a[i]>0){/*a[i]与a[high]交换,随之high减1*/t=a[i];a[i]=a[high];a[high]=t;high--;}else if(a[i]==0)i++; /* 掠过该元素*/else{/*a[i]与a[low]交换,随之low增1, i增1*/t=a[i];a[i]=a[low];a[low]=t;low++;i++;}}}int s[]={8,4,0,-1,6,0,-5};main(){int i;clrscr();printf("\n The arry before rest is:\n");for(i=0;i<sizeof(s)/sizeof(s[0]);i++)printf("%4d",s[i]);rest(s,sizeof(s)/sizeof(s[0]));printf("\n The arry after rest is:\n");for(i=0;i<sizeof(s)/sizeof(s[0]);i++)printf("%4d",s[i]);printf("\n Press any key to quit...\n");getch();}任意进制数的转换/* 函数trans将无符号整数n翻译成d(2<=d<=16)进制表示的字符串s */ #define M sizeof(unsigned int)*8int trans(unsigned n, int d, char s[]){static char digits[] ="0123456789ABCDEF"; /* 十六进制数字的字符*/char buf[M+1];int j, i = M;if(d<2||d>16){s[0]='\0'; /* 不合理的进制,置s为空字符串*/return 0; /* 不合理的进制,函数返回0 */}buf[i]='\0';do{buf[--i]=digits[n%d]; /*译出最低位,对应字符存入对应工作数组中*/n/=d;}while(n);/* 将译出在工作数组中的字符串复制到s */for(j=0;(s[j]=buf[i])!='\0';j++,i++);/* 其中控制条件可简写成s[j]=buf[i] */return j;}/* 主函数用于测试函数trans() */main(){unsigned int num = 253;int scale[]={2,3,10,16,1};char str[33];int i;clrscr();for(i=0;i<sizeof(scale)/sizeof(scale[0]);i++){if(trans(num,scale[i],str))printf("%5d = %s(%d)\n",num,str,scale[i]);elseprintf("%5d => (%d) Error! \n",num,scale[i]);}printf("\n Press any key to quit...\n");getch();}判断回文数/* 函数circle用于判断正整数n的d进制数表示形式是否是回文数*/ int circle(int n, int d){int s=0,m=n;while(m){s=s*d+m%d;m/=d;}return s==n;}/* main函数用于测试circle函数*/int num[]={232,27,851};int scale[]={2,10,16};main(){int i,j;clrscr();for(i=0;i<sizeof(num)/sizeof(num[0]);i++)for(j=0;j<sizeof(scale)/sizeof(scale[0]);j++)if(circle(num[i],scale[j]))printf("%d -> (%d) is a Circle Number!\n",num[i],scale[j]);elseprintf("%d -> (%d) is not a Circle Number!\n",num[i],scale[j]);printf("\n Press any key to quit...\n");getch();}求解钢材切割的最佳订单#include <stdio.h>#define N 20#define DELTA 2int bestlen;int bestsele[N];int sele[N];int n;int orderlen[N];int total;main(){int i;clrscr();printf("\n Please enter total length of the steel:\n");/* 输入钢材总长*/scanf("%d",&total);printf("\n Please enter number of order:\n"); /* 输入定单数*/ scanf("%d",&n);printf("\n Please enter the orders:\n"); /* 输入各定单*/for(i=0;i<n;i++)scanf("%d",&orderlen[i]);bestlen=0; /*最佳解用料的初值*/for(i=0;i<n;i++)sele[i]=bestsele[i]=0; /*置当前选择和最佳选择初值*/try(); /* 调用函数求解*/for(i=0;i<n;i++) /* 输出结果*/if(bestsele[i])printf("order %d length = %d\n",i+1,orderlen[i]);printf("\n Press any key to quit...");getch();}try(){int i,len;for(len=i=0;i<n;i++) /* 求当前选中的用料量*/if(sele[i])len+=orderlen[i]+DELTA;if(len-DELTA<=total) /* 注意最后一段可能不需要切割*/{if(bestlen < len){/* 找到一个更好的解*/bestlen = len;for(i=0;i<n;i++)bestsele[i]=sele[i];}for(i=0;i<n;i++) /* 对所有未选定单逐一作选中尝试循环*/if(!sele[i]){sele[i]=1; /* 做选中尝试*/try();sele[i]=0;}}}指向数组的指针main(){int x,y,z; /* 定义三个int型变量*/int *xp = &x, /* 定义指针变量xp,并赋值为x的地址,使xp指向x */ *yp = &y, /* 定义指针变量yp,并赋值为y的地址,使yp指向y */*zp = &z; /* 定义指针变量zp,并赋值为z的地址,使zp指向z */int t;printf("\nPlease input x,y,z:\n");scanf("%d%d%d",xp,yp,zp); /* 通过变量的指针,为变量输入值*/ if(*xp>*yp) /* 通过指向变量的指针引用变量的值*/{t=*xp; /* 通过指向变量的指针引用变量的值*/*xp=*yp;/* 通过指向变量x的指针xp,引用变量x的值*/*yp=t; /* 通过指向变量y的指针yp,引用变量y的值*/}if(*xp>*zp) /* 通过指向变量的指针,引用变量的值*/{t=*xp; /* 通过指向变量x的指针xp,引用变量x的值*/*xp=*zp;/* 通过指向变量x的指针xp,引用变量x的值*/*zp=t; /* 通过指向变量z的指针zp,引用变量z的值*/}if(*yp>*zp) /* 通过指向变量的指针,引用变量的值*/{t=*yp; /* 通过指向变量的指针,引用变量的值*/*yp=*zp;/* 通过指向变量y的指针yp,引用变量y的值*/*zp=t;/* 通过指向变量z的指针zp,引用变量z的值*/}printf("x = %d\ty = %d\tz = %d\n",x,y,z);printf("\nPress any key to quit...\n");getch();}阿拉伯数字转换为罗马数字#include <stdio.h>#define ROWS 4#define COLS 4int nums[ROWS][COLS]={{1000,1000,1000,1000},{900,500,400,100},{90,50,40,10},{9,5,4,1}};char *roms[ROWS][COLS]={{"m","m","m","m"}, {"cm","d","cd","c"},{"xc","l","xl","x"},{"ix","v","iv","i"}}; main(int argc,char *argv[ ]){int low,high;char roman[25]; if(argc<2){ printf("Usage:roman decimal_number\n");/*运行程序需带整数参数*/}high=low=atoi(argv[1]);/*将第一个参数转换成整数*/checknum(low);if(argc>2){/*带两个参数*/high=atoi(argv[2]);checknum(high);if(low>high){low=high;high=atoi(argv[1]);}}elselow=1;for(;low<=high;low++){to_roman(low,roman);printf("%d\t%s\n",low,roman);}} checknum(int val)/*检查参数合理性*/{if(val<1||val>9999){printf("The number must be in range 1..9999.\n");exit(0);}}to_roman(int decimal,char roman[ ])/*将整数转换成罗马数字表示*/ {int power,index;roman[0]='\0';for(power=0;power<ROWS;power++)for(index=0;index<COLS;index++)while(decimal>=nums[power][index]){strcat(roman,roms[power][index]);decimal-=nums[power][index];}}通讯录的输入输出#include <stdio.h>#define ZIPLEN 10#define PHONLEN 15/*struct addr类型定义*/ struct addr{char *name;/*姓名*/char *address;/*地址*/char zip[ZIPLEN];/*邮政编码*/char phone[PHONLEN];/*电话号码*/}; main()/*本主函数示意上述输入输出函数的用法*/{struct addr p[100];int i,j;clrscr();for(i=0;readaddr(p+i);i++);for(j=0;j<i;j++) writeaddr(p+j);puts("\n Press any key to quit...");getch();} /* 函数readaddr用于输入一个通信录函数*/int readaddr(struct addr *dpt){int len;char buf[120];/*输入字符串的缓冲区*/ printf("\nPlease input theName:\n");/*输入姓名*/if(scanf("%s",buf)==1){len=strlen(buf);dpt->name=(char *)malloc(len+1);/*申请存贮姓名的空间*/ strcpy(dpt->name,buf);}else return 0;/*Ctrl+Z结束输入*/printf("Please input the Address:\n");/*输入地址*/if(scanf("%s",buf)==1){len=strlen(buf);dpt->address=(char *)malloc(len+1);/*申请存贮地址的空间*/ strcpy(dpt->address,buf);}else{/*Ctrl+Z结束输入*/free(dpt->name);/*释放存贮姓名的空间*/return 0;}printf("Please input the Zip code:\n");/*输入邮编*/if(scanf("%s",buf)==1)strncpy(dpt->zip,buf,ZIPLEN-1);else{free(dpt->name);/*释放存贮姓名的空间*/free(dpt->address);/*释放存贮地址的空间*/return 0;/*Ctrl+Z结束输入*/}printf("Please input the Phone number:\n");/*输入电话号码*/ if(scanf("%s",buf)==1)strncpy(dpt->phone,buf,PHONLEN-1);else{free(dpt->name);free(dpt->address);return 0;/*Ctrl+Z结束输入*/}return 1;} /* 函数writeaddr用于输出通讯录*/int writeaddr(struct addr*dpt){printf("Name : %s\n", dpt->name);/*输出姓名*/printf("Address : %s\n", dpt->address);/*输出地址*/printf("Zip : %s\n", dpt->zip);/*输出邮编*/printf("Phone : %s\n\n", dpt->phone);/*输出电话号码*/}扑克牌的结构表示enum suits{CLUBS,DIAMONDS,HEARTS,SPADES}; struct card{enum suits suit;char value[3];};struct card deck[52];char cardval[][3]= {"A","2","3","4","5","6","7","8","9","10","J","Q","K"};char suitsname[][9]={"CLUBS","DIAMONDS","HEARTS","SPADES"}; main() {int i,j;enum suits s;clrscr();for(i=0;i<=12;i++)for(s=CLUBS;s<=SPADES;s++){j=i*4+s;deck[j].suit=s;strcpy(deck[j].value,cardval[i]);}for(j=0;j<52;j++)printf("(%s%3s)%c",suitsname[deck[j].suit],deck[j].value,j%4==3?'\n':'\t');puts("\nPress any key to quit...");getch();}用“结构”统计学生成绩#include <stdio.h>#define N 200#define SCORES 5#define NUMLEN 10struct std_type{char no[NUMLEN];/*学号*/char *name;/*名字符串指针*/int scores[SCORES];/*五门功课的成绩*/};struct std_type students[N];int order[N];int total[N]; /*[函数]输入一个学生信息函数*/int readastu(struct std_type *spt){int len,j;char buf[120];/*输入字符串的缓冲区*/ printf("\nNumber : ");/*输入学号*/if(scanf("%s",buf)==1)strncpy(spt->no,buf,NUMLEN-1);elsereturn 0;/*Ctrl+Z结束输入*/printf("Name : ");/*输入姓名*/if(scanf("%s",buf)==1){len=strlen(buf);spt->name=(char *)malloc(len+1);/*申请存贮姓名的空间*/ strcpy(spt->name,buf);}else return 0;/*Ctrl+Z结束输入*/printf("Scores : ");/*输入成绩*/for(j=0;j<SCORES;j++)if(scanf("%d",spt->scores+j)!=1)break;if(j==0)/*一个成绩也未输入*/{free(spt->name);/*释放存贮姓名的空间*/return 0;}for(;j<SCORES;j++)/*少数未输入的成绩用0分代之*/ spt->scores[j]=0;return 1;} /*[函数]输出一个学生信息的函数*/int writeastu(struct std_type *spt){int i; printf("Number : %s\n",spt->no);/*输出学号*/printf("Name : %s\n",spt->name);/*输出姓名*/printf("Scores : ");/*输出成绩*/for(i=0;i<SCORES;i++)printf("%4d",spt->scores[i]);printf("\n\n");} main(){int n,i,j,t; clrscr();for(n=0;readastu(students+n);n++);/*采用冒泡法对学生信息数组排序*/for(i=0;i<n;i++){order[i]=i;/*预置第i个输入的学生*/for(t=0,j=0;j<SCORES;j++)/*求第i个学生的总分*/t+=students[i].scores[j];total[i]=t;}/*冒泡排序*/for(i=0;i<n-1;i++)/*共扫视n-1遍*/for(j=0;j<n-1-i;j++)if(total[order[j]]<total[order[j+1]]){/*交换名次*/t=order[j];order[j]=order[j+1];order[j+1]=t;}for(j=0;j<n;j++)/*输出*/writeastu(students+order[j]);printf("\n Press any key to quit...\n");getch();}报数游戏#include <stdio.h>struct ele{int no;struct ele *link;}main(){int n,m,i;struct ele *h,*u,*p;clrscr();printf("Please input n&m:\n");scanf("%d%d",&n,&m);/*输入n和m*/h=u=(struct ele *)malloc(sizeof(struct ele));/*形成首表元*/ h->no=1;for(i=2;i<=n;i++)/*形成其余的n-1个表元*/{u->link=(struct ele *)malloc(sizeof(struct ele));u=u->link;u->no=i;/*第i个表元置编号i*/}u->link=h;/*末表元后继首表元,形成环*/puts("\nThe numbers of who will quit the cycle in turn are:"); while(n){for(i=1;i<m;i++)/*掠过m-1个表元*/u=u->link;p=u->link;/*p指向第m个表元*/u->link=p->link;/*第m个表元从环中脱钩*/printf("%4d",p->no);free(p);/*释放第m个表元占用的空间*/n--;}printf("\n\n Press any key to quit...\n");getch();}学生成绩管理程序/*学生成绩管理程序编制一个统计学生考试分数的管理程序。
C#100例经典源代码
C#语言100例经典源代码程序1】题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。
组成所有的排列后再去掉不满足条件的排列。
2.程序源代码:main(){int i,j,k;printf("\n");for(i=1;i<5;i++) /*以下为三重循环*/for(j=1;j<5;j++)for (k=1;k<5;k++){if (i!=k&&i!=j&&j!=k) /*确保i、j、k三位互不相同*/printf("%d,%d,%d\n",i,j,k);}}==============================================================【程序2】题目:企业发放的奖金根据利润提成。
利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?1.程序分析:请利用数轴来分界,定位。
注意定义时需把奖金定义成长整型。
2.程序源代码:main(){long int i;int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;scanf("%ld",&i);bonus1=100000*0.1;bonus2=bonus1+100000*0.75;bonus4=bonus2+200000*0.5;bonus6=bonus4+200000*0.3;bonus10=bonus6+400000*0.15;if(i<=100000)bonus=i*0.1;else if(i<=200000)bonus=bonus1+(i-100000)*0.075;else if(i<=400000)bonus=bonus2+(i-200000)*0.05;else if(i<=600000)bonus=bonus4+(i-400000)*0.03;else if(i<=1000000)bonus=bonus6+(i-600000)*0.015;elsebonus=bonus10+(i-1000000)*0.01;printf("bonus=%d",bonus);}==============================================================【程序3】题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?1.程序分析:在10万以内判断,先将该数加上100后再开方,再将该数加上268后再开方,如果开方后的结果满足如下条件,即是结果。
经典C语言源代码
经典C语言源代码1、(1)某年某月某日是星期几#include<stdio.h>intmain(){intyear,month,day;{if(month==1||month==2)//判断month是否为1或2{ year--;month+=12;}intc=year/100;inty=year-c*100;intweek=(c/4)-2*c+(y+y/4)+(13*(month+1)/5)+day-1;while(week<0){week+=7;}week%=7;switch(week){}}return0;}1、(2)某年某月某日是第几天(一维数组)voidmain(){inti,flag,year,month,day,dayth;intmonth_day[]={0,31,28,31,30,31,30,31,31,30,31,30,31};请输入年/月/日:dayth=day;flag=(year%400==0)||(year%4==0&&year%100!=0);if(flag)month_day[2]=29;for(i=1;i<month;i++)dayth=dayth+month_day[i];是第%4天}2、30个数中找最小的数及其位置#defineSIZE30voidmain(){inti;floatdata[SIZE];intmin;请输入%d个浮点数:for(i=0;i<SIZE;i++){data[i]=rand()%30+1;、}min=0;for(i=1;i<SIZE;i++){if(data[i]<data[min])min=i;最小值是%5.2f,位置是}3、30个数从小到大排序(1)#defineSIZE30voidmain(){inti,j;floatdata[SIZE],temp;intmin;请输入%d个整型数:for(i=0;i<SIZE;i++){}for(i=0;i<SIZE;i++){min=i;for(j=i+1;j<SIZE;j++)if(data[j]<data[min])temp=data[min];data[min]=data[i];data[i]=temp;}排序后的结果是:for(i=0;i<SIZE;i++)min=j;}(2)模块化程序(数组名作为函数参数)#defineSIZE5voidaccept_array(floata[],intsize);voidsort(floata[],intsize); voidshow_array(floata[],intsize);voidmain(){floatscore[SIZE];accept_array(score,SIZE);排序前:show_array(score,SIZE);sort(score,SIZE);排序后:show_array(score,SIZE);}voidaccept_array(floata[],intsize){inti;请输入%d个分数:for(i=0;i<size;i++)}voidshow_array(floata[],intsize){inti;for(i=0;i<size;i++)}voidsort(floata[],intsize){inti,min,j;floattemp;for(i=0;i<SIZE;i++){min=i;for(j=i+1;j<SIZE;j++)if(a[j]<a[min])min=j;}temp=a[min]; a[min]=a[i]; a[i]=temp;}}4、(1)指针加减:#defineSIZE10voidmain(){inta[SIZE]={1,2,3,4,5,6,7,8,9,10};int*pa,i;pa=&a[0];//pa=a;for(i=0;i<SIZE;i++){pa++;(2)指针比较:#defineSIZE10voidmain(){inta[SIZE]={1,2,3,4,5,6,7,8,9,10};int*pa,i;int*qa;pa=qa=&a[0];请输入%d整型数:for(;pa<qa+SIZE;pa++)for(pa--;qa<=pa;pa--)}5、两字符串相连:voidstr_cat(charstr1[],charstr2[]);voidmain(){inti,j;charstr1[160];charstr2[80];请输入第一个字符串:gets(str1);请输入第二个字符串:gets(str2);str_cat(str1,str2);puts(str1);}voidstr_cat(charstr1[],charstr2[]){ inti,j;i=0;i++;j=0;str1[i]=str2[j];i++;j++;}}6、二维数组(a,b转置)voidmain(){inti,j,b[2][3];inta[3][2]={{1,2},{3,4},{5,6}};for(i=0;i<2;i++){for(j=0;j<3;j++)b[i][j]=a[j][i];}for(i=0;i<3;i++){for(j=0;j<2;j++)}for(i=0;i<2;i++){for(j=0;j<3;j++)}7、输入一个二维数组并输出(指针)voidmain(){intx[2][3];inti,j;for(i=0;i<2;i++)for(j=0;j<3;j++)putchar('');for(i=0;i<2;i++){for(j=0;j<3;j++)putchar('');}}8、冒泡法排序一个数组#definesize10voidmaopao(inta[]);voidmain(){inta[10];inti;请输入10个整数:for(i=0;i<10;i++)maopao(a);}voidmaopao(inta[]){inti,j,temp;for(i=0;i<9;i++){//进行9轮排序for(j=0;j<9-i;j++)//每轮进行9-i次交换{if(a[j]>a[j+1]){temp=a[j];a[j]=a[j+1];//大的沉底,小的上浮a[j+1]=temp;排序结果:for(i=0;i<10;i++)}}9、两数组A,B,要求A<B,如A :4,7,9B :1,3,5,8,9变换后A :1,3, 5B :4,7,8,9,9#include<stdio.h>voidReArranger(int*A,int*B,intm,intn)//A和B是各有m个和n个整数的非降序数组,本算法将B数组元素逐个插入到A中,使A中各元素均不大于B中各元素,且两数组仍保持非降序排列。
C#100例经典源代码
long int i,x, y, z;
for (i=1;i<100000;i++)
{ x=sqrt(i+100); /*x为加上100后开方后的结果*/
y=sqrt(i+268); /*y为再加上168后开方后的结果*/
i f (x*x== i +100&&y*y== i +268)/*如果一个数的平方根的平方等于该数,这说明此 数是完全平方数*/
bonus二bonus2+(i-200000) *;
else if(i<=600000)
bonus二bonus4+(i-400000)*;
else if(i<=1000000)
bonus二bonus6+(i-600000)*;
e I se
bonus二bonusl0+ (i T 000000)*; pr intf ("bonus=%d", bonus);
pr intf (H\n%ld\n,\ i);
}
)
【程序4】
题目:输入某年某月某日,判断这一天是这一年的第几天
1.程序分析:以3月5日为例,应该先把前两个月的加起来,然后再加上5天即 本年的第几天,特殊
情况,闰年且输入月份大于3时需考虑多加一天。
2•程序源代码:
ma i n()
int day, month, year, sum, Ieap;
bonus4=bonus2+200000*;
bonus6=bonus4+200000*;
bonusl0=bonus6+400000*;
if (i<=100000)
软件登记源程序源代码参考样本
if (gridView[j, i].ValueType == typeof(string)) {
excel.Cells[i + 2, j + 1] = "'" + gridView[j, i].Value.ToString(); } else {
ParameterDirection.ReturnValue, false, 0, 0,
string.Empty, DataRowVersion.Default, null));
return cmd;
}
#endregion
}
}
usingБайду номын сангаасSystem;
using System.Collections.Generic;
cmd.ExecuteNonQuery();
this.Close();
return 1;
}
public DataSet RunProcReturn(string procName, SqlParameter[] prams, string tbName)
{
SqlDataAdapter dap = CreateDataAdaper(procName, prams);
{
return data.RunProc("insert into tb_units (units,linkman,address,tel,memo) values
}
public int UpdateUnits(string units, string linkman, string address, string tel, string
python语言入门源代码大全
Python语言入门源代码大全一,彩色螺旋import turtlet=turtle.Turtle()a=5color=['red','yellow','pink','brown']t.speed(10000)while a<=300:for i in range(7):t.pencolor(color[i])t.forward(a)t.right(91)a=a+1二,计算长方形的周长和面积a=float(input("请输入长方形的长:"))b=float(input("请输入长方形的宽:"))s=a*bc=2*a+2*bprint("长方形的面积是:",s)print("长方形的周长是:",c)三,计算圆的面积r=int(input("请输入圆的半径:"))s=3.14*r*rprint("圆的面积是:",s)四,海龟跑圈import turtlet=turtle.Turtle()t.pensize(20)t.color("red")t.up()t.goto(50,-50)t.down()t.circle(50,180)t.forward(100)t.circle(50,180)t.forward(100)p=turtle.Turtle()p.shape("turtle")p.up()p.goto(0,-50)a=int(input("请输入海龟要跑的圈数:")) for x in range(a):print("海龟正在跑第",x+1,"圈")p.forward(50)p.circle(50,180)p.forward(100) p.circle(50,180) p.forward(50)五,多边形import turtlet=turtle.Turtle() t.color("red")for x in range(10): t.forward(100) t.right(36)。
c语言入门源代码
c语言入门源代码以下是一些c语言入门源代码,供初学者参考: 1. Hello World!#include <stdio.h>int main() {printf('Hello World!');return 0;}2. 计算两个数之和#include <stdio.h>int main() {int a, b, c;printf('请输入两个数,用空格隔开:');scanf('%d %d', &a, &b);c = a + b;printf('%d + %d = %d', a, b, c);return 0;}3. 判断一个数是否为质数#include <stdio.h>int main() {int n, i, flag = 0;printf('请输入一个正整数:'); scanf('%d', &n);for(i = 2; i <= n/2; ++i) { if(n%i == 0) {flag = 1;break;}}if(flag == 0 && n != 1)printf('%d是质数', n);elseprintf('%d不是质数', n);return 0;}4. 递归求阶乘#include <stdio.h>int factorial(int n) {if(n == 1)return 1;elsereturn n * factorial(n-1);}int main() {int n;printf('请输入一个正整数:');scanf('%d', &n);printf('%d! = %d', n, factorial(n));return 0;}5. 冒泡排序#include <stdio.h>void bubble_sort(int arr[], int n) { int i, j, temp;for(i = 0; i < n-1; ++i)for(j = 0; j < n-i-1; ++j)if(arr[j] > arr[j+1]) {temp = arr[j];arr[j] = arr[j+1];arr[j+1] = temp;}}int main() {int arr[] = {64, 25, 12, 22, 11}; int n = sizeof(arr)/sizeof(arr[0]); bubble_sort(arr, n);printf('排序后的数组:');for(int i = 0; i < n; ++i)printf('%d ', arr[i]);return 0;}。
网站首页源代码100例之七十八
网站首页源代码100例之七十八:<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd" ><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;charset=gb2312" /><title>广场鱼(吃奶鱼广场鸽)-潍坊银鸽文化传播有限责任公司</title><meta name="Keywords" content="广场鱼(吃奶鱼广场鸽)"><meta name="description" content=""><link href="css/style.css" rel="stylesheet" type="text/css" /></head><body><div class="bg"><div class="logo"><img src="images/logo.jpg" class="logo" /><img src="images/phone.jpg" class="phone" /></div></div><div class="top"><div class="left-bg"></div><div class="menu"><ul><li><a href="Default.aspx">首页</a></li><li><a href="Company.aspx?id=3">公司简介</a></li><li><a href="News.aspx?id=25">资讯动态</a></li><li><a href="Company.aspx?id=20">项目介绍</a></li><li><a href="Products.aspx">展示中心</a></li><li><a href="News.aspx?id=26">成功案例</a></li><li><a href="Company.aspx?id=21">投资回报</a></li><li><a href="Company.aspx?id=22">合作协议</a></li><li><a href="Message.aspx">留言中心</a></li><li><a href="ContactUs.aspx">联系我们</a></li></ul></div><div class="right-bg"></div><div class="banner"><script src="css/viewer.js"language="javascript" type="text/javascript"></script></div></div><div class="container"><div class="shang"><div class="left"><div class="pn4"><a >在线视频</a></div><!--width:200px;height:150px--><div class="shipin"><objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="/pub/shockwave/ca bs/flash/swflash.cab#version=8,0,0,0" width="219"height="164" id="FLVPlayer"><param name="movie"value="FLVPlayer_Progressive.swf" /><param name="quality" value="high" /><param name="wmode" value="opaque" /><param name="scale" value="noscale" /><param name="salign" value="lt" /><param name="FlashVars"value="&MM_ComponentVersion=1&skinName=Clear_Skin _1&streamName=images/%E9%B8%BD%E5%AD%90&autoPlay= false&autoRewind=false" /><embed src="FLVPlayer_Progressive.swf"flashvars="&MM_ComponentVersion=1&skinName=Clear_Skin_1&s treamName=images/%E9%B8%BD%E5%AD%90&autoPlay=false&autoRe wind=false" quality="high" wmode="opaque" scale="noscale" width="219" height="164" name="FLVPlayer" salign="lt"type="application/x-shockwave-flash"pluginspage="/shockwave/download/down load.cgi?P1_Prod_Version=ShockwaveFlash"></embed></object></div></div><div class="zhong"></div><div class="right"><div class="pn5"><ahref="Company.aspx?id=3">公司简介</a></div><!--(字数限制:200)--><div class="jianjie"><p><img src="images/img.jpg" /><p>潍坊银鸽文化传播有限责任公司(原潍坊银鸽游艺发展有限责任公司)成立于2000年6月,2002年起在全国各地投放驯养广场鸽,并大力推广该项目.投放场地遍布全国黑龙江、吉林、河北、天津、上海、河南、湖南、广西、甘肃等省市,并得到用户的一致好评和认可(详情可参看成功案例)。
源代码清单
附录:主要窗体的源代码:1:订房信息窗体的源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc AsPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer)Dim mrcc AsDim intCount As IntegerDim MsgText As StringIf gintBmode = 1 ThenIf Index = 0 ThentxtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "' and putup <> '是'"Set mrcc = ExecuteSQL(txtSQL, MsgText)For intCount = 1 To 3cboItem(intCount).ClearcboItem(intCount).AddItem (intCount)cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = (5)End IfEnd IfEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And ThenIf MsgBox("保存当前记录的变化吗", vbOKCancel + vbExclamation, "警告") = vbOK Then'保存Call cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc AsDim MsgText As StringFor intCount = 0 To 3If Trim(txtItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "顾客姓名"Case 1sMeg = "身份证号码"Case 2sMeg = "折扣"Case 3sMeg = "入住时间"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountFor intCount = 0 To 3If Trim(cboItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "客房编号"Case 1sMeg = "客房种类"Case 2sMeg = "客房位置"Case 3sMeg = "客房单价"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告" cboItem(intCount).SetFocusExit SubEnd IfNext intCountIf IsDate(txtItem(2)) ThentxtItem(2) = Format(txtItem(2), "yyyy-mm-dd")ElseMsgBox "入库时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"txtItem(2).SetFocusExit SubEnd IfFor intCount = 1 To 3 Step 2If Not IsNumeric(txtItem(intCount)) ThenMsgBox "请输入数字", vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountIf gintBmode = 2 ThentxtSQL = "delete from bookin where bookno = '" & Trim(txtNo) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)End IftxtSQL = "select * from bookin"Set mrcc = ExecuteSQL(txtSQL, MsgText)(0) = txtNoFor intCount = 0 To 1(intCount + 1) = txtItem(intCount)Next intCount(3) = cboItem(0)For intCount = 2 To 4(intCount + 2) = txtItem(intCount)Next intCount(8) = 0txtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not Thenmrcc!putup = "y"End IfIf gintBmode = 1 ThenMsgBox "添加订房信息成功!", vbOKOnly + vbExclamation, "添加订房消息"Unload MeIf flagBedit ThenUnload frmBookinEnd If= "select bookno,customname,customID,roomno,indate,discount,inmemo from bookin where ammount = '0'"ElseMsgBox "修改订房信息成功!", vbOKOnly + vbExclamation, "修改订房消息"Unload MeIf flagBedit ThenUnload frmBookinEnd If= "select bookno,customname,customID,roomno,indate,discount,inmemo frombookin where ammount = '0'"End IfEnd SubPrivate Sub Form_Load()Dim sSql As StringDim intCount As IntegerDim MsgText As StringIf flagSedit ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If Not ThenFor intCount = 0 To 3cboItem(intCount).AddItem (intCount) cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = (5)End IftxtNo = GetRkno()gintBmode = 1ElseIf gintBmode = 1 Then= & "添加"'初始化客房信息txtSQL = "select DISTINCT roomNO from rooms where putup <> 'y'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not ThenDo While NotcboItem(0).AddItem Trim(0))LoopElseMsgBox "请先进行客房登记!", vbOKOnly + vbExclamation, "警告"= FalseExit SubEnd IftxtNo = GetRknoElseIf gintBmode = 2 ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenWith mrctxtNo = !booknoFor intCount = 0 To 1If Not IsNull(.Fields(intCount + 1)) ThentxtItem(intCount)= .Fields(intCount + 1)End IfNext intCountcboItem(0).AddItem !roomnocboItem(0).ListIndex = 0For intCount = 2 To 4If Not IsNull(.Fields(intCount + 2)) ThentxtItem(intCount)= .Fields(intCount + 2)End IfNext intCountEnd WithEnd If= & "修改"txtSQL = "select * from rooms where roomNO = '" & Trim(cboItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not ThenFor intCount = 1 To 3cboItem(intCount).AddItem (intCount) cboItem(intCount).ListIndex = 0Next intCounttxtItem(5) = (5)End IfEnd IfEnd IfmblChange = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)gintBmode = 0End SubPrivate Sub txtItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End SubPrivate Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)EnterToTab KeyCodeEnd Sub2:订房信息查询窗体源代码:Option Explicit'用于传递查询块Private Sub chkItem_Click(Index As Integer)If Index = 2 ThencboYear(0).SetFocusElsetxtItem(Index).SetFocusEnd IfEnd SubPrivate Sub cmdExit_Click()End SubPrivate Sub cmdOK_Click()Dim dBeginDate As StringDim sQSql As StringIf chkItem(0).Value = vbChecked ThensQSql = " customname = '" & Trim(txtItem(0) & " ") & "'"End IfIf chkItem(1).Value = vbChecked ThenIf Trim(sQSql & " ") = "" ThensQSql = " roomno ='" & Trim(txtItem(1) & " ") & "'" ElsesQSql = sQSql & " and roomno ='" & Trim(txtItem(1) & " ") & "'"End IfEnd IfIf chkItem(2).Value = vbChecked ThendBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")If Trim(sQSql & " ") = "" ThensQSql = " indate ='" & dBeginDate & "'"ElsesQSql = sQSql & " and indate ='" & dBeginDate & "'" End IfEnd IfIf Trim(sQSql) = "" ThenMsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告"Exit SubElseIf flagBedit ThenUnload frmBookinEnd If= "select bookno,customname,customID,roomno,indate,discount,inmemo from bookin where ammount = '0' and " & sQSqlEnd IfEnd SubPrivate Sub Form_Load()Dim i As IntegerDim j As IntegerDim sSql As StringDim txtSQL As StringDim MsgText As StringDim mrc AstxtSQL = "select distinct datepart(yy,indate) from bookin where ammount = '0' "Set mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenWith mrcDo While Not .EOFcboYear(0).AddItem .Fields(0).MoveNextLoopEnd WithcboYear(0).ListIndex = 0For j = 1 To 12cboMonth(0).AddItem jNext jcboMonth(0).Text = Month(Now())For j = 1 To 31jNext j= Day(Now())Else= FalseEnd IfEnd SubPrivate Sub lblitem_Click(Index As Integer)chkItem(Index).Value = vbCheckedEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index)) End Sub3:订房信息列表窗体源代码:Option ExplicitPublic txtSQL As StringDim mrc AsDim MsgText As StringPrivate Sub Form_Load()ShowTitleShowDataflagBedit = TrueEnd SubPrivate Sub Form_Resize()If <> vbMinimized And <> vbMinimized Then '边界处理If < 10 * ThenExit SubEnd IfIf < + / 2 ThenExit SubEnd If'控制控件的位置== - / 2= + + / 2= - 200= + 100= - - 200End IfEnd SubPublic Sub FormClose()Unload MeEnd Sub'删除记录Private Sub Form_Unload(Cancel As Integer) flagBedit = FalsegintBmode = 0End Sub'显示Grid的内容Private Sub ShowData()Dim j As IntegerDim i As IntegerSet mrc = ExecuteSQL(txtSQL, MsgText)With msgList.Rows = 1Do While Not.Rows = .Rows + 1For i = 1 To Select Case (i - 1).Type Case adDBDate.TextMatrix(.Rows - 1, i) = Format(i - 1) & "", "yyyy-mm-dd")Case Else.TextMatrix(.Rows - 1, i) = (i - 1) & "" End SelectNext iLoopEnd WithEnd Sub'显示Grid表头Private Sub ShowTitle()Dim i As IntegerWith msgList.Cols = 8.TextMatrix(0, 1) = "".TextMatrix(0, 2) = "顾客姓名" .TextMatrix(0, 3) = "身份证号码" .TextMatrix(0, 4) = "房间编号" .TextMatrix(0, 5) = "入住日期" .TextMatrix(0, 6) = "折扣".TextMatrix(0, 7) = "备注"'固定表头.FixedRows = 1'设置各列的对齐方式For i = 0 To 7.ColAlignment(i) = 0Next i'表头项居中.FillStyle = flexFillRepeat.Col = 0.Row = 0.RowSel = 1.ColSel = .Cols - 1.CellAlignment = 4'设置单元大小.ColWidth(0) = 300.ColWidth(1) = 0.ColWidth(2) = 1000.ColWidth(3) = 2000.ColWidth(4) = 2000.ColWidth(5) = 1000.ColWidth(6) = 1000.ColWidth(7) = 600.Row = 1End WithEnd SubPrivate Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)'右键弹出If Button = 2 And Shift = 0 ThenPopupMenuEnd IfEnd Sub4:结算信息窗体源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc AsPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer) '有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer) Dim sSql As StringDim MsgText As StringDim mrcc AsDim intCount As IntegerIf gintCmode = 1 Then'初始化员工名称和IDIf Index = 0 ThencboItem(1).Enabled = TruecboItem(2).Enabled = TruecboItem(3).Enabled = TruecboItem(1).ClearcboItem(2).ClearcboItem(3).CleartxtSQL = "select roomNO,roomtype,roomposition,roomprice from rooms where roomNO ='" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not ThencboItem(1).AddItem mrcc!roomtypecboItem(2).AddItem mrcc!roompositioncboItem(3).AddItem mrcc!roompricecboItem(1).Enabled = FalsecboItem(2).Enabled = FalsecboItem(3).Enabled = FalsecboItem(1).ListIndex = 0cboItem(2).ListIndex = 0cboItem(3).ListIndex = 0= TrueElseMsgBox "没有订房信息!", vbOKOnly + vbExclamation, "警告"= FalseExit SubEnd IftxtSQL = "select * from bookin where ammount = '0' and roomno = '" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not ThentxtNo = mrcc!booknotxtItem(0) = mrcc!customnametxtItem(1) = mrcc!customIDtxtItem(2) = mrcc!indatetxtItem(3) = mrcc!discounttxtItem(5) = mrcc!inmemoFor intCount = 0 To 3txtItem(intCount).Enabled = FalseNext intCountEnd IfEnd IfEnd IfExit SubEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And ThenIf MsgBox("保存当前记录的变化吗", vbOKCancel + vbExclamation, "警告") = vbOK ThenCall cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc AsDim MsgText As StringDim bYear As IntegerDim eYear As IntegerDim bDays As IntegerDim eDays As IntegerDim aDays As IntegerDim amMount As DoubleIf Trim(txtItem(4) & " ") = "" ThenMsgBox sMeg, vbOKOnly + vbExclamation, "警告" txtItem(4).SetFocusEnd IfIf IsDate(txtItem(4)) ThentxtItem(4) = Format(txtItem(4), "yyyy-mm-dd")ElseMsgBox "入库时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"txtItem(4).SetFocusExit SubEnd If'再加入新记录txtSQL = "select * from bookin where bookno = '" & Trim(txtNo) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)(6) = txtItem(5)(7) = txtItem(4)bYear = DatePart("yyyy", txtItem(2))eYear = DatePart("yyyy", txtItem(4))bDays = DatePart("y", txtItem(2))eDays = DatePart("y", txtItem(4))If bYear = eYear ThenaDays = eDays - bDaysElseaDays = (eYear - bYear - 1) * 365 + (365 - bDays) + eDays End If(8) = aDays * Trim(cboItem(3)) * Trim(txtItem(3)) / 100amMount = aDays * Trim(cboItem(3)) * Trim(txtItem(3)) / 100txtSQL = "select * from rooms where roomNO = '" & cboItem(0) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not Thenmrcc!putup = " "End IfIf gintCmode = 1 ThenUnload MemblChange = FalseMsgBox "金额为" & amMount & "元,结算完毕!", vbOKOnly +vbExclamation, "添加结算信息"If flagCedit ThenUnload frmCheckoutEnd If= "select * from bookin where ammount <> '0'"ElseIf gintCmode = 2 ThenMsgBox "金额为" & amMount & "元,结算信息修改完毕!", vbOKOnly + vbExclamation, "修改结算信息"Unload MeIf flagCedit ThenUnload frmCheckoutEnd If= "select * from bookin where ammount <> '0'"End IfEnd SubPrivate Sub Form_Load()Dim sSql As StringDim intCount As IntegerDim MsgText As StringIf gintCmode = 1 Then= & "添加"'初始化物资名称txtSQL = "select DISTINCT roomno from bookin where ammount = '0'"Set mrc = ExecuteSQL(txtSQL, MsgText)If Not ThenDo While NotcboItem(0).AddItem Trim(mrc!roomno)LoopElseMsgBox "没有顾客入住!", vbOKOnly + vbExclamation, "警告"= FalseExit SubEnd IfElseIf gintCmode = 2 ThenSet mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenWith mrctxtNo = (0)For intCount = 0 To 1txtItem(intCount) = .Fields(intCount + 1)Next intCountcboItem(0).AddItem .Fields(3)cboItem(0).ListIndex = 0For intCount = 2 To 3If Not IsNull(.Fields(intCount + 2)) ThentxtItem(intCount) = .Fields(intCount + 2) End IfNext intCounttxtItem(5) = .Fields(6)txtItem(4) = .Fields(7)End WithEnd IftxtSQL = "select * from rooms where roomNO = '" & cboItem(0) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenWith mrcFor intCount = 1 To 3cboItem(intCount).AddItem .Fields(intCount) cboItem(intCount).ListIndex = 0Next intCountEnd WithEnd IfFor intCount = 0 To 3txtItem(intCount).Enabled = FalseNext intCount= & "修改"End IfmblChange = FalseEnd SubPrivate Sub Form_Unload(Cancel As Integer)gintCmode = 0End SubPrivate Sub txtItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index))End SubPrivate Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer,Shift As Integer)EnterToTab KeyCodeEnd Sub5:结算信息查询窗体源代码:Option Explicit'用于传递查询块Private Sub chkItem_Click(Index As Integer) If Index = 2 ThencboYear(0).SetFocusElsetxtItem(Index).SetFocusEnd IfEnd SubPrivate Sub cmdExit_Click()End SubPrivate Sub cmdOK_Click()Dim dBeginDate As StringDim sQSql As StringIf chkItem(0).Value = vbChecked ThensQSql = " customname = '" & Trim(txtItem(0) & " ") & "'" End IfIf chkItem(1).Value = vbChecked ThenIf Trim(sQSql & " ") = "" ThensQSql = " roomno ='" & Trim(txtItem(1) & " ") & "'" ElsesQSql = sQSql & " and roomno ='" & Trim(txtItem(1) & " ") & "'"End IfEnd IfIf chkItem(2).Value = vbChecked ThendBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")If Trim(sQSql & " ") = "" ThensQSql = " indate ='" & dBeginDate & "'"ElsesQSql = sQSql & " and indate ='" & dBeginDate & "'" End IfEnd IfIf Trim(sQSql) = "" ThenMsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告"Exit SubElseIf flagBedit ThenUnload frmCheckoutEnd If= "select * from bookin where ammount <> '0' and " & sQSql End IfEnd SubPrivate Sub Form_Load()Dim i As IntegerDim j As IntegerDim sSql As StringDim txtSQL As StringDim MsgText As StringDim mrc AstxtSQL = "select distinct datepart(yy,indate) from bookin where ammount <> '0'"Set mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenWith mrcDo While Not .EOFcboYear(0).AddItem .Fields(0).MoveNextLoopEnd WithcboYear(0).ListIndex = 0For j = 1 To 12cboMonth(0).AddItem jNext jcboMonth(0).Text = Month(Now())For j = 1 To 31jNext j= Day(Now())Else= FalseEnd IfEnd SubPrivate Sub lblitem_Click(Index As Integer)chkItem(Index).Value = vbCheckedEnd SubPrivate Sub txtItem_GotFocus(Index As Integer)txtItem(Index).SelStart = 0txtItem(Index).SelLength = Len(txtItem(Index)) End Sub6:结算信息列表窗体源代码:Option ExplicitPublic txtSQL As StringDim mrc AsDim MsgText As StringPrivate Sub Form_Load()ShowTitleShowDataflagCedit = TrueEnd SubPrivate Sub Form_Resize()If <> vbMinimized And <> vbMinimized Then '边界处理If < 10 * ThenExit SubEnd IfIf < + / 2 ThenExit SubEnd If'控制控件的位置== - / 2= + + / 2= - 200= + 100= - - 200End IfEnd SubPublic Sub FormClose()Unload MeEnd SubPrivate Sub Form_Unload(Cancel As Integer) flagCedit = FalsegintCmode = 0End Sub'显示Grid的内容Private Sub ShowData()Dim j As IntegerDim i As IntegerSet mrc = ExecuteSQL(txtSQL, MsgText)With msgList.Rows = 1Do While Not.Rows = .Rows + 1For i = 1 To Select Case (i - 1).Type Case adDBDate.TextMatrix(.Rows - 1, i) = Format(i - 1) & "", "yyyy-mm-dd")Case Else.TextMatrix(.Rows - 1, i) = (i - 1) & "" End SelectNext iLoopEnd WithEnd Sub'显示Grid表头Private Sub ShowTitle()Dim i As IntegerWith msgList.Cols = 10.TextMatrix(0, 1) = "".TextMatrix(0, 2) = "顾客姓名" .TextMatrix(0, 3) = "身份证号码" .TextMatrix(0, 4) = "房间编号" .TextMatrix(0, 5) = "入住日期" .TextMatrix(0, 6) = "折扣".TextMatrix(0, 7) = "备注信息" .TextMatrix(0, 8) = "结算日期" .TextMatrix(0, 9) = "金额"'固定表头.FixedRows = 1'设置各列的对齐方式For i = 0 To 9.ColAlignment(i) = 0Next i'表头项居中.FillStyle = flexFillRepeat .Col = 0.Row = 0.RowSel = 1.ColSel = .Cols - 1.CellAlignment = 4'设置单元大小.ColWidth(0) = 300.ColWidth(1) = 0.ColWidth(2) = 1000.ColWidth(3) = 2000.ColWidth(4) = 2000.ColWidth(5) = 2000.ColWidth(6) = 2000.ColWidth(7) = 2000.ColWidth(8) = 2000.ColWidth(9) = 1000.Row = 1End WithEnd SubPrivate Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)'右键弹出If Button = 2 And Shift = 0 ThenPopupMenuEnd IfEnd Sub7:客房信息窗体源代码:Option Explicit'是否改动过记录,ture为改过Dim mblChange As BooleanDim mrc AsPublic txtSQL As StringPrivate Sub cboItem_Change(Index As Integer)'有变化设置gblchangemblChange = TrueEnd SubPrivate Sub cboItem_Click(Index As Integer)Dim sSql As StringDim MsgText As StringDim mrcc As'初始化员工名称和IDIf Index = 0 ThentxtSQL = "select typename,price from roomtype where typename='" & Trim(cboItem(0)) & "'"Set mrcc = ExecuteSQL(txtSQL, MsgText)If Not ThentxtItem(2) = mrcc!price= TrueElseMsgBox "请先建立客房标准!", vbOKOnly + vbExclamation, "警告"= FalseExit SubEnd IfEnd IfExit SubEnd SubPrivate Sub cboItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)EnterToTab KeyCodeEnd SubPrivate Sub cmdExit_Click()If mblChange And ThenIf MsgBox("保存当前记录的变化吗", vbOKCancel + vbExclamation, "警告") = vbOK Then'保存Call cmdSave_ClickEnd IfEnd IfUnload MeEnd SubPrivate Sub cmdSave_Click()Dim intCount As IntegerDim sMeg As StringDim mrcc AsDim MsgText As StringFor intCount = 0 To 3If Trim(txtItem(intCount) & " ") = "" ThenSelect Case intCountCase 0sMeg = "客房编号"Case 1sMeg = "客房位置"End SelectsMeg = sMeg & "不能为空!"MsgBox sMeg, vbOKOnly + vbExclamation, "警告"txtItem(intCount).SetFocusExit SubEnd IfNext intCountIf gintRmode = 1 ThentxtSQL = "select * from rooms where roomNO='" & Trim(txtItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)If = False ThenMsgBox "已经存在此客房编号的记录!", vbOKOnly + vbExclamation, "警告"txtItem(0).SetFocusExit SubEnd IfEnd IfIf gintRmode = 2 Then'先删除已有记录txtSQL = "delete from rooms where roomNO='" & Trim(txtItem(0)) & "'"Set mrc = ExecuteSQL(txtSQL, MsgText)End If'再加入新记录txtSQL = "select * from rooms"Set mrc = ExecuteSQL(txtSQL, MsgText)(0) = Trim(txtItem(0))(1) = Trim(cboItem(0))For intCount = 1 To 2If Trim(txtItem(intCount) & " ") = "" Then (intCount + 1) = NullElse(intCount + 1) = Trim(txtItem(intCount)) End IfNext intCount(4) = " "(5) = Trim(txtItem(3))If gintRmode = 1 ThenFor intCount = 0 To 3txtItem(intCount) = ""Next intCountmblChange = FalseIf flagRedit ThenUnload frmRoom= "select * from rooms"End If。
20个python3大项目开发源代码(附源码)
在此文中,我们将为您介绍20个Python3大型项目开发的源代码,以帮助您了解Python3的应用和实际项目开发。
以下是这20个Python3大型项目开发源代码的详细内容:1. 人脸识别系统- 该项目使用Python3编写,利用OpenCV和Dlib库实现人脸识别功能。
它可以识别图像和视频中的人脸,并进行特征提取和匹配。
2. 文件同步工具- 这个项目使用Python3编写,可以实现不同计算机之间的文件同步。
它可以检测文件的新增、删除和修改,并及时同步到其他设备。
3. 聊天机器人- 该项目利用Python3编写,使用自然语言处理技术和机器学习算法,实现了一个智能聊天机器人。
它可以回答一般性问题,处理用户输入的文本,并给出相应的回复。
4. 数据可视化工具- 这个项目采用Python3编写,利用Matplotlib和Seaborn库实现数据可视化功能。
它可以将数据以图表、图形等形式展现出来,方便用户分析和理解数据。
5. 网络爬虫- 该项目使用Python3编写,利用BeautifulSoup和Requests库实现网络爬虫功能。
它可以抓取网页数据,对数据进行处理和分析,用于各种网页数据的采集和整理。
6. 视频流分析系统- 这个项目利用Python3编写,借助FFmpeg和NumPy库实现对视频流的分析和处理。
它可以提取视频流中的特征,并进行目标识别和跟踪。
7. 在线投票系统- 该项目采用Python3编写,利用Django框架实现在线投票系统。
它可以处理用户投票请求,进行实时统计数据,并生成相应的数据报表。
8. 电流信箱客户端- 这个项目使用Python3编写,利用smtplib和poplib库实现电流信箱客户端功能。
它可以发送、接收和管理电流信箱,支持对邮件进行筛选、归档等操作。
9. 文档管理系统- 该项目利用Python3编写,使用Django框架实现文档管理系统。
它可以上传、下载和管理文档,支持文档的分类、版本管理等功能。
Python语言程序设计(刘卫国)全书各章节程序源代码
Python语言程序设计刘卫国全书源代码第1章例1-1控制输出格式的转义字符的用法示例。
print("**ab*c\t*de***\ttg**\n")print("h\nn***k")例1-2表达式应用实例。
x=2**10y=pow(2,10)z=2<<9a=3/5b=3//5c=3%5print(x,y,z)print(a,b,c)第2章例2-5程序如下:x=int(input('input x:')) #输入x的值y=int(input('input y:')) #输入y的值z=int(input('input z:')) #输入z的值if x>y: #如果x>y,则x和y的值互换x,y=y,xif x>z: #如果x>z,则x和z的值互换x,z=z,xif y>z: #如果y>z,则y和z的值互换y,z=z,yprint(x,y,z)例2-6程序如下:def f(x,y):return x**2+y**2print("f(3,4)=",f(3,4))f(x,y)函数可以定义成lambda函数的形式。
f=lambda x,y:x**2+y**2print("f(3,4)=",f(3,4))例2-7 程序如下:a,b=0,1s=0for i in range(50): #i从0变化到49s+=ba,b=b,a+bprint("s=",s)例2-8 程序如下:import mathx=5+3J; #x是一个复数y=math.exp(math.sqrt(math.pi)/2);z=2*math.sin(math.radians(56)) #z的分子z/=(x+math.cos(abs(x+y))) #求zprint("z=",z)例2-9 程序如下:n=int(input("n="))a=n%10; #求n的个位数字b=n//10%10; #求n的十位数字c=n//100; #求n的百位数字m=a*100+b*10+cprint("{0:3}的逆序数是{1:3}".format(n,m))例2-10 程序如下:from cmath import sqrta=float(input('a=?'))b=float(input('b=?'))c=float(input('c=?'))d=b*b-4*a*cx1=(-b+sqrt(d))/(2*a)x2=(-b-sqrt(d))/(2*a)print("x1={0:.5f}, x2={1:.5f}".format(x1,x2))例2-11 程序如下:a=complex(input("a="))b=complex(input("b="))c=a+0.618*(b-a)s=abs(a-b)print("长度:",s)print("黄金分割点:",c)第3章例3-2程序如下:a,b=eval(input("输入a,b:"))if a<b: #若a<b,交换a和b,否则不交换 a,b=b,aprint("{0},{1}".format(a,b))例3-3程序如下:from math import *a,b,c=eval(input("a,b,c="))if a+b>c and a+c>b and b+c>a:p=(a+b+c)/2s=sqrt(p*(p-a)*(p-b)*(p-c))print("a={0},b={1},c={2}".format(a,b,c))print("area={}".format(s))else:print("a={0},b={1},c={2}".format(a,b,c))print("input data error")例3-4程序如下:from math import *x=eval(input("x="))if x<0:y=log(-5*x)+fabs(x)else:y=sin(x)+sqrt(x+exp(2))/(2*pi)print("x={},y={}".format(x,y))还可以采用两个单分支结构来实现,程序如下:from math import *x=eval(input("x="))if x<0:y=log(-5*x)+fabs(x)if x>=0:y=sin(x)+sqrt(x+exp(2))/(2*pi) print("x={},y={}".format(x,y))例3-5 程序如下:g=float(input("请输入学生成绩:"))if g<60:print("不及格")elif g<70:print("及格")elif g<85:print("良好")else:print("优秀")例3-6程序如下:g=float(input("请输入学生成绩:"))if g>=60:if g>=70:if g>=85:print("优秀")else:print("良好")else:print("及格")else:print("不及格")例3-7用嵌套的if结构来实现,看下面的程序:x,y,z=eval(input("x,y,z=?"))max=xif z>y:if z>x:max=zelse:if y>x:max=yprint("The max is",max)例3-8程序如下:import randomx=random.randint(10,99)y=random.randint(10,99)z=random.randint(10,99)max=x if x>y else ymax=max if max>z else zprint("x={0},y={1},z={2}".format(x,y,z))print("max=",max)例3-9程序如下:x=eval(input())a=x%10; #求个位数字b=(x//10)%10; #求十位数字c=x//100; #求百位数字if x==a*a*a+b*b*b+c*c*c:print("{0}是水仙花数".format(x))else:print("{0}不是水仙花数".format(x))例3-10 程序如下:hour=int(input('请输入小时:'))minute=int(input('请输入分钟:'))second=int(input('请输入秒:'))second+=30if second>=60:second=second-60minute+=1minute+=5if minute>=60:minute=minute-60hour+=1if hour==24:hour=0print('{0:d}:{1:d}:{2:d}'.format(hour,minute,second))例3-11if嵌套的程序如下:gh,gs=eval(input())if gs>120:gz=gs*84+(gs-120)*84*0.15else:if gs>60:gz=gs*84else:gz=gs*84-700print("{0}号职工应发工资{1}".format(gh,gz))例3-12程序如下:year=int(input("year="))month=int(input("month="))if month in(1,3,5,7,8,10,12):day=31elif month in(4,6,9,11):day=30else:logi=(year%4==0 and year%100!=0) or year%400==0day=29 if logi else 28print(year,month,day)第4章例4-1程序如下:s=0n=1while n<=100: #循环条件s+=n #实现累加求和n+=1 #n增1print("1+2+3+……+9+100=",s)例4-2程序如下:from math import *i=1x1=int(input()) #输入一个角度x=radians(x1) #将角度化为弧度s=xa=xwhile fabs(a)>=1e-6: #|a|≥1e-6时继续循环,否则退出循环i+=1a*=-x*x/(2*i-2)/(2*i-1) #求累加项s+=aprint("x={0},sinx={1}".format(x1,s))例4-3 程序如下:n=int(input())k=0while n>0:k+=1n//=10print('k=',k)例4-4程序如下:x=int(input())max=min=xfor i in range(1,20):x=int(input())if x>max:max=xelif x<min:min=xprint("max={0},min={1}".format(max,min))例4-5 程序如下:f1,f2=1,1print(f1,'\t',f2,end='\t')for i in range(3,31):f=f2+f1print(f,end='\t')if i%5==0:print(); #控制一行输出5个数f2,f1=f1,f #更新f1,f2,为求下一项作准备例4-6用for语句实现的程序如下:import mathm=int(input("请输入一个数:"))j=int(math.sqrt(m))flag=True #素数标志for i in range(2,j+1):if m%i==0:flag=False #修改素数标志if flag and m>1:print(m,"是素数。
毕业设计源代码
毕业设计源代码由于文本长度限制,我只能给出一个简短的源代码示例:```python# 这是一个简单的Python程序,用于实现一个简单的计算器功能def add(x, y):"""相加两个数"""return x + ydef subtract(x, y):"""相减两个数"""return x - ydef multiply(x, y):"""相乘两个数"""return x * ydef divide(x, y):"""相除两个数"""return x / y# 主程序入口if __name__ == "__main__":print("选择运算:")print("1. 相加")print("2. 相减")print("3. 相乘")print("4. 相除")choice = input("请输入你的选择 (1/2/3/4): ")num1 = int(input("请输入第一个数字: "))num2 = int(input("请输入第二个数字: "))if choice == '1':print(num1, "+", num2, "=", add(num1, num2))elif choice == '2':print(num1, "-", num2, "=", subtract(num1, num2))elif choice == '3':print(num1, "*", num2, "=", multiply(num1, num2))elif choice == '4':print(num1, "/", num2, "=", divide(num1, num2))else:print("非法输入")```这是一个简单的计算器程序,可以进行加减乘除四则运算。
附录源代码
附录import java.awt.*;import .*;import java.sql.*;import java.awt.event.*;import javax.swing.JOptionPane;import java.io.*;import sun.audio.*;class dzcd extends Frame implements ActionListener{MenuBar menubar=new MenuBar();//菜单Menu fileMenu,editMenu,helpMenu;MenuItem fileenglish,filechinese,exit,editAdd,editmod,editDel;TextField inputtext;TextArea txt;Label label1,label2;Button btn1,btnsound;Panel p,p1,p2,p3;dzcd(){super("电子词典");setBounds(200,300,350,400);setMenuBar(menubar);fileMenu=new Menu("文件");editMenu=new Menu("编辑");helpMenu=new Menu("帮助");fileenglish=new MenuItem("英汉词典");filechinese=new MenuItem("汉英词典");exit=new MenuItem("退出");editAdd=new MenuItem("添加词汇");editmod=new MenuItem("修改词汇");editDel=new MenuItem("删除词汇");menubar.add(fileMenu);menubar.add(editMenu);menubar.add(helpMenu);fileMenu.add(filechinese);fileMenu.addSeparator();fileMenu.add(exit);editMenu.add(editAdd);editMenu.add(editmod);editMenu.add(editDel);inputtext=new TextField("",10);txt=new TextArea(10,10);label1=new Label("输入要查询的英语单词:");label2=new Label("查询结果:");btn1=new Button("查询");btnsound=new Button("发音");p=new Panel(new BorderLayout());p2=new Panel(new FlowLayout(FlowLayout.LEFT,5,0));p2.add(label1);p2.add(inputtext);p2.add(btn1);p2.add(btnsound);add(p2,"North");p.add(label2,"North");p.add(txt,"Center");add(p,"Center");setVisible(true);setResizable(false);validate();fileenglish.addActionListener(this);filechinese.addActionListener(this);exit.addActionListener(this);editAdd.addActionListener(this);editmod.addActionListener(this);editDel.addActionListener(this);btn1.addActionListener(this);btnsound.addActionListener(this);addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}public void actionPerformed(ActionEvent e){if(e.getSource()==fileenglish)//英汉(外观变化){label1.setText("输入要查询的英语单词:");label2.setText("查询结果:");txt.setText("");btn1.setLabel("查询");btnsound.setVisible(true);}else if(e.getSource()==filechinese)//汉英(外观变化){label1.setText("输入要查询的汉语词语:");label2.setText("查询结果:");txt.setText("");btn1.setLabel("查询");btnsound.setVisible(true);}else if(e.getSource()==exit)//退出{System.exit(0);}else if(e.getSource()==btn1){if(btn1.getLabel().equals("查询"))//实现查询功能(包括英汉或汉英){txt.setText(null);try{Listwords();}catch(SQLException ee){}}else if(btn1.getLabel().equals("提交"))//实现添加功能{try{addwords();}catch(SQLException ee){}}try{modwords();}catch(SQLException ee){}}else if(btn1.getLabel().equals("删除"))//实现删除功能{try{delwords();}catch(SQLException ee){}}}else if(e.getSource()==editAdd)//添加(外观变化){label1.setText("输入新单词:");label2.setText("输入中文解释:");btn1.setLabel("提交");btnsound.setVisible(false);}else if(e.getSource()==editmod)//修改(外观变化){label1.setText("输入要修改的单词:");label2.setText("输入更新后的解释:");btn1.setLabel("更新");btnsound.setVisible(false);}else if(e.getSource()==editDel)//删除(外观变化){label1.setText("输入要删除的单词:");label2.setText("");btn1.setLabel("删除");btnsound.setVisible(false);}else if(e.getSource()==btnsound)//发音{if(inputtext.getText()!=null){try{inputtext.getText().trim()+".wav").openStream();AudioPlayer.player.start(is);}catch(IOException e1){}}}}public void Listwords() throws SQLException//查询实现过程{String cname,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())&&label1.getText().equals("输入要查询的英语单词:")){txt.append(cname);break;}else if(cname.equals(inputtext.getText())&&label1.getText().equals("输入要查询的汉语词语:")){txt.append(ename);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"查无此单词!","警告",JOptionPane.W ARNING_MESSAGE);}public void addwords() throws SQLException//向数据库添加新词汇{String cname,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())&&cname.equals(txt.getText())){JOptionPane.showMessageDialog(this,"此词汇已存在!","警告",JOptionPane.W ARNING_MESSAGE);break;}}if(boo==false){Ex1Stmt.executeUpdate("INSERT INTO words (英语,汉语) V ALUES ('"+inputtext.getText().trim()+"','"+txt.getText().trim()+"')");JOptionPane.showMessageDialog(this,"添加成功!","恭喜",JOptionPane.W ARNING_MESSAGE);}Ex1Con.close();}public void modwords() throws SQLException//修改词库中记录{String ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:words","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");if(ename.equals(inputtext.getText())){Ex1Stmt.executeUpdate("UPDATE words SET 汉语='"+txt.getText().trim()+"' WHERE 英语='"+inputtext.getText().trim()+"'");JOptionPane.showMessageDialog(this,"记录修改成功!","恭喜",JOptionPane.W ARNING_MESSAGE);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"不存在此单词!","警告",JOptionPane.W ARNING_MESSAGE);}}public void delwords() throws SQLException//删除词库中记录{@SuppressWarnings("unused")String cname,ename;try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}catch(ClassNotFoundException e){}Connection Ex1Con=DriverManager.getConnection("jdbc:odbc:wordskechengsheji","","");Statement Ex1Stmt=Ex1Con.createStatement();ResultSet rs=Ex1Stmt.executeQuery("SELECT * FROM words");boolean boo=false;while((boo=rs.next())==true){ename=rs.getString("英语");cname=rs.getString("汉语");if(ename.equals(inputtext.getText())){inputtext.getText().trim()+"'");JOptionPane.showMessageDialog(this,"成功删除记录!","恭喜",JOptionPane.W ARNING_MESSAGE);break;}}Ex1Con.close();if(boo==false){JOptionPane.showMessageDialog(this,"不存在此单词!","警告",JOptionPane.W ARNING_MESSAGE);}}public static void main(String args[]){new dzcd()}}。
源代码清单
诊所管理系统案例研究项目源代码清单1. 工程prjClinic的标准模块:ModMain.Bas的代码如下:
2. ActiveX控件工程prjDocLogin的控件文档:docLogin.Ctl的代码如下:
3. ActiveX控件工程prjChat的控件文档:ChatControl.Ctl的代码如下:
4. ActiveX DLL组件工程prjBill的类模块:ClsBill.Cls的代码如下:
5. 工程prjClinic的窗体:Menu_form.frm代码如下:
6. 工程prjClinic的窗体:FrmLogin.frm代码如下:
7.工程prjClinic的窗体:frmDoctor.frm代码如下:
8.工程prjClinic的窗体:frmPatient.frm代码如下:
9.工程prjClinic的窗体:frmMedicine.frm代码如下:
10.工程prjClinic的窗体:FrmDoctorsDetails.frm代码如下:
11.工程prjClinic的窗体:FrmDoctorsPatients.frm代码如下:
12.工程prjClinic的窗体:FrmBillDetails.frm代码如下:
13.工程prjClinic的窗体:frmdpBill.frm代码如下:
(说明:
1、以上的代码的编写,没有符合代码的命名规则,在此仅作为例子;
2、以上编码的实现,在与设计上存在一些实际的差异,这些差异应该经过评审;
3、在一些时候,可以不必打印全部的源代码,特别是程序的保密性非常强的时候;
4、对于大型项目,特别是牵涉到多语言实现的系统的时候,源代码还需要进行重新索
引;
)。
程序源代码模板 (2).doc
页面布局模块程序代码MainActivity.javapackage com.my.llkangame;//第一个页面import android.app.ListActivity;import android.app.ProgressDialog;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.ViewGroup;import android.widget.ImageView;import android.widget.ListView;import android.widget.TextView;import com.plter.lib.android.java.controls.ArrayAdapter;import com.plter.linkgame.R;public class MainActivity extends ListActivity {private ArrayAdapter<GameListCellData> adapter;//定义适配器private ProgressDialog dialog=null;//dialog//savedInstanceStateprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(yout.main_activity);//main_activity.xml//设置适配器adapter=newArrayAdapter<MainActivity.GameListCellData>(this,yout.game_list_cell) {@Overridepublic void initListCell(int position, View listCell, ViewGroup parent) {ImageView iconIv = (ImageView) listCell.findViewById(R.id.iconIv);TextView labelTv=(TextView) listCell.findViewById(belTv);GameListCellData data = getItem(position);iconIv.setImageResource(data.iconResId);labelTv.setText(bel);}};setListAdapter(adapter);//适配器集合adapter.add(new GameListCellData("水果连连看", R.drawable.sg_icon, "sg_config.json"));adapter.add(new GameListCellData("蔬菜连连看", R.drawable.sc_icon, "sc_config.json"));adapter.add(new GameListCellData("动物连连看", R.drawable.dw_icon, "dw_config.json"));adapter.add(new GameListCellData("爱心连连看", R.drawable.love_icon, "love_config.json"));adapter.add(new GameListCellData("宝石连连看", R.drawable.coin_icon, "coin_config.json"));}@Overrideprotected void onPause() {if (dialog!=null) {dialog.dismiss();dialog=null;}super.onPause();}@Overrideprotected void onListItemClick(ListView l, View v, int position, long id) {dialog=ProgressDialog.show(this, "请稍候", "正在加载游戏资源");GameListCellData data = adapter.getItem(position);Intent i = new Intent(this, LinkGameActivity.class);i.putExtra("configFile", data.gameConfigFile);startActivity(i);super.onListItemClick(l, v, position, id);}public static class GameListCellData{public String label=null;public int iconResId=0;public String gameConfigFile=null;public GameListCellData(String label,int iconResId,String gameConfigFile) {bel=label;this.iconResId=iconResId;this.gameConfigFile=gameConfigFile;}}}LinkGameActivity.javapackage com.my.llkangame;import android.app.Activity;import android.os.Bundle;import android.text.TextUtils;import android.view.Display;import android.widget.Button;import android.widget.TextView;import com.my.cord.Config;import com.my.cord.GameViewhhxx;import com.my.reader.InnerGameReader;import com.plter.linkgame.R;//游戏开始界面宽高、布局等且开始游戏public class LinkGameActivity extends Activity {private GameViewhhxx gameView;/** Called when the activity is first created. */@SuppressWarnings("deprecation")public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);String configFile = getIntent().getStringExtra("configFile");if (TextUtils.isEmpty(configFile)) {finish();return;}//获得屏幕宽高Display display = getWindowManager().getDefaultDisplay();Config.setScreenWidth(display.getWidth());Config.setScreenHeight(display.getHeight());//设置内容布局setContentView(yout.link_game_activity);gameView=(GameViewhhxx) findViewById(R.id.gameView);gameView.setTimeTv((TextView) findViewById(R.id.timeTv));gameView.setLevelTv((TextView) findViewById(R.id.levelTv));gameView.setBreakCardsBtn((Button) findViewById(R.id.breakCardsBtn));gameView.setNoteBtn((Button) findViewById(R.id.noteBtn));gameView.setPauseBtn((Button) findViewById(R.id.pauseBtn));//根据游戏资源包初始化游戏gameView.initWithGamePkg(InnerGameReader.readGame(this, configFile));//开始启动游戏gameView.showStartGameAlert();}protected void onPause() {gameView.pause();super.onPause();}protected void onResume() {gameView.resume();super.onResume();}}LinesContainer.javapackage com.my.cord;import java.util.List;import android.content.Context;import android.graphics.Canvas;import android.graphics.Paint;import android.graphics.Paint.Style;import android.graphics.Path;import android.graphics.PointF;import android.view.View;import android.view.animation.AlphaAnimation;import android.view.animation.Animation;import android.view.animation.Animation.AnimationListener;/*** 设置对图片进行连接的线的宽度和颜色*/public class LinesContainer extends View implements AnimationListener{ private List<PointF> points=null;private final Paint paint=new Paint();private final Path path = new Path();private final AlphaAnimation aa = new AlphaAnimation(1, 0);public LinesContainer(Context context) {super(context);paint.setStyle(Style.STROKE);paint.setStrokeWidth(5);paint.setColor(0xFFFF0000);aa.setDuration(500);aa.setAnimationListener(this);setVisibility(View.GONE);}public void showLines(List<PointF> points){if (points.size()<2) {throw new RuntimeException("点的个数不能小于2");}else{setVisibility(View.VISIBLE);this.points=points;invalidate();startAnimation(aa);}}protected void onDraw(Canvas canvas) {if (points==null||points.size()<2) {return;}path.reset();PointF p=points.get(0);path.moveTo(p.x, p.y);for (int i = 1; i < points.size(); i++) {p=points.get(i);path.lineTo(p.x, p.y);}canvas.drawPath(path, paint);super.onDraw(canvas);}public void onAnimationStart(Animation animation) {}public void onAnimationEnd(Animation animation) { setVisibility(View.GONE);}public void onAnimationRepeat(Animation animation) {} }Config.javapackage com.my.cord;public class Config {private static float cardWidth=0;private static float cardHeight=0;private static float screenWidth=0;private static float screenHeight=0;private static float cardsOffsetX=0;private static float cardsOffsetY=0;/*** 游戏区域的宽度*/private static float gameCardsAreaWidth=0;/*** 游戏区域的高度*/private static float gameCardsAreaHeight=0;/*** 卡片的上边距*/public static final float GAME_CARDS_AREA_TOP=80;/*** 卡片的下边距*/public static final float GAME_CARDS_AREA_BOTTOM=80;/*** 卡片区域左边距*/public static final float GAME_CARDS_AREA_LEFT=0;/*** 卡片区域右边距*/public static final float GAME_CARDS_AREA_RIGHT=0;/*** @return the screenWidth*/public static float getScreenWidth() {return screenWidth;}/*** @param screenWidth the screenWidth to set*/public static void setScreenWidth(float screenWidth) {Config.screenWidth = screenWidth;Config.setGameCardsAreaWidth(Config.getScreenWidth()-Config.GAME_CARDS_AREA_ LEFT-Config.GAME_CARDS_AREA_RIGHT);computeCardWidthAndHeight();}/*** @return the screenHeight*/public static float getScreenHeight() {return screenHeight;}/*** @param screenHeight the screenHeight to set*/public static void setScreenHeight(float screenHeight) {Config.screenHeight = screenHeight;Config.setGameCardsAreaHeight(Config.getScreenHeight()-Config.GAME_CARDS_ARE A_BOTTOM-Config.GAME_CARDS_AREA_TOP);computeCardWidthAndHeight();}private static void computeCardWidthAndHeight(){float cardWidth=Config.getGameCardsAreaWidth()/Level.MAX_H_CARDS_COUNT;floatcardHeight=Config.getGameCardsAreaHeight()/Level.MAX_V_CARDS_COUNT;float min = Math.min(cardWidth, cardHeight);Config.setCardWidth(min);//卡片最小宽Config.setCardHeight(min);//卡片最小高}/*** @return the cardWidth*/public static float getCardWidth() {return cardWidth;}/*** @param cardWidth the cardWidth to set*/private static void setCardWidth(float cardWidth) {Config.cardWidth = cardWidth;}/*** @return the cardHeight*/public static float getCardHeight() {return cardHeight;}/*** @param cardHeight the cardHeight to set*/private static void setCardHeight(float cardHeight) {Config.cardHeight = cardHeight;}/*** @return the cardsOffsetX*/public static float getCardsOffsetX() {return cardsOffsetX;}/*** @param cardsOffsetX the cardsOffsetX to set*/public static void setCardsOffsetX(float cardsOffsetX) { Config.cardsOffsetX = cardsOffsetX;}/*** @return the cardsOffsetY*/public static float getCardsOffsetY() {return cardsOffsetY;}/*** @param cardsOffsetY the cardsOffsetY to set*/public static void setCardsOffsetY(float cardsOffsetY) { Config.cardsOffsetY = cardsOffsetY;}/*** @return the gameCardsAreaWidth*/public static float getGameCardsAreaWidth() {return gameCardsAreaWidth;}/*** @param gameCardsAreaWidth the gameCardsAreaWidth to set */private static void setGameCardsAreaWidth(float gameCardsAreaWidth) { Config.gameCardsAreaWidth = gameCardsAreaWidth;}/*** @return the gameCardsAreaHeight*/public static float getGameCardsAreaHeight() {return gameCardsAreaHeight;}/*** @param gameCardsAreaHeight the gameCardsAreaHeight to set*/private static void setGameCardsAreaHeight(float gameCardsAreaHeight) { Config.gameCardsAreaHeight = gameCardsAreaHeight;}}Picture.javapackage com.my.reader;import android.graphics.Bitmap;/*** Bitmap 面板**/public class Picture {public Picture(Bitmap bitmap) {this.bitmap=bitmap;id=__getId();}public Bitmap getBitmap() {return bitmap;}private int id=0;public int getId() {return id;}private Bitmap bitmap=null;private static int __id=0;private static int __getId(){__id++;return __id;}}算法分析模块程序代码Cardmm.javapackage com.my.cord;/**重排:先遍历当前页面还有的图片,调用随机算法调换页面中图片的位置* 先选中一张图片,获取此图片在垂直和水平方向上的的位置,判断是否被选中,判断当前已选中的图片个数*若选中图片个数小于2张,再选择一张图片,重复上一个动作,若选中图片个数达到2张,判断是否满足消除条件*若满足,则消除,若不满足,则不发生任何变化。
计算机毕业论文源代码
计算机毕业论文源代码计算机毕业论文源代码.doc计算机毕业论文源代码计算机毕业论文源代码:会计信息生产社会化仿真系统1.折旧年限表(pany_zjnx)建表源程序: CREATETABLE[dbo].[pany_zjnx]([cname][char](40)COLLATEChinese_PRC_CI_ASNULL, [obj_name][char](40)COLLATEChinese_PRC_CI_ASNULL, [zj_years][int]NULL,[zj_idea][char](40)COLLATEChinese_PRC_CI_ASNULL, [canzhi][float]NULL)2.企业基本情况表(pany_total)建表源程序: CREATETABLE[dbo].[pany_total]([_id][int]NOTNULL,[cname][char](40)COLLATEChinese_PRC_CI_ASNOTNULL, [ccode][char](18)COLLATEChinese_PRC_CI_ASNULL, [rmoney][float]NULL,[faren][char](8)COLLATEChinese_PRC_CI_ASNULL, [cadd][char](40)COLLATEChinese_PRC_CI_ASNULL, [kinds][char](20)COLLATEChinese_PRC_CI_ASNULL, [act_area][text]COLLATEChinese_PRC_CI_ASNULL, [tel][char](12)COLLATEChinese_PRC_CI_ASNULL, [cell][char](11)COLLATEChinese_PRC_CI_ASNULL, [fax][char](12)COLLATEChinese_PRC_CI_ASNULL,[ccontent][char](8)COLLATEChinese_PRC_CI_ASNULL, [bank][char](30)COLLATEChinese_PRC_CI_ASNULL, [bank_num][char](18)COLLATEChinese_PRC_CI_ASNULL, [zz_num][char](12)COLLATEChinese_PRC_CI_ASNULL, [tax_num][char](15)COLLATEChinese_PRC_CI_ASNULL, [realmoney][float]NULL,[zz_years][int]NULL,[fz_date][char](8)COLLATEChinese_PRC_CI_ASNULL,[fz_jiguan][char](30)COLLATEChinese_PRC_CI_ASNULL, [hangye][char](10)COLLATEChinese_PRC_CI_ASNULL)3.企业初始投资表(pany_cstz)见表源程序: CREATETABLE[dbo].[pany_cstz]([cname][char](40)COLLATEChinese_PRC_CI_ASNOTNULL, [cz_pro][char](40)COLLATEChinese_PRC_CI_ASNULL, [cz_money][real]NULL,[cz_man][char](20)COLLATEChinese_PRC_CI_ASNULL, [cz_code][char](10)COLLATEChinese_PRC_CI_ASNULL, [cz_date][char](10)COLLATEChinese_PRC_CI_ASNULL, [cz_percent][char](10)COLLATEChinese_PRC_CI_ASNULL, [extra][char](60)COLLATEChinese_PRC_CI_ASNULL)4.交易总表(contract_total)建表源程序: CREATETABLE[dbo].[contract_total]([y][char](10)COLLATEChinese_PRC_CI_ASNULL,[m][char](10)COLLATEChinese_PRC_CI_ASNULL,[d][char](10)COLLATEChinese_PRC_CI_ASNULL, [gname][char](40)COLLATEChinese_PRC_CI_ASNULL, [gtax_num][char](15)COLLATEChinese_PRC_CI_ASNULL, [g_add][char](40)COLLATEChinese_PRC_CI_ASNULL, [gbank_num][char](18)COLLATEChinese_PRC_CI_ASNULL, [obj_bh][char](10)COLLATEChinese_PRC_CI_ASNULL, [obj_name][char](20)COLLATEChinese_PRC_CI_ASNULL, [obj_dw][char](8)COLLATEChinese_PRC_CI_ASNULL, [obj_sl][int]NULL,[obj_dj][real]NULL,[jine][float]NULL,[tax_per][decimal](18,0)NULL,[taxe][float]NULL,[jshj][float]NULL,[xname][char](40)COLLATEChinese_PRC_CI_ASNULL, [xtax_num][char](15)COLLATEChinese_PRC_CI_ASNULL, [x_add][char](40)COLLATEChinese_PRC_CI_ASNULL, [xbank_num][char](18)COLLATEChinese_PRC_CI_ASNULL, [zj_years][int]NULL,[zj_idear][char](40)COLLATEChinese_PRC_CI_ASNULL, [canzhi][float]NULL,[pz_num][int]NULL,[zy][char](30)COLLATEChinese_PRC_CI_ASNULL)5.科目表(kmb)建表源程序:CREATETABLE[dbo].[kmb]([km_num][char](15)COLLATEChinese_PRC_CI_ASNULL, [km_name][char](26)COLLATEChinese_PRC_CI_ASNULL, [km_xzh][char](10)COLLATEChinese_PRC_CI_ASNULL, [jdfx][char](2)COLLATEChinese_PRC_CI_ASNULL, [km_jb][int]NULL)6.记账凭证表(jzpz)建表源程序:CREATETABLE[dbo].[jzpz]([y][char](10)COLLATEChinese_PRC_CI_ASNULL, [m][char](10)COLLATEChinese_PRC_CI_ASNULL,[d][char](10)COLLATEChinese_PRC_CI_ASNULL,[pz_num][int]NULL,[z_cname][char](40)COLLATEChinese_PRC_CI_ASNULL, [d_cname][char](40)COLLATEChinese_PRC_CI_ASNULL, [km_num][char](10)COLLATEChinese_PRC_CI_ASNULL, [km_name][char](26)COLLATEChinese_PRC_CI_ASNULL, [mxkm][char](26)COLLATEChinese_PRC_CI_ASNULL, [zy][char](30)COLLATEChinese_PRC_CI_ASNULL,[j_jine][float]NULL,[d_jine][float]NULL)7.时间维表(time_dim)建表源程序:CREATETABLE[dbo].[time_dim]([time_num][int]IDENTITY(1,1)NOTNULL,[y][char](10)COLLATEChinese_PRC_CI_ASNULL,[m][char](10)COLLATEChinese_PRC_CI_ASNULL,[d][char](10)COLLATEChinese_PRC_CI_ASNULL)8.货物维表(obj_dim)建表源程序:CREATETABLE[dbo].[obj_dim]([obj_num][int]IDENTITY(1,1)NOTNULL,[obj_bh][char](10)COLLATEChinese_PRC_CI_ASNOTNULL, [obj_name][char](20)COLLATEChinese_PRC_CI_ASNOTNULL, [obj_dw][char](8)COLLATEChinese_PRC_CI_ASNOTNULL, [obj_dj][real]NOTNULL)9.购货单位维表(g_dim)建表源程序:CREATETABLE[dbo].[g_dim]([g_num][int]IDENTITY(1,1)NOTNULL,[gname][char](40)COLLATEChinese_PRC_CI_ASNOTNULL, [gtax_num][char](15)COLLATEChinese_PRC_CI_ASNULL, [g_add][char](40)COLLATEChinese_PRC_CI_ASNULL, [gbank_num][char](18)COLLATEChinese_PRC_CI_ASNULL)10.销货单位维表(x_dim)建表源程序:CREATETABLE[dbo].[x_dim]([x_num][int]IDENTITY(1,1)NOTNULL,[xname][char](40)COLLATEChinese_PRC_CI_ASNOTNULL,[xtax_num][char](15)COLLATEChinese_PRC_CI_ASNULL,[x_add][char](40)COLLATEChinese_PRC_CI_ASNULL,[xbank_num][char](18)COLLATEChinese_PRC_CI_ASNULL)11.交易事实表(contract_total)建表源程序:CREATETABLE[dbo].[contract_fact]([s_num][int]IDENTITY(1,1)NOTNULL,[g_num][int]NOTNULL,[x_num][int]NOTNULL,[time_num][int]NOTNULL,[obj_num][int]NOTNULL,[obj_sl][int]NOTNULL,[jine][float]NOTNULL,[tax_per][decimal](18,0)NOTNULL,[taxe][float]NOTNULL,[jshj][float]NOTNULL)计算机毕业论文源代码:企业人事管理系统的设计与实现各模块实现的主要源代码F1.1登录模块的设计与实现的主要代码if(tbxUserCode.Text.Trim()==““){BigMessageBox.Show(“请您输入用户或密码!!”,“警告”,MessageBoxButtons.OK,MessageBoxIcon.Stop);this.tbxUserCode.Text=““;this.tbxUserCode.Text=““;this.tbxUserCode.Focus();return;}else{EmployeeInfoemp=null;switch(User.LoginValidate(tbxUserCode.Text.Trim(),tbxUserPwd.Text .Trim(),outemp)){caseUser.LoginResult.NoUser:{BigMessageBox.Show(“没有该用户信息”,“用户验证”,MessageBoxButtons.OK,MessageBoxIcon.Stop);tbxUserCode.Text=““;tbxUserCode.Focus();break;}caseUser.LoginResult.PasswordError:{BigMessageBox.Show(“用户密码错误!!”,“用户验证”,MessageBoxButtons.OK,MessageBoxIcon.Stop);tbxUserPwd.Text=““;tbxUserPwd.Focus();break;}caseUser.LoginResult.Success:{FormMainobjMain=newFormMain();this.Hide();objMain.Show();break;}default:break;}}F1.2登陆实体类:StringBuilderstrSql=newStringBuilder();strSql.Append(“selectEmpID,LoginName,LoginCode,Password,RoleID,I sUsed,CreateName,CreateDatetime,RemarkFROMLogin“);strSql.Append(“whereLoginrCode=“+LoginrCode);Loginmodel=newLogin();DataTabledt=DbHelperSQL.Instance.GetDataTable(strSql.ToString());if(dt.Rows.Count>0){model.EmpNO=dt.Rows[0][“EmpNO”].ToString();model.LoginName=dt.Rows[0][“LoginName”].ToString();model.LoginrCode=dt.Rows[0][“LoginCode”].ToString();model.Password=dt.Rows[0][“Password”].To String();if(dt.Rows[0][“RoleID”].ToString()!=““){model.RoleID=int.Parse(dt.Rows[0][“RoleID”].ToString());}model.IsUsed=dt.Rows[0][“IsUsed”].ToString();model.CreateName=dt.Rows[0][“CreateName”].ToString();if(dt.Rows[0][“CreateDatetime”].ToString()!=““){model.CreateDatetime=DateTime.Parse(dt.Rows[0][“CreateDatetime”].ToString());}model.Remark=dt.Rows[0][“Remark”].ToString();returnmodel;}else{returnnull;}检查该员工是否应该是系统用户:returnDbHelperSQL.Instance.E xecuteScalar(“SELECTLoginIDFROMLogin WHERELoginCode=“+LoginrCode+““);检查用户编码是否可以使用:returnDbHelperSQL.Instance.ExecuteScalar(“SELECTLoginrCodeFROMLo ginWHERELoginCode=“+LoginrCode+““);通过LoginID查找相应的密码:returnDbHelperSQL.Instance.ExecuteScalar(“SelectPassword fromLogin WhereLoginID=“+LoginID);F1.3员工管理模块的设计与实现的主要代码F1.3.1员工管理实现的主要代码:publicclassBllAttendance{//////增加一条数据///publicstaticintAdd(Attendancemodel,DbTransactiontrans){StringBuildersb=newStringBuilder();sb.Append(“INSERTINTOAttendance(AttenDate,EmpNo,Adsum,Fact,Late, Leave,Absent,Overtime,NotIn,NotOut,Outgo,”);sb.Append(“WorkOut,WorkTime,NumCount,[In],Out,Artificial,[Work], Illness,Thing,Family)”);sb.Append(“VALUES(@AttenDate,@EmpNo,@Adsum,@Fact,@Late,@Le ave,@A bsent,@Overtime,@NotIn,@NotOut,@Outgo,”);sb.Append(“@WorkOut,@WorkTime,@NumCount,@In,@Out,@Artificial,@Wo rk,@Illness,@Thing,@Family)”);returnDbHelperSQL.Instance.ExcuteTransNonQuery(sb.ToString(),DbHe lperSQL.Instance.CreateParamters(sb.ToString(),model),trans);}//////更新一条数据///publicstaticintUpdate(Attendancemodel){StringBuildersb=newStringBuilder();sb.Append(“UPDATEAttendanceSETAdsum=@Adsum,Fact=@Fact,Late=@Late ,Leave=@Leave,Absent=@Absent,Overtime=@Overtime,”);sb.Append(“NotIn=@NotIn,NotOu t=@NotOut,Outgo=@Outgo,WorkOut=@Wor kOut,WorkTime=@WorkTime,NumCount=@NumCount,”);sb.Append(“[In]=@In,Artificial=@Artificial,Out=@Out,[Work]=@Work ,Illness=@Illness,Thing=@Thing,Family=@FamilyWHEREEmpNo=@EmpNo”);returnDbHelperSQL.Instance.ExcuteNonQuery(sb.ToString(),DbHelperS QL.Instance.CreateParamters(sb.ToString(),model));}//////删除一条数据///publicstaticintDelete(stringEmpNo){StringBuildersb=newStringBuilder();sb.Append(String.Format(“DELETEFROMAttendanceWHEREEmpNo={0}”,Em pNo));returnDbHelperSQL.Instance.ExcuteNonQuery(sb.ToString());}publicstaticDataTableGetAttenddanceDataTable(){StringBuildersb=newStringBuilder();sb.Append(“SELECTAttenDate,EmpNo,Adsum,Fact,Late,Leave,Absent,Ov ertime,NotIn,NotOut,”);sb.Append(“Outgo,WorkOu t,WorkTime,NumCount,[In],Out,Artificial,[ Work],Illness,Thing,FamilyFROMAttendance“);returnDbHelperSQL.Instance.GetDataTable(sb.ToString());}F1.3.2部门管理实现主要代码:publicclassBLLDepartment{//////增加一条数据///publicstaticintAdd(Departmentmodel){StringBuilderstrSql=newStringBuilder();strSql.Append(“intoDepartment(“);strSql.Append(“DepartNo,DepartName,DepartDesn,ParentID,Remark”);strSql.Append(“)”);strSql.Append(“values(“);strSql.Append(““+model.DepartNo+“,”);strSql.Append(““+model.DepartName+“,”);strSql.Append(““+model.DepartDesn+“,”);strSql.Append(““+model.ParentID+“,”);strSql.Append(““+model.Remark+““);strSql.Append(“)”);returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString()); }//////更新一条数据///publicstaticintUpdate(Departmentmodel){StringBuilderstrSql=newStringBuilder();strSql.Append(“Departmentset“);strSql.Append(“DepartName=“+model.DepartName+“,”);strSql.Append(“DepartDesn=“+model.DepartDesn+“,”);strSql.Append(“ParentID=“+model.ParentID+“,”);strSql.Append(“Remark=“+model.Remark+““);strSql.Append(“whereDepartNo=“+model.DepartNo+““); returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString()); }//////删除一条数据///publicstaticintDelete(stringDepartNo){StringBuilderstrSql=newStringBuilder();strSql.Append(“Department“);strSql.Append(“whereDepartNo=“+DepartNo+““);returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString());}//////得到一个对象实体///publicstaticDepartmentGeDepartment(stringDepartNo){StringBuilderstrSql=newStringBuilder();strSql.Append(“SELECTDepartNo,DepartName,DepartDesn,ParentID,Rem arkFROMDepartment”);strSql.Append(“WHEREDepartNo=“+DepartNo);Departmentmodel=newDepartment();DataTabledt=DbHelperSQL.Instance.GetDataTable(strSql.ToString());if(dt.Rows.Count>0){model.De partNo=dt.Rows[0][“DepartNo”].ToString();model.DepartName=dt.Rows[0][“DepartName”].ToString();model.DepartDesn=dt.Rows[0][“DepartDesn”].ToString();if(dt.Rows[0][“ParentID”].ToString()!=““){model.ParentID=int.Parse(dt.Rows[0][“ParentID”].ToString());}model.Remark=dt.Rows[0][“Remark”].ToString();returnmodel;}else{returnnull;}}publicstaticstringGetDepartmentIDIsNull(intempID){returnDbHelperSQL.Instance.ExecuteScalar(“SELECTDepartmentIDFROM EmployeeWHEREDepartmentID=“+empID+““);}}F1.3.3工资管理主要代码:publicpartialclassUcPay:UserControl{privatestringempNo=““;publicUcPay(){Initializeponent();}privatevoidbtnExit_Click(objectsender,EventArgse){(this.ParentasPanel).Controls.Clear();}privatevoidbtnAdd_Click(objectsender,EventArgse){if(BLLGongZ.Add(GetGongZ())>0){BigMessageBox.Show(“员工工资添加成功”,“员工工资维护”,MessageBoxButtons.OK,rmation);this.Bind();}else{BigMessageBox.Show(“员工工资添加失败!!”,“员工工资维护”,MessageBoxButtons.OK,MessageBoxIcon.Stop);}}privateGongZGetGongZ(){GongZmodel=newGongZ();model.EmpNO=empNo;model.MonthID=Utilities.ConverObjectInt(cboMonth.SelectedValue);model.GBGZ=Convert.ToDecimal(txtGBGZ.Text.Trim());model.FZYJ=Convert.ToDecimal(txtFZYJ.Text.Trim());model.XSTC=Convert.ToDecimal(txtXSTC.Text.Trim());model.BJGZ=Convert.ToDecimal(txtBJGZ.Text.Trim());model.JXGZ=Convert.ToDecimal(txtJXGZ.Text.Trim());model.SJGZ=Convert.ToDecimal(txtSJGZ.Text.Trim());model.JLGZ=Convert.ToDecimal(txtJLGZ.Text.Trim());model.YLBX=Convert.ToDecimal(txtYLBX.Text.Trim());model.JBGZ=Convert.ToDecimal(txtJBGZ.Text.Trim());model.ZSGZ=Convert.ToDecimal(txtZSGZ.Text.Trim());model.QQJJ=Convert.ToDecimal(txtQQJJ.Text.Trim());model.GSKF=Convert.ToDecimal(txtGSKF.Text.Trim());model.OTHER=Convert.ToDecimal(ttxtOTHER.Text.Trim());model.NOTES=““;returnmodel;}privatevoidUcPay_Load(objectsender,EventArgse){this.cboMonth.DisplayMember=“CDesc”;this.cboMonth.ValueMember=“CodeID”;this.cboMonth.DataSource=BLLGongZ.GetMonth();this.cboMonth.SelectedIndex=0;this.dgEmp.DataSource=BLLGongZ.GetEmpInfo();this.Bind();}privatevoiddgEmp_CellClick(objectsender,DataGridViewCellEventArgs e){if(dgEmp.DataSource!=null&&dgEmp.Rows.Count>0){if(e.RowIndex!=-1){empNo=this.dgEmp.Rows[e.RowIndex].Cells[0].Value.ToString();this.Bind();}}}privatevoidbtnUpdate_Click(objectsender,EventArgse){if(BLLGongZ.Update(GetGongZ())>0){BigMessageBox.Show(“员工工资添加成功”,“员工工资维护”,MessageBoxButtons.OK,rmation);this.Bind();}else{BigMessageBox.Show(“员工工资添加失败!!”,“员工工资维护”,MessageBoxButtons.OK,MessageBoxIcon.Stop);}}privatevoidBind(){this.dgvSalaryItem.DataSource=BLLGongZ.GetGongZ(empNo);}privatevoiddgvSalaryItem_CellClick(objectsender,DataGridViewCellE ventArgse){if(dgvSalaryItem.DataSource!=null&&dgvSalaryItem.Rows.Count>0) {if(e.RowIndex!=-1){empNo=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“empID”].Value. ToString();cboMonth.SelectedValue=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“MonthID”].Value;txtGBGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“GBGZ”]. Value.ToString();txtFZYJ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“FZYJ”]. Value.ToString();txtXSTC.Tex t=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“XSTC”]. Value.ToString();txtBJGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“BJGZ”]. Value.ToString();txtJXGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“JXGZ”]. Value.ToString();txtSJGZ.Text=this.dgvSal aryItem.Rows[e.RowIndex].Cells[“SJGZ”]. Value.ToString();txtJLGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“JLGZ”]. Value.ToString();txtYLBX.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“YLBX”]. Value.ToString();txtJBGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“JBGZ”].Value.ToString();txtZSGZ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“ZSGZ”]. Value.ToString();txtQQJJ.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“QQJJ”]. Value.ToString();txtGSKF.Text=this.dgvSalaryItem.Rows[e.RowIndex].C ells[“GSKF”]. Value.ToString();ttxtOTHER.Text=this.dgvSalaryItem.Rows[e.RowIndex].Cells[“OTHER ”].Value.ToString();}}}privatevoidbtnDelete_Click(objectsender,EventArgse){if(empNo!=““){if(BigMessageBox.Show(“您确定要删除员工基本信息吗?”,“删除员工工资信息”,MessageBoxButto ns.OKCancel,MessageBoxIcon.Question)==DialogResul t.OK){if(BLLGongZ.Delete(empNo)>0){BigMessageBox.Show(“删除员工工资信息成功”,“删除员工工资信息”,MessageBoxButtons.OK,rmation);this.Bind();}else{BigMessageBox.Show(“删除员工考评信息失败”,“删除员工工资信息”,MessageBoxButtons.OK,rmation);}}}else{BigMessageBox.Show(“请选择一个员工信息”,“删除员工工资信息”,MessageBoxButtons.OK,rmation);}}}F1.3.4考勤信息设计与实现主要代码:privatevoidbtnAdd_Click(objectsender,EventArgse){if(BllEvaluation.Add(GetEvaluation())>0){BigMessageBox.Show(“添加员工考评信息成功”,“添加员工考评信息”,MessageBoxButtons.OK,rmation);Bind();Init();}else{BigMessageBox.Show(“添加员工考评信息失败”,“添加员工考评信息”,MessageBoxButtons.OK,rmation);}}privateEvaluationGetEvaluation(){Evaluationmodel=newEvaluation();if(Utilities.ConvertNullToSpace(cboMonth.SelectedValue)!=““){model.EvaMonth=Utilities.ConvertInt(cboMonth.SelectedValue.ToStri ng());}if(Utilities.ConvertNullToSpace(cboGrade.SelectedValue)!=““){model.MarkDegreeID=Utilities.ConvertInt(cboGrade.SelectedValue.To String());}model.Invigilater=txtPerson.Text;model.EmployeeNO=labEmpID.Text.Trim();model.Mark=Utilities.ConvertInt(this.txtNumber.Text);model.Remark=this.txtRemark.Text;model.Result=this.txtResult.Text;model.Subject=this.txtProject.Text;if(labID.Text.Trim()!=““){model.EvaluationID=int.Parse(labID.Text.Trim());}returnmodel;}privatevoidbtnUpdate_Click(objectsender,EventArgse){if(labID.Text.Trim()!=““){if(BllEvaluation.Update(GetEvaluation())>0){BigMessageBox.Show(“修改员工考评信息成功”,“修改员工考评信息”,MessageBoxButtons.OK,rmation);this.dgvAssess.DataSource=BoxDataTable.GetAssessTable(labEmpID.Te xt.Trim());Init();}else{BigMessageBox.Show(“修改员工考评信息失败”,“修改员工考评信息”,MessageBoxButtons.OK,rmation);}}else{BigMessageBox.Show(“请选择一个员工的考评信息”,“修改员工考评信息”,MessageBoxBut tons.OK,rmation);}}privatevoidbtnDelete_Click(objectsender,EventArgse){if(!Utilities.ConvertNullToSpace(this.dgvAssess.Rows[this.dgvAsse ss.CurrentRow.Index].Cells[“EvaluationID”]).Equals(““)) {if(BllEvaluation.Delete(Utilities.ConvertInt(this.dgvAssess.Rows[ this.dgvAssess.CurrentRow.Index].Cells[“EvaluationID”].Value.ToStri ng()))>0){BigMessageBox.Show(“删除员工考评信息成功”,“删除员工考评信息”,MessageBoxButtons.OK,rmation);this.dgvAssess.DataSource=BoxDataTable.GetAssessTable(labEmpID.Te xt.Trim());Init();}else{BigMessageBox.Show(“删除员工考评信息失败”,“删除员工考评信息”,MessageBoxButtons.OK,rmation);}}else{BigMessageBox.Show(“请选择一个员工的考评信息”,“删除员工考评信息”,MessageBoxButtons.OK,rmation);}}privatevoiddgvEmp_CellClick(objectsender,DataGridViewCellEventArg se){if(dgvEmp.DataSource!=null&&dgvEmp.Rows.Count>0){labEmpID.Text=this.dgvEmp.Rows[e.RowIndex].Cells[“EmployeeNO”]. Value.ToString();this.dgvAssess.SelectionMode=DataGridViewSelectionMode.FullRowSel ect;this.dgvAssess.DataSource=BoxDataTable.GetAssessTable(this.dgvEmp .Rows[e.RowIndex].Cells[“EmployeeNO”].Value.ToString());this.btnAdd.Enabled=true;}}privatevoiddgvAssess_CellClick(objectsender,DataGridViewCellEvent Argse){if(dgvAssess.DataSource!=null&&dgvAssess.Rows.Count>0){labID.Text=this.dgvAssess.Rows[e.RowIndex].Cells[“EvaluationID”].Value.ToString();this.btnUpdate.Enabled=true;this.btnDelete.Enabled=true;this.txtNumber.Text=Utilities.ConvertNullToSpace(this.dgvAssess.R ows[e.RowIndex].Cells[“Mark”].Value);this.txtProject.Text=Utilities.ConvertNullToSpace(this.dgvAssess. Rows[e.RowIndex].Cells[“Subject”].Value);this.txtRemark.Text=Utilities.ConvertNullToSpace(this.dgvAssess.R ows[e.RowIndex].Cells[“Remark”].Value);this.txtResult.Text=Utilities.ConvertNullToSpace(this.dgvAssess.R ows[e.RowIndex].Cells[“Result”].Value);this.cboGrade.Text=Utilities.ConvertNullToSpace(this.dgvAssess.Ro ws[e.RowIndex].Cells[“MarkDegreeID”].Value);this.cboMonth.Text=Utilities.ConvertNullToSpace(this.dgvAssess.Ro ws[e.RowIndex].Cells[“EvaMonth”].Value);this.txtPerson.Text=Utilities.ConvertNullToSpace(this.dgvAssess.R ows[e.RowIndex].Cells[“Invigilater”].Value);}}privatevoidbtnClean_Click(objectsender,EventArgse){Init();F1.4数据访问类:publicclassBllExperience{publicBllExperience(){}//////增加一条数据///publicstaticintAdd(Experiencemodel){StringBuilderstrSql=newStringBuilder();strSql.Append(“intoExperience(“);strSql.Append(“Posi tion,Department,StartDate,EndDate,EmployeeNO, Remark”);strSql.Append(“)”);strSql.Append(“values(“);strSql.Append(““+model.Position+“,”);strSql.Append(““+model.Department+“,”);strSql.Append(““+model.StartDate+“,”);strSql.Append(““+model.EndDate+“,”);strSql.Append(““+model.EmployeeNO+“,”);strSql.Append(““+model.Remark+““);strSql.Append(“)”);returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString());}///更新一条数据///publicstaticintUpdate(Experiencemodel){StringBuilderstrSql=newStringBuilder();strSql.Append(“Experienceset“);strSql.Append(“Position=“+model.Position+“,”);strSql.Append(“Department=“+model.Department+“,”);strSql.Append(“StartDate=“+model.StartDate+“,”);strSql.Append(“EndDate=“+model.EndDate+“,”);strSql.Append(“EmployeeNO=“+model.EmployeeNO+“,”);strSql.Append(“Remark=“+model.Remark+““);strSql.Append(“WHEREExperienceID=“+model.ExperienceID+““); returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString()); }//////删除一条数据///publicstaticintDelete(intExperienceID){StringBuilderstrSql=newStringBuilder();strSql.Append(“Experience“);strSql.Append(“whereExperienceID=“+ExperienceID); returnDbHelperSQL.Instance.ExcuteNonQuery(strSql.ToString());//////得到一个对象实体///publicExperienceGetModel(intExperienceID){StringBuilderstrSql=newStringBuilder();strSql.Append(“select“);strSql.Append(“[ExperienceID],[Position],[Department],[StartDate ],[EndDate],[EmployeeID],[Remark]“);strSql.Append(“fromExperience“);strSql.Append(“whereExperienceID=“+ExperienceID);Experiencemodel=newExperience();DataTabledt=DbHelperSQL.Instance.GetDataTable(strSql.ToString());model.ExperienceID=ExperienceID;if(dt.Rows.Count>0){model.Position=dt.Rows[0][“Position”].ToString();model.Departmen t=dt.Rows[0][“Department”].ToString();if(dt.Rows[0][“StartDate”].ToString()!=““){model.StartDate=DateTime.Parse(dt.Rows[0][“StartDate”].ToString ());}if(dt.Rows[0][“EndDate”].ToString()!=““)model.EndDate=DateTime.Parse(dt.Rows[0][“EndDate”].ToString());}if(dt.Rows[0][“EmployeeID”].ToString()!=““){model.EmployeeNO=dt.Rows[0][“EmployeeID”].ToString();}model.Remark=dt.Rows[0][“Remark”].ToString();returnmodel;}else{returnnull;}}}F1.5生日提醒主要代码:获得当天生日的员工名称StringBuildersb=newStringBuilder();sb.Append(“SELECTEmployNameFROMEMPLOYEE“);sb.Append(“WHERECAST(MONTH(BIRTHDAY)ASVARCHAR(2))+CAST(DAY(BIRTH DAY)ASVARCHAR(2))=CAST(MONTH(GETDATE())ASVARCHAR(2))+CAST(DAY(GETDATE ())ASVARCHAR(2))”);returnDbHelperSQL.Instance.GetDataTable(sb.ToString());F1.6启动第三方EXE文件操作类:publicclassTools{//////启动数据库备份///publicstaticvoidDataBak(){System.Diagnostics.Process.Start(“BACKUP.exe”); }//////计算器///publicstaticvoidputer(){System.Diagnostics.Process.Start(“calc.exe”);}//////启动画图工具///publicstaticvoidImg(){System.Diagnostics.Process.Start(“mspaint.exe”); }//////记事本///publicstaticvoidOpenNotepad(){System.Diagnostics.Process.Start(“Notepad.exe”); }}[计算机毕业论文源代码]。
各种指标源码范文
各种指标源码范文以下是一些常见的指标源码,用于计算不同方面的数据指标。
1. 平均值(Mean):```pythondef mean(data):sum = 0count = 0for d in data:sum += dcount += 1return sum / count```2. 中位数(Median):```pythondef median(data):sorted_data = sorted(data)n = len(sorted_data)if n % 2 == 0:return (sorted_data[n//2 - 1] + sorted_data[n//2]) / 2else:return sorted_data[n//2]```3. 众数(Mode):```pythondef mode(data):from collections import Countercounter = Counter(data)max_count = max(counter.values()return [k for k, v in counter.items( if v == max_count] ```4. 方差(Variance):```pythondef variance(data):mean_val = mean(data)squared_diff_sum = sum([(d - mean_val)**2 for d in data]) return squared_diff_sum / len(data)```5. 标准差(Standard Deviation):```pythondef std_deviation(data):return variance(data) ** 0.5```6. 相关系数(Correlation Coefficient):```pythondef correlation_coefficient(x, y):mean_x = mean(x)mean_y = mean(y)n = len(x)sum_xy = sum([xi*yi for xi, yi in zip(x, y)])sum_xx = sum([(xi - mean_x)**2 for xi in x])sum_yy = sum([(yi - mean_y)**2 for yi in y])return (sum_xy - (n * mean_x * mean_y)) / ((sum_xx * sum_yy) ** 0.5)```7. 百分位数(Percentile):```pythondef percentile(data, p):sorted_data = sorted(data)n = len(sorted_data)k=(n-1)*pf = math.floor(k)c = math.ceil(k)if f == c:return sorted_data[int(k)]else:return sorted_data[int(f)] * (c - k) + sorted_data[int(c)] * (k - f)```8. 四分位数(Quartiles):```pythondef quartiles(data):q1 = percentile(data, 0.25)q2 = percentile(data, 0.5)q3 = percentile(data, 0.75)return q1, q2, q3```以上是一些常见的指标计算方法的源代码。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
实验一:源代码参考:程序如下:#include <stdio.h>#include <stdlib.h>/*顺序表的定义:*/#define ListSize 100typedef struct{ int data[ListSize]; /*向量data用于存放表结点*/ int length; /*当前的表长度*/}SeqList;void main(){ void CreateList(SeqList *L,int n);void PrintList(SeqList *L,int n);int LocateList(SeqList *L,int x);void InsertList(SeqList *L,int x,int i);void DeleteList(SeqList *L,int i);SeqList L;int i,x;int n=10; /*THE LENGTH OF LIST*/L.length=0;clrscr();CreateList(&L,n); /*CREAT THE LIST*/PrintList(&L,n); /*PRINT THE LIST*/printf("INPUT THE RESEARCH ELEMENT");scanf("%d",&x);i=LocateList(&L,x);printf("the research position is %d\n",i); /*顺序表查找*/ printf("input the position of insert:\n");scanf("%d",&i);printf("input the value of insert\n");scanf("%d",&x);InsertList(&L,x,i); /*顺序表插入*/PrintList(&L,n); /*打印顺序表*/printf("input the position of delete\n");scanf("%d",&i);DeleteList(&L,i); /*顺序表删除*/PrintList(&L,n);getch();/*打印顺序表*/}/*顺序表的建立:*/void CreateList(SeqList *L,int n){int i;printf("please input n numbers\n");for(i=1;i<=n;i++){scanf("%d",&L->data[i]);}L->length=n;}/*顺序表的打印:*/void PrintList(SeqList *L,int n){int i;printf("the sqlist is\n");for(i=1;i<=n;i++)printf("%d ",L->data[i]);}/*顺序表的查找:*/int LocateList(SeqList *L,int x) {int i;for(i=1;i<=10;i++)if((L->data[i])==x) return(i);else return(0);}/*顺序表的插入:*/void InsertList(SeqList *L,int x,int i) {int j;for(j=L->length;j>=i;j--)L->data[j+1]=L->data[j];L->data[i]=x;L->length++;}/*顺序表的删除:*/void DeleteList(SeqList *L,int i){ int j;for(j=i;j<=(L->length)-1;j++)L->data[j]=L->data[j+1];}实验二源代码参考#include "stdio.h"#include "conio.h"#define MaxSize 100 /*栈中的元素的最大个数*/ typedef int ElemType;typedef struct{ElemType data[MaxSize];/*存放堆栈的数组*/int top;/*栈顶元素*/}Stack,*S;/*堆栈的初始化*/void InitStack(Stack *S){/*指向的是最顶端的元素取值范围为从0~MaxSize-1为-1时说明为空栈*/S->top=-1;}/*判栈空操作*/int StackEmpty(Stack *S){return (S->top==-1?1:0);}/*压栈操作*/void Push(Stack *S,ElemType x){int i ;if (S->top==MaxSize-1){printf("Stack is full");exit(1);}/*else S->data[++S->top]=x; */else{S->top = S->top+1;i = S->top;S->data[i] = x;}}/*出栈操作*/int Pop(Stack *S){int i;if(StackEmpty(S)){printf("\n Stack is free!");return 0;}else{i=S->data[S->top];S->top--;return i;}}/*栈长度操作*/int GetLength(Stack *S){return S->top+1;}/*取栈顶操作*/int GetTop(Stack *S){if(StackEmpty(S)){printf("\nStack is free");return 0;}else{if(GetLength(S))return 0;elsereturn S->data[S->top]; }}main(){Stack *S;int i,j,e,result;InitStack(S);for(i=1;i<=2;i++){scanf("%d",&e);Push(S,e);}printf("The number of elem is :%d",GetLength(S));e = Pop(S);printf("\nAfter a pop ,The number of elem is :%d",GetLength(S));printf("\n%d",e);for(i =0; i<10 ; i++)printf("\n%d",GetTop(S));getch();}实验三源代码参考. #include <stdio.h>#include <string.h>/*得到数组的长度*/int strLen(char *s){int i = 0;while(s[i]!='\0'){i ++;}return i ;}/*简单模式匹配算法*/int Index(char *S,char *T,int pos){/*存放比较的总次数*/int times = 0;int i = pos-1, j = 0;int sLen = strLen(S);int tLen = strLen(T);while(i<sLen && j<tLen){times ++;if(S[i]==T[j]) {i++; j++;} /* 继续比较后续字符*/else {i = i-j+1; j=0;} /* 指针后退重新比较*/ }printf("the times that compares are %d\n",times);if( j >= tLen ){return i-tLen+1;}else return 0;}实验四源代码参考# define bitreptr struct type1 /*二叉树及其先序边历*/ # define null 0# define len sizeof(bitreptr)bitreptr *bt;int f,g;bitreptr /*二叉树结点类型说明*/{char data;bitreptr *lchild,*rchild;};preorder(bitreptr *bt) /*先序遍历二叉树*/{if(g==1) printf("先序遍历序列为:\n");g=g+1;if(bt){printf("%6c",bt->data);preorder(bt->lchild);preorder(bt->rchild);}else if(g==2) printf("空树\n");}bitreptr *crt_bt() /*建立二叉树*/{bitreptr *bt;char ch;if(f==1) printf("输入根结点,#表示结束\n"); else printf("输入结点,#表示结束\n");scanf("\n%c",&ch);f=f+1;if(ch=='#') bt=null;else{bt=(bitreptr *)malloc(len);bt->data=ch;printf("%c 左孩子",bt->data);bt->lchild=crt_bt();printf("%c 右孩子",bt->data);bt->rchild=crt_bt();}return(bt);}main(){f=1;g=1;bt=crt_bt();preorder(bt);}。