📄 coffitem.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;
using PlatF;
namespace Charge
{
/// <summary>
/// COffItem 的摘要说明。
/// </summary>
public class COffItem : System.Windows.Forms.Form
{
private ArrayList itemList=new ArrayList();
int v_itemid;
private System.Windows.Forms.GroupBox ggg;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ComboBox cbbitem;
private System.Windows.Forms.Button btnoff;
private System.Windows.Forms.Button btncancel;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public COffItem()
{
//
// 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.ggg = new System.Windows.Forms.GroupBox();
this.cbbitem = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.btnoff = new System.Windows.Forms.Button();
this.btncancel = new System.Windows.Forms.Button();
this.ggg.SuspendLayout();
this.SuspendLayout();
//
// ggg
//
this.ggg.Controls.Add(this.cbbitem);
this.ggg.Controls.Add(this.label1);
this.ggg.ForeColor = System.Drawing.SystemColors.ControlText;
this.ggg.Location = new System.Drawing.Point(0, 0);
this.ggg.Name = "ggg";
this.ggg.Size = new System.Drawing.Size(408, 120);
this.ggg.TabIndex = 0;
this.ggg.TabStop = false;
this.ggg.Text = "项目选择";
//
// cbbitem
//
this.cbbitem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbbitem.Location = new System.Drawing.Point(176, 48);
this.cbbitem.Name = "cbbitem";
this.cbbitem.Size = new System.Drawing.Size(208, 20);
this.cbbitem.TabIndex = 1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(48, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(104, 23);
this.label1.TabIndex = 0;
this.label1.Text = "选择要废止的项目";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// btnoff
//
this.btnoff.ForeColor = System.Drawing.SystemColors.ControlText;
this.btnoff.Location = new System.Drawing.Point(56, 136);
this.btnoff.Name = "btnoff";
this.btnoff.Size = new System.Drawing.Size(75, 32);
this.btnoff.TabIndex = 1;
this.btnoff.Text = "废止(&O)";
this.btnoff.Click += new System.EventHandler(this.btnoff_Click);
//
// btncancel
//
this.btncancel.ForeColor = System.Drawing.SystemColors.ControlText;
this.btncancel.Location = new System.Drawing.Point(248, 136);
this.btncancel.Name = "btncancel";
this.btncancel.Size = new System.Drawing.Size(75, 32);
this.btncancel.TabIndex = 2;
this.btncancel.Text = "取消(&C)";
this.btncancel.Click += new System.EventHandler(this.btncancel_Click);
//
// COffItem
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(410, 178);
this.Controls.Add(this.btncancel);
this.Controls.Add(this.btnoff);
this.Controls.Add(this.ggg);
this.ForeColor = System.Drawing.SystemColors.Window;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "COffItem";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "项目废止";
this.Load += new System.EventHandler(this.COffItem_Load);
this.ggg.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void COffItem_Load(object sender, System.EventArgs e)
{
OracleConnection myConn = Connection.DBConnection;
if (myConn == null)
{
return;
}
//导入当前在用的项目
itemList.Clear();
string mySql1="select ItemID,ItemName from Charge_Items where Useable=1";
OracleCommand dbCommand1 = new OracleCommand(mySql1, myConn);
try
{
OracleDataReader myReader1 = dbCommand1.ExecuteReader();
while(myReader1.Read())
{
itemList.Add(myReader1.GetInt32(0));
itemList.Add(myReader1.GetString(1));
}
myReader1.Close();
myConn.Close();
}
catch(Exception ee)
{
//E.ShowMessage(ErrorCode.E_8_DBUnknownError_Code);
MessageBox.Show(this,"未知数据库错误");
return;
}
cbbitem.Items.Add("全部");
for (int i = 1; i < itemList.Count; i += 2)
{
cbbitem.Items.Add(itemList[i]);
}
cbbitem.SelectedIndex = 0;
}
private void btnoff_Click(object sender, System.EventArgs e)
{
if(cbbitem.SelectedIndex==0)
{
MessageBox.Show(this,"请选择要废止的收费项目");
return;
}
v_itemid=Convert.ToInt32(itemList[cbbitem.SelectedIndex*2-2]);
int count=0;
OracleConnection myConn1 = Connection.DBConnection;
if (myConn1 == null)
{
return;
}
string mysql2="select count(*) from Charge_io where charged=0 and itemid="+v_itemid;
OracleCommand dbCommand2 = new OracleCommand(mysql2, myConn1);
try
{
OracleDataReader myReader2 = dbCommand2.ExecuteReader();
while(myReader2.Read())
{
//itemList.Add(myReader1.GetInt32(0));
//itemList.Add(myReader1.GetString(1));
count=myReader2.GetInt32(0);
}
myReader2.Close();
//myConn.Close();
}
catch(Exception ee)
{
//E.ShowMessage(ErrorCode.E_8_DBUnknownError_Code);
MessageBox.Show(this,"未知数据库错误");
return;
}
if(count>0)
{
string report="本收费项目尚存在未交费对象,废止后无法对其进行收费。\n"+
"确定废止吗?";
if(MessageBox.Show(report,"项目属性",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.No)
{
return;
}
}
//调用存储过程(Charge.SP_Off_Item)
OracleParameter[] inParam = {new OracleParameter()};
inParam[0].ParameterName = "p_itemid";
inParam[0].OracleType = OracleType.Int32;
inParam[0].Value = v_itemid;
OracleParameter[] outParam = {new OracleParameter()};
outParam[0].ParameterName = "p_Result";
outParam[0].OracleType = OracleType.Int32;
outParam[0].Direction = ParameterDirection.Output;
GlobleHelper.ExecStoredProc("SP_Off_Item", inParam, ref outParam);
int error = Convert.ToInt32(outParam[0].Value);
if (error != 0)
{
MessageBox.Show(this, "未知数据库错误,废止项目失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
MessageBox.Show(this, "废止收费项目成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btncancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -