Exemple #1
0
        public bool Update(AutomobilBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string sql = "UPDATE AUTOMOBIL SET producator=@producator, model=@model, an_incepere_fabricatie=@an_incepere_fabricatie, an_incetare_fabricatie=an_incetare_fabricatie, tip=@tip WHERE automobil_id=@automobil_id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@automobil_id", a.Id);
                cmd.Parameters.AddWithValue("@producator", a.Producator);
                cmd.Parameters.AddWithValue("@model", a.Model);
                cmd.Parameters.AddWithValue("@an_incepere_fabricatie", a.Incepere);
                cmd.Parameters.AddWithValue("@an_incetare_fabricatie", a.Incetare);
                cmd.Parameters.AddWithValue("@tip", a.Tip);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSucces = true;
                }
                else
                {
                    isSucces = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(isSucces);
        }
Exemple #2
0
        public bool Insert(AutomobilBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string     sql = "INSERT INTO AUTOMOBIL (automobil_id, producator, model, an_incepere_fabricatie, an_incetare_fabricatie, tip) VALUES (@automobil_id, @producator, @model, @an_incepere_fabricatie, @an_incetare_fabricatie, @tip)";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@automobil_id", a.Id);
                cmd.Parameters.AddWithValue("@producator", a.Producator);
                cmd.Parameters.AddWithValue("@model", a.Model);
                cmd.Parameters.AddWithValue("@an_incepere_fabricatie", a.Incepere);
                cmd.Parameters.AddWithValue("@an_incetare_fabricatie", a.Incetare);
                cmd.Parameters.AddWithValue("@tip", a.Tip);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSucces = true;
                }
                else
                {
                    isSucces = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSucces);
        }
Exemple #3
0
        public bool Delete(AutomobilBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string     sql = "DELETE FROM AUTOMOBIL WHERE automobil_id=@automobil_id";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@automobil_id", a.Id);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSucces = true;
                }
                else
                {
                    isSucces = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSucces);
        }