📄 selectstorage.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace 进销存管理系统
{
/// <summary>
/// ModifyFrm 的摘要说明。
/// </summary>
public class SelectStorage : System.Windows.Forms.Form
{
//查询所有仓库信息
private DataSet ds = new DataSet();
private LinkDataBase link = new LinkDataBase();
private string sendTableName = "库存库";
private string strSQL;
private System.Windows.Forms.DataGrid dgrd_Storage;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public SelectStorage()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
//重载构造函数,以便生成窗体时传入参数
public SelectStorage(string tempStrSQL)
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
this.strSQL = tempStrSQL;
this.ds = link.SelectDataBase(strSQL,sendTableName);
this.DataGridStateControl();
this.dgrd_Storage.DataSource = ds.Tables[0];
}
/// <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.dgrd_Storage = new System.Windows.Forms.DataGrid();
((System.ComponentModel.ISupportInitialize)(this.dgrd_Storage)).BeginInit();
this.SuspendLayout();
//
// dgrd_Storage
//
this.dgrd_Storage.CaptionVisible = false;
this.dgrd_Storage.DataMember = "";
this.dgrd_Storage.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgrd_Storage.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgrd_Storage.Location = new System.Drawing.Point(0, 0);
this.dgrd_Storage.Name = "dgrd_Storage";
this.dgrd_Storage.ReadOnly = true;
this.dgrd_Storage.Size = new System.Drawing.Size(208, 301);
this.dgrd_Storage.TabIndex = 1;
this.dgrd_Storage.DoubleClick += new System.EventHandler(this.dgrd_Storage_DoubleClick);
//
// SelectStorage
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(208, 301);
this.Controls.Add(this.dgrd_Storage);
this.Name = "SelectStorage";
this.Text = "选择仓库";
((System.ComponentModel.ISupportInitialize)(this.dgrd_Storage)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void DataGridStateControl()//设置表的显示格式
{
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.Alignment = HorizontalAlignment.Center;
aColumnTextColumn.NullText = "";
aColumnTextColumn.Format = "F";
ts.GridColumnStyles.Add(aColumnTextColumn);
}
this.dgrd_Storage.TableStyles.Add(ts);
}
//-----------其他窗体中调用该窗体,双击选中数据并送回----------
private void dgrd_Storage_DoubleClick(object sender, System.EventArgs e)
{
//如果该商品信息在库存库中存在
if (this.ds.Tables[0].Rows.Count > 0)
{
string sendStorageID = this.dgrd_Storage[this.dgrd_Storage.CurrentCell.RowNumber,0].ToString().Trim();
SellTable.inputDataGridArray[3] = sendStorageID;
this.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -