public static int AddCTHP(SQLiteConnection connection, CTHocPhi ct) { DataProvider dtb = new DataProvider (connection); if (dtb.GetCTHP (ct) == null) { return dtb.AddCTHP (ct); } return 0; }
public HocPhiSource() { tableItems = new List<CTHocPhi> (); isHeader = true; CTHocPhi ct = new CTHocPhi (); ct.MaMH="Môn Học"; tableItems.Add (ct); }
public static async Task<HocPhi> MakeDataFromXml(SQLiteConnection connection) { var httpClient = new HttpClient (); Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/hocphi/3111410089/secret01"); string contents = await contentsTask; XDocument doc = XDocument.Parse (contents); XElement node = doc.Root; HocPhi hp = new HocPhi(); hp.HocKy = int.Parse(node.Elements().ElementAt(1).Value[7].ToString()); hp.NamHoc = int.Parse(node.Elements().ElementAt(1).Value.Substring(19, 4)); hp.TienConNo = node.Elements ().ElementAt (2).Value.Trim (); hp.TienDaDong = node.Elements ().ElementAt (3).Value.Trim (); hp.TienDongTTLD = node.Elements ().ElementAt (4).Value.Trim (); hp.TongSoTC = node.Elements ().ElementAt (5).Value.Trim (); hp.TongSoTien = node.Elements ().ElementAt (6).Value.Trim (); foreach (XElement node1 in node.Elements ().ElementAt (0).Elements()) { CTHocPhi ct = new CTHocPhi(); ct.HocPhi = node1.Elements().ElementAt(0).Value.Trim(); ct.MaNhom = node1.Elements().ElementAt(1).Value.Trim(); ct.MienGiam = node1.Elements().ElementAt(2).Value.Trim(); ct.PhaiDong = node1.Elements().ElementAt(3).Value.Trim(); ct.HocKy = hp.HocKy; ct.NamHoc = hp.NamHoc; ct.MaMH = node1.Elements().ElementAt(4).Elements().ElementAt(0).Value.Trim();; AddCTHP (connection, ct); } AddHP(connection,hp); return hp; }
public int AddCTHP (CTHocPhi T) { int i = _connection.Insert (T); _connection.Commit (); return i; }
public CTHocPhi GetCTHP (CTHocPhi hp) { var query = from c in _connection.Table<CTHocPhi> () where (c.HocKy == hp.HocKy) && (c.NamHoc == hp.NamHoc) && (c.MaMH.Equals (hp.MaMH)) select c; return query.FirstOrDefault (); }
public static async Task<HocPhi> MakeDataFromXml(SQLiteConnection connection) { if (BUser.GetMainUser (connection) != null) { var httpClient = new HttpClient (); httpClient.Timeout = TimeSpan.FromSeconds (20); string contents; Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlHP(BUser.GetMainUser(connection).Id,BUser.GetMainUser(connection).Password)); HocPhi hp = new HocPhi (); try { contents = await contentsTask; } catch(Exception e) { return hp; } XDocument doc = XDocument.Parse (contents); XElement node = doc.Root; hp.HocKy = int.Parse (node.Elements ().ElementAt (1).Value [7].ToString ()); hp.NamHoc = int.Parse (node.Elements ().ElementAt (1).Value.Substring (19, 4)); hp.TienConNo = node.Elements ().ElementAt (2).Value.Trim (); hp.TienDaDong = node.Elements ().ElementAt (3).Value.Trim (); hp.TienDongTTLD = node.Elements ().ElementAt (4).Value.Trim (); hp.TongSoTC = node.Elements ().ElementAt (5).Value.Trim (); hp.TongSoTien = node.Elements ().ElementAt (6).Value.Trim (); foreach (XElement node1 in node.Elements ().ElementAt (0).Elements()) { CTHocPhi ct = new CTHocPhi (); ct.HocPhi = node1.Elements ().ElementAt (0).Value.Trim (); ct.MaNhom = node1.Elements ().ElementAt (1).Value.Trim (); ct.MienGiam = node1.Elements ().ElementAt (2).Value.Trim (); ct.PhaiDong = node1.Elements ().ElementAt (3).Value.Trim (); ct.HocKy = hp.HocKy; ct.NamHoc = hp.NamHoc; MonHoc mh = new MonHoc (); ct.MaMH = node1.Elements ().ElementAt (4).Elements ().ElementAt (0).Value.Trim (); mh.MaMH = ct.MaMH; mh.TenMH=node1.Elements ().ElementAt (4).Elements ().ElementAt (2).Value.Trim (); mh.SoTC=int.Parse(node1.Elements ().ElementAt (4).Elements ().ElementAt (1).Value.Trim ()); ; AddCTHP (connection, ct); BMonHoc.Add (connection, mh); } AddHP (connection, hp); return hp; } return null; }