Exemple #1
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.SelectedCells[0].Tag == null)
            {
                lbProductName.Text = lbUnit.Text = "";
                dataGridView1.SelectedCells[0].Selected = false;
                tbAmount.Enabled = npButcher.Enabled = false;
                return;
            }
            sProductType prod = DBproc.GetProduct((int)dataGridView1.SelectedCells[0].Tag);

            lbProductName.Text = prod.Name;
            lbUnit.Text        = prod.Units;
            tbAmount.Enabled   = npButcher.Enabled = true;
        }
Exemple #2
0
        public static sProductType GetProduct(int pid)
        {
            if (!connected)
            {
                return(null);
            }
            sProductType    result = null;
            MySqlCommand    cmd    = new MySqlCommand(String.Format("SELECT p_id,p_name,p_unit,p_image,p_imgsize FROM products WHERE p_id={0};", pid.ToString()), _sql);
            MySqlDataReader rd     = cmd.ExecuteReader();

            if (rd.Read())
            {
                byte[] img = new byte[rd.GetInt32("p_imgsize")];
                if (img.Length != 0)
                {
                    rd.GetBytes(rd.GetOrdinal("p_image"), 0, img, 0, img.Length);
                }
                result = new sProductType(rd.GetInt32("p_id"), rd.GetString("p_name"), rd.GetString("p_unit"), img);
            }
            rd.Close();
            return(result);
        }