年度变更建库软件5.0版本
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

155 lines
5.7 KiB

using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Geodatabase;
using KGIS.Framework.AE;
using KGIS.Framework.AE.Enum;
using KGIS.Framework.Commands;
using KGIS.Framework.Maps;
using KGIS.Framework.Utils;
using KGIS.Framework.Utils.ExtensionMethod;
using KGIS.Framework.Utils.Helper;
using Kingo.Plugin.BGResultManager.View;
using Kingo.PluginServiceInterface;
using System;
using System.Runtime.InteropServices;
namespace kingo.Plugin.BGResultManager.Commands
{
public class BGNMKResultExportCommand : BaseMenuCommand
{
private IHookHelper m_hookHelper = null;
public override void OnCreate(object hook)
{
if (hook == null)
{
return;
}
try
{
if (m_hookHelper == null)
{
m_hookHelper = new HookHelperClass();
m_hookHelper.Hook = hook;
}
}
catch
{
m_hookHelper = null;
return;
}
}
public override void OnClick()
{
try
{
GetMJInfo();
if ((((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJ + (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJHD) * 0.0001).ToDecimal(2) <= 0)
{
MessageHelper.ShowTips("控制面积错误,故导出失败!");
return;
}
//if ((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ISHD)
//{
// if ((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJ2 <= 0 && (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJHD2 <= 0)
// {
// MessageHelper.ShowTips("错误的陆地控制面积或者海岛控制面积,故导出失败!");
// return;
// }
//}
FrmResultsExportForTheBGNMK frm = new FrmResultsExportForTheBGNMK();
frm.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
frm.ShowInMainWindow();
}
catch (Exception ex)
{
LogAPI.Debug("年末库导出失败" + ex.Message);
MessageHelper.ShowError("年末库导出失败,可能的原因是:" + ex.Message);
}
}
public void GetMJInfo()
{
double dDCMJ_LD = 0;
double dDCMJ_HD = 0;
decimal dLDKZMJ2 = 0;
decimal dHDKZMJ2 = 0;
ICursor pCur = null;
string connStr = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).GetProjFilePath();
IWorkspaceAPI s_WsAPI = null;
try
{
s_WsAPI = new WorkspaceAPI(connStr, WorkspaceTypeEnum.GDBFile);
//获取基础mdb中的tbmj之和
IQueryDef pQDef = (s_WsAPI.CurrentWorkspace as IFeatureWorkspace).CreateQueryDef();
pQDef.Tables = "jc_dltb";
pQDef.WhereClause = "mssm='00'";
pQDef.SubFields = "sum(TBMJ)";
pCur = pQDef.Evaluate();
IRow pRow = pCur.NextRow();
if (pRow != null)
{
dDCMJ_LD = pRow.get_Value(0).ToString().ToDouble(2);
}
Marshal.ReleaseComObject(pCur);
pQDef.Tables = "jc_dltb";
pQDef.WhereClause = "mssm='01'";
pQDef.SubFields = "sum(TBMJ)";
pCur = pQDef.Evaluate();
pRow = pCur.NextRow();
if (pRow != null)
{
dDCMJ_HD = pRow.get_Value(0).ToString().ToDouble(2);
}
dLDKZMJ2 = (decimal)dDCMJ_LD * (decimal)0.0001;
dLDKZMJ2 = Math.Round(dLDKZMJ2, 2, MidpointRounding.AwayFromZero);
dHDKZMJ2 = (decimal)dDCMJ_HD * (decimal)0.0001;
dHDKZMJ2 = Math.Round(dHDKZMJ2, 2, MidpointRounding.AwayFromZero);
(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJ = dDCMJ_LD;
(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).DCMJHD = dDCMJ_HD;
//(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ISHD = dDCMJ_HD > 0 ? true : false;
//(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).LDKZMJ2 = dLDKZMJ2;
//(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).HDKZMJ2 = dHDKZMJ2;
}
catch (Exception ex)
{
LogAPI.Debug("获取面积失败,异常原因: " + ex + " ; ");
}
finally
{
if (s_WsAPI != null)
{
s_WsAPI.CloseWorkspace();
}
if (pCur != null)
{
Marshal.ReleaseComObject(pCur);
}
}
}
public override bool Enabled
{
get
{
ProjectInfo pTemp = (MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo);
if (pTemp == null)
{
return false;
}
else
{
if (string.IsNullOrWhiteSpace(pTemp.GetProjFilePath()))
{
return false;
}
else
{
return true;
}
}
}
}
}
}