/// <summary> /// Sự kiện AfterEdit của GridPanel1, xảy ra khi người dùng thay đổi giá trị combobox trên Grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void AfterEdit_Event(object sender, DirectEventArgs e) { JsonObject data = JSON.Deserialize <JsonObject>(e.ExtraParams["record"]); foreach (StoreDaTa store in StoreList) { StoreDaTa _s = StoreList.Where(p => p.ColumnID == store.MasterColumnID).FirstOrDefault(); if (_s == null) { continue; } if (!string.IsNullOrEmpty(store.WhereFilter)) { store.WhereFilter = string.Format(store.WhereFilter, "N'" + data[_s.ColumnName] + "'"); } else { store.WhereFilter = "1=1"; } string sql = string.Format("select top 1 {0} from {1} where {2}", store.DisplayField, store.TableName, store.WhereFilter); DataTable Data = DataHandler.GetInstance().ExecuteDataTable(sql); if (Data.Rows.Count != 0) { this.Store1.UpdateRecordField(e.ExtraParams["id"], store.ColumnName, Data.Rows[0][store.DisplayField].ToString()); } } }
private void SearchStoreMethod() { if (!string.IsNullOrWhiteSpace(SearchStore)) { SearchStoreResultList = new ObservableCollection <StoresSet>(StoreList.Where(s => s.StoreName.ToLower().Contains(SearchStore.ToLower()) || s.StoreNumber.ToString().Contains(SearchStore))); } else { SearchStoreResultList.Clear(); } }
/// <summary> /// Store được sử dụng để fill data vào combobox trên grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void cbBoxStoreRefresh(object sender, StoreRefreshDataEventArgs e) { try { StoreDaTa storeData = StoreList.Where(p => p.Store.ID == ((Store)sender).ID).FirstOrDefault(); string query = e.Parameters["query"]; List <object> dataList = new List <object>(); if (string.IsNullOrEmpty(storeData.WhereFilter)) { storeData.WhereFilter = "1=1"; } else if (string.IsNullOrEmpty(query) == false ) //Note: Nếu muốn sử dụng query thì trong trường filter phải có đoạn text như FieldName like {0} { storeData.WhereFilter = string.Format(storeData.WhereFilter, "N'" + query + "'"); } string sql = string.Format("select {0},{1} from {2} where {3}", storeData.DisplayField, storeData.ValueField, storeData.TableName, storeData.WhereFilter); DataTable Data = DataHandler.GetInstance().ExecuteDataTable(sql); foreach (DataRow row in Data.Rows) { string _displayField = row[storeData.DisplayField].ToString(); string _valueField = row[storeData.ValueField].ToString(); dataList.Add(new { valueField = _valueField, displayField = _displayField }); } if (storeData.Store != null) { storeData.Store.DataSource = dataList; storeData.Store.DataBind(); } } catch { } }
public async Task DeleteStore(int id) { if (await JS.InvokeAsync <bool>("confirm", "Are you sure you want to mark this store as deleted?")) { if (await JS.InvokeAsync <bool>("exampleJsFunctions.deleteStoreDisplayNumber", StoreList.Where(x => x.Id == id).FirstOrDefault().StoreNumber)) { await StoreInformationDataService.MarkAsDeleted(id); } } //StateHasChanged(); NavigationManager.NavigateTo($"/storeinformation", forceLoad: true); }