private void Click_Logout(object sender, EventArgs e) { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Thông báo"); alert.SetMessage("Bạn có muốn đăng xuất không?"); alert.SetButton2("Có", (c, ev) => { dialog.Dispose(); list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) { // xoa gio hang CmmVar.LIST_SHOPPING_CART = new List <BeanShoppingCart>(); SQLiteDataHandler.BeanSession_ClearSession(); Intent intent = new Intent(this, typeof(Activity_Home)); StartActivity(intent); } }); alert.SetButton("Không", (c, ev) => { dialog.Dispose(); }); alert.Show(); }
private void SetData() { try { // check session List <BeanSession> list = new List <BeanSession>(); list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) // Co session { _tvName.Text = list[0].TaiKhoan; } else // chua co session { _tvName.Text = "Bạn chưa đăng nhập!"; } _listMonAn = SQLiteDataHandler.BeanMonAn_LoadList(); if (_listMonAn != null && _listMonAn.Count > 0) { HomeRecyclerViewAdapter adapter = new HomeRecyclerViewAdapter(this, _listMonAn, 0); adapter.ItemClick += Click_RecyclerData; _recyclerData.SetAdapter(adapter); _recyclerData.SetLayoutManager(new LinearLayoutManager(this)); } } catch (System.Exception ex) { } }
private void Click_DeleteItem(object sender, int e) { if (_lstCart[e] != null) { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Xác nhận"); alert.SetMessage("Bạn có muốn xoá không?"); alert.SetButton("Có", (c, ev) => { bool res = SQLiteDataHandler.BeanShoppingCart_DeleteItem(_lstCart[e]); if (res == true) { _lstCart = SQLiteDataHandler.BeanShoppingCart_LoadList(); ShoppingCartRecyclerViewAdapter adapter = new ShoppingCartRecyclerViewAdapter(this, _lstCart); adapter.ClickDecrease += Click_ItemDecrease; adapter.ClickIncrease += Click_ItemIncrease; adapter.ItemClick += Click_DeleteItem; _recyclerData.SetAdapter(adapter); _recyclerData.SetLayoutManager(new LinearLayoutManager(this)); _currentmoney = CountTotalMoney(_lstCart); _tvPrice.Text = String.Format("{0:#,0}", _currentmoney) + " VNĐ"; } }); alert.SetButton2("Không", (c, ev) => { alert.Dismiss(); }); alert.Show(); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); list = SQLiteDataHandler.BeanSession_LoadList(); _lstCart = SQLiteDataHandler.BeanShoppingCart_LoadList(); if (_btnClose == null) { if (list != null && list.Count > 0) // Co session { _MaNguoiDung = list[0].MaNguoiDung; if (!String.IsNullOrEmpty(_MaNguoiDung)) // keo API dia chi { await Utilities_API.API_GetListDiaChiByMaNguoiDung(_MaNguoiDung); _lstDiaChi = Utilities_API.RESULT_APIGET_LISTDIACHI_BYMANGUOIDUNG; if (_lstDiaChi != null && _lstDiaChi.Count > 0) { List <BeanDiaChi> temp = _lstDiaChi.Where(x => x.MacDinh == true).ToList(); await Utilities_API.API_GetShipFee(generateDistrict(temp[0].QuanHuyen)); _selectedBeanDiaChi = temp[0]; _currentship = Utilities_API.RESULT_API_COUNTSHIP; } } } else // chua co session { } } getLayout(); SetData(); }
private void setupSQLite() { SQLiteDataHandler.CreateDBSQLite(); if (API_RESULT_LISTMONAN != null && API_RESULT_LISTMONAN.Count > 0) { List <BeanMonAn> listMonAn = new List <BeanMonAn>(); listMonAn = SQLiteDataHandler.BeanMonAn_LoadList(); foreach (BeanMonAn item in API_RESULT_LISTMONAN) { if (String.IsNullOrEmpty(item.SearchData)) // de search { item.SearchData = CmmFunction.RemoveVietNamAccent(item.TenMon) + " " + CmmFunction.RemoveVietNamAccent(item.MieuTa); } if (listMonAn.Any(x => x.MaMon.Equals(item.MaMon))) // da ton tai trong db { BeanMonAn temp = listMonAn.Find(x => x.MaMon.Equals(item.MaMon)); if (temp.Modified != item.Modified) // cap nhat moi { SQLiteDataHandler.BeanMonAn_Update(item); Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this); string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh; download.Execute(url); } } else { SQLiteDataHandler.BeanMonAn_Insert(item); Utilities_DownloadImageFromURL download = new Utilities_DownloadImageFromURL(this); string url = Utilities_API._SiteName + Utilities_API._SiteImageUrl + item.HinhAnh; download.Execute(url); } } } }
private void Click_DialogOrder(object sender, EventArgs e) { AlertDialog.Builder builder = new AlertDialog.Builder(this); View root = LayoutInflater.Inflate(Resource.Layout.Layout_Food_Detail_AddItem, null); TextView _tvFoodName_Detail = root.FindViewById <TextView>(Resource.Id.AddItem_tvFoodName); TextView _tvPrice_Detail = root.FindViewById <TextView>(Resource.Id.AddItem_tvPrice); TextView _tvCount_Detail = root.FindViewById <TextView>(Resource.Id.AddItem_tvCount); Button _btnDecrease_Detail = root.FindViewById <Button>(Resource.Id.AddItem_btnDecrease); Button _btnIncrease_Detail = root.FindViewById <Button>(Resource.Id.AddItem_btnIncrease); Button _btnAdd_Detail = root.FindViewById <Button>(Resource.Id.AddItem_btnAdd); _tvFoodName_Detail.Text = _beanMonAn.TenMon.ToString(); _tvPrice_Detail.Text = String.Format("{0:#,0}", _beanMonAn.GiaTien).ToString() + " VNĐ"; _btnIncrease_Detail.Click += delegate { int _temp = int.Parse(_tvCount_Detail.Text); _temp = _temp + 1; _tvCount_Detail.Text = _temp.ToString(); _tvPrice_Detail.Text = String.Format("{0:#,0}", _beanMonAn.GiaTien * (_temp * 1.0)).ToString() + " VNĐ"; }; _btnDecrease_Detail.Click += delegate { int _temp = int.Parse(_tvCount_Detail.Text); if (_temp != 1) { _temp = _temp - 1; _tvCount_Detail.Text = _temp.ToString(); _tvPrice_Detail.Text = String.Format("{0:#,0}", _beanMonAn.GiaTien * (_temp * 1.0)).ToString() + " VNĐ"; } }; _btnAdd_Detail.Click += delegate { _dialog.Dismiss(); List <BeanShoppingCart> tempCart = SQLiteDataHandler.BeanShoppingCart_LoadList(); BeanShoppingCart addItem = new BeanShoppingCart(MaMon, int.Parse(_tvCount_Detail.Text)); if (tempCart != null && tempCart.Count > 0) { if (tempCart.Any(x => x.MaMonAn.Equals(MaMon))) // them so luong { SQLiteDataHandler.BeanShoppingCart_UpdateItemCount(addItem); Toast.MakeText(this, "Đã cập nhật số lượng", ToastLength.Long).Show(); } else { SQLiteDataHandler.BeanShoppingCart_AddItem(addItem); Toast.MakeText(this, "Đã thêm vào giỏ hàng", ToastLength.Long).Show(); } } else { SQLiteDataHandler.BeanShoppingCart_AddItem(addItem); Toast.MakeText(this, "Đã thêm vào giỏ hàng", ToastLength.Long).Show(); } }; builder.SetView(root); _dialog = builder.Create(); _dialog.Show(); }
private void setupData() { _listMonAn = SQLiteDataHandler.BeanMonAn_LoadList(); filterData(); HomeRecyclerViewAdapter adapter = new HomeRecyclerViewAdapter(this, _listMonAn_Filtered, _category); adapter.ItemClick += Click_RecyclerData; _recyclerData = FindViewById <RecyclerView>(Resource.Id.FoodCategory_RecyclerView_Data); _recyclerData.SetAdapter(adapter); _recyclerData.SetLayoutManager(new LinearLayoutManager(this)); }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { _monAn = SQLiteDataHandler.BeanMonAn_SearchItem(_lstData[position].MaMonAn); if (_monAn != null) { CartHolder recyclerViewHolder = holder as CartHolder; recyclerViewHolder._tvDishName.Text = _monAn.TenMon; recyclerViewHolder._tvDishPrice.Text = String.Format("{0:#,0}", _monAn.GiaTien) + " VNĐ"; Utilities.Utilities_LoadImage.LoadImageToImageView(_monAn.HinhAnh, recyclerViewHolder._imgDish); recyclerViewHolder._tvCount.Text = _lstData[position].SoLuong.ToString(); } }
private async void Click_Login(object sender, EventArgs e) { if (String.IsNullOrEmpty(_edtEmail.Text) || String.IsNullOrEmpty(_edtPassword.Text)) { Toast.MakeText(this, "Vui lòng nhập đủ thông tin!", ToastLength.Long).Show(); } else // nhap du thong tin { //Intent intent = new Intent(this, typeof(Activity_Login_ConfirmOTP)); //StartActivity(intent); await Utilities_API.API_GetLogIn(_edtEmail.Text, _edtPassword.Text); BeanNguoiDung result = Utilities_API.RESULT_APILOGIN_BEANNGUOIDUNG; if (result != null) { if (!String.IsNullOrEmpty(result.MaNguoiDung) && !String.IsNullOrEmpty(result.TaiKhoan) && !String.IsNullOrEmpty(result.MatKhau)) // thanh cong { // kiem tra coi co confirm otp chua if (result.KichHoat == true) // da kich hoat { BeanSession session = new BeanSession(result.MaNguoiDung, result.TaiKhoan, result.MatKhau, result.HoTen, result.GioiTinh, result.NgaySinh, result.HinhAnh, result.Email, result.LoaiNguoiDung, result.KhoaNguoiDung, result.MaOtp, result.KichHoat, result.Created, result.Modified, result.CreatedBy, result.ModifiedBy); SQLiteDataHandler.BeanSession_AddSession(session); Finish(); Intent intent = new Intent(this, typeof(Activity_Home)); StartActivity(intent); } else // chua kich hoat { Finish(); Intent intent = new Intent(this, typeof(Activity_Login_ConfirmOTP)); intent.PutExtra("MaNguoiDung", result.MaNguoiDung); intent.PutExtra("TaiKhoan", result.TaiKhoan); intent.PutExtra("MatKhau", result.MatKhau); StartActivity(intent); } } else { Toast.MakeText(this, "Đăng nhập thất bại!", ToastLength.Long).Show(); } } } }
private float CountTotalMoney(List <BeanShoppingCart> data) { float _totalMoney = 0; List <BeanMonAn> _lstSelectMonAn = new List <BeanMonAn>(); for (int i = 0; i < data.Count; i++) { BeanMonAn _monAn = SQLiteDataHandler.BeanMonAn_SearchItem(data[i].MaMonAn); if (data != null) { _lstSelectMonAn.Add(_monAn); } } for (int i = 0; i < data.Count; i++) { _totalMoney += data[i].SoLuong * _lstSelectMonAn[i].GiaTien; } return(_totalMoney); }
private void Click_ItemDecrease(object sender, int e) { if (_lstCart[e] != null) { if (_lstCart[e].SoLuong > 1) { _lstCart[e].SoLuong = _lstCart[e].SoLuong - 1; SQLiteDataHandler.BeanShoppingCart_UpdateItem(_lstCart[e]); _lstCart = SQLiteDataHandler.BeanShoppingCart_LoadList(); ShoppingCartRecyclerViewAdapter adapter = new ShoppingCartRecyclerViewAdapter(this, _lstCart); adapter.ClickDecrease += Click_ItemDecrease; adapter.ClickIncrease += Click_ItemIncrease; adapter.ItemClick += Click_DeleteItem; _recyclerData.SetAdapter(adapter); _recyclerData.SetLayoutManager(new LinearLayoutManager(this)); _currentmoney = CountTotalMoney(_lstCart); _tvPrice.Text = String.Format("{0:#,0}", _currentmoney) + " VNĐ"; } } }
private async void SendOTP(object sender, EventArgs e) { if (_edtOTP.Text.Length == 6) { if (!String.IsNullOrEmpty(_MaNguoiDung)) { // get List Mon An await Utilities_API.API_ConfirmOTP(_MaNguoiDung, _edtOTP.Text); bool result_confirm = Utilities_API.RESULT_APIOTP_BOOL; BeanNguoiDung result = Utilities_API.RESULT_APICONFIRMOTP_BEANNGUOIDUNG; if (result_confirm == true) { Toast.MakeText(this, "Xác nhận OTP thành công!", ToastLength.Long).Show(); // Add session BeanSession session = new BeanSession(result.MaNguoiDung, result.TaiKhoan, result.MatKhau, result.HoTen, result.GioiTinh, result.NgaySinh, result.HinhAnh, result.Email, result.LoaiNguoiDung, result.KhoaNguoiDung, result.MaOtp, result.KichHoat, result.Created, result.Modified, result.CreatedBy, result.ModifiedBy); SQLiteDataHandler.BeanSession_AddSession(session); Finish(); Intent intent = new Intent(this, typeof(Activity_Home)); StartActivity(intent); } else if (result_confirm == false) { Toast.MakeText(this, "Xác nhận OTP thất bại!", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Tài khoản có lỗi xảy ra", ToastLength.Long).Show(); } } else { Toast.MakeText(this, "Mã OTP không hợp lệ", ToastLength.Long).Show(); } }
private void setData() { // check session list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) // Co session { if (!String.IsNullOrEmpty(list[0].TaiKhoan)) { _edtID.Text = list[0].TaiKhoan; } if (!String.IsNullOrEmpty(list[0].Email)) { _edtEmail.Text = list[0].Email; } if (!String.IsNullOrEmpty(list[0].MatKhau)) { for (int i = 0; i < list[0].MatKhau.Length; i++) { _passHide += "*"; } _edtPassword.Text = _passHide; } if (list[0].NgaySinh != null) { _edtNgaySinh.Text = list[0].NgaySinh.Value.Date.ToString("d"); } if (list[0].GioiTinh == true) { _edtGioiTinh.Text = "Nam"; } else { _edtGioiTinh.Text = "Nữ"; } } }
/// <summary> /// 初始化H5数据 /// </summary> private void InitH5() { if (!AddInUtility.H5) { return; } new Thread(delegate() { try { List <int> marketTypes = new List <int>(); XmlDocument xmlDocument = new XmlDocument(); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; XmlReader xmlReader = XmlReader.Create("h5sdk.xml", settings); xmlDocument.Load(xmlReader); foreach (XmlNode xmlNode in xmlDocument.DocumentElement.ChildNodes) { foreach (XmlAttribute xmlAttribute in xmlNode.Attributes) { if (xmlAttribute.Name == "mkttype") { marketTypes.Add(Int32.Parse(xmlAttribute.Value.Substring(2, xmlAttribute.Value.Length - 2), NumberStyles.HexNumber)); } } } IH5Adapter h5Adapter = this.communication.DBFactory.GetH5Data(); if (null == h5Adapter) { return; } else { ISQLiteDataHandler sqlDataHandler = new SQLiteDataHandler(Path.Combine(Application.StartupPath, "Quotation.db3"), "12345678"); string cmdText = "Delete From SecurityCollection"; sqlDataHandler.ExecuteNonQuery(cmdText); SQLiteParameter[] parameters = new SQLiteParameter[0]; List <string> batchSqls = new List <string>(); foreach (int marketType in marketTypes) { int errno = 0; IMarketOverview mktOverview = h5Adapter.GetSupportMarketInfo(marketType, 2000, ref errno, false); int totalCount = mktOverview.TotalCount; for (int stockIndex = 0; stockIndex < totalCount; stockIndex++) { IStockInitInfo stockInitInfo = mktOverview.GetStockInitInfo(stockIndex); string insertSql = "Insert Into SecurityCollection Values( '" + stockInitInfo.StockCode + "', '" + stockInitInfo.StockName + "', " + Convert.ToString(stockInitInfo.MarketType) + ", " + Convert.ToString(stockInitInfo.CodeType) + ", " + Convert.ToString(stockInitInfo.StockStatus) + " )"; batchSqls.Add(insertSql); } } sqlDataHandler.ExecuteBatchNonQuery(batchSqls); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }).Start(); }
private void getLayout() { SetContentView(Resource.Layout.Layout_Home); _btnSearch = FindViewById <ImageView>(Resource.Id.Home_btnSearch); _btnMore = FindViewById <ImageView>(Resource.Id.Home_btnMore); _btnShoppingCart = FindViewById <ImageView>(Resource.Id.Home_btnCart); _btnCategory1 = FindViewById <Button>(Resource.Id.Home_btnCategory1); _btnCategory2 = FindViewById <Button>(Resource.Id.Home_btnCategory2); _btnCategory3 = FindViewById <Button>(Resource.Id.Home_btnCategory3); _tvName = FindViewById <TextView>(Resource.Id.Home_tvName); _recyclerData = FindViewById <RecyclerView>(Resource.Id.Home_RecyclerView_Data); _viewPagerBanner = FindViewById <ViewPager>(Resource.Id.Home_ViewPagerBanner); ViewPageradapter = new HomeViewPagerBannerAdapter(SupportFragmentManager); _viewPagerBanner.Adapter = ViewPageradapter; _viewPagerBanner.OffscreenPageLimit = 3; SetupTimerViewPager(); _btnCategory1.Click += delegate { Intent intent = new Intent(this, typeof(Activity_Food_Category)); intent.PutExtra("Category", "1"); StartActivity(intent); }; _btnCategory2.Click += delegate { Intent intent = new Intent(this, typeof(Activity_Food_Category)); intent.PutExtra("Category", "2"); StartActivity(intent); }; _btnCategory3.Click += delegate { Intent intent = new Intent(this, typeof(Activity_Food_Category)); intent.PutExtra("Category", "3"); StartActivity(intent); }; _btnSearch.Click += delegate { Intent intent = new Intent(this, typeof(Activity_Food_Category)); intent.PutExtra("Category", "0"); StartActivity(intent); }; _btnMore.Click += delegate { List <BeanSession> list = new List <BeanSession>(); list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) // Co session { Intent intent = new Intent(this, typeof(Activity_Logout)); StartActivity(intent); } else // chua co session { Intent intent = new Intent(this, typeof(Activity_Login2)); StartActivity(intent); } }; _btnShoppingCart.Click += delegate { List <BeanSession> list = new List <BeanSession>(); list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) // Co session { Intent intent = new Intent(this, typeof(Activity_Bill_Confirm)); StartActivity(intent); } else // chua co session { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Lưu ý"); alert.SetMessage("Vui lòng đăng nhập vào hệ thống!"); alert.SetButton("OK", (c, ev) => { dialog.Dispose(); }); alert.Show(); } }; }
private async void Click_Order(object sender, EventArgs e) { if (!_tvShip.Text.Equals("Không giao hàng") && _currentmoney > 0) { list = SQLiteDataHandler.BeanSession_LoadList(); if (list != null && list.Count > 0) // Co session { // don hang BeanDonHang beanDonHang = new BeanDonHang(); beanDonHang.MaKH = list[0].MaNguoiDung; if (!String.IsNullOrEmpty(_selectedBeanDiaChi.SoNha)) { beanDonHang.DiaChi = _selectedBeanDiaChi.SoNha + " " + generateDistrict(_selectedBeanDiaChi.PhuongXa) + " " + generateDistrict(_selectedBeanDiaChi.QuanHuyen) + " " + _selectedBeanDiaChi.TinhThanh; } beanDonHang.SoDT = _selectedBeanDiaChi.SoDT; beanDonHang.PhiVanChuyen = _currentship; beanDonHang.ThanhTien = _currentmoney; // CT don hang List <BeanItemCart> _lstAddCart = new List <BeanItemCart>(); _lstCart = SQLiteDataHandler.BeanShoppingCart_LoadList(); foreach (BeanShoppingCart item in _lstCart) { BeanItemCart temp = new BeanItemCart(); temp.MaMon = item.MaMonAn; temp.SoLuong = item.SoLuong; _lstAddCart.Add(temp); } await Utilities_API.API_Order(beanDonHang, _lstAddCart); bool res = Utilities_API.RESULT_APIADD_BILL; if (res == true) { SQLiteDataHandler.BeanShoppingCart_ClearAll(); _lstCart = new List <BeanShoppingCart>(); ShoppingCartRecyclerViewAdapter adapter = new ShoppingCartRecyclerViewAdapter(this, _lstCart); adapter.ClickDecrease += Click_ItemDecrease; adapter.ClickIncrease += Click_ItemIncrease; adapter.ItemClick += Click_DeleteItem; _recyclerData.SetAdapter(adapter); _recyclerData.SetLayoutManager(new LinearLayoutManager(this)); Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Thông báo"); alert.SetMessage("Thêm mới thành công"); alert.SetButton("OK", (c, ev) => { dialog.Dispose(); Finish(); }); alert.Show(); } else { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Thông báo"); alert.SetMessage("Thêm mới thất bại"); alert.SetButton("OK", (c, ev) => { dialog.Dispose(); }); alert.Show(); } } } else { Android.App.AlertDialog.Builder dialog = new AlertDialog.Builder(this); AlertDialog alert = dialog.Create(); alert.SetTitle("Thông báo"); alert.SetMessage("Vui lòng nhập đủ thông tin"); alert.SetButton("OK", (c, ev) => { dialog.Dispose(); }); alert.Show(); } }