示例#1
0
        protected void CancelEdit(T item)
        {
            Grid.CancelEditRow(item);
            int Id    = (int)ReflectionExten.GetPropValue(item, "Id");
            var value = dsource.FindIndex(x => (int)ReflectionExten.GetPropValue(x, "Id") == Id);

            dsource[value] = temp;
        }
示例#2
0
        protected virtual async void OnSubmit(T model)
        {
            try
            {
                loading.Visible = true;
                var result = await serv.InsertAsync <T>(model, ApiUrl);

                dsource.Insert(0, result);
                dataform = ReflectionExten.GetNewObject <T>();
                await ShowNotification(new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "Успешно", Detail = "Успешно Добавлено", Duration = 1500 });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await ShowNotification(new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "Ошибка", Detail = "Ошибка при получении", Duration = 2500 });
            }
            finally
            {
                loading.Visible = false;
                await Grid.Reload();
            }
        }
示例#3
0
        protected async void DeleteRow(T item)
        {
            try
            {
                loading.Visible = true;
                int Id = (int)ReflectionExten.GetPropValue(item, "Id");
                await DeleteData(Id);

                dsource.Remove(item);
                count = dsource.Count;
                await ShowNotification(new NotificationMessage { Severity = NotificationSeverity.Success, Summary = "Успешно", Detail = "Успешно Удалено", Duration = 1500 });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                await ShowNotification(new NotificationMessage { Severity = NotificationSeverity.Error, Summary = "Ошибка", Detail = string.IsNullOrEmpty(ErrorMessage) ? "Ошибка при получении" : ErrorMessage, Duration = 2500 });
            }
            finally
            {
                loading.Visible = false;
                await Grid.Reload();
            }
        }
示例#4
0
 protected async virtual Task UpdateData(T item)
 {
     int Id = (int)ReflectionExten.GetPropValue(item, "Id");
     await serv.UpdateAsync <T>(item, Id, ApiUrl);
 }
示例#5
0
 protected override void OnInitialized()
 {
     dataform = ReflectionExten.GetNewObject <T>();
 }