Example #1
0
        private void idelete_btn_Click_1(object sender, EventArgs e)
        {
            if (iid_txt.Text == "")
            {
                MessageBox.Show("Please enter item id...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    string       insertquery = "DELETE FROM items WHERE id='" + iid_txt.Text + "'";
                    MySqlCommand cmd         = new MySqlCommand(insertquery, conn);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Record is deleted...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    conn.Close();
                    Grideloaditem();
                    autovalueadded();
                    autovalueaddedBar();
                    Main_Menu mn = new Main_Menu();
                    mn.autovalueaddedID();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            conn.Close();
        }
Example #2
0
        private void iupdate_btn_Click_1(object sender, EventArgs e)
        {
            if (iid_txt.Text == "")
            {
                MessageBox.Show("Please enter item id...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (barcodeid_txt.Text == "")
            {
                MessageBox.Show("Please enter Barcode id...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (iname_txt.Text == "")
            {
                MessageBox.Show("Please enter item name...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (qty_txt.Text == "")
            {
                MessageBox.Show("Please enter item quentity...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (realprice_txt.Text == "")
            {
                MessageBox.Show("Please enter item Real price...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (saleprice_txt.Text == "")
            {
                MessageBox.Show("Please enter item Sale price...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    MemoryStream ms = new MemoryStream();
                    pictureBox1.Image.Save(ms, pictureBox1.Image.RawFormat);
                    byte[] img = ms.ToArray();
                    ms.Close();

                    string       insertquery = "UPDATE items SET item_id=@item_id,barcode_id=@barcode_id,name=@name,brand=@brand, qty=@qty,price_real=@price_real,price_sale=@price_sale,description=@description,image=@image WHERE id='" + iid_txt.Text + "'";
                    MySqlCommand cmd         = new MySqlCommand(insertquery, conn);

                    cmd.Parameters.AddWithValue("@item_id", iid_txt.Text);
                    cmd.Parameters.AddWithValue("@barcode_id", barcodeid_txt.Text);
                    cmd.Parameters.AddWithValue("@name", iname_txt.Text);
                    cmd.Parameters.AddWithValue("@brand", bname_combo.SelectedItem);
                    cmd.Parameters.AddWithValue("@qty", qty_txt.Text);
                    cmd.Parameters.AddWithValue("@price_real", realprice_txt.Text);
                    cmd.Parameters.AddWithValue("@price_sale", saleprice_txt.Text);
                    cmd.Parameters.AddWithValue("@description", idec_txt.Text);
                    cmd.Parameters.AddWithValue("@image", img);

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    MessageBox.Show("Record is updated...", "POS Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    conn.Close();
                    Grideloaditem();
                    autovalueadded();
                    autovalueaddedBar();
                    Main_Menu mn = new Main_Menu();
                    mn.autovalueaddedID();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            conn.Close();
        }