public MainForm() { //Check DB if (String.IsNullOrEmpty(MainUtils.readDataConnect())) { loadAttachDBFirst(); } InitializeComponent(); MainUtils.checkFolder(); dropboxNemiro = new DropboxNemiro(this, null); DBHelper = new DatabaseHelper(); mainUtils = new MainUtils(); //CheckBox network mainUtils.runCheckConnection(); SyncWithDropbox(); updateDataGridView(); loadProductDetail(IDItemCurrent); autoComplete(); }
public void updateDataBaseFromJson(DropboxNemiro dropboxNemiro) { String versionJsonPath = ConstantPath.jsonPath + ConstantPath.verJson; String productJsonPath = ConstantPath.jsonPath + ConstantPath.productJson; String orderJsonPath = ConstantPath.jsonPath + ConstantPath.orderJson; dropboxNemiro.downloadFileFromDropbox(); if (File.Exists(productJsonPath)) { List <Product> products = JsonHelper.loadProductsFromJson(File.ReadAllText(productJsonPath)); DBhelper.removeAllProduct(); //remove all db in local foreach (Product pro in products) //add new db from json { DBhelper.addProduct(pro); } } //if (File.Exists(orderJsonPath)) //{ // List<Order> orders = JsonHelper.loadOrdersFromJson(File.ReadAllText(orderJsonPath)); //foreach (Order ord in orders) //{ // DBhelper.updateProductByID(pro); //} //} //save version in local if (File.Exists(versionJsonPath)) { VersionUpload versionUpload = JsonHelper.loadVersionUploadFromJson(File.ReadAllText(versionJsonPath)); Properties.Settings.Default.FinalVersionUpload = Convert.ToString(versionUpload.time); } }
public OptionForm() { dropboxNemiro = new DropboxNemiro(null, this); this.CenterToScreen(); InitializeComponent(); cbSizePagePrint.SelectedIndex = 2; cbTimeSync.SelectedIndex = 0; }
public bool checkVersionWithDialog(DropboxNemiro dropboxNemiro, MainForm mainForm) { if (!checkVersionUpload(dropboxNemiro)) { DialogResult dr = MessageBox.Show("Dữ liệu trên máy đã cũ, bạn phải cập nhất trước khi thay đổi! \n Chọn Yes để cập nhật.", "Cập nhật", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { mainForm.SyncToDropboxNow(); return(true); } else if (dr == DialogResult.No) { return(false); } } return(true); }
public bool checkVersionUpload(DropboxNemiro dropboxNemiro) //true - new false - old { String versionPath = ConstantPath.jsonPath + ConstantPath.verJson; { dropboxNemiro.downloadFileVersionFromDropbox(); if (File.Exists(versionPath)) { double currentTime = TimeUtils.getCurrentTimeInMilisecond(); VersionUpload versionUpload = JsonHelper.loadVersionUploadFromJson(File.ReadAllText(versionPath)); if (versionUpload.time != Double.Parse(Properties.Settings.Default.FinalVersionUpload)) { return(false); } } } return(true); }