📄 choosestatus.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Lib;
namespace AssetCheck
{
/// <summary>
/// ChooseStatus 的摘要说明。
/// </summary>
public class ChooseStatus : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.Button btnChoose;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn1;
private System.Windows.Forms.DataGrid dgStatus;
private System.Windows.Forms.DataGridTextBoxColumn dataGridTextBoxColumn2;
public static CurrencyManager cmStatus=null;
public static DataTable dtStatus=null;
public static string StatusNo="";
public static string StatusName="";
public ChooseStatus()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.dgStatus = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this.dataGridTextBoxColumn1 = new System.Windows.Forms.DataGridTextBoxColumn();
this.dataGridTextBoxColumn2 = new System.Windows.Forms.DataGridTextBoxColumn();
this.btnExit = new System.Windows.Forms.Button();
this.btnChoose = new System.Windows.Forms.Button();
//
// dgStatus
//
this.dgStatus.Location = new System.Drawing.Point(8, 0);
this.dgStatus.Size = new System.Drawing.Size(224, 152);
this.dgStatus.TableStyles.Add(this.dataGridTableStyle1);
this.dgStatus.Text = "dataGrid1";
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.GridColumnStyles.Add(this.dataGridTextBoxColumn1);
this.dataGridTableStyle1.GridColumnStyles.Add(this.dataGridTextBoxColumn2);
this.dataGridTableStyle1.MappingName = "dt";
//
// dataGridTextBoxColumn1
//
this.dataGridTextBoxColumn1.HeaderText = "编号";
this.dataGridTextBoxColumn1.MappingName = "Code";
this.dataGridTextBoxColumn1.NullText = "(null)";
this.dataGridTextBoxColumn1.Width = 65;
//
// dataGridTextBoxColumn2
//
this.dataGridTextBoxColumn2.HeaderText = "名称";
this.dataGridTextBoxColumn2.MappingName = "Names";
this.dataGridTextBoxColumn2.NullText = "(null)";
this.dataGridTextBoxColumn2.Width = 150;
//
// btnExit
//
this.btnExit.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold);
this.btnExit.Location = new System.Drawing.Point(125, 156);
this.btnExit.Size = new System.Drawing.Size(104, 39);
this.btnExit.Text = "0.返回";
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
//
// btnChoose
//
this.btnChoose.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold);
this.btnChoose.Location = new System.Drawing.Point(14, 156);
this.btnChoose.Size = new System.Drawing.Size(111, 39);
this.btnChoose.Text = "ENT.确定";
this.btnChoose.Click += new System.EventHandler(this.btnChoose_Click);
//
// ChooseStatus
//
this.ClientSize = new System.Drawing.Size(242, 197);
this.ControlBox = false;
this.Controls.Add(this.btnExit);
this.Controls.Add(this.btnChoose);
this.Controls.Add(this.dgStatus);
this.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold);
this.Text = "资产状况选择";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ChooseStatus_KeyDown);
this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.ChooseStatus_KeyPress);
this.Load += new System.EventHandler(this.ChooseStatus_Load);
}
#endregion
private void ChooseStatus_Load(object sender, System.EventArgs e)
{
dgStatus.Font=this.Font;
try
{
dtStatus.Clear();
}
catch
{}
dtStatus=E.ExecDT("select * from ZT");
dgStatus.DataSource=dtStatus;
cmStatus=(CurrencyManager) this.BindingContext[dtStatus];
if (cmStatus.Count<=0)
{
E.Beep("",50,2670,2);
E.MessageShow(true,"没有数据,不能更改!");
Close();
return;
}
}
private void btnExit_Click(object sender, System.EventArgs e)
{
DialogResult=DialogResult.Cancel;
Close();
}
private void btnChoose_Click(object sender, System.EventArgs e)
{
StatusNo=E.GetData(cmStatus,dtStatus,"Code");
StatusName=E.GetData(cmStatus,dtStatus,"Names");
DialogResult=DialogResult.OK;
Close();
}
private void ChooseStatus_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.KeyData==Keys.Down)
{
E.FPNL(cmStatus,dgStatus,"n");
this.Focus();
}
if (e.KeyData==Keys.Up)
{
E.FPNL(cmStatus,dgStatus,"p");
this.Focus();
}
if (e.KeyData==Keys.Left)
{
E.FPNL(cmStatus,dgStatus,"f");
this.Focus();
}
if (e.KeyData==Keys.Right)
{
E.FPNL(cmStatus,dgStatus,"l");
this.Focus();
}
}
private void ChooseStatus_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar==(char)13)
{
btnChoose_Click(sender,e);
}
if (e.KeyChar==(char)48)
{
btnExit_Click(sender,e);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -