📄 cdlgitwmmaintain.cs
字号:
this.groupBox1.TabStop = false;
this.groupBox1.Text = "对象范围选定";
//
// groupBox2
//
this.groupBox2.Controls.Add(this.cbbItem);
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Location = new System.Drawing.Point(0, 8);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(568, 64);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "收费项目选定";
//
// cbbItem
//
this.cbbItem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbbItem.Location = new System.Drawing.Point(192, 32);
this.cbbItem.Name = "cbbItem";
this.cbbItem.Size = new System.Drawing.Size(256, 20);
this.cbbItem.TabIndex = 1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(64, 32);
this.label1.Name = "label1";
this.label1.TabIndex = 0;
this.label1.Text = "收费项目:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.label3);
this.groupBox4.Controls.Add(this.txtMoney);
this.groupBox4.Controls.Add(this.label2);
this.groupBox4.Controls.Add(this.lvSel);
this.groupBox4.Location = new System.Drawing.Point(0, 368);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(576, 168);
this.groupBox4.TabIndex = 2;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "取得对象";
//
// label3
//
this.label3.Location = new System.Drawing.Point(352, 136);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(24, 23);
this.label3.TabIndex = 3;
this.label3.Text = "元";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtMoney
//
this.txtMoney.Location = new System.Drawing.Point(235, 136);
this.txtMoney.Name = "txtMoney";
this.txtMoney.TabIndex = 2;
this.txtMoney.Text = "";
//
// label2
//
this.label2.Location = new System.Drawing.Point(112, 136);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "收费金额:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lvSel
//
this.lvSel.BackColor = System.Drawing.SystemColors.Info;
this.lvSel.Location = new System.Drawing.Point(0, 16);
this.lvSel.Name = "lvSel";
this.lvSel.Size = new System.Drawing.Size(576, 104);
this.lvSel.TabIndex = 0;
//
// btnSelected
//
this.btnSelected.Location = new System.Drawing.Point(104, 336);
this.btnSelected.Name = "btnSelected";
this.btnSelected.TabIndex = 3;
this.btnSelected.Text = "进入列表";
this.btnSelected.Click += new System.EventHandler(this.btnSelected_Click);
//
// btnIntoDB
//
this.btnIntoDB.Location = new System.Drawing.Point(248, 544);
this.btnIntoDB.Name = "btnIntoDB";
this.btnIntoDB.TabIndex = 4;
this.btnIntoDB.Text = "入库";
this.btnIntoDB.Click += new System.EventHandler(this.btnIntoDB_Click);
//
// btnOutListView
//
this.btnOutListView.Location = new System.Drawing.Point(312, 336);
this.btnOutListView.Name = "btnOutListView";
this.btnOutListView.TabIndex = 5;
this.btnOutListView.Text = "退出列表";
this.btnOutListView.Click += new System.EventHandler(this.btnOutListView_Click);
//
// CdlgItwmMaintain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(576, 573);
this.Controls.Add(this.btnOutListView);
this.Controls.Add(this.btnIntoDB);
this.Controls.Add(this.btnSelected);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.gb1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "CdlgItwmMaintain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "项目任务维护";
this.Load += new System.EventHandler(this.CdlgItwmMaintain_Load);
this.gb1.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void ckbTDept_CheckedChanged(object sender, System.EventArgs e)
{
if(ckbTDept.Checked)//选中部门,则部门选择按钮可用
{
btnTDept.Enabled=true;
}
else
{
btnTDept.Enabled=false;
}
}
private void rbtTec_CheckedChanged(object sender, System.EventArgs e)
{
if(rbtTec.Checked)//选中教工
{
ckbTDept.Enabled=true;//教工部门可选
}
else
{
ckbTDept.Enabled=false;
}
}
private void ckbTSubDept_CheckedChanged(object sender, System.EventArgs e)
{
}
private void txtTDept_TextChanged(object sender, System.EventArgs e)
{
if(txtTDept.Text.Length==0)//未选定教工部门,则无法选择子部门
{
ckbTSubDept.Enabled=false;
}
else
{
ckbTSubDept.Enabled=true;
}
}
private void rbtStu_CheckedChanged(object sender, System.EventArgs e)
{
if(rbtStu.Checked)//选中学生
{
ckbSDept.Enabled=true;//系可选
ckbSClass.Enabled=true;//班级可选
}
else
{
ckbSDept.Enabled=false;
ckbSClass.Enabled=false;
}
}
private void ckbSDept_CheckedChanged(object sender, System.EventArgs e)
{
if(ckbSDept.Checked)//选中系,则系选择按钮可用
{
btnSDept.Enabled=true;
}
else
{
btnSDept.Enabled=false;
}
}
private void ckbSClass_CheckedChanged(object sender, System.EventArgs e)
{
if(ckbSClass.Checked)
{
btnSClass.Enabled=true;
}
else
{
btnSClass.Enabled=false;
}
}
private void CdlgItwmMaintain_Load(object sender, System.EventArgs e)
{
//页面载入事件导入当前在用的收费项目
System.Data.OracleClient.OracleConnection myconn = Connection.DBConnection;
if(myconn==null)
{
return;
}
string mysql="select ItemID,ItemName from Charge_Items where useable=1";
OracleCommand mycommand=new OracleCommand(mysql, myconn);
OracleDataReader myreader=null;
try
{
myreader = mycommand.ExecuteReader();
}
catch(Exception ee)
{
MessageBox.Show("数据库查询出错,消息如下:\r\n"+ee.Message,"消息:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
while(myreader.Read())
{
ArrItemID.Add(myreader.GetInt32(0));
cbbItem.Items.Add(myreader.GetString(1));
}
myreader.Close();
myreader.Dispose();
myconn.Close();
}
private void btnSelected_Click(object sender, System.EventArgs e)
{
if(CheckInput())//输入性检查
{
System.Data.OracleClient.OracleConnection myconn = Connection.DBConnection;
if(myconn==null)
{
return;
}
string sql="";//选择收费对象sql语句
if(rbtStu.Checked)//选中学生
{
sql=StuSql();
OracleCommand stucommand=new OracleCommand(sql, myconn);
OracleDataReader stureader=null;
try
{
stureader=stucommand.ExecuteReader();
}
catch(Exception ee)
{
MessageBox.Show("数据库查询出错,消息如下:\r\n"+ee.Message,"消息:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
lvSel.Items.Clear();
lvSel.BeginUpdate();
FillListView(stureader,ref lvSel);
lvSel.EndUpdate();
}
if(rbtTec.Checked)
{
sql=TecSql();
OracleCommand teccommand=new OracleCommand(sql, myconn);
OracleDataReader tecreader=null;
try
{
tecreader=teccommand.ExecuteReader();
}
catch(Exception ee)
{
MessageBox.Show("数据库查询出错,消息如下:\r\n"+ee.Message,"消息:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
return;
}
lvSel.Items.Clear();
lvSel.BeginUpdate();
FillListView(tecreader,ref lvSel);
lvSel.EndUpdate();
}
}
}
//将由查询所得对象记录集加入ListView控件并显示
private void FillListView(OracleDataReader myreader,ref ListView mylv)
{
if(myreader==null)
return;
while(myreader.Read())
{
ListViewItem lvi=null;
lvi=mylv.Items.Add(myreader.GetString(1));//学号/教工号
lvi.SubItems.Add(myreader.GetString(2));//姓名
lvi.SubItems.Add(myreader.GetInt32(3).ToString());//类别
int type=myreader.GetInt32(3);
if(type==1)//学生 系,专业,班级都不为空
{
lvi.SubItems.Add(myreader.GetInt32(4).ToString());
lvi.SubItems.Add(myreader.GetInt32(5).ToString());
lvi.SubItems.Add(myreader.GetInt32(6).ToString());
}
else //教工 专业,班级为空
{
lvi.SubItems.Add(myreader.GetInt32(4).ToString());
lvi.SubItems.Add("");
lvi.SubItems.Add("");
}
lvi.Tag=myreader.GetString(0);
}
}
//选中学生,获得学生查询sql语句
private string StuSql()
{
string sql="select stu.userid,stu.usernumber,stu.name,1,class.deptid,stu.majorid,stu.classid"+
" from charge_suser_info stu,charge_class_info class where stu.classid=class.classid";
if(ckbSDept.Checked)
{
sql=sql+" and class.deptid="+txtSDept.Tag;//选中系
}
if(ckbSClass.Checked)//选中班级
{
sql=sql+" and stu.classid="+txtSClass.Tag;
}
if(ckbNumber.Checked)//选中学号
{
sql=sql+" and stu.usernumber like '"+txtNumber.Text.Trim()+"%'";
}
if(ckbName.Checked)//选中姓名
{
sql=sql+" and stu.name like '"+txtName.Text.Trim()+"%'";
}
return sql;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -