Esempio n. 1
0
        /// <summary>
        /// 模型数据改变
        /// </summary>
        /// <param name="obj"></param>
        private void dataChanged(EquipmentTypeModel equipmentTypeModel)
        {
            getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize);
            var tmpModel = EquipmentTypeInfoList.FirstOrDefault(a => a.Id == equipmentTypeModel.Id);

            this.EquipmentTypeInfo = EquipmentTypeInfoList.FirstOrDefault();
        }
        public static List <EquipmentTypeModel> GetEquipmentAgreementList()
        {
            var connectionString = ConfigurationManager.AppSettings["DbConnection"];
            var sqlString        = "SELECT * FROM sys_Equipment_Type ";

            SqlParameter[] sqlParams         = new SqlParameter[] {
                // new SqlParameter("@ClientIp", clientIp)
            };
            List <EquipmentTypeModel> list   = new List <EquipmentTypeModel>();
            SqlDataReader             reader = SqlHelper.ExecuteReader(connectionString, CommandType.Text, sqlString, sqlParams);

            while (reader.Read())
            {
                EquipmentTypeModel e = new EquipmentTypeModel
                {
                    TypeName    = reader.GetString(0),
                    ParentId    = reader.GetString(1),
                    EquipmentId = reader.GetString(2),
                    ModelNumber = reader.GetString(3),
                    Remark      = reader.GetString(4),
                    Id          = reader.GetString(5),
                };
                list.Add(e);
            }
            reader.Close();
            return(list);
        }
Esempio n. 3
0
        public async Task <ResultModel <EquipmentTypeOutputModel> > InsertEquipmentType([FromBody] EquipmentTypeInputModel item)
        {
            var equipmentTypeItem = new EquipmentTypeModel()
            {
                Name        = item.Name,
                Description = item.Description
            };

            return(await _equipmentTypeStoreService.InsertAndSaveAsync <EquipmentTypeOutputModel>(equipmentTypeItem));
        }
Esempio n. 4
0
        /// <summary>
        /// 执行导出命令
        /// </summary>
        private async void OnExecuteExportCommand()
        {
            var window       = (MetroWindow)Application.Current.MainWindow;
            var dialogResult = await window.ShowMessageAsync("数据导出"
                                                             , "确定要从磁盘中导出企业信息数据吗?"
                                                             , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
            {
                AffirmativeButtonText = "是", NegativeButtonText = "否"
            });

            if (dialogResult == MessageDialogResult.Affirmative)
            {
                string filePath = "";
                System.Windows.Forms.SaveFileDialog openFileDialog = new System.Windows.Forms.SaveFileDialog();
                openFileDialog.FileName = "设备类型信息" + DateTime.Now.ToString("yyyy-MM-dd_hh-mm-ss") + ".xls";
                if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)//注意,此处一定要手动引入System.Window.Forms空间,否则你如果使用默认的DialogResult会发现没有OK属性
                {
                    filePath = openFileDialog.FileName;
                }
                if (string.IsNullOrEmpty(filePath))
                {
                    await window.ShowMessageAsync("数据导出"
                                                  , "数据导出失败,选择存储路径为空!"
                                                  , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "确定"
                    });

                    return;
                }
                if (EquipmentTypeInfoList.Any())
                {
                    try
                    {
                        EquipmentTypeModel model           = new EquipmentTypeModel();
                        List <string>      displayNameList = model.GetDisplayName();
                        DataTable          dataTable       = EquipmentTypeInfoList.ToDataTable <EquipmentTypeModel>(displayNameList);
                        NPOIHelper.Export(dataTable, "企业信息", filePath);
                    }
                    catch (Exception ex)
                    {
                        await window.ShowMessageAsync("数据导出"
                                                      , "数据导出失败!"
                                                      , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                        {
                            AffirmativeButtonText = "确定"
                        });
                    }

                    if (File.Exists(filePath))
                    {
                        await window.ShowMessageAsync("数据导出"
                                                      , "数据导出已完成!"
                                                      , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                        {
                            AffirmativeButtonText = "确定"
                        });
                    }
                    else
                    {
                        await window.ShowMessageAsync("数据导出"
                                                      , "数据导出失败!"
                                                      , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                        {
                            AffirmativeButtonText = "确定"
                        });
                    }
                }
                else
                {
                    await window.ShowMessageAsync("数据导出"
                                                  , "数据导出失败,无数据!"
                                                  , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "确定"
                    });
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 执行导入命令
        /// </summary>
        private async void OnExecuteImportCommand()
        {
            var window       = (MetroWindow)System.Windows.Application.Current.MainWindow;
            var dialogResult = await window.ShowMessageAsync("数据导入"
                                                             , "确定要导入企业信息数据到磁盘中吗?将会删除磁盘中原有数据"
                                                             , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
            {
                AffirmativeButtonText = "是", NegativeButtonText = "否"
            });

            if (dialogResult == MessageDialogResult.Affirmative)
            {
                string         filePath       = "";
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == DialogResult.OK)//注意,此处一定要手动引入System.Window.Forms空间,否则你如果使用默认的DialogResult会发现没有OK属性
                {
                    filePath = openFileDialog.FileName;
                }
                if (string.IsNullOrEmpty(filePath))
                {
                    UiMessage = "数据导入失败,选择存储路径为空!";
                    return;
                }
                if (EquipmentTypeInfoList.Any())
                {
                    try
                    {
                        EquipmentTypeModel        model       = new EquipmentTypeModel();
                        Dictionary <String, Type> filedNameDc = model.GetFiledNameAndType();
                        DataTable dt    = NPOIHelper.Import(filePath);
                        DataTable dtNew = new DataTable();
                        foreach (var kvp in filedNameDc)
                        {
                            dtNew.Columns.Add(kvp.Key, kvp.Value);
                        }
                        object[] values = new object[filedNameDc.Count];
                        foreach (DataRow row in dt.Rows)
                        {
                            for (int i = 0; i < dtNew.Columns.Count; i++)
                            {
                                values[i] = row[i];
                            }
                            dtNew.Rows.Add(values);
                        }
                        List <EquipmentTypeModel> enterpriseModels = dtNew.DataTableToList <EquipmentTypeModel>();
                        getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize);
                        var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult>(GlobalData.ServerRootUri + "EquipmentTypeInfo/Remove", Utility.JsonHelper.ToJson(EquipmentTypeInfoList.Select(x => x.Id).ToList()));
                        if (!Equals(result, null) && result.Successed)
                        {
                            var addResult = Utility.Http.HttpClientHelper.PostResponse <OperationResult>(GlobalData.ServerRootUri + "EquipmentTypeInfo/Add", Utility.JsonHelper.ToJson(enterpriseModels));
                            await window.ShowMessageAsync("数据导入"
                                                          , "数据导入已完成!"
                                                          , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                            {
                                AffirmativeButtonText = "确定"
                            });

                            getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize);
                            EquipmentTypeInfo = null;
                        }
                        else
                        {
                            //操作失败,显示错误信息
                            UiMessage = "数据删除失败,请联系管理员!";
                        }
                    }
                    catch (Exception ex)
                    {
                        await window.ShowMessageAsync("数据导入"
                                                      , "数据导入失败!"
                                                      , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                        {
                            AffirmativeButtonText = "确定"
                        });
                    }

                    //if (File.Exists(filePath))
                    //{
                    //    await window.ShowMessageAsync("数据导入"
                    //        , "数据导入已完成!"
                    //        , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { AffirmativeButtonText = "确定" });
                    //}
                    //else
                    //{
                    //    await window.ShowMessageAsync("数据导入"
                    //            , "数据导入失败!"
                    //            , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings() { AffirmativeButtonText = "确定" });
                    //}
                }
                else
                {
                    await window.ShowMessageAsync("数据导入"
                                                  , "数据导入失败,无数据!"
                                                  , MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "确定"
                    });
                }
            }
        }