//THÊM TÀI KHOẢN public int AddAcc(Acc a) { SqlCommand cmd = new SqlCommand(); ConnectionDB con = new ConnectionDB(cmd); con.Sql = @"select * from ACC where USERNAME = '******'"; con.ExecuteReader(); SqlDataReader rd = con.ExecuteReader(); if (rd.Read()) { return(2); //Có tên tk này rồi } con.Sql = @"insert into ACC values (" + "N'" + a.Username + "',N'" + a.Pass + "',N'" + a.Name + "',N'" + a.Sex + "'," + a.Type.ToString() + ")"; rd = con.ExecuteReader(); if (rd.Read()) { return(1); } else { return(0); } }
//Khởi tạo 1 Vip từ 1 Acc public Vip(Acc ac) { this.Username = ac.Username; this.Pass = ac.Pass; this.Name = ac.Name; this.Sex = ac.Sex; this.Type = ac.Type; }
//Get thông tin 1 acc khi biết username public Acc GetAcc(string s) { cmd = new SqlCommand(); con = new ConnectionDB(cmd); con.Sql = @"select * from ACC where USERNAME = '******'"; DataTable dt = con.GetTable(); Acc ac = new Acc(dt.Rows[0][0].ToString(), dt.Rows[0][1].ToString(), dt.Rows[0][2].ToString(), dt.Rows[0][3].ToString(), Convert.ToInt32(dt.Rows[0][4].ToString())); return(ac); }