?? copenchargeitem.cs
字號(hào):
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 的摘要說(shuō)明。
/// </summary>
public class COpenChargeItem : System.Windows.Forms.Form
{
private ErrorCode E = new ErrorCode();
private int sItemID;//所選項(xiàng)目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>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public COpenChargeItem()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </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 = "選擇項(xiàng)目";
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 = "開(kāi)通(&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 = "開(kāi)通收費(fèi)項(xiàng)目";
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)
{
//加載項(xiàng)目名
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();
}
//開(kāi)通項(xiàng)目
private void button1_Click(object sender, System.EventArgs e)
{
//確保選擇收費(fèi)項(xiàng)目
if(cboItem.Text.Trim()=="")
{
MessageBox.Show(this,"請(qǐng)選擇收費(fèi)項(xiàng)目!","提示信息");
return;
}
//取得所選項(xiàng)目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();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -