📄 mainform1.cs
字号:
this.panel6.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.panel6.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel6.Location = new System.Drawing.Point(16, 208);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(168, 288);
this.panel6.TabIndex = 7;
//
// splitter4
//
this.splitter4.Dock = System.Windows.Forms.DockStyle.Right;
this.splitter4.Location = new System.Drawing.Point(717, 64);
this.splitter4.Name = "splitter4";
this.splitter4.Size = new System.Drawing.Size(3, 513);
this.splitter4.TabIndex = 10;
this.splitter4.TabStop = false;
//
// splitter5
//
this.splitter5.Dock = System.Windows.Forms.DockStyle.Bottom;
this.splitter5.Location = new System.Drawing.Point(200, 574);
this.splitter5.Name = "splitter5";
this.splitter5.Size = new System.Drawing.Size(517, 3);
this.splitter5.TabIndex = 11;
this.splitter5.TabStop = false;
//
// panel5
//
this.panel5.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.panel5.Controls.Add(this.dataGrid1);
this.panel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel5.Location = new System.Drawing.Point(200, 64);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(517, 510);
this.panel5.TabIndex = 12;
//
// dataGrid1
//
this.dataGrid1.AllowDrop = true;
this.dataGrid1.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.dataGrid1.CaptionBackColor = System.Drawing.Color.Gold;
this.dataGrid1.DataMember = "";
this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGrid1.Location = new System.Drawing.Point(16, 24);
this.dataGrid1.Name = "dataGrid1";
this.dataGrid1.ReadOnly = true;
this.dataGrid1.Size = new System.Drawing.Size(484, 396);
this.dataGrid1.TabIndex = 0;
this.dataGrid1.TableStyles.AddRange(new System.Windows.Forms.DataGridTableStyle[] {
this.dataGridTableStyle1});
//
// dataGridTableStyle1
//
this.dataGridTableStyle1.DataGrid = this.dataGrid1;
this.dataGridTableStyle1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dataGridTableStyle1.MappingName = "ArrayList";
//
// menuItem24
//
this.menuItem24.Index = 7;
this.menuItem24.Text = "返回";
this.menuItem24.Click += new System.EventHandler(this.menuItem24_Click_1);
//
// MainForm1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(720, 577);
this.Controls.Add(this.panel5);
this.Controls.Add(this.splitter5);
this.Controls.Add(this.splitter4);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel2);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "MainForm1";
this.Text = "MainForm1";
this.Load += new System.EventHandler(this.MainForm1_Load);
this.panel2.ResumeLayout(false);
this.panel4.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel5.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void panel1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
}
public void getdispose(bool s)
{
this.Dispose(s);
}
private void button1_Click(object sender, System.EventArgs e)
{
}
private void MainForm1_Load(object sender, System.EventArgs e)
{
switch (this.employeeNo[0])
{
case 'A':
this.menuItem9.Enabled = false;
this.menuItem10.Enabled = false;
this.menuItem11.Enabled = false;
this.menuItem13.Enabled = false;
this.menuItem14.Enabled = false;
this.menuItem15.Enabled = false;
//this.menuItem23.Enabled = false;
this.menuItem17.Enabled = false;
this.menuItem19.Enabled = false;
this.menuItem5.Enabled = false;
this.menuItem6.Enabled = false;
this.menuItem20.Visible = false;
break;
case 'a':
this.menuItem9.Enabled = false;
this.menuItem10.Enabled = false;
this.menuItem11.Enabled = false;
this.menuItem13.Enabled = false;
this.menuItem14.Enabled = false;
this.menuItem15.Enabled = false;
//this.menuItem23.Enabled = false;
this.menuItem17.Enabled = false;
this.menuItem19.Enabled = false;
this.menuItem5.Enabled = false;
this.menuItem6.Enabled = false;
this.menuItem20.Visible = false;
break;
case 'B':
this.menuItem8.Enabled = false;
this.menuItem12.Enabled = false;
this.menuItem11.Enabled = false;
this.menuItem16.Enabled = false;
this.menuItem14.Enabled = false;
//this.menuItem15.Enabled = false;
//this.menuItem23.Enabled = false;
//this.menuItem17.Enabled = false;
this.menuItem19.Enabled = false;
this.menuItem5.Enabled = false;
this.menuItem7.Visible = false;
//this.menuItem6.Enabled = false;
break;
case 'b':
this.menuItem8.Enabled = false;
this.menuItem12.Enabled = false;
this.menuItem11.Enabled = false;
this.menuItem16.Enabled = false;
this.menuItem14.Enabled = false;
//this.menuItem15.Enabled = false;
//this.menuItem23.Enabled = false;
//this.menuItem17.Enabled = false;
this.menuItem19.Enabled = false;
this.menuItem5.Enabled = false;
this.menuItem7.Visible = false;
//this.menuItem6.Enabled = false;
break;
case 'C':
this.menuItem9.Enabled = false;
this.menuItem10.Enabled = false;
this.menuItem8.Enabled = false;
this.menuItem13.Enabled = false;
this.menuItem12.Enabled = false;
this.menuItem15.Enabled = false;
this.menuItem16.Enabled = false;
this.menuItem17.Enabled = false;
this.menuItem20.Visible = false;
//this.menuItem18.Enabled = false;
//this.menuItem5.Enabled = false;
this.menuItem6.Enabled = false;
this.menuItem7.Visible = false;
break;
case 'c':
this.menuItem9.Enabled = false;
this.menuItem10.Enabled = false;
this.menuItem8.Enabled = false;
this.menuItem13.Enabled = false;
this.menuItem12.Enabled = false;
this.menuItem15.Enabled = false;
this.menuItem16.Enabled = false;
this.menuItem17.Enabled = false;
this.menuItem20.Visible = false;
//this.menuItem18.Enabled = false;
//this.menuItem5.Enabled = false;
this.menuItem6.Enabled = false;
this.menuItem7.Visible = false;
break;
}
}
private void comboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string s = this.comboBox1.Text.ToString();
switch(s)
{
case "员工":
this.comboBox2.Items.Clear();
this.comboBox2.Text = "";
this.comboBox2.Items.Add("员工编号");
this.comboBox2.Items.Add("姓名");
this.comboBox2.Items.Add("员工住址");
break;
case "资产":
this.comboBox2.Items.Clear();
this.comboBox2.Text = "";
this.comboBox2.Items.Add("资产编号");
this.comboBox2.Items.Add("资产种类");
this.comboBox2.Items.Add("所属员工");
this.comboBox2.Items.Add("序列号");
break;
case"估价":
this.comboBox2.Items.Clear();
this.comboBox2.Text = "";
this.comboBox2.Items.Add("估价编号");
this.comboBox2.Items.Add("资产编号");
this.comboBox2.Items.Add("估价人编号");
break;
case"维护":
this.comboBox2.Items.Clear();
this.comboBox2.Text = "";
this.comboBox2.Items.Add("维护编号");
this.comboBox2.Items.Add("记录者编号");
this.comboBox2.Items.Add("资产编号");
this.comboBox2.Items.Add("维护商编号");
break;
case"维护商":
this.comboBox2.Items.Clear();
this.comboBox2.Text = "";
this.comboBox2.Items.Add("维护商编号");
this.comboBox2.Items.Add("维护商名称");
this.comboBox2.Items.Add("所在地址");
break;
default:
if (this.comboBox1.Text == "")
MessageBox.Show("请选择查询类别!");
else
{
MessageBox.Show("查询类别不存在!");
}
break;
}
}
//点击资产详细信息;显示资产查询用户窗体;
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
this.panel5.Visible = true;
SqlConnection conn = new SqlConnection(s.getConnectionString);
this.panel6.Controls.Clear();
this.panel6.Focus();
listBoxAsset l = new listBoxAsset();
this.panel6.Controls.Add(l);
l.ButtonClickA += new AssetManagement.listBoxAsset.ButtonClickHandler1(ButtonClickA);//实例化事件ButtonClickA就是调用下面代码中private void ButtonClickA()方法
l.ButtonClickA1 += new AssetManagement.listBoxAsset.ButtonClickHandler1(ButtonClickA1);
l.ButtonClickA2 += new AssetManagement.listBoxAsset.ButtonClickHandler1(ButtonClickA2);
l.ButtonClickA3 += new AssetManagement.listBoxAsset.ButtonClickHandler1(ButtonClickA3);
l.ButtonClickA4 += new AssetManagement.listBoxAsset.ButtonClickHandler1(ButtonClickA4);
//this.dataGrid1.Controls.Clear();
//SqlConnection conn = new SqlConnection(s.getConnectionString);
conn.Open();
string Query = "select assetNo as 资产编号,employeeNo as 所属员工编号,assetDescription as 资产备注,serialNo as 序列号,dateAcquired as 购进日期,purchasePrice as 购入价格,currentValue as 当前价值,dateSold as 卖出日期,nextMaintenanceDate as 下次维护时间 from asset";
SqlCommand cmd = new SqlCommand(Query,conn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(Query,conn);
DataSet ds = new DataSet();
da.Fill(ds,"asset");//这是填充主窗体中的表;
DataTable assetTable = ds.Tables["asset"];
//assetTable.s
this.dataGrid1.DataSource = ds;
// dataGrid1.TableStyles[0].GridColumnStyles.Add( = "资产编号";
// dataGrid1.TableStyles[0].GridColumnStyles["employeeNo"].HeaderText = "所属员工编号";
// dataGrid1.TableStyles[0].GridColumnStyles["assetDescription"].HeaderText = "资产备注";
// dataGrid1.TableStyles[0].GridColumnStyles["serialNo"].HeaderText = "序列号";
// dataGrid1.TableStyles[0].GridColumnStyles["dateAcquired"].HeaderText = "购进日期";
// dataGrid1.TableStyles[0].GridColumnStyles["purchasePrice"].HeaderText = "购入价格";
// dataGrid1.TableStyles[0].GridColumnStyles["currentValue"].HeaderText= "当前价值";
// dataGrid1.TableStyles[0].GridColumnStyles["dateSold"].HeaderText = "卖出日期";
// dataGrid1.TableStyles[0].GridColumnStyles["nextMaintenanceDate"].HeaderText = "下次维护时间";
this.dataGrid1.DataMember = "asset";
//this.dataGrid1.Focus();
this.dataGrid1.AllowDrop = true;
conn.Close();
}
private void linkLabel2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
this.panel5.Visible = true;
SqlConnection conn = new SqlConnection(s.getConnectionString);
this.panel6.Controls.Clear();
listBoxEmployee list = new listBoxEmployee();
this.panel6.Controls.Add(list);
list.ButtonClick += new AssetManagement.listBoxEmployee.ButtonClickHandler(ButtonClick);
list.ButtonClick1 += new AssetManagement.listBoxEmployee.ButtonClickHandler(ButtonClick1);
list.ButtonClick2 += new AssetManagement.listBoxEmployee.ButtonClickHandler(ButtonClick2);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -