예제 #1
0
 protected override void Refresh(object o)
 {
     Services.YuanXiServicesClient service = new Services.YuanXiServicesClient();
     string result = service.YuanXiQuery();
     DataList = JsonConvert.DeserializeObject<DataTable>(result);
     service.Close();
 }
예제 #2
0
 protected override void Delete(object model)
 {
     ModernDataGrid datagrid = model as ModernDataGrid;
     var selectList = datagrid.SelectedItems;
     if (selectList.Count == 0)
     {
         ModernDialog.ShowMessage("没有选择要删除的数据", "消息", MessageBoxButton.OK);
     }
     else
     {
         if (ModernDialog.ShowMessage("确定要删除选择的记录?", "消息", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
         {
             List<int> ids = new List<int>();
             foreach (DataRowView item in selectList)
             {
                 ids.Add(int.Parse(item.Row["ID"].ToString()));
             }
             Services.YuanXiServicesClient service = new Services.YuanXiServicesClient();
             service.YuanXiDelete(ids.ToArray(), new YuanXiModel());
             service.Close();
         }
     }
 }
예제 #3
0
        protected override void OnDgLeftMouseDoubleClick(object model)
        {
            DataGrid dg = model as DataGrid;
            if (dg == null) return;

            BorderVisibility = Visibility.Visible;
            var selectItem = dg.SelectedItem;
            if (selectItem != null)
            {
                int id = Convert.ToInt32(((DataRowView)selectItem).Row["ID"].ToString());
                Services.YuanXiServicesClient service = new Services.YuanXiServicesClient();
                YuanXi = service.GetYuanXiModelById(id);
            }
        }
예제 #4
0
 protected override void Save(object model)
 {
     if (_YuanXi != null)
     {
         if (string.IsNullOrEmpty(_YuanXi.Code))
         {
             ModernDialog.ShowMessage("院系代码不能为空", "消息", MessageBoxButton.OK);
             return;
         }
         if (string.IsNullOrEmpty(_YuanXi.Name))
         {
             ModernDialog.ShowMessage("院系名称不能为空", "消息", MessageBoxButton.OK);
             return;
         }
         if (_YuanXi.XiaoQuId == 0)
         {
             ModernDialog.ShowMessage("校区名称不能为空", "消息", MessageBoxButton.OK);
             return;
         }
         Services.YuanXiServicesClient service = new Services.YuanXiServicesClient();
         //_YuanXi.XiaoQuId = SelectedXiaoQu.Id;
         //新增
         if (_YuanXi.Id == 0)
         {
             string result= service.YuanXiAdd(_YuanXi);
             ResultEx ex = JsonConvert.DeserializeObject<ResultEx>(result);
             if (ex.Result)
             {
                 ModernDialog.ShowMessage("    新增成功  ", "消息", MessageBoxButton.OK);
                 BorderVisibility = Visibility.Collapsed;
             }
             else ModernDialog.ShowMessage(ex.Message, "消息", MessageBoxButton.OK);
         }
         //修改
         else
         {
             int i = service.YuanXiUpdate(_YuanXi);
             if (i > 0)
             {
                 ModernDialog.ShowMessage("    修改成功  ", "消息", MessageBoxButton.OK);
                 BorderVisibility = Visibility.Collapsed;
                 RefreshCommand.Execute(new object());
             }
             else
                 ModernDialog.ShowMessage("    修改失败  ", "消息", MessageBoxButton.OK);
         }
         RefreshCommand.Execute(new object());
         service.Close();
     }
 }