Пример #1
0
		public static async Task<List<LichThi>> MakeDataFromXml(SQLiteConnection connection)
		{
			list = new List<LichThi> ();
			var httpClient = new HttpClient ();
			Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/lichthi/3111410094");
			string contents = await contentsTask;
			XDocument doc = XDocument.Parse (contents);

			//get lichthi 
			IEnumerable<XElement> childList =
				from el in doc.Root.Elements()
				select el;
			//get attri lichthi
			foreach (XElement node in childList)
			{
				
				LichThi lt = new LichThi();
				lt.GhepThi = node.Elements().ElementAt(0).Value.Trim();
				lt.GioBD = node.Elements().ElementAt(1).Value.Trim();
				MonHoc mh = new MonHoc();
				lt.MaMH = node.Elements().ElementAt(3).Value.Trim();
				mh.MaMH = lt.MaMH;
				mh.TenMH=node.Elements().ElementAt(8).Value.Trim();
				lt.NgayThi = node.Elements().ElementAt(4).Value.Trim();
				lt.PhongThi = node.Elements().ElementAt(5).Value.Trim();
				lt.SoLuong = int.Parse(node.Elements().ElementAt(6).Value.Trim());
				lt.SoPhut = int.Parse(node.Elements().ElementAt(7).Value.Trim());
				lt.ToThi = node.Elements().ElementAt(9).Value.Trim();
				list.Add(lt);
				BMonHoc.Add(connection,mh);
				AddLT(lt,connection);
			}
			return list;
		}
Пример #2
0
 public static int Add(SQLiteConnection connection,MonHoc mh)
 {
     DataProvider dtb = new DataProvider (connection);
     if (dtb.GetMonHoc (mh.MaMH) == null) {
         return dtb.AddMH (mh);
     }
     return 0;
 }
Пример #3
0
		public static async  Task<List<DiemThi>> MakeDataFromXml(SQLiteConnection connection)
			{
				list = new List<DiemThi> ();

			var httpClient = new HttpClient ();
			Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/diemthi/3111410094");
			string contents = await contentsTask;
			XDocument doc = XDocument.Parse (contents);
			//get lichthi 
			IEnumerable<XElement> childList =
				from el in doc.Root.Elements ()
				select el;
			//get attri lichthi

			foreach (XElement node in childList) {
				DiemThi lt = new DiemThi();
				lt.DiemRL = node.Elements().ElementAt(0).Value.Trim();

				foreach (XElement nod in node.Elements().ElementAt(5).Elements())
				{
					DiemMon dm = new DiemMon();
					MonHoc mh = new MonHoc();
					dm.Hocky = int.Parse(node.Elements().ElementAt(9).Value.Trim()[7].ToString());
					dm.NamHoc = int.Parse(node.Elements().ElementAt(9).Value.Trim().Substring(17));
					dm.DiemKT = nod.Elements().ElementAt(0).Value.Trim();
					// change TIle & also happened in BlichHOc
					dm.MaMH = nod.Elements().ElementAt(1).Value.Trim();
					mh.MaMH = dm.MaMH;
					mh.TenMH = nod.Elements().ElementAt(5).Value.Trim();
					mh.SoTC = int.Parse(nod.Elements().ElementAt(4).Value.Trim());
					mh.TiLeThi = int.Parse(nod.Elements().ElementAt(3).Value.Trim());
					dm.DiemThi = nod.Elements().ElementAt(6).Value.Trim();
					dm.DiemTK10 = nod.Elements ().ElementAt (7).Value.Trim ();
					dm.DiemChu = nod.Elements ().ElementAt (8).Value.Trim ();

					AddDM(dm,connection);
					BMonHoc.Add (connection, mh);
					BMonHoc.UpdateMH(connection,mh);
				}
				lt.DiemTB4 = node.Elements().ElementAt(1).Value.Trim();
				lt.DiemTB10 = node.Elements().ElementAt(2).Value.Trim();
				lt.DiemTBTL4 = node.Elements().ElementAt(3).Value.Trim();
				lt.DiemTBTL10 = node.Elements().ElementAt(4).Value.Trim();
				lt.LoaiRL = node.Elements().ElementAt(6).Value.Trim();
				lt.SoTCDat = node.Elements().ElementAt(7).Value.Trim();
				lt.SoTCTL = node.Elements().ElementAt(8).Value.Trim();  
				lt.NamHoc = int.Parse(node.Elements().ElementAt(9).Value.Trim().Substring(17));
				lt.Hocky = int.Parse(node.Elements().ElementAt(9).Value.Trim()[7].ToString());

				Add(lt,connection);
				list.Add(lt);


			}
			return list;
			}
Пример #4
0
        public static int UpdateMH(SQLiteConnection connection,MonHoc mh)
        {
            try
            {

                DataProvider dtb = new DataProvider (connection);
                return dtb.UpdateMH(mh);

            }
            catch
            {
                return 0;
            }
        }
Пример #5
0
		public static async Task<List<LichThi>> MakeDataFromXml(SQLiteConnection connection)
		{
			if (BUser.GetMainUser (connection) != null) {
				list = new List<LichThi> ();
				var httpClient = new HttpClient ();
				httpClient.Timeout = TimeSpan.FromSeconds (20);
				Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlLT(BUser.GetMainUser(connection).Id));
				string contents;
				try{
					contents = await contentsTask;
				}
				catch {
					return null;
				}
				XDocument doc = XDocument.Parse (contents);

				//get lichthi 
				IEnumerable<XElement> childList =
					from el in doc.Root.Elements ()
					select el;
				//get attri lichthi
				foreach (XElement node in childList) {
				
					LichThi lt = new LichThi ();
					lt.GhepThi = node.Elements ().ElementAt (0).Value.Trim ();
					lt.GioBD = node.Elements ().ElementAt (1).Value.Trim ();
					lt.HocKy = node.Elements ().ElementAt (3).Value.Trim ();
					lt.NamHoc = node.Elements ().ElementAt (5).Value.Trim ();
					MonHoc mh = new MonHoc ();
					lt.MaMH = node.Elements ().ElementAt (4).Value.Trim ();
					mh.MaMH = lt.MaMH;
					mh.TenMH = node.Elements ().ElementAt (10).Value.Trim ();
					lt.NgayThi = node.Elements ().ElementAt (6).Value.Trim ();
					lt.PhongThi = node.Elements ().ElementAt (7).Value.Trim ();
					lt.SoLuong = int.Parse (node.Elements ().ElementAt (8).Value.Trim ());
					lt.SoPhut = int.Parse (node.Elements ().ElementAt (9).Value.Trim ());
					lt.ToThi = node.Elements ().ElementAt (11).Value.Trim ();

					BMonHoc.Add (connection, mh);
					int i=AddLT (lt, connection);
					if (i == 1) {
						list.Add (lt);
					}
				}
				return list;
			}return null;
		}
Пример #6
0
		public static async Task<List<LichHoc>> MakeDataFromXml (SQLiteConnection connection)
		{
			if (BUser.GetMainUser (connection) != null) {
				list = new List<LichHoc> ();
				var httpClient = new HttpClient ();
				httpClient.Timeout = TimeSpan.FromSeconds (20);
				Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlLH(BUser.GetMainUser(connection).Id));
				string contents;

				try
				{
					contents =  await contentsTask;

				}
				catch(Exception e) {
					return null;
				}
				XDocument doc = XDocument.Parse (contents);
				//get lichthi 
				IEnumerable<XElement> childList =
					from el in doc.Root.Elements ()
					select el;
				//get attri lichthi
				int k = GetId (connection);
				DataProvider dtb = new DataProvider (connection);
				foreach (XElement node in childList) {
				
					LichHoc lichhoc = new LichHoc ();
					lichhoc = dtb.GetLH_Ma (node.Elements ().ElementAt (3).Value.Trim (),node.Elements ().ElementAt (4).Value.Trim (),node.Elements ().ElementAt (1).Value.Trim ());

					if (lichhoc != null) {
						chiTietLH ct = new chiTietLH ();
						ct.Id = lichhoc.Id;
						ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
						ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
						ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
						ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
						ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
						ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
						ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
						ct.Tuan = convertToDate (setTKB_Tuan (node.Elements ().ElementAt (13).Value.Trim ()),ct.ThoigianBD);
						AddCTLH (connection, ct);
					} else {
						k++;
						LichHoc lh = new LichHoc ();
						MonHoc mh = new MonHoc ();

						lh.Id = k.ToString ();
						lh.MaMH = node.Elements ().ElementAt (3).Value.Trim ();
						lh.MaLop = node.Elements ().ElementAt (2).Value.Trim ();
						lh.NhomMH = node.Elements ().ElementAt (5).Value.Trim ();
						lh.HocKy = node.Elements ().ElementAt (1).Value.Trim ();
						lh.NamHoc = node.Elements ().ElementAt (4).Value.Trim ();
						mh.MaMH = lh.MaMH;
						mh.TenMH = node.Elements ().ElementAt (9).Value.Trim ();
						mh.SoTC = int.Parse (node.Elements ().ElementAt (7).Value.Trim ());

						chiTietLH ct = new chiTietLH ();
						ct.Id = k.ToString ();
						ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
						ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
						ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
						ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
						ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
						ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
						ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
						ct.Tuan = convertToDate (setTKB_Tuan (node.Elements ().ElementAt (13).Value.Trim ()),ct.ThoigianBD);
						AddCTLH (connection, ct);

						bool done=AddLH (lh, connection);
						if (done) {
							list.Add (lh);
						}
						BMonHoc.Add (connection, mh);
					
					}


				}
				return list;
			}
			return null;
		}
Пример #7
0
		public static async Task<List<LichHoc>> MakeDataFromXml (SQLiteConnection connection)
		{
			list = new List<LichHoc> ();
			var httpClient = new HttpClient ();
			Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/thoikhoabieu/3111410094");
			string contents = await contentsTask;
			XDocument doc = XDocument.Parse (contents);
			//get lichthi 
			IEnumerable<XElement> childList =
				from el in doc.Root.Elements ()
				select el;
			//get attri lichthi
			int k = GetId (connection);
			DataProvider dtb = new DataProvider (connection);
			foreach (XElement node in childList) {
				
				LichHoc lichhoc = new LichHoc ();
				lichhoc = dtb.GetLH_Ma (node.Elements ().ElementAt (3).Value.Trim());

					if (lichhoc!=null) {
					chiTietLH ct = new chiTietLH ();
					ct.Id = lichhoc.Id;
					ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
					ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
					ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
					ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
					ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
					ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
					ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
					ct.Tuan = node.Elements ().ElementAt (13).Value.Trim ();
					AddCTLH (connection, ct);
				} else {
					k++;
					LichHoc lh = new LichHoc ();
					MonHoc mh = new MonHoc ();

					lh.Id = k.ToString ();
					lh.MaMH = node.Elements ().ElementAt (3).Value.Trim ();
					lh.MaLop = node.Elements ().ElementAt (2).Value.Trim ();
					lh.NhomMH = node.Elements ().ElementAt (5).Value.Trim ();
					lh.HocKy = node.Elements ().ElementAt (1).Value.Trim ();
					lh.NamHoc = node.Elements ().ElementAt (4).Value.Trim ();
					mh.MaMH = lh.MaMH;
					mh.TenMH = node.Elements ().ElementAt (9).Value.Trim ();
					mh.SoTC = int.Parse (node.Elements ().ElementAt (7).Value.Trim ());

					chiTietLH ct = new chiTietLH ();
					ct.Id = k.ToString ();
					ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
					ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
					ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
					ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
					ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
					ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
					ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
					ct.Tuan = node.Elements ().ElementAt (13).Value.Trim ();
					AddCTLH (connection, ct);
					list.Add (lh);
					AddLH (lh, connection);
					BMonHoc.Add (connection, mh);
					
				}


			}
			return list;
		}
Пример #8
0
		public int UpdateMH (MonHoc mh)
		{
			int i = _connection.Update (mh);
			_connection.Commit ();
			return i;
		}
Пример #9
0
		public int AddMH (MonHoc T)
		{
			int i = _connection.Insert (T);
			_connection.Commit ();
			return i;
		}
Пример #10
0
		public static async  Task<List<DiemThi>> MakeDataFromXml (SQLiteConnection connection)
		{
			if (BUser.GetMainUser (connection) != null) {
				list = new List<DiemThi> ();

				var httpClient = new HttpClient ();
				httpClient.Timeout = TimeSpan.FromSeconds (30);
				string contents;
				Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlDT(BUser.GetMainUser(connection).Id));
				try{
					contents = await contentsTask;
				}
				catch {
					return null;
				}
				XDocument doc = XDocument.Parse (contents);
				//get lichthi 
				IEnumerable<XElement> childList =
					from el in doc.Root.Elements ()
					select el;
				//get attri lichthi

				foreach (XElement node in childList) {
					DiemThi lt = new DiemThi ();
					lt.DiemRL = node.Elements ().ElementAt (0).Value.Trim ();

					foreach (XElement nod in node.Elements().ElementAt(5).Elements()) {
						DiemMon dm = new DiemMon ();
						MonHoc mh = new MonHoc ();
						dm.Hocky = node.Elements ().ElementAt (9).Value.Trim () [7].ToString ();
						dm.NamHoc = node.Elements ().ElementAt (9).Value.Trim ().Substring (17);
						dm.DiemKT = nod.Elements ().ElementAt (0).Value.Trim ();
						dm.MaMH = nod.Elements ().ElementAt (1).Value.Trim ();
						mh.MaMH = dm.MaMH;
						mh.TenMH = nod.Elements ().ElementAt (5).Value.Trim ();
						mh.SoTC = int.Parse (nod.Elements ().ElementAt (4).Value.Trim ());
						mh.TiLeThi = int.Parse (nod.Elements ().ElementAt (3).Value.Trim ());
						dm.DiemThi = nod.Elements ().ElementAt (6).Value.Trim ();
						dm.DiemTK10 = nod.Elements ().ElementAt (7).Value.Trim ();
						dm.DiemChu = nod.Elements ().ElementAt (8).Value.Trim ();

						AddDM (dm, connection);
						BMonHoc.Add (connection, mh);
						BMonHoc.UpdateMH (connection, mh);
					}
					lt.DiemTB4 = node.Elements ().ElementAt (1).Value.Trim ();
					lt.DiemTB10 = node.Elements ().ElementAt (2).Value.Trim ();
					lt.DiemTBTL4 = node.Elements ().ElementAt (3).Value.Trim ();
					lt.DiemTBTL10 = node.Elements ().ElementAt (4).Value.Trim ();
					lt.LoaiRL = node.Elements ().ElementAt (6).Value.Trim ();
					lt.SoTCDat = node.Elements ().ElementAt (7).Value.Trim ();
					lt.SoTCTL = node.Elements ().ElementAt (8).Value.Trim ();  
					lt.NamHoc = node.Elements ().ElementAt (9).Value.Trim ().Substring (17);
					lt.Hocky = node.Elements ().ElementAt (9).Value.Trim () [7].ToString ();

					Add (lt, connection);
					list.Add (lt);


				}
				return list;
			}
			return null;
		}
Пример #11
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Reminder_Dialog);
			Save = FindViewById<Button> (Resource.Id.btnSave);
			Del = FindViewById<Button> (Resource.Id.btnDel);
			Cancel = FindViewById<Button> (Resource.Id.btnCancel);
			Space = FindViewById<View> (Resource.Id.view_Reminder);
			edtxt_content = FindViewById<EditText> (Resource.Id.edtxt_Content);
			TextView title = FindViewById<TextView> (Resource.Id.txtTitleRM);
			TextView subject = FindViewById<TextView> (Resource.Id.txtSubjectRM);
			TextView time = FindViewById<TextView> (Resource.Id.txtTimeRM);
			TextView date = FindViewById<TextView> (Resource.Id.txtDateRM);
			edtxt_minutes = FindViewById<EditText> (Resource.Id.txt_minutes);
			bundle = Intent.GetBundleExtra ("RemindValue");
			MH = bundle.GetString ("MH");
			check = bundle.GetBoolean ("check");
			string minutes, mess;
			if (check) {
				string namhoc=bundle.GetString ("NamHoc");
				string hocky=bundle.GetString ("HocKy");
				mh = BMonHoc.GetMH (SQLite_Android.GetConnection (), MH);
				lt = BLichThi.GetLT (SQLite_Android.GetConnection (), MH,namhoc,hocky);
				title.Text = "NHẮC LỊCH THI";
				subject.Text = "Môn:" + mh.TenMH;
				date.Text = " Ngày: " + lt.NgayThi;
				time.Text = "Thời gian: " + lt.GioBD ;
				LTRemindItem item = BRemind.GetLTRemind (SQLite_Android.GetConnection (), lt.MaMH, lt.NamHoc, lt.HocKy);
				if (item != null) {
					ScheduleReminder reminder = new ScheduleReminder (this);
					reminder.GetRemind (item.EventID, out minutes, out mess);
					if (minutes != null) {
						edtxt_content.Text = mess;
						edtxt_minutes.Text = minutes;
					
					}
					else {
						NewReminder ();
					}
				}
				else {
					NewReminder ();
				}


			} else {
				tietBD = bundle.GetString ("TietBD");
				isLHT= bundle.GetBoolean ("isLHT");
				lh = BLichHoc.GetLH (SQLite_Android.GetConnection (), MH);
				mh = BMonHoc.GetMH (SQLite_Android.GetConnection (), lh.MaMH);
				isLHT = true;
				isLHT= bundle.GetBoolean ("isLHT");
				title.Text = "NHẮC LỊCH HOC";
				subject.Text = "Môn: " + mh.TenMH;


				if (isLHT) {
					ngayhoc= bundle.GetString ("NgayHoc");
					soTiet= bundle.GetString ("SoTiet");
					thu = bundle.GetString ("Thu");
					string exNgay = ngayhoc.Substring (3, 2);
					exNgay = exNgay + "/" + ngayhoc.Substring (0, 2) + "/" + ngayhoc.Substring (6, 4);
					date.Text = "Ngày: " + exNgay;
					time.Text = "Tiết: " + tietBD;
					LHRemindItem item = BRemind.GetLHRemind (SQLite_Android.GetConnection (), lh.Id, ngayhoc);
					if (item != null) {
						ScheduleReminder reminder = new ScheduleReminder (this);
						reminder.GetRemind (item.EventID, out minutes, out mess);
						if (minutes != null) {
							edtxt_content.Text = mess;
							edtxt_minutes.Text = minutes;
						
						} 
						else {
							NewReminder ();

						}
						checkBox = FindViewById<CheckBox> (Resource.Id.checkBox1);
						checkBox.Visibility = ViewStates.Visible;
					}
					else {
						NewReminder ();
						checkBox = FindViewById<CheckBox> (Resource.Id.checkBox1);
						checkBox.Visibility = ViewStates.Invisible;
					}
				}
				else {
					 
					List<LHRemindItem> list = BRemind.GetLHRemind(SQLite_Android.GetConnection (),lh.Id);
					if (list.Count > 1) {
						edtxt_content.Visibility = ViewStates.Gone;
						edtxt_minutes.Visibility = ViewStates.Gone;
						LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams (0, LinearLayout.LayoutParams.MatchParent, 0.1f);
						Space.LayoutParameters = layout;
						Save.Visibility = ViewStates.Gone;
					}else {

						date.Visibility = ViewStates.Gone;
						time.Visibility = ViewStates.Gone;
						NewReminder ();
					}
				}


			}
			// 
			Save.Click += Save_Click;
			Cancel.Click += new EventHandler (btnCancel_OnClickListener);
			Del.Click += Del_Click;

		}
Пример #12
0
		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;
		}