📄 frmgysinfosee.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 生产销售管理系统
{
/// <summary>
/// StorageSearch 的摘要说明。
/// </summary>
public class FrmGYSInfoSee : System.Windows.Forms.Form
{
private DataSet ds = new DataSet();
private DataView dv;
private LinkDataBase link = new LinkDataBase();
private string sendTableName = "供货商清单";
private string sendStrSQL = "SELECT 供货商号, 拼音编码, 名称, 采购员, 电话, 地址, 邮编, 区号, 地区, 类型, 传真, 电报, 开户行, 开户行邮编, 银行帐号, 税号, 库房地址, 库房电话, 业务部门 FROM 供货商清单";
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btn_Search;
private System.Windows.Forms.DataGrid dgrd_StorageSearch;
private System.Windows.Forms.TextBox txt_WareWord;
private System.Windows.Forms.TextBox txt_WareNum;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public FrmGYSInfoSee()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
this.DataGridStateControl();
}
/// <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.btn_Search = new System.Windows.Forms.Button();
this.txt_WareWord = new System.Windows.Forms.TextBox();
this.txt_WareNum = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.dgrd_StorageSearch = new System.Windows.Forms.DataGrid();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgrd_StorageSearch)).BeginInit();
this.SuspendLayout();
//
// btn_Search
//
this.btn_Search.Location = new System.Drawing.Point(601, 13);
this.btn_Search.Name = "btn_Search";
this.btn_Search.Size = new System.Drawing.Size(48, 24);
this.btn_Search.TabIndex = 4;
this.btn_Search.Text = "查询";
this.btn_Search.Click += new System.EventHandler(this.btn_Search_Click);
//
// txt_WareWord
//
this.txt_WareWord.Location = new System.Drawing.Point(464, 15);
this.txt_WareWord.MaxLength = 14;
this.txt_WareWord.Name = "txt_WareWord";
this.txt_WareWord.TabIndex = 2;
this.txt_WareWord.Text = "";
//
// txt_WareNum
//
this.txt_WareNum.Location = new System.Drawing.Point(232, 15);
this.txt_WareNum.MaxLength = 14;
this.txt_WareNum.Name = "txt_WareNum";
this.txt_WareNum.TabIndex = 1;
this.txt_WareNum.Text = "";
//
// label1
//
this.label1.Location = new System.Drawing.Point(136, 19);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 16);
this.label1.TabIndex = 3;
this.label1.Text = "供应商编号:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(360, 19);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(88, 16);
this.label2.TabIndex = 4;
this.label2.Text = "供应商中文拼音:";
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.btn_Search);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.txt_WareNum);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Controls.Add(this.txt_WareWord);
this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
this.groupBox1.Location = new System.Drawing.Point(0, -2);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(720, 50);
this.groupBox1.TabIndex = 7;
this.groupBox1.TabStop = false;
//
// dgrd_StorageSearch
//
this.dgrd_StorageSearch.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dgrd_StorageSearch.CaptionVisible = false;
this.dgrd_StorageSearch.DataMember = "";
this.dgrd_StorageSearch.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgrd_StorageSearch.Location = new System.Drawing.Point(0, 48);
this.dgrd_StorageSearch.Name = "dgrd_StorageSearch";
this.dgrd_StorageSearch.Size = new System.Drawing.Size(720, 326);
this.dgrd_StorageSearch.TabIndex = 5;
//
// FrmGYSInfoSee
//
this.AcceptButton = this.btn_Search;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(720, 373);
this.Controls.Add(this.dgrd_StorageSearch);
this.Controls.Add(this.groupBox1);
this.Name = "FrmGYSInfoSee";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "【供应商清单查询】";
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgrd_StorageSearch)).EndInit();
this.ResumeLayout(false);
}
#endregion
//--------------根据输入查询供应商信息--------------
private void btn_Search_Click(object sender, System.EventArgs e)
{
string strRowFilter = "";
string strWareNumFilter ="供应商号 like '" + txt_WareNum.Text.Trim() + "%'";
string strWareWordFilter ="拼音编码 like '" + txt_WareWord.Text.Trim() + "%'";
if (txt_WareNum.Text.Trim() != "")
strRowFilter += strWareNumFilter + " and ";
if (txt_WareWord.Text.Trim() != "")
strRowFilter += strWareWordFilter + " and ";
if (strRowFilter != "") // 存在查询条件
strRowFilter = strRowFilter.Substring(0,strRowFilter.Length-5);
dv.RowFilter = strRowFilter;
}
//-----------设置表格状态--------------
private void DataGridStateControl()
{
this.ds = this.link.SelectDataBase(sendStrSQL,sendTableName);
this.dv = new DataView(ds.Tables[0]);
this.dgrd_StorageSearch.DataSource = dv;
DataGridTableStyle ts = new DataGridTableStyle();
DataGridNoActiveCellColumn aColumnTextColumn;
ts.AlternatingBackColor = Color.LightGray;
ts.MappingName = this.ds.Tables[0].TableName;
int numCols = this.ds.Tables[0].Columns.Count;
for (int i = 0;i< numCols;i++)
{
aColumnTextColumn = new DataGridNoActiveCellColumn();
aColumnTextColumn.MappingName = this.ds.Tables[0].Columns[i].ColumnName;
aColumnTextColumn.HeaderText = this.ds.Tables[0].Columns[i].ColumnName;
aColumnTextColumn.NullText = "";
aColumnTextColumn.Format = "D";
ts.GridColumnStyles.Add(aColumnTextColumn);
}
this.dgrd_StorageSearch.TableStyles.Add(ts);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -