📄 copenchargeitem.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OracleClient;
using GlobleUtility;
namespace Charge
{
/// <summary>
/// COpenChargeItem 的摘要说明。
/// </summary>
public class COpenChargeItem : System.Windows.Forms.Form
{
private ErrorCode E = new ErrorCode();
private int sItemID;//所选项目ID
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ComboBox cboItem;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public COpenChargeItem()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cboItem = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.cboItem);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.ForeColor = System.Drawing.SystemColors.ControlText;
this.groupBox1.Location = new System.Drawing.Point(0, 8);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(448, 128);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "选定";
//
// cboItem
//
this.cboItem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboItem.Location = new System.Drawing.Point(192, 48);
this.cboItem.Name = "cboItem";
this.cboItem.Size = new System.Drawing.Size(152, 20);
this.cboItem.TabIndex = 1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(160, 24);
this.label1.TabIndex = 0;
this.label1.Text = "选择项目";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
this.button1.Location = new System.Drawing.Point(80, 152);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(72, 24);
this.button1.TabIndex = 1;
this.button1.Text = "开通(&O)";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
this.button2.Location = new System.Drawing.Point(304, 152);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(72, 24);
this.button2.TabIndex = 2;
this.button2.Text = "取消(&C)";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// COpenChargeItem
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(442, 186);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.ForeColor = System.Drawing.SystemColors.Window;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "COpenChargeItem";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "开通收费项目";
this.Load += new System.EventHandler(this.COpenChargeItem_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void COpenChargeItem_Load(object sender, System.EventArgs e)
{
//加载项目名
OracleConnection myConn = Connection.DBConnection;
if (myConn == null)
{
return;
}
string mySql = "";
//mySql = "Select ItemName From Charge_Items where Useable=1 Order By ItemID";
mySql = "Select ItemName From Charge_Items where Useable=0 Order By itemid";
OracleCommand dbCommand = new OracleCommand(mySql, myConn);
try
{
OracleDataReader myReader = dbCommand.ExecuteReader();
while (myReader.Read())
{
cboItem.Items.Add(myReader.GetString(0));
}
myReader.Close();
myConn.Close();
}
catch(Exception ee)
{
E.ShowMessage(ErrorCode.E_8_DBUnknownError_Code);
return;
}
}
private void button2_Click(object sender, System.EventArgs e)
{
this.Close();
}
//开通项目
private void button1_Click(object sender, System.EventArgs e)
{
//确保选择收费项目
if(cboItem.Text.Trim()=="")
{
MessageBox.Show(this,"请选择收费项目!","提示信息");
return;
}
//取得所选项目ID
OracleConnection myConn = Connection.DBConnection;
if (myConn == null)
{
return;
}
string mySql = "";
mySql = "Select ItemID From Charge_Items where ItemName like '"+cboItem.Text.Trim()+"'";
OracleCommand dbCommand = new OracleCommand(mySql, myConn);
try
{
OracleDataReader myReader = dbCommand.ExecuteReader();
while (myReader.Read())
{
sItemID=myReader.GetInt32(0);
}
myReader.Close();
//myConn.Close();
}
catch
{
E.ShowMessage(ErrorCode.E_8_DBUnknownError_Code);
return;
}
string mySql1="update Charge_Items set Useable=1 where ItemID="+sItemID;
OracleCommand dbCommand1 = new OracleCommand(mySql1, myConn);
try
{
int back=dbCommand1.ExecuteNonQuery();
}
catch
{
E.ShowMessage( ErrorCode.E_8_DBUnknownError_Code);
return;
}
myConn.Close();
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -