コード例 #1
0
        private void cboxCat_SelectedIndexChanged(object sender, EventArgs e)
        {
            flowLayoutPanel1.Controls.Clear();
            List_prodId.Clear();
            List_cat.Clear();
            List_desc.Clear();
            List_price.Clear();

            txtQty.Clear();
            txtSuppName.Clear();
            txtQty.Enabled  = false;
            btnSave.Enabled = false;

            if (cboxCat.SelectedIndex == 0)
            {
                getProduct();
                return;
            }

            try
            {
                string query = "Select * from tblproduct WHERE ProdCat = '" + cboxCat.Text + "'";
                cmd = new MySqlCommand(query, con);
                con.Open();
                adpt = new MySqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                adpt.Fill(dt);
                con.Close();
                int count = dt.Rows.Count;
                if (count > 0)
                {
                    for (int i = 0; i < count; i++)
                    {
                        Button b = new Button();
                        b.Name = dt.Rows[i]["ProdId"].ToString();
                        b.Size = new Size(100, 100);

                        byte[]       img = (byte[])dt.Rows[i]["ProdImage"];
                        MemoryStream ms  = new MemoryStream(img);
                        //b.Image = Image.FromStream(ms);
                        b.BackgroundImage       = Image.FromStream(ms);
                        b.BackgroundImageLayout = ImageLayout.Stretch;

                        adpt.Dispose();
                        b.Click += new EventHandler(OnButtonClick);
                        flowLayoutPanel1.Controls.Add(b);

                        List_prodId.Add(dt.Rows[i]["ProdId"].ToString());
                        List_cat.Add(dt.Rows[i]["ProdCat"].ToString());
                        List_desc.Add(dt.Rows[i]["ProdDesc"].ToString());
                        List_price.Add(dt.Rows[i]["ProdPrice"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                con.Close();
            }
        }
コード例 #2
0
        private void button5_Click(object sender, EventArgs e)
        {
            cboxCat.SelectedIndex = -1;
            flowLayoutPanel1.Controls.Clear();
            List_prodId.Clear();
            List_cat.Clear();
            List_desc.Clear();
            List_price.Clear();

            selectTransId();
            reset();
            txtTableNo.Clear();
            textBox1.Clear();
            lViewPOS.Items.Clear();
            total();
            lblTotSales.Text = "0.00";
            lblVat.Text      = "0.00";
            ItemClick        = 0;
            getProduct();
        }