Beispiel #1
0
        public int removeProduct(string maSP)
        {
            Provider provider = new Provider();
            int      nRow     = 0;

            try
            {
                string SqlQuery = "DELETE FROM SanPham WHERE MaSP = @MaSP";
                provider.Connect();
                nRow = provider.ExeCuteNonQuery(CommandType.Text, SqlQuery,
                                                new SqlParameter {
                    ParameterName = "@MaSp", Value = maSP
                }
                                                );
                if (nRow > 0)
                {
                    return(1);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }
Beispiel #2
0
        public int updateProduct(SanPham sp)
        {
            Provider provider = new Provider();
            int      nRow     = 0;

            try
            {
                string SqlQuery = "UPDATE SanPham SET TenSP = @TenSP, GiaTien = @GiaTien, SoLuong = @SoLuong, DonViTinh = @DonViTinh WHERE MaSP = @MaSP";
                provider.Connect();
                nRow = provider.ExeCuteNonQuery(CommandType.Text, SqlQuery,
                                                new SqlParameter {
                    ParameterName = "@MaSP", Value = sp.MaSP
                },
                                                new SqlParameter {
                    ParameterName = "@TenSP", Value = sp.TenSP
                },
                                                new SqlParameter {
                    ParameterName = "@GiaTien", Value = sp.GiaTien
                },
                                                new SqlParameter {
                    ParameterName = "@SoLuong", Value = sp.SoLuong
                },
                                                new SqlParameter {
                    ParameterName = "@DonViTinh", Value = sp.DonVi
                }
                                                );
                if (nRow > 0)
                {
                    return(1);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }

            return(nRow);
        }
Beispiel #3
0
        public int addProduct(SanPham sp)
        {
            Provider provider = new Provider();
            int      nRow     = 0;

            try
            {
                string strSQL = "INSERT INTO SanPham VALUES(@MaSP, @TenSP, @GiaTien, @SoLuong, @DonVi)";
                provider.Connect();
                nRow = provider.ExeCuteNonQuery(CommandType.Text, strSQL,
                                                new SqlParameter {
                    ParameterName = "@MaSP", Value = sp.MaSP
                },
                                                new SqlParameter {
                    ParameterName = "@TenSP", Value = sp.TenSP
                },
                                                new SqlParameter {
                    ParameterName = "@GiaTien", Value = sp.GiaTien
                },
                                                new SqlParameter {
                    ParameterName = "@SoLuong", Value = sp.SoLuong
                },
                                                new SqlParameter {
                    ParameterName = "@DonVi", Value = sp.DonVi
                }
                                                );
                if (nRow > 0)
                {
                    return(1);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                provider.DisConnect();
            }
            return(nRow);
        }