Ejemplo n.º 1
0
        public bool Update(posBLL p)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try {
                string     sql = "UPDATE brand SET brand.brand=@brand WHERE brand.idbrand=@idbrand";
                SqlCommand cmd = new SqlCommand(sql, conn);

                cmd.Parameters.AddWithValue("@brand", p.brand);
                cmd.Parameters.AddWithValue("@idbrand", p.idbrand);

                conn.Open();

                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    //Query success
                    isSuccess = true;
                }
                else
                {
                    //query failed
                    isSuccess = false;
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            finally {
                conn.Close();
            }

            return(isSuccess);
        }
Ejemplo n.º 2
0
        public bool Insert(posBLL p)
        {
            bool          isSuccess = false;
            SqlConnection conn      = new SqlConnection(myconnstring);

            try
            {
                String     sql = "INSERT into brand (brand) VALUES(@brand)";
                SqlCommand cmd = new SqlCommand(sql, conn);
                cmd.Parameters.AddWithValue("@brand", p.brand);

                conn.Open();
                int rows = cmd.ExecuteNonQuery();
                if (rows > 0)
                {
                    //Queryable success
                    isSuccess = true;
                }
                else
                {
                    //Query failed
                    isSuccess = false;
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(isSuccess);
        }