📄 computer.cs
字号:
this.textBox2.Enabled=false;
this.textBox4.Enabled=false;
this.textBox5.Enabled=false;
this.textBox6.Enabled=false;
this.textBox7.Enabled=false;
}
private void button7_Click(object sender, System.EventArgs e)
{
num=2;
//权限
if(l==1)
this.textBox7.Enabled=true;
else
this.textBox7.Enabled=false;
//权限
//this.button11.Visible=true;
//dataGrid2.Visible=true;
this.comboBox2.Visible=false;
pictureBox1.Visible=false;
this.comboBox1.Enabled=true;
this.textBox1.Enabled=true;
this.textBox2.Enabled=true;
this.textBox4.Enabled=true;
this.textBox5.Enabled=true;
this.textBox6.Enabled=true;
this.textBox7.Enabled=true;
}
private void button8_Click(object sender, System.EventArgs e)
{
num=1;
//权限
if(l==1)
this.textBox7.Enabled=true;
else
this.textBox7.Enabled=false;
//权限
//this.button11.Visible=false;
pictureBox1.Visible=false;
this.comboBox2.Visible=true;
this.comboBox1.Enabled=true;
this.textBox1.Enabled=true;
this.textBox2.Enabled=true;
this.textBox4.Enabled=true;
this.textBox5.Enabled=true;
this.textBox6.Enabled=true;
this.textBox7.Enabled=true;
//dataGrid2.Visible=false;
searchall a=new searchall();
a.searchcom("select * from computer",this.comboBox2,"computer","computer.comid");
}
private void button9_Click(object sender, System.EventArgs e)
{
num=3;
//this.dataGrid2.Visible=false;
//this.button11.Visible=false;
pictureBox1.Visible=false;
this.comboBox2.Visible=true;
this.comboBox1.Enabled=false;
this.textBox1.Enabled=false;
this.textBox2.Enabled=false;
this.textBox4.Enabled=false;
this.textBox5.Enabled=false;
this.textBox6.Enabled=false;
this.textBox7.Enabled=false;
searchall a=new searchall();
a.searchcom("select * from computer",this.comboBox2,"computer","computer.comid");
}
private void computer_Load(object sender, System.EventArgs e)
{
//显示computer.lzl1的值
searchall a=new searchall();
a.textboxsearch("select lzl1 from computer where lzl1=lzl2",this.textBox8,"t1.lzl1");
lzl1=this.textBox8.Text.Length;
//权限
this.textBox8.Text=lzl.textBox2.Text;
if(this.textBox8.Text=="管理员")
{
l=0;
//this.button8.Enabled=false;
this.button9.Enabled=true;
this.textBox7.Enabled=true;
}
else
{
l=1;
//this.button8.Enabled=true;
this.button9.Enabled=false;
this.textBox7.Enabled=false;
}
//权限
}
private void button12_Click(object sender, System.EventArgs e)
{
switch (num)
{
case 0:
//查询数据
if(l==0)
search();
else
searchall();
break;
case 1:
//修改纪录
if(this.comboBox2.Text.Length<1|this.comboBox1.Text.Length<1|this.textBox2.Text.Length<1|this.textBox4.Text.Length<1)
{
MessageBox.Show("产品编号,产品名称,产品厂商,产品数量为必填项!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
if(l==0)
{
searchall a=new searchall();
a.change1("UPDATE computer SET lzl1='"+this.textBox8.Text+" 'WHERE lzl2='"+this.textBox8.Text+" '","copmpter");
change();
search();
this.textBox8.Text=this.textBox8.Text+"1";
}
else
{
searchall a=new searchall();
a.change1("UPDATE computer SET lzl1='"+this.textBox8.Text+" 'WHERE lzl2='"+this.textBox8.Text+" '","copmpter");
changeall();
searchall();
this.textBox8.Text=this.textBox8.Text+"1";
}
}
break;
case 2:
//增加纪录
if(this.textBox1.Text.Length<1|this.comboBox1.Text.Length<1|this.textBox2.Text.Length<1|this.textBox4.Text.Length<1)
{
MessageBox.Show("产品编号,产品名称,产品厂商,产品数量为必填项!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
if(l==0)
{
searchall a=new searchall();
a.change1("UPDATE computer SET lzl1='"+this.textBox8.Text+" 'WHERE lzl2='"+this.textBox8.Text+" '","copmpter");
add();
search();
this.textBox8.Text=this.textBox8.Text+"1";
}
else
{
searchall a=new searchall();
a.change1("UPDATE computer SET lzl1='"+this.textBox8.Text+" 'WHERE lzl2='"+this.textBox8.Text+" '","copmpter");
addall();
searchall();
this.textBox8.Text=this.textBox8.Text+"1";
}
}
break;
case 3:
//删除纪录
if(this.comboBox2.Text.Length<1)
{
MessageBox.Show("没有填写用户名字!","信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
else
{
searchall a=new searchall();
a.delect("DELETE FROM computer WHERE comid='"+this.comboBox2.Text+"'");
searchall();
}
break;
}
}
public void searchall()
{
searchall a=new searchall();
a.search("select comid as 产品编号,comname as 产品名称,company as 产品厂商 ,comsum as 产品数量,comsell as 产品价格,dess as 备注 ,ent as 产品利润 from computer",this.dataGrid1);
}
public void search()
{
searchall a=new searchall();
a.search("select comid as 产品编号,comname as 产品名称,company as 产品厂商 ,comsum as 产品数量,comsell as 产品价格,dess as 备注 from computer",this.dataGrid1);
}
public void addall()
{
searchall a=new searchall();
a.add("INSERT INTO computer(comid,comname,company,comsum,comsell,dess,ent,lzl1,lzl2)VALUES('"+this.textBox1.Text+"','"+this.comboBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox4.Text+"','"+this.textBox5.Text+"','"+this.textBox6.Text+"','"+this.textBox7.Text+"','"+this.textBox8.Text +1 +"','"+this.textBox8.Text+"')");
searchall();
}
public void add()
{
searchall a=new searchall();
a.add("INSERT INTO computer(comid,comname,company,comsum,comsell,dess,lzl1,lzl2)VALUES('"+this.textBox1.Text+"','"+this.comboBox1.Text+"','"+this.textBox2.Text+"','"+this.textBox4.Text+"','"+this.textBox5.Text+"','"+this.textBox6.Text+"','"+this.textBox8.Text + 1 +"','"+this.textBox8.Text+"')");
search();
}
public void changeall()
{
searchall a=new searchall();
a.change("UPDATE computer SET comid='"+this.comboBox2.Text+"', comname='"+this.comboBox1.Text+"', company='"+this.textBox2.Text+"', comsum='"+this.textBox4.Text+"', comsell='"+this.textBox5.Text+"', dess='"+this.textBox6.Text+"', ent='"+this.textBox7.Text+"',lzl1='"+this.textBox8.Text+1+"' ,lzl2='"+this.textBox8.Text+"' WHERE comid='"+this.comboBox2.Text+"'","copmpter");
}
public void change()
{
searchall a=new searchall();
a.change("UPDATE computer SET comid='"+this.comboBox2.Text+"', comname='"+this.comboBox1.Text+"', company='"+this.textBox2.Text+"', comsum='"+this.textBox4.Text+"', comsell='"+this.textBox5.Text+"', dess='"+this.textBox6.Text+"', lzl1='"+this.textBox8.Text+1+"',lzl2='"+this.textBox8.Text+"' WHERE comid='"+this.comboBox2.Text+"'","copmpter");
}
private void button11_Click(object sender, System.EventArgs e)
{
//this.dataGrid2.Visible=true;
searchall a=new searchall();
a.search("select comid as 产品编号,comname as 产品名称,company as 产品厂商 ,comsum as 产品数量,comsell as 产品价格,dess as 备注 from computer",this.dataGrid1);
}
private void textBox1_TextChanged(object sender, System.EventArgs e)
{
//this.dataGrid2.Visible=false;
}
private void button13_Click(object sender, System.EventArgs e)
{
pictureBox1.Visible=true;
num=100;
}
private void button10_Click(object sender, System.EventArgs e)
{
searchall a=new searchall();
a.change1("UPDATE computer SET lzl2='"+this.textBox8.Text+1+" 'WHERE lzl2='"+this.textBox8.Text+" '","copmpter");
this.Close();
}
private void tabPage1_Click(object sender, System.EventArgs e)
{
//this.dataGrid2.Visible=false;
}
private void dataGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
DataGrid myGrid = (DataGrid) sender;
System.Windows.Forms.DataGrid.HitTestInfo hti;
hti = myGrid.HitTest(e.X, e.Y);
//int Column=this.dataGrid1.CurrentCell.ColumnNumber;
//int Row=this.dataGrid1.CurrentCell.RowNumber;
string myValue=this.dataGrid1[hti.Row,hti.Column].ToString();
if(this.textBox1.Enabled==false)
{
/*if (hti.Column==0)
this.textBox1.Text =myValue;
if (hti.Column==2)
this.textBox2.Text =myValue;
if (hti.Column==3)
this.textBox4.Text =myValue;
if (hti.Column==4)
this.textBox5.Text =myValue;
if (hti.Column==5)
this.textBox6.Text =myValue;
if (hti.Column==6)
this.textBox7.Text =myValue;*/
this.textBox1.Text =this.dataGrid1[hti.Row,0].ToString();
this.comboBox1.Text =this.dataGrid1[hti.Row,1].ToString();
this.textBox2.Text =this.dataGrid1[hti.Row,2].ToString();
this.textBox4.Text =this.dataGrid1[hti.Row,3].ToString();
this.textBox5.Text =this.dataGrid1[hti.Row,4].ToString();
this.textBox6.Text =this.dataGrid1[hti.Row,5].ToString();
if(l==1)
this.textBox7.Text =this.dataGrid1[hti.Row,6].ToString();
}
else
return;
}
private void button1_Click(object sender, System.EventArgs e)
{
searchall a=new searchall();
a.search("select comid as 产品编号,comname as 产品名称,company as 产品厂商 ,comsum as 产品数量,comsell as 产品价格,dess as 备注 from computer WHERE lzl1='10'*lzl2+'1'",this.dataGrid3);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -