大家好,先向大家鞠躬了问题如下:我数据库里面都是用户存的快餐清单,例如,里面存着,鸡肉,猪肉,红烧肉啊啥的清单,然后我要在界面把这些数据库里面的东西全部导出来 如同一个BUTTON一样的外观,当用户一点这个特定的BUTTON,例如红烧肉,那么我知道用户是在点了红烧肉,,然后这个红烧肉被我存在另外一个数据库里面,呆会打印出来,, 流程如下:从DB中获得各项菜名——》各项菜名已按钮形式显示在窗口上,给用户点击--》获得点击的菜名,然后保存到另外一个DB中--》打印 ,现在问题是当我用户点在红烧肉上,怎么知道这么动态生成的红烧肉被点到了吗???
感谢大家了,,,敬礼
感谢大家了,,,敬礼
解决方案 »
- WinForm里面怎么打开文件夹下面所有文件内容?
- 连数据库的问题,有点难度
- System.Threading.Tasks是哪个版本的.NET FRAMEWORK 支持的?
- 简单问题,快抢分.同时弹出两个窗体???
- 在精简版下Form 中怎么读取一个图片文件到PictureBox?请高手帮忙
- 一般只读文本框等显示灰色,怎样使其保持只读状态的情况下显示为正常情况下的那种背景、前景颜色?
- comboBox1 中的内容来自数据库,comboBox1 中选择如:“软件部”datagrid1中显示软件部人员名单,如何实现?
- 用Graphic Class画string,string倒过来了,怎么会这样??
- mm急救急急急!分全加上了,请教如何在英文版的WIN98上运行C#程序?
- 100分啦,高手请进(同一套软件在2000和98下运行的问题)
- Winform作的文件列表与OS拖动问题!
- 关于XmlAttribute的一段代码读不懂!请详细介绍一下!
例如如下代码..被我绑在LISTBOX(或者LISTVIEW) 里面然后产生了4个BUTTON,我怎么能判断第一BUTTON被点几是USER MGMT? 依此类推????希望高人能给我提供理解....
<Catalog>
<Products>
<Product>
<Name>User Mgmt</Name>
<Image>Images\product01.png</Image>
<Description>High resistent polymers and aluminum extracts that will protect your widget for life. Fire, Snow, Water or Dust... This guy takes it all.</Description>
<Price>$89.00</Price>
</Product>
<Product>
<Name>Product Mgmt</Name>
<Image>Images\product02.png</Image>
<Description>Add some high quality audio to your video experience. With these comfortable headphones you'll feel like sound comes out of your brain.</Description>
<Price>$19.90</Price>
</Product>
<Product>
<Name>Customer Mgmt</Name>
<Image>Images\product03.png</Image>
<Description>Get connected to local wireless networks and download streaming media directly to your VPR-1000</Description>
<Price>$38.45</Price>
</Product>
<Product>
<Name>Business Report</Name>
<Image>Images\product04.png</Image>
<Description>If you are about to travel then you need extra storage space. With this 2TB drive you'll finally be able to take thousands of hours of entertainment with you.</Description>
<Price>$75.90</Price>
</Product> </Products>
</Catalog>
大哥,我意思是说这些BUTTON是被自动生成出来的,它们没有ID的噢我觉得,,,怎么判断被点了???
既然button上能看到菜名,肯定是某个属性被赋值为菜名了呗(例如是caption属性),取出来
类似的例子可以参考的简单计算器应用程序的代码,很多地方都有下
public struct Product
{
private string _name;
private string _image;
private string _description;
private decimal _price; public Product(string name, string image, string description, decimal price)
{
this._name = name;
this._image = image;
this._description = description;
this._price = price;
} public string Name
{
get { return _name; }
set { _name = value; }
} public string Image
{
get { return _image; }
set { _image = value; }
} public string Description
{
get { return _description; }
set { _description = value; }
} public string Price
{
get { return _price; }
set { _price = value; }
}
} public class Form1 : Form
{
public Form1()
{
InitializeComponent();
} //加载数据
private void LoadData(object sender, EventArgs e)
{
//按DB自动生成按钮
Button btn = new Button();
//菜信息存储
btn.Text = "菜名";
btn.Tag = new Product("菜名", "图片", "描述", 10);
//绑定事件
btn.Click+=new EventHandler(btn_Click);
} //菜按钮点击
private void button_Click(object sender, EventArgs e)
{
Button currentBtn = sender as Button;
Product myP = (Product)currentBtn.Tag; //菜名
MessageBox.Show(myP.Name);
//...其它(略)
//拿去保存
}
}
namespace DBconnection
{ public struct ProductFoods
{
private string _id;
private string _name;
private decimal _price; public ProductFoods(string id, string name, decimal price)
{
this._id = id;
this._name = name;
this._price = price;
} public string id
{
get { return _id; }
set { _id = value; }
} public string name
{
get { return _name; }
set { _name = value; }
} public decimal Price
{
get { return _price; }
set { _price = value; }
}
} public partial class ProductInitialize : Window
{
public ProductInitialize()
{
InitializeComponent();
} } public class Products
{
private SqlConnection sqlConn = new SqlConnection();
string conn = @"server=DEVTAO\SQLEXPRESS;" + "database=testdb;" + "Integrated Security=SSPI;" + "Connection Timeout=100"; public SqlConnection openConnection(string connectionString)
{
sqlConn.ConnectionString = connectionString;
sqlConn.Open();
return sqlConn;
} public void closeConnection()
{
sqlConn.Close();
} public ArrayList GetProducts()
{
ArrayList myProducts = new ArrayList();
sqlConn = new SqlConnection(conn);
SqlCommand cmd = new SqlCommand("GetProducts", sqlConn);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds, "Products"); foreach (DataTable dt in ds.Tables)
{
for (int curRow = 0; curRow < dt.Rows.Count; curRow++)
{
myProducts.Add(dt.Rows[curRow][1].ToString());
}
}
return myProducts;
} }
} 我数据库结构是 如下:db_id int (primary key ,)
products_id varchar(MAX)
Products varchar(MAX)
Price float
里面内容就是乱七八糟的假设数据了,,,
希望各位大虾给点思路,,,新手求救嘛....哎