public void AddNewItem(LawDictionaryModel lawDictionaryModel) { ShowAjax(); LawDictionaryModels.Add(lawDictionaryModel); writeData(); CloseAjax(); }
private void simpleButtonDelete_Click(object sender, EventArgs e) { if (SelectedModel == null) { return; } var isDelete = true; //kZFlyoutDialog.AlertDelete(this, //"តើអ្នកពិតជាចង់លុបឯកសារលេខ \"" + SelectedModel.Code + "\" ដែរឺទេ?"); if (isDelete) { ShowAjax(); var file = dir + "Files\\" + SelectedModel.ID; LawDictionaryModels.Remove(SelectedModel); if (File.Exists(file)) { File.Delete(file); } writeData(); CloseAjax(); } }
private void writeData() { try { //foreach (var lawDictionaryModel in LawDictionaryModels) //{ // lawDictionaryModel.ID = Guid.NewGuid(); // if (File.Exists(dir + "Files\\" + lawDictionaryModel.Code)) // { // File.Move(dir + "Files\\" + lawDictionaryModel.Code, dir + "Files\\" + lawDictionaryModel.ID); // } //} if (LawDictionaryModels.Count() < _limitRecord) { BinaryFileHelper.WriteToBinaryFile(dir + "MyLDData.dll", LawDictionaryModels); } else { kZFlyoutDialog.AlertMessage(this, "ការប្រើប្រាស់លើសចំនួនកំនត់សំរាប់ការសាកល្បង។"); } } finally { GetData(); } }
private void Search() { var code = textEditCode.Text ?? ""; var doc = textEditDoc.Text ?? ""; BindSource = new BindingList <LawDictionaryModel>(LawDictionaryModels.Where(s => (string.IsNullOrEmpty(code) || s.Code.ToLower().Contains(code.ToLower())) && (string.IsNullOrEmpty(doc) || s.Document.ToLower().Contains(doc.ToLower())) && (comboBoxEditType.Text == null || comboBoxEditType.Text == AllString || comboBoxEditType.Text == s.Type) && (comboBoxEditYear.Text == null || comboBoxEditYear.Text == AllString || comboBoxEditYear.Text == s.Year) && (comboBoxEditNGO.Text == null || comboBoxEditNGO.Text == AllString || comboBoxEditNGO.Text == s.NGO) ).ToList()); BindGrid(); }
private void AddUpdateLD_Load(object sender, EventArgs e) { layoutControlGroupLD.Text = IsUpdate ? "កែប្រែឯកសារ" : "បញ្ចូលឯកសារ"; if (!IsUpdate) { LawDictionaryModel = new LawDictionaryModel(); } Types = new BindingList <string>( LawDictionaryModels.OrderBy(s => s.OrderType).Select(s => s.Type).Distinct().ToList()); Years = new BindingList <string>( LawDictionaryModels.OrderByDescending(s => s.Year).Select(s => s.Year).Distinct().ToList()); NGOs = new BindingList <string>(LawDictionaryModels.OrderBy(s => s.NGO).Select(s => s.NGO).Distinct().ToList()); BindType(); BindYear(); BindNGO(); if (LawDictionaryModel != null) { textEditName.EditValue = LawDictionaryModel.Document; textEditNo.EditValue = LawDictionaryModel.Code; comboBoxEditType.Text = LawDictionaryModel.Type; comboBoxEditYear.Text = LawDictionaryModel.Year; comboBoxEditNGO.Text = LawDictionaryModel.NGO; if (IsUpdate && File.Exists(dir + "Files\\" + LawDictionaryModel.ID)) { OldFile = textEditDocLocation.Text = dir + "Files\\" + LawDictionaryModel.ID; textEditDocLocation.Text = OldFile; } } }