Esempio n. 1
0
        public new List <Class_LoaiMon> Select()
        {
            string sql = "SELECT * FROM LoaiMon";
            List <Class_LoaiMon> list = new List <Class_LoaiMon>();
            SqlConnection        con  = new SqlConnection();

            con.ConnectionString = @"Data Source=DESKTOP-MFCIF4Q\SQLEXPRESS;Initial Catalog=QLNhaHang;Integrated Security=True";
            con.Open();
            SqlCommand cmd = new SqlCommand(sql, con);

            using (DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string        MaLoai  = reader.GetString(0);
                        string        TenLoai = reader.GetString(1);
                        Class_LoaiMon Test    = new Class_LoaiMon(MaLoai, TenLoai);
                        list.Add(Test);
                    }
                }
            }
            con.Close();
            return(list);
        }
Esempio n. 2
0
        public void delete(Class_LoaiMon loai_mon)
        {
            string sql = "DELETE FROM LoaiMon WHERE MaLoaiMon = " + loai_mon.MaLoai1;

            query.insert(sql);
            query.insert(sql);
        }
Esempio n. 3
0
        public void update(Class_LoaiMon loai_mon)
        {
            string sql = "UPDATE LoaiMon WHERE SET MaLoai=" + loai_mon.MaLoai1 + ",TenLoai=N'" +
                         loai_mon.TenLoai1 + "')";

            query.insert(sql);
        }
Esempio n. 4
0
        public void insert(Class_LoaiMon loai_mon)
        {
            string sql = "INSERT INTO LoaiMon(MaLoai,TenLoai) VALUES(";

            sql += loai_mon.MaLoai1 + ",N'" + loai_mon.TenLoai1 + "')";
            query.insert(sql);
        }
Esempio n. 5
0
        public new List <Class_LoaiMon> Select()
        {
            string sql = "SELECT * FROM LoaiMon";
            List <Class_LoaiMon> list = new List <Class_LoaiMon>();

            query.ketnoiSQL();
            using (DbDataReader reader = query.Reader(sql))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        string        MaLoai  = reader.GetString(0);
                        string        TenLoai = reader.GetString(1);
                        Class_LoaiMon Test    = new Class_LoaiMon(MaLoai, TenLoai);
                        list.Add(Test);
                    }
                }
            }
            query.DongketnoiSQL();
            return(list);
        }