?? 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 + -