コード例 #1
0
ファイル: AutoCompDAL.cs プロジェクト: alexserban26/Magazin
        public bool Update(AutoCompBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string sql = "UPDATE AUTOMOBIL_COMPATIBIL SET cod_motor=@cod_motor, producator=@producator, model=@model, an_fabricatie=@an_fabricatie WHERE cod_produs=@cod_produs AND automobil_id=@automobil_id";

                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@automobil_id", a.Id);
                cmd.Parameters.AddWithValue("@cod_produs", a.Cod_produs);
                cmd.Parameters.AddWithValue("@cod_motor", a.Cod_motor);
                cmd.Parameters.AddWithValue("@producator", a.Producator);
                cmd.Parameters.AddWithValue("@model", a.Model);
                cmd.Parameters.AddWithValue("@an_fabricatie", a.An_fabricatie);

                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);
        }
コード例 #2
0
ファイル: AutoCompDAL.cs プロジェクト: alexserban26/Magazin
        public bool Insert(AutoCompBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

            try
            {
                string     sql = "INSERT INTO AUTOMOBIL_COMPATIBIL (automobil_id, cod_produs, cod_motor, producator, model, an_fabricatie) VALUES (@automobil_id, @cod_produs, @cod_motor, @producator, @model, @an_fabricatie)";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@automobil_id", a.Id);
                cmd.Parameters.AddWithValue("@cod_produs", a.Cod_produs);
                cmd.Parameters.AddWithValue("@cod_motor", a.Cod_motor);
                cmd.Parameters.AddWithValue("@producator", a.Producator);
                cmd.Parameters.AddWithValue("@model", a.Model);
                cmd.Parameters.AddWithValue("@an_fabricatie", a.An_fabricatie);

                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);
        }
コード例 #3
0
ファイル: AutoCompDAL.cs プロジェクト: alexserban26/Magazin
        public bool Delete(AutoCompBLL a)
        {
            bool isSucces = false;

            SqlConnection conn = new SqlConnection(myconnstrng);

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

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

                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);
        }