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