📄 ys_zhudan.vb
字号:
Private Sub gongchengbianhao()
Dim mystr As String
Dim mydataset As New DataSet
mystr = "select 工程编号 from technologyInf where 预算过程标志 =" + Chr(39) + "0" + Chr(39) + " "
mydataset = GetDataFromDB(mystr)
Dim i As Integer
Dim y As Integer = mydataset.Tables(0).Rows.Count
Dim str As String
ComboBox2.Items.Clear()
For i = 0 To (y - 1)
str = Trim(mydataset.Tables(0).Rows(i)("工程编号"))
ComboBox2.Items.Add(str)
Next
mydataset.Dispose()
End Sub
'本窗体的load 事件
Private Sub ys_zhudan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
gongchengbianhao() '得到待填写的工程编号
End Sub
'显示已有请购单的请购内容
Private Sub xianshicailiaoxinxi()
Dim ssstr As String
If RadioButton2.Checked = True Then
ssstr = ComboBox3.Text.Trim
ElseIf RadioButton1.Checked = True Then
ssstr = ComboBox1.Text.Trim
End If
Dim str As String
str = "select 编号,项目费用编码,[CD1+2编码],[CD3+4编码],设备名称,参数,[预算支出(人民币-元)] from yusuan_xiangxiqingkuangbiao where 预算单编号=" + Chr(39) + ssstr + Chr(39) + " and 项目费用编码 > " + Chr(39) + "299" + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(str)
Me.DataGrid1.DataSource = mydataset
mydataset.Dispose()
End Sub
'根据TextBox17,显示物品录入窗口
Private Sub TextBox17_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox17.DoubleClick
If TextBox16.Text.Trim = "" And RadioButton2.Checked = False Then
MsgBox("请输入预算单号!", MsgBoxStyle.Information, "提示")
TextBox16.Focus()
Exit Sub
End If
If RadioButton2.Checked = False Then
qg_pub_str = TextBox16.Text.Trim
Else
pub_str = ComboBox3.Text.Trim '预算编号
fk_pub_str = ComboBox2.Text.Trim '工程编号
qg_pub_str = TextBox2.Text.Trim '工程名称
End If
If qg_pub_str = "现有预算单号" Then
MsgBox("请选择预算单号!", MsgBoxStyle.Information, "提示")
Exit Sub
End If
Dim myform As New project_budget_inf
myform.Show()
Me.Dispose()
End Sub
'在ComboBox3中显示现在有的请购单
Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
If RadioButton2.Checked = True Then
xianshiqinggoudan_cmb3() '在ComboBox3中显示现在有的请购单
Button2.Enabled = False
Button3.Enabled = True
Button1.Enabled = True
TextBox17.Enabled = True
TextBox16.Enabled = False
DataGrid1.Enabled = True
ComboBox3.Text = "现有预算单号"
End If
End Sub
'在ComboBox3上显示所有正在录入的请购编号
Private Sub xianshiqinggoudan_cmb3()
Dim str As String = "select 预算单编号 from yusuan_zhubiao where 标志 = " + Chr(39) + "2" + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(str)
Dim i As Integer = 0
Dim y As Integer = mydataset.Tables(0).Rows.Count
Me.ComboBox3.Items.Clear()
For i = 0 To (y - 1)
Dim sstr As String = Trim(mydataset.Tables(0).Rows(i)("预算单编号"))
ComboBox3.Items.Add(sstr)
Next
mydataset.Dispose()
End Sub
'根据请购单编号,显示请购单的内容
Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
'判断是否是退回审批
If Me.RadioButton2.Checked = True Then
Dim mystr As String
mystr = "select * from yusuan_zhubiao where 预算单编号 =" + Chr(39) + ComboBox3.Text.Trim + Chr(39) + " and 是否为退回 =" + "1"
Dim mydataset As New DataSet
mydataset = GetDataFromDB(mystr)
If mydataset.Tables(0).Rows.Count <> 0 Then
MsgBox("此为退回预算!", MsgBoxStyle.Information, "提示")
End If
mydataset.Dispose()
End If
xianshicailiaoxinxi() '根据请购单编号,显示请购单的内容
xianzhiqinggoudanzhudanneirong() '显示请购单主单内容
End Sub
'显示请购单主单内容
Private Sub xianzhiqinggoudanzhudanneirong()
Dim ssstr As String
If RadioButton2.Checked = True Then
ssstr = ComboBox3.Text.Trim
ElseIf RadioButton1.Checked = True Then
ssstr = ComboBox1.Text.Trim
End If
Dim str As String
str = "select * from yusuan_zhubiao where 预算单编号=" + Chr(39) + ssstr + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(str)
DataGrid2.DataSource = mydataset
TextBox16.Text = ssstr
ComboBox2.Text = Trim(mydataset.Tables(0).Rows(0)("工程编码"))
TextBox2.Text = Trim(mydataset.Tables(0).Rows(0)("工程名称"))
mydataset.Dispose()
End Sub
'新建采购单号
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox16.ReadOnly = False
TextBox16.Enabled = True
TextBox17.Enabled = False
Button3.Enabled = False
Button2.Enabled = True
RadioButton2.Checked = False
DataGrid1.Enabled = False
End Sub
'保存新建的请购单
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox17.Enabled = True
Button3.Enabled = True
'判断请购单号有没有填写
If TextBox16.Text.Trim = "" Then
MsgBox("预算单编号不能为空,请输入预算单编号!", MsgBoxStyle.Information, "提示!")
TextBox16.Focus()
Exit Sub
End If
'判断该请购单号是否存在
Dim sstr As String
sstr = "select * from yusuan_zhubiao where 预算单编号 = " + Chr(39) + TextBox16.Text.Trim + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(sstr)
If mydataset.Tables(0).Rows.Count > 0 Then
MsgBox("该预算单编号已经存在,请输入其它预算单编号!", MsgBoxStyle.Information, "提示!")
TextBox16.Focus()
Exit Sub
End If
mydataset.Dispose()
'保存新建的请购单的信息
Dim sqlstr As String
sqlstr = "INSERT INTO yusuan_zhubiao " & _
"(预算单编号,工程编码,工程名称) " & _
"VALUES ('" & Me.TextBox16.Text.Trim & "','" & Me.ComboBox2.Text.Trim & "','" & Me.TextBox2.Text.Trim & "')"
If UpdateData(sqlstr) = False Then
MsgBox("没有成功添加了该信息,请与管理员联系!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
Else
'更新工程的预算过程标志
Dim sqlstr1 As String
sqlstr1 = "UPDATE technologyInf SET 预算过程标志=" + Chr(39) + "1" + Chr(39) + "where 工程编号=" + Chr(39) + Trim(ComboBox2.Text) + Chr(39)
If UpdateData(sqlstr1) = True Then
MsgBox("预算单保存成功,请双击-录入信息-文本筐,填写具体预算信息!", MsgBoxStyle.Information, "提示!")
Button2.Enabled = False
RadioButton2.Checked = True
Else
MsgBox("工程信息中预算过程标志,没有成功更新,请与管理员联系!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "添加成功")
Exit Sub
End If
End If
End Sub
'已经提交请购单
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
ComboBox1.Text = "已提交预算单号"
Button1.Enabled = True
Button2.Enabled = False
Button3.Enabled = False
Dim str As String
str = "select 预算单编号 from yusuan_zhubiao where 标志 > " + Chr(39) + "2" + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(str)
Dim i As Integer = 0
Dim y As Integer = mydataset.Tables(0).Rows.Count
Me.ComboBox1.Items.Clear()
For i = 0 To (y - 1)
Dim sstr As String = Trim(mydataset.Tables(0).Rows(i)("预算单编号"))
ComboBox1.Items.Add(sstr)
Next
mydataset.Dispose()
End Sub
'由工程编号得到工程名称
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
TextBox16.Text = "ys_" + ComboBox2.Text.Trim
Dim str As String = "select 工程名称 from technologyInf where 工程编号 = " + Chr(39) + ComboBox2.Text.Trim + Chr(39)
Dim mydataset As New DataSet
mydataset = GetDataFromDB(str)
TextBox2.Text = Trim(mydataset.Tables(0).Rows(0)("工程名称"))
mydataset.Dispose()
End Sub
'更新主采购单的内容
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim sqlstr As String
sqlstr = "UPDATE yusuan_zhubiao SET 工程编码=" + Chr(39) + Trim(ComboBox2.Text) + Chr(39) + ",工程名称=" + Chr(39) + Trim(TextBox2.Text) + Chr(39) + "where 预算单编号=" + Chr(39) + Trim(ComboBox3.Text) + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功更新了该预算主单信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "更新成功")
Else
MsgBox("不能成功更新该预算主单信息,请与管理员联系!", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "提示!")
Exit Sub
End If
End Sub
'改变已提交请购编号,显示详细的请购信息
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text.Trim = "已提交请购单" Then
Exit Sub
End If
xianzhiqinggoudanzhudanneirong() '显示请购单内容
xianshicailiaoxinxi() '根据请购单编号,显示请购单的内容
End Sub
'提交请购单,如果“现有请购单”没有被选中,或者选中了,但他的text为“现有请购单”,则不能进行提交
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If RadioButton2.Checked = False Or ComboBox3.Text = "现有预算单号" Then
MsgBox("请选择要提交的预算单号!", MsgBoxStyle.Information, "提示!")
Exit Sub
End If
If MsgBox("注意:请再好好复查一下,如果确定无误后再提交,提交后你将不能再进行修改了。你确定要提交吗?", MsgBoxStyle.OKCancel, "提示") = MsgBoxResult.OK Then
Dim sqlstr As String
Dim mysqlstr As String
sqlstr = "UPDATE yusuan_zhubiao SET 项目部人员提交时间=" + Chr(39) + Now + Chr(39) + " , 项目部录入人员 =" + Chr(39) + UserName + Chr(39) + ",标志=" + Chr(39) + "3" + Chr(39) + ",是否为退回=" + Chr(39) + "0" + Chr(39) + "where 预算单编号=" + Chr(39) + ComboBox3.Text.Trim + Chr(39)
If UpdateData(sqlstr) = True Then
MsgBox("已经成功提交了该预算信息", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "提示")
Me.RadioButton1.Checked = True
Else
MsgBox("没有成功提交该预算信息,请与管理员联系", MsgBoxStyle.OKOnly + _
MsgBoxStyle.Exclamation, "提示")
Exit Sub
End If
Else
Exit Sub
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim myform As New technologyInf
myform.Show()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -