?? frmkuncun.cs
字號:
using System;
using System.Data.SqlClient;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using Indispost;
namespace MainPrj_CarShop
{
/// <summary>
/// frmKunCun 的摘要說明。
/// </summary>
public class frmKunCun : System.Windows.Forms.Form
{
private System.Data.SqlClient.SqlConnection _sqlCon;
private System.Data.DataView _dvKuCun;
private System.Windows.Forms.DataGrid _dgKuCun;
private System.Windows.Forms.ToolBar _tbar;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.DataGridTableStyle dataGridTableStyle1;
private System.Data.SqlClient.SqlDataAdapter _sqlAdapKu;
private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
private MainPrj_CarShop.DSKuCun dsKuCun1;
private System.Windows.Forms.ImageList imageList1;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.ToolBarButton tbnPre;
private System.Windows.Forms.ToolBarButton tbnBack;
private System.Windows.Forms.ToolBarButton tbnReport;
private CurrencyManager _msg;
public frmKunCun()
{
//
// 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.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmKunCun));
this._sqlAdapKu = new System.Data.SqlClient.SqlDataAdapter();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this._sqlCon = new System.Data.SqlClient.SqlConnection();
this._dvKuCun = new System.Data.DataView();
this.dsKuCun1 = new MainPrj_CarShop.DSKuCun();
this._dgKuCun = new System.Windows.Forms.DataGrid();
this.dataGridTableStyle1 = new System.Windows.Forms.DataGridTableStyle();
this._tbar = new System.Windows.Forms.ToolBar();
this.toolBarButton1 = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.tbnPre = new System.Windows.Forms.ToolBarButton();
this.tbnBack = new System.Windows.Forms.ToolBarButton();
this.tbnReport = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
((System.ComponentModel.ISupportInitialize)(this._dvKuCun)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dsKuCun1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this._dgKuCun)).BeginInit();
this.SuspendLayout();
//
// _sqlAdapKu
//
this._sqlAdapKu.SelectCommand = this.sqlSelectCommand1;
this._sqlAdapKu.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "view_CarKuCun", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("庫存單號", "庫存單號"),
new System.Data.Common.DataColumnMapping("入庫日期", "入庫日期"),
new System.Data.Common.DataColumnMapping("采購單號", "采購單號"),
new System.Data.Common.DataColumnMapping("采購日期", "采購日期"),
new System.Data.Common.DataColumnMapping("廠商名稱", "廠商名稱"),
new System.Data.Common.DataColumnMapping("車型代碼", "車型代碼"),
new System.Data.Common.DataColumnMapping("車輛名稱", "車輛名稱"),
new System.Data.Common.DataColumnMapping("車輛類型", "車輛類型"),
new System.Data.Common.DataColumnMapping("產地", "產地"),
new System.Data.Common.DataColumnMapping("車輛廠牌名稱", "車輛廠牌名稱"),
new System.Data.Common.DataColumnMapping("車輛顏色", "車輛顏色"),
new System.Data.Common.DataColumnMapping("底盤號", "底盤號"),
new System.Data.Common.DataColumnMapping("發動機號", "發動機號"),
new System.Data.Common.DataColumnMapping("合格證號", "合格證號"),
new System.Data.Common.DataColumnMapping("進口證號", "進口證號"),
new System.Data.Common.DataColumnMapping("商檢單號", "商檢單號"),
new System.Data.Common.DataColumnMapping("自編號", "自編號"),
new System.Data.Common.DataColumnMapping("鑰匙號", "鑰匙號"),
new System.Data.Common.DataColumnMapping("行駛里程", "行駛里程"),
new System.Data.Common.DataColumnMapping("出廠日期", "出廠日期"),
new System.Data.Common.DataColumnMapping("提單號", "提單號"),
new System.Data.Common.DataColumnMapping("進價", "進價"),
new System.Data.Common.DataColumnMapping("采購參考價", "采購參考價"),
new System.Data.Common.DataColumnMapping("銷售參考價", "銷售參考價"),
new System.Data.Common.DataColumnMapping("備注", "備注")})});
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT 庫存單號, 入庫日期, 采購單號, 采購日期, 廠商名稱, 車型代碼, 車輛名稱, 車輛類型, 產地, 車輛廠牌名稱, 車輛顏色, 底盤號, 發動機" +
"號, 合格證號, 進口證號, 商檢單號, 自編號, 鑰匙號, 行駛里程, 出廠日期, 提單號, 進價, 采購參考價, 銷售參考價, 備注 FROM view_C" +
"arKuCun";
this.sqlSelectCommand1.Connection = this._sqlCon;
//
// _sqlCon
//
this._sqlCon.ConnectionString = "workstation id=Nebular;packet size=4096;user id=sa;data source=\".\";persist securi" +
"ty info=False;initial catalog=dbCarsys";
//
// _dvKuCun
//
this._dvKuCun.AllowDelete = false;
this._dvKuCun.AllowEdit = false;
this._dvKuCun.AllowNew = false;
this._dvKuCun.Table = this.dsKuCun1.view_CarKuCun;
//
// dsKuCun1
//
this.dsKuCun1.DataSetName = "DSKuCun";
this.dsKuCun1.Locale = new System.Globalization.CultureInfo("zh-CN");
//
// _dgKuCun
//
this._dgKuCun.BackColor = System.Drawing.Color.WhiteSmoke;
this._dgKuCun.DataMember = "";
this._dgKuCun.DataSource = this._dvKuCun;
this._dgKuCun.Dock = System.Windows.Forms.DockStyle.Bottom;
this._dgKuCun.GridLineColor = System.Drawing.Color.DodgerBlue;
this._dgKuCun.HeaderForeColor = System.Drawing.Color.Blue;
this._dgKuCun.Location = new System.Drawing.Point(0, 22);
this._dgKuCun.Name = "_dgKuCun";
this._dgKuCun.Size = new System.Drawing.Size(672, 432);
this._dgKuCun.TabIndex = 0;
this._dgKuCun.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.BackColor = System.Drawing.Color.WhiteSmoke;
this.dataGridTableStyle1.DataGrid = this._dgKuCun;
this.dataGridTableStyle1.GridLineColor = System.Drawing.Color.CornflowerBlue;
this.dataGridTableStyle1.HeaderBackColor = System.Drawing.Color.WhiteSmoke;
this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "";
this.dataGridTableStyle1.ReadOnly = true;
//
// _tbar
//
this._tbar.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
this._tbar.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this._tbar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.tbnPre,
this.tbnBack,
this.tbnReport});
this._tbar.ButtonSize = new System.Drawing.Size(50, 30);
this._tbar.DropDownArrows = true;
this._tbar.Font = new System.Drawing.Font("宋體", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this._tbar.ImageList = this.imageList1;
this._tbar.Location = new System.Drawing.Point(0, 0);
this._tbar.Name = "_tbar";
this._tbar.ShowToolTips = true;
this._tbar.Size = new System.Drawing.Size(672, 46);
this._tbar.TabIndex = 1;
this._tbar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this._tbar_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton2
//
this.toolBarButton2.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// tbnPre
//
this.tbnPre.ImageIndex = 0;
this.tbnPre.Text = "上一條";
this.tbnPre.ToolTipText = "上一條";
//
// tbnBack
//
this.tbnBack.ImageIndex = 1;
this.tbnBack.Text = "下一條";
this.tbnBack.ToolTipText = "下一條";
//
// tbnReport
//
this.tbnReport.ImageIndex = 2;
this.tbnReport.Text = "報表";
this.tbnReport.ToolTipText = "報表";
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(20, 20);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// frmKunCun
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.WhiteSmoke;
this.ClientSize = new System.Drawing.Size(672, 454);
this.Controls.Add(this._tbar);
this.Controls.Add(this._dgKuCun);
this.Name = "frmKunCun";
this.Text = "庫存車輛";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Resize += new System.EventHandler(this.frmKunCun_Resize);
this.Load += new System.EventHandler(this.frmKunCun_Load);
((System.ComponentModel.ISupportInitialize)(this._dvKuCun)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dsKuCun1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this._dgKuCun)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void frmKunCun_Load(object sender, System.EventArgs e)
{
try
{
if(this.IsMdiChild)
this.MdiParent.Cursor=Cursors.WaitCursor;
this._sqlAdapKu.Fill(this.dsKuCun1);
this._msg=(CurrencyManager)this.BindingContext[this._dvKuCun];
this._msg.PositionChanged+=new EventHandler(_msg_PositionChanged);
}
catch(SqlException ex)
{
MessageBox.Show("系統發生一個異常的錯誤!請與管理員聯系。\n"+ex.Message,"系統錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
catch(Exception ex)
{
MessageBox.Show("系統發生一個異常的錯誤!請與管理員聯系。\n"+ex.Message,"系統錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
finally
{
this._sqlCon.Close();
if(this.IsMdiChild)
this.MdiParent.Cursor=Cursors.Arrow;
}
}
private void frmKunCun_Resize(object sender, System.EventArgs e)
{
try
{
this._dgKuCun.Height=this.Height-this._tbar.Height-30;
}
catch(Exception ex)
{
MessageBox.Show("系統發生一個異常的錯誤!請與管理員聯系。\n"+ex.Message,"系統錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void _tbar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
try
{
ToolBarButton tbb=e.Button;
if(tbb==this.tbnPre)
{
this._msg.Position--;
}
else if(tbb==this.tbnBack)
{
this._msg.Position++;
}
else if(tbb==this.tbnReport)
{
Indispost.frmInDepotReport rep=new frmInDepotReport(new TextBox());
rep.Show();
}
}
catch(Exception ex)
{
MessageBox.Show("系統發生一個異常的錯誤!請與管理員聯系。\n"+ex.Message,"系統錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
private void _msg_PositionChanged(object sender, EventArgs e)
{
try
{
this._dgKuCun.Focus();
this._dgKuCun.Expand(this._msg.Position);
this._dgKuCun.Select(this._msg.Position);
}catch(Exception ex)
{
MessageBox.Show("系統發生一個異常的錯誤!請與管理員聯系。\n"+ex.Message,"系統錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -