Ejemplo n.º 1
0
        public bool Update(CProductBLL p)
        {
            bool          isSuccess = false;
            SqlConnection cn        = new SqlConnection(cnString);

            cn = CDatabase.Get_Database_Connection();
            try
            {
                string sqlText = "UPDATE HANG_HOA SET MAHH=@m_MaHH,MAHTDG=@m_MaHTDG,MANHOM=@m_MaNhom,TENHH=@m_TenHH, DVT=@m_DVT, DONGIA=@m_DonGia, SLTON=@m_SLTon WHERE MAHH=@m_MaHH";

                SqlCommand cmd = new SqlCommand(sqlText, cn);

                cmd.Parameters.AddWithValue("@m_MaHH", p.m_MaHH);
                cmd.Parameters.AddWithValue("@m_MaHTDG", p.m_MaHTDG);
                cmd.Parameters.AddWithValue("@m_MaNhom", p.m_MaNhom);
                cmd.Parameters.AddWithValue("@m_TenHH", p.m_TenHH);
                cmd.Parameters.AddWithValue("@m_DVT", p.m_DVT);
                cmd.Parameters.AddWithValue("@m_DonGia", p.m_DonGia);
                cmd.Parameters.AddWithValue("@m_SLTon", p.m_SLTon);

                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CDatabase.Close_Database_Connection();
            }

            return(isSuccess);
        }
Ejemplo n.º 2
0
        public bool Delete(CProductBLL p)
        {
            bool          isSuccess = false;
            SqlConnection cn        = new SqlConnection(cnString);

            cn = CDatabase.Get_Database_Connection();
            try
            {
                string sqlText = "DELETE FROM HANG_HOA WHERE MAHH=@m_MaHH";

                SqlCommand cmd = new SqlCommand(sqlText, cn);

                cmd.Parameters.AddWithValue("@m_MaHH", p.m_MaHH);


                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                CDatabase.Close_Database_Connection();
            }

            return(isSuccess);
        }