private void DeleteFacility(object obj)
 {
     if (MessageBox.Show("Are you Sure You want to Delete this Record?", "Pinna Fitness", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes)
     {
         try
         {
             SelectedFacility.Enabled = false;
             var stat = _facilityService.Disable(SelectedFacility);
             if (stat == string.Empty)
             {
                 Facilitys.Remove(SelectedFacility);
             }
             else
             {
                 MessageBox.Show("Can't Delete, may be the data is already in use..."
                                 + Environment.NewLine + stat, "Can't Delete",
                                 MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show("Can't Delete, may be the data is already in use..."
                             + Environment.NewLine + ex.Message + Environment.NewLine + ex.InnerException, "Can't Delete",
                             MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
 }
        private void SaveFacility(object obj)
        {
            try
            {
                var newObject = SelectedFacility.Id;
                SelectedFacility.Services = new List <FacilityServiceDTO>();
                foreach (var role in SelectedServices)
                {
                    SelectedFacility.Services.Add(new FacilityServiceDTO {
                        FacilityId = SelectedFacility.Id, Service = role
                    });
                }

                var stat = _facilityService.InsertOrUpdate(SelectedFacility);
                if (stat != string.Empty)
                {
                    MessageBox.Show("Can't save"
                                    + Environment.NewLine + stat, "Can't save", MessageBoxButton.OK,
                                    MessageBoxImage.Error);
                }

                else if (newObject == 0)
                {
                    Facilitys.Insert(0, SelectedFacility);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Can't save"
                                + Environment.NewLine + exception.Message, "Can't save", MessageBoxButton.OK,
                                MessageBoxImage.Error);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Обновление коллекции.
 /// </summary>
 private async void Initialization()
 {
     Facilitys.Clear();
     foreach (var item in await _facilityService.GetResultQuery())
     {
         Facilitys.Add(item);
     }
 }
Beispiel #4
0
        ///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
        //[EditorBrowsable(EditorBrowsableState.Never)]
        //protected override void InitData()
        //{
        //    base.InitData();

        //    // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
        //    // Meta.Count是快速取得表记录数
        //    if (Meta.Count > 0) return;

        //    // 需要注意的是,如果该方法调用了其它实体类的首次数据库操作,目标实体类的数据初始化将会在同一个线程完成
        //    if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}[{1}]数据……", typeof(FacilityType).Name, Meta.Table.DataTable.DisplayName);

        //    var entity = new FacilityType();
        //    entity.Serialnum = "abc";
        //    entity.CreateTime = DateTime.Now;
        //    entity.CreateSysUserSerialnum = "abc";
        //    entity.UpdateTime = DateTime.Now;
        //    entity.UpdateSysUserSerialnum = "abc";
        //    entity.Name = "abc";
        //    entity.ParentSerialnum = "abc";
        //    entity.IsSystem = true;
        //    entity.Css = "abc";
        //    entity.PhotoUrl = "abc";
        //    entity.Introduce = "abc";
        //    entity.Sort = 0;
        //    entity.Remark = "abc";
        //    entity.Insert();

        //    if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}[{1}]数据!", typeof(FacilityType).Name, Meta.Table.DataTable.DisplayName);
        //}

        /// <summary>已重载。删除关联数据</summary>
        /// <returns></returns>
        protected override int OnDelete()
        {
            if (Facilitys != null)
            {
                Facilitys.Delete();
            }

            return(base.OnDelete());
        }
Beispiel #5
0
 /// <summary>
 /// Отмена.
 /// </summary>
 private void Annulment()
 {
     try
     {
         Facilitys.Clear();
         Initialization();
         ItemFacility = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(
             $"Повторите попытку.\nДетали - {ex.Message}",
             "Ошибка",
             MessageBoxButton.OK,
             MessageBoxImage.Warning);
         return;
     }
 }
Beispiel #6
0
 /// <summary>
 /// Добавление нового обьекта.
 /// </summary>
 private void AddNewFacility()
 {
     try
     {
         var facility = new Facility();
         Facilitys.Add(facility);
         ItemFacility = facility;
     }
     catch (Exception ex)
     {
         MessageBox.Show(
             $"Во время дабавления произошла ошибка. Проверьте данные и повторите попытку.",
             "Ошибка",
             MessageBoxButton.OK,
             MessageBoxImage.Warning);
         return;
     }
 }
Beispiel #7
0
        /// <summary>
        /// Удаление обьекта.
        /// </summary>
        /// <returns></returns>
        private async Task Remove()
        {
            try
            {
                await _facilityService.Remove(ItemFacility.Id);

                Facilitys.Remove(ItemFacility);
                PopupCancel();
            }
            catch (Exception ex)
            {
                PopupCancel();
                MessageBox.Show(
                    $"Во время удаления произошла ошибка. Повторите попытку.\nДетали - {ex.Message}",
                    "Ошибка",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return;
            }
        }