Exemplo n.º 1
0
        private void materiiView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex > -1)
            {
                string id   = materiiView.Rows[e.RowIndex].Cells[1].Value.ToString();
                string nume = materiiView.Rows[e.RowIndex].Cells[2].Value.ToString();


                string q = materiiView.Rows[e.RowIndex].Cells[3].Value.ToString();

                decimal pret = Decimal.Parse(q);

                AddMaterie adm = new AddMaterie();
                adm.set(nume, pret);

                if (adm.ShowDialog() == DialogResult.OK)
                {
                    SqlCommand cmd = new SqlCommand("UPDATE Materii SET nume = @nm , pret = @pr WHERE id_materie = '" + id + "'");
                    cmd.Parameters.AddWithValue("@nm", adm.name);
                    cmd.Parameters.AddWithValue("@pr", adm.price);
                    Database.Execute(cmd);
                    refreshMaterii();
                    refreshProduse();
                    refreshProfit();
                    MessageBox.Show("Materie prima actualizata cu succes");
                }
            }
        }
Exemplo n.º 2
0
        private void materiiAdd_Click(object sender, EventArgs e)
        {
            AddMaterie adm = new AddMaterie();

            if (adm.ShowDialog() == DialogResult.OK)
            {
                SqlCommand cmd = new SqlCommand("INSERT INTO Materii VALUES( @nume , @pret)");
                cmd.Parameters.AddWithValue("@nume", adm.name);
                cmd.Parameters.AddWithValue("@pret", adm.price);
                Database.Execute(cmd);
                refreshMaterii();
                refreshProduse();
                refreshProfit();
                MessageBox.Show("Materie prima adaugata cu succes");
            }
        }