private void btnAddFast_Click(object sender, EventArgs e) { try{ if (!string.IsNullOrWhiteSpace(txtStart.Text)) { DataStoreModel _reModel = new DataStoreModel(); List <DataStoreModel> getDataStoreModels = _listDic.GetRange(Convert.ToInt32(txtStart.Text), Convert.ToInt32(txtEnd.Text)); foreach (DataStoreModel dataStoreModel in getDataStoreModels) { dataStoreModel.Id = Unitils.RandomGUID(); dataStoreModel.Date = dateDate.Value.ToString("dd/MM/yyyy"); } _dataStoreEntity.AddByList(getDataStoreModels); GetAll(); myFlagChange(true); mainStatus.Text = (string)statusObj["AddSuccess"]; } else { mainStatus.Text = (string)statusObj["AddFaile"]; } } catch { mainStatus.Text = (string)statusObj["AddFaile"]; } }
private void Add() { try { if (txtJapanese.Text != "") { DataStoreModel _reModel = new DataStoreModel(); _reModel.Id = Unitils.RandomGUID(); _reModel.Japanese = txtJapanese.Text.Trim(); _reModel.Pronounce = txtPronounce.Text; _reModel.Mean = txtMean.Text; _reModel.Example = txtExample.Text; _reModel.Genre = txtRemember.Text; _reModel.Date = dateDate.Value.ToString("dd/MM/yyyy"); try { if (!String.IsNullOrEmpty(txtChooseImage.Text)) { if (!File.Exists(picImage.ImageLocation)) { System.IO.File.Copy(picImage.ImageLocation, Config.pictureFolder + imgTempUrl, true); } _reModel.Picture = imgTempUrl; } else { _reModel.Picture = ""; } } catch (Exception ex) { string abc = ex.ToString(); } _dataStoreEntity.Add(_reModel); GetAll(); myFlagChange(true); mainStatus.Text = (string)statusObj["AddSuccess"]; } else { mainStatus.Text = (string)statusObj["AddFaile"]; } } catch { mainStatus.Text = (string)statusObj["AddFaile"]; } }
private void btnAddLesson_Click(object sender, EventArgs e) { using (var webClient = new System.Net.WebClient()) { if (string.IsNullOrWhiteSpace(txtNumerLession.Text)) { return; } var json = webClient.DownloadString(string.Format("http://japaneseclub.jp//eBooks/MinnaNihongo/Lesson-{0}/Vocabulary/Vocabulary-vi.json", txtNumerLession.Text)); List <VocabularyModel> m = JsonConvert.DeserializeObject <List <VocabularyModel> >(json); foreach (var item in m) { try { DataStoreModel _reModel = new DataStoreModel(); _reModel.Id = Unitils.RandomGUID(); _reModel.Japanese = item.Hiragana; _reModel.Pronounce = item.Category; _reModel.Mean = item.Mean; _reModel.Genre = item.Category; _reModel.Date = dateDate.Value.ToString("dd/MM/yyyy"); if (!String.IsNullOrEmpty(txtChooseImage.Text)) { if (!File.Exists(picImage.ImageLocation)) { System.IO.File.Copy(picImage.ImageLocation, Config.pictureFolder + imgTempUrl, true); } _reModel.Picture = imgTempUrl; } else { _reModel.Picture = ""; } _dataStoreEntity.Add(_reModel); } catch (Exception ex) { string abc = ex.ToString(); } } GetAll(); myFlagChange(true); mainStatus.Text = (string)statusObj["AddSuccess"]; } }