Пример #1
0
        public bool Delete(cfiBLL u)
        {
            bool          isSucces = false;
            SqlConnection conn     = new SqlConnection(myconnstring);

            try
            {
                string     sql = "delete FROM Cfi where Id=@Id";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@Id", u.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);
        }
Пример #2
0
        public bool Insert(cfiBLL u)
        {
            bool          isSucces = false;
            SqlConnection conn     = new SqlConnection(myconnstring);

            try
            {
                string     sql = "INSERT INTO Cfi (Cfi,Description,CfiRatach) VALUES (@Cfi,@Description,@CfiRatach) ";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@Cfi", u.Cfi);
                cmd.Parameters.AddWithValue("@Description", u.Description);
                cmd.Parameters.AddWithValue("@CfiRatach", u.CfiRatach);


                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
        public bool Modifier(cfiBLL u)
        {
            bool          isSucces = false;
            SqlConnection conn     = new SqlConnection(myconnstring);

            try
            {
                string     sql = "UPDATE Cfi set Cfi=@Cfi,Description=@Description,CfiRatach=@CfiRatach  where Id=@Id";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@Cfi", u.Cfi);
                cmd.Parameters.AddWithValue("@Description", u.Description);
                cmd.Parameters.AddWithValue("@CfiRatach", u.CfiRatach);
                cmd.Parameters.AddWithValue("@Id", u.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);
        }