Example #1
0
        public void LoadOperatii()
        {
            if (_operatii != null)
            {
                _operatii.Clear();
            }
            const string stringSql = "SELECT * FROM Operatii";

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand(stringSql, connection);

                using (SqlDataReader sqlReader = command.ExecuteReader())
                {
                    while (sqlReader.Read())
                    {
                        int    id   = (int)sqlReader["Id"];
                        string nume = (string)sqlReader["Nume"];
                        if (nume.Contains("Inchidere"))
                        {
                            InchidereCont inchidere = new InchidereCont(id, nume);

                            _operatii.Add(inchidere);
                        }
                        else
                        {
                            ModificaSuma modifica = new ModificaSuma(id, nume);
                            _operatii.Add(modifica);
                        }
                    }
                }
            }
        }
Example #2
0
        private void BtnClose_Click(object sender, EventArgs e)
        {
            string nume = "Inchidere " + _cont.Id.ToString() + tbNumeOp.Text;

            long suma = 0;

            InitOperatie(nume);
            InchidereCont inchidere = new InchidereCont();
            const string  stringSql = " SELECT Id FROM Operatii WHERE nume = @nume ";

            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();

                var command = new SqlCommand(stringSql, connection);
                command.Parameters.AddWithValue("@nume", nume);
                using (SqlDataReader sqlReader = command.ExecuteReader())
                {
                    while (sqlReader.Read())
                    {
                        int id = (int)sqlReader["Id"];
                        inchidere.Id = id;
                    }
                }
                connection.Close();
            }
            inchidere.nume = nume;
            inchidere.EfOperatie(nume, _cont, suma);
        }