Example #1
0
        public bool Delete(ClientiBLL c, SqlConnection conn)
        {
            //set bool var
            bool isSuccess = false;



            try
            {
                //sql Query
                string sql = "DELETE FROM Clienti WHERE ID_client=@ID_client ";

                //sql comand
                SqlCommand cmd = new SqlCommand(sql, conn);

                //param to get value
                cmd.Parameters.AddWithValue("@ID_client", c.ID_client);



                //open conection
                conn.Open();

                //var to hold value after quer executed
                int rows = cmd.ExecuteNonQuery();

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



            return(isSuccess);
        }
Example #2
0
        public bool Insert(ClientiBLL c, SqlConnection conn)
        {
            //set bool var
            bool isSuccess = false;

            try
            {
                //sql Query
                string sql = "INSERT INTO Clienti( Nume, Adresa, Cod_fiscal) VALUES ( @Nume, @Adresa, @Cod_fiscal)";

                //sql comand
                SqlCommand cmd = new SqlCommand(sql, conn);

                //param to get value
                cmd.Parameters.AddWithValue("@Nume", c.Nume);
                cmd.Parameters.AddWithValue("@Adresa", c.Adresa);
                cmd.Parameters.AddWithValue("@Cod_fiscal", c.Cod_fiscal);

                //open conection
                conn.Open();

                //var to hold value after quer executed
                int rows = cmd.ExecuteNonQuery();

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



            return(isSuccess);
        }
Example #3
0
        public bool Update(ClientiBLL c, SqlConnection conn)
        {
            //set bool var
            bool isSuccess = false;


            try
            {
                //sql Query
                string sql = "UPDATE Clienti SET  Nume=@Nume, Adresa=@Adresa, Cod_fiscal=@Cod_fiscal WHERE ID_client=@ID_client ";

                //sql comand
                SqlCommand cmd = new SqlCommand(sql, conn);

                //param to get value
                cmd.Parameters.AddWithValue("@ID_client", c.ID_client);
                cmd.Parameters.AddWithValue("@Nume", c.Nume);
                cmd.Parameters.AddWithValue("@Adresa", c.Adresa);
                cmd.Parameters.AddWithValue("@Cod_fiscal", c.Cod_fiscal);

                //open conection
                conn.Open();

                //var to hold value after quer executed
                int rows = cmd.ExecuteNonQuery();

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

            return(isSuccess);
        }