违法占耕辅助处理软件
1、功能界面
1.1登录界面
1.2主界面
1.2.1功能选项
1.2.2系统设置
1.3属性质量检查
1.3.1检查项设置
1.4属性对等计算
1.4转换后属性质量检查
1.5 多媒体处理
主界面源码:
public partial class MainForm : DevExpress.XtraEditors.XtraForm
{
/// <summary>
/// 委托实现皮肤切换
/// </summary>
public MyDelegateGetSkin getSkinDel;
/// 用于存储所有要素-属性计算
/// </summary>
private List<IFeatureLayer> listFLayerCalcu = null;
/// <summary>
/// 用于存储所有要素-转换前检查
/// </summary>
private List<IFeatureLayer> listFLayerZHQ_Check = null;
/// <summary>
/// 用于存储所有要素-转换后检查
/// </summary>
private List<IFeatureLayer> listFLayerZHH_Check = null;
private void tsBTN_openGDB_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
listFLayerCalcu = new List<IFeatureLayer>();
cmbxFeatureCls.Items.Clear();//清空
culFeatLayer = null;//
//cmbxFeatureCls.SelectedIndex = -1;
//cmbxMB.SelectedIndex = -1;
string strGDB_Path = mfbd.DirectoryPath;
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
axMapControl1.Map.ClearLayers();
tslbStatus.Text = "正在加载要素...";
statusStrip1.Refresh();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
listFLayerCalcu.Add(tempLayer);
cmbxFeatureCls.Items.Add(temp.AliasName);
axMapControl1.Map.AddLayer(tempLayer);
pDs = pEnumDs.Next();
}
tslbStatus.Text = "加载完成!";
tlSpStLb.Text = " 选项:属性对等计算 当前数据库:" + strGDB_Path;
statusStrip1.Refresh();
}
}
/// <summary>
/// 当前选择的待计算数据
/// </summary>
private IFeatureLayer culFeatLayer = null;
/// <summary>
/// 选择待计算的数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbxFeatureCls_SelectedIndexChanged(object sender, EventArgs e)
{
culFeatLayer= listFLayerCalcu[cmbxFeatureCls.SelectedIndex];
}
private string strSelMB = String.Empty;
/// <summary>
/// 选择数据计算模板
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbxMB_SelectedIndexChanged(object sender, EventArgs e)
{
if (culFeatLayer==null)
{
MessageBox.Show("请先选择图层");
return;
}
strSelMB = cmbxMB.SelectedItem.ToString();
}
/// <summary>
/// 执行计算
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tsBTN_ExcuteCacl_Click(object sender, EventArgs e)
{
if (culFeatLayer==null)
{
MessageBox.Show("没有数据可计算!请先打开或选择数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (cmbxMB.SelectedIndex == -1)
{
MessageBox.Show("请选择模板类型", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
DateTime dtStart = DateTime.Now;
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("正在计算 "+ strSelMB);
splashScreenManager1.SetWaitFormDescription("请耐心等待...");
/*
住宅类
产业类
公共服务类
其他构筑物
*/
if (strSelMB == "住宅类")
{
string selSQL = String.Empty;
//计算---直接等于
selSQL = null;
IFeatureLayer tempFeatLayer = culFeatLayer;
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
#region
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "CITY_NAME");
CaculValue2(tempFeatLayer, selSQL, "CITY_NAME", "shi");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_XQ");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_XQ", "xian");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_XZ");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_XZ", "xiang");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_CUN");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_CUN", "cun");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XXDZ_Z");
CaculValue2(tempFeatLayer, selSQL, "XXDZ_Z", "zu");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XXDZ_MPH");
CaculValue2(tempFeatLayer, selSQL, "XXDZ_MPH", "mph");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_KGSJ");
CaculValue2(tempFeatLayer, selSQL, "JBXX_KGSJ", "kgsj");
//超过本地区宅基地标准面积 cggdmj GLXX_CCBZMJ
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_CCBZMJ");
CaculValue3(tempFeatLayer, selSQL, "GLXX_CCBZMJ", "cggdmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "glxx_zygdmj");
CaculValue3(tempFeatLayer, selSQL, "glxx_zygdmj", "zygdmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "glxx_zyyjjbntmj");
CaculValue3(tempFeatLayer, selSQL, "glxx_zyyjjbntmj", "zyjbntmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "BZ");
CaculValue2(tempFeatLayer, selSQL, "BZ", "cjybz");
selSQL = "XXDZ_Z is null or XXDZ_Z=''";
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算2 " + "XXDZ_Z");
CaculValue2(tempFeatLayer, selSQL, "XXDZ_Z", "无");
try
{
//单用户住宅---个人姓名 grxm JBXX_JSZT_GRXM
selSQL = ""fwlx"='" + "单户住宅" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZT_GRXM");
CaculValue2(tempFeatLayer, selSQL, "JBXX_JSZT_GRXM", "grxm");
}catch{ }
try
{
//单用户住宅---身份证 sfzh JBXX_JSZT_ZJHM
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZT_ZJHM");
selSQL = ""fwlx"='" + "单户住宅" + "'";
CaculValue2(tempFeatLayer, selSQL, "JBXX_JSZT_ZJHM", "sfzh");
}catch{}
try
{
//多用户住宅---计算项目名称 xmmc JBXX_XMMC
selSQL = ""fwlx"='" + "多户住宅" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_XMMC");
CaculValue2(tempFeatLayer, selSQL, "JBXX_XMMC", "xmmc");
} catch { }
//房屋类型 fwlx JBXX_FWLX
//1 - 单户住宅
//2 - 多户住宅
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_FWLX");
selSQL = ""fwlx"='" + "单户住宅" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWLX", 1);
selSQL = ""fwlx"='" + "多户住宅" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWLX", 2);
//个人身份 grsf JBXX_JSZT_GRSF
//1:干部
//2:中共党员
//3:群众
selSQL = ""grsf"='" + "干部" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZT_GRSF");
CaculValue(tempFeatLayer, selSQL, "JBXX_JSZT_GRSF", 1);
selSQL = ""grsf" like '%" + "中共党员" + "%'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_JSZT_GRSF", 2);
selSQL = ""grsf"='" + "群众" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_JSZT_GRSF", 3);
//是否本村村民 sfbccm JBXX_JSZT_SFBCCM
//1:本村村民
//2:外村村民
//3:城镇居民
//4:其他
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZT_SFBCCM");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listSFBCCM)
{
selSQL = ""sfbccm"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_JSZT_SFBCCM", keyValuePair.Value);
}
//多户填报---建设单位名称 jsdwmc JBXX_JSZT_DWMC
selSQL = ""fwlx"='" + "多户住宅" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZT_DWMC");
CaculValue2(tempFeatLayer, selSQL, "JBXX_JSZT_DWMC", "jsdwmc");
//土地主要来源 tdzyly JBXX_TDZYLY
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_TDZYLY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listJBXX_TDZYLY)
{
if (keyValuePair.Key== "集体自营土地")
{
selSQL = ""tdzyly" like '集体自营%'";
}
else
{
selSQL = ""tdzyly"='" + keyValuePair.Key + "'";
}
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_TDZYLY", keyValuePair.Value);
}
//
////将老宅基地继承 计算为 其他8
//
selSQL = "tdzyly='老宅基地继承'";
CaculValue(tempFeatLayer, selSQL, "JBXX_TDZYLY", 8);
//建房原因 jfyy JBXX_JFYY
//1:分户
//2:移民搬迁
//3:异地扶贫搬迁
//4:地质灾害搬迁
//5:生态整治搬迁
//6:拆迁安置
//7:其他
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JFYY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listJFYY)
{
selSQL = ""jfyy"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_JFYY", keyValuePair.Value);
}
//房屋是否出售 fwsfcs JBXX_FWSFCS
//0-否1-部分2-全部
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_FWSFCS");
selSQL = ""fwsfcs"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWSFCS", 0);
selSQL = ""fwsfcs"='" + "部分" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWSFCS", 1);
selSQL = ""fwsfcs"='" + "全部" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWSFCS", 2);
//管理信息_项目总占用土地面积 GLXX_ZYDMJ=房屋(项目)占地面积 fwzdmj +附属设施面积 fsssmj
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_ZYDMJ");
CaculValue4(culFeatLayer, "GLXX_ZYDMJ", "fwzdmj", "fsssmj");
//是否符合一户一宅 sffhyhyz GLXX_SFFH_YHYZHFH
//单户住宅特有:0-否1-是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SFFH_YHYZHFH");
selSQL = ""sffhyhyz"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_YHYZHFH", 0);
selSQL = ""sffhyhyz"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_YHYZHFH", 1);
//一户多宅原因 yhdzyy GLXX_YHDZYY
//1:不符合分户条件
//2:继承
//3:建新未拆旧
//4:赠予
//5:出售后再建
//6:购买
//7:纯多占
//8:其他
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_YHDZYY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listYHDZYY)
{
selSQL = ""yhdzyy"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YHDZYY", keyValuePair.Value);
}
//用地手续情况 ydsxqk GLXX_YDSXQK
//0 - 无手续
//1 - 手续不全
//2 - 有手续但不合规
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_YDSXQK");
selSQL = ""ydsxqk"='" + "无手续" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 1);
selSQL = ""ydsxqk"='" + "手续不全" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 2);
selSQL = ""ydsxqk"='" + "有手续但不合规" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 3);
//没有合法合规用地手续主要原因 wydspyy GLXX_MYSXYY
//1:未申请办理用地手续
//2:停批
//3:不符合申请条件
//4:不符合规划
//5:无用地计划指标
//6:未缴费
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_MYSXYY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listMYSXYY)
{
selSQL = ""wydspyy"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_MYSXYY", keyValuePair.Value);
}
//占用耕地主要类型 zygdzylx GLXX_ZYGDLX
//zygdzylx01
//zygdzylx02
//zygdzylx03
//zygdzylx04
//zygdzylx05
//zygdzylx06
//zygdzylx07
//zygdzylx08
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_ZYGDLX");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listGLXX_ZYGDLX)
{
selSQL = ""zygdzylx"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_ZYGDLX", keyValuePair.Value);
}
//是否符合城乡(村庄)规划 sffhcxgh GLXX_SFFH_CXGH
//1:未编制规划
//2:符合
//3:部分符合
//4:不符合
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SFFH_CXGH");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listSFFH_CXGH)
{
selSQL = ""sffhcxgh"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_CXGH", keyValuePair.Value);
}
//是否符合土地利用总体规划(国土空间规划)情况 sffhtdly GLXX_SFFH_TDLYGH
//0 - 符合
//1 - 部分符合
//2 - 不符合
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SFFH_TDLYGH");
selSQL = ""sffhtdly"='" + "符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 2);
selSQL = ""sffhtdly"='" + "部分符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 1);
selSQL = ""sffhtdly"='" + "不符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 0);
//是否作出行政处罚 sfxzcf GLXX_SF_XZCF
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_XZCF");
selSQL = ""sfxzcf"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_XZCF", 0);
selSQL = ""sfxzcf"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_XZCF", 1);
//是否申请法院强制执行 sfqzzx GLXX_SF_SQFYQZZX
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_SQFYQZZX");
selSQL = ""sfqzzx"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_SQFYQZZX", 0);
selSQL = ""sfqzzx"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_SQFYQZZX", 1);
//法院是否受理 fysfsl GLXX_SF_FYSL
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_FYSL");
selSQL = ""fysfsl"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_FYSL", 0);
selSQL = ""fysfsl"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_FYSL", 1);
#endregion
}
//
//产业类 公共服务类
//
if (strSelMB == "产业类" || strSelMB == "公共服务类")
{
#region
string selSQL = String.Empty;
//计算---直接等于
selSQL = null;
IFeatureLayer tempFeatLayer = culFeatLayer;
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "CITY_NAME");
CaculValue2(tempFeatLayer, selSQL, "CITY_NAME", "shi");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_XQ");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_XQ", "xian");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_XZ");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_XZ", "xiang");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XZQMC_CUN");
CaculValue2(tempFeatLayer, selSQL, "XZQMC_CUN", "cun");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XXDZ_Z");
CaculValue2(tempFeatLayer, selSQL, "XXDZ_Z", "zu");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "XXDZ_MPH");
CaculValue2(tempFeatLayer, selSQL, "XXDZ_MPH", "mph");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_XMMC");
CaculValue2(tempFeatLayer, selSQL, "JBXX_XMMC", "xmmc");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZTMC");
CaculValue2(tempFeatLayer, selSQL, "JBXX_JSZTMC", "jsztmc");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_KGSJ");
CaculValue2(tempFeatLayer, selSQL, "JBXX_KGSJ", "kgsj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "glxx_zydmj");
CaculValue3(tempFeatLayer, selSQL, "glxx_zydmj", "fwzdmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "glxx_zygdmj");
CaculValue3(tempFeatLayer, selSQL, "glxx_zygdmj", "zygdmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "glxx_zyyjjbntmj");
CaculValue3(tempFeatLayer, selSQL, "glxx_zyyjjbntmj", "zyjbntmj");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "BZ");
CaculValue2(tempFeatLayer, selSQL, "BZ", "cjybz");
//房屋主要用途 fwzyyt JBXX_FWYT
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_FWYT");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listJBXX_FWYT)
{
selSQL = ""fwzyyt"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_FWYT", keyValuePair.Value);
}
//建设主体性质 jsztxz JBXX_JSZTXZ
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_JSZTXZ");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listJBXX_JSZTXZ)
{
selSQL = ""jsztxz"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_JSZTXZ", keyValuePair.Value);
}
//土地主要来源 tdzyly JBXX_TDZYLY
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_TDZYLY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listJBXX_TDZYLY)
{
selSQL = ""tdzyly"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_TDZYLY", keyValuePair.Value);
}
//是否扶贫项目 sffp JBXX_SF_FPXM
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_SF_FPXM");
selSQL = ""sffp"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SF_FPXM", 0);
selSQL = ""sffp"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SF_FPXM", 1);
//是否上级部门有明确要求 sfsjmqyq JBXX_SF_SJBMYQ
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_SF_SJBMYQ");
selSQL = ""sfsjmqyq"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SF_SJBMYQ", 0);
selSQL = ""sfsjmqyq"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SF_SJBMYQ", 1);
//
//JBXX_BMMC
//
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_BMMC");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listBMMCY)
{
selSQL = ""bmmc"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_BMMC", keyValuePair.Value);
}
//与本村农产品生产、加工销售等是否直接相关--- 产业类特有 ybcncp JBXX_SFZJXG_NCP
//0 - 否
//1 - 是
if (strSelMB == "产业类")
{
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_SFZJXG_NCP");
selSQL = ""ybcncp"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SFZJXG_NCP", 0);
selSQL = ""ybcncp"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_SFZJXG_NCP", 1);
}
//利用情况 lyqk JBXX_LYQK--------公共服务类特有
//1:闲置
//2:很少使用
//3:经常使用
if (strSelMB == "公共服务类")
{
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "JBXX_LYQK");
selSQL = ""lyqk"='" + "闲置" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_LYQK", 1);
selSQL = ""lyqk"='" + "很少使用" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_LYQK", 2);
selSQL = ""lyqk"='" + "经常使用" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "JBXX_LYQK", 3);
}
//----------------------------管理信息--------------------------------------------------
//占用耕地主要类型 zygdzylx GLXX_ZYGDLX
//zygdzylx01
//zygdzylx02
//zygdzylx03
//zygdzylx04
//zygdzylx05
//zygdzylx06
//zygdzylx07
//zygdzylx08
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_ZYGDLX");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listGLXX_ZYGDLX)
{
selSQL = ""zygdzylx"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_ZYGDLX", keyValuePair.Value);
}
//是否符合城乡(村庄)规划 sffhcxgh GLXX_SFFH_CXGH
//1:未编制规划
//2:符合
//3:部分符合
//4:不符合
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SFFH_CXGH");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listSFFH_CXGH)
{
selSQL = ""sffhcxgh"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_CXGH", keyValuePair.Value);
}
//是否符合土地利用总体规划(国土空间规划)情况 sffhtdly GLXX_SFFH_TDLYGH
//0 - 符合
//1 - 部分符合
//2 - 不符合
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SFFH_TDLYGH");
selSQL = ""sffhtdly"='" + "符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 0);
selSQL = ""sffhtdly"='" + "部分符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 1);
selSQL = ""sffhtdly"='" + "不符合" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SFFH_TDLYGH", 2);
//用地手续情况 ydsxqk GLXX_YDSXQK
//1 - 无手续
//2 - 手续不全
//3 - 有手续但不合规
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_YDSXQK");
selSQL = ""ydsxqk"='" + "无手续" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 1);
selSQL = ""ydsxqk"='" + "手续不全" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 2);
selSQL = ""ydsxqk"='" + "有手续但不合规" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_YDSXQK", 3);
//没有合法合规用地手续主要原因 wydspyy GLXX_MYSXYY
//1:未申请办理用地手续
//2:停批
//3:不符合申请条件
//4:不符合规划
//5:无用地计划指标
//6:未缴费
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_MYSXYY");
foreach (KeyValuePair<string, int> keyValuePair in ModelDataCls.listMYSXYY)
{
selSQL = ""wydspyy"='" + keyValuePair.Key + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_MYSXYY", keyValuePair.Value);
}
//是否作出行政处罚 sfxzcf GLXX_SF_XZCF
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_XZCF");
selSQL = ""sfxzcf"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_XZCF", 0);
selSQL = ""sfxzcf"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_XZCF", 1);
//是否申请法院强制执行 sfqzzx GLXX_SF_SQFYQZZX
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_SQFYQZZX");
selSQL = ""sfqzzx"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_SQFYQZZX", 0);
selSQL = ""sfqzzx"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_SQFYQZZX", 1);
//法院是否受理 fysfsl GLXX_SF_FYSL
//0 - 否
//1 - 是
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "GLXX_SF_FYSL");
selSQL = ""fysfsl"='" + "否" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_FYSL", 0);
selSQL = ""fysfsl"='" + "是" + "'";
//tempFeatLayer = SelectFeatureLyByAttribute(culFeatLayer, selSQL);
CaculValue(tempFeatLayer, selSQL, "GLXX_SF_FYSL", 1);
#endregion
}
splashScreenManager1.SetWaitFormCaption("正在计算 " + strSelMB + " 根据名称计算代码");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "city"); //city_name
CaculValueGetCodeByNameShi(culFeatLayer, null, "city_name", "city");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "xzqdm_xq");
CaculValueGetCodeByNameQuXian(culFeatLayer, null, "xzqmc_xq", "xzqdm_xq");
//计算乡镇代码
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "xzqdm_xz");
CaculValueGetCodeByNameXiang(culFeatLayer, null, "xzqmc_xz", "xzqdm_xz");
splashScreenManager1.SetWaitFormCaption("正在计算" + strSelMB);
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "province_name"); //city_name
CaculValue(culFeatLayer, null, "province_name", "贵州省");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "province"); //city_name
CaculValue(culFeatLayer, null, "province", "520000");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "collect_type"); //collect_type
//计算collect_type
string strFeatureLys = culFeatLayer.FeatureClass.AliasName;
if (strFeatureLys.Contains("住宅类"))
{
CaculValue(culFeatLayer, null, "collect_type", "Z");
}else if (strFeatureLys.Contains("产业类"))
{
CaculValue(culFeatLayer, null, "collect_type", "C");
}else if (strFeatureLys.Contains("公共服务类"))
{
CaculValue(culFeatLayer, null, "collect_type", "G");
}
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "id"); //collect_type
CaculValue2(culFeatLayer, null, "id", "fwbh");
DateTime dtEnd = DateTime.Now;
TimeSpan dtDiff = dateDiff(dtStart, dtEnd);
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
MessageBox.Show("计算完成! 耗时("+ dtDiff + ")", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
//MessageBox.Show("检查完成! 检查结果存放在矢量数据的CheckResult字段里", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 属性数据预览
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ts_BTNAttribute_Click(object sender, EventArgs e)
{
if (culFeatLayer == null)
{
MessageBox.Show("请先打开或选择数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
//FormAttribute formAttribute = new FormAttribute(culFeatLayer);
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("正在执行 打开属性表");
splashScreenManager1.SetWaitFormDescription("请耐心等待...数据加载中");
FormAttribute formAttribute = FormAttribute.getFormFunc(culFeatLayer);
splashScreenManager1.CloseWaitForm();
formAttribute.Text = "违法占耕辅助处理软件-" +culFeatLayer.FeatureClass.AliasName+"-属性预览";
formAttribute.Show();
}
/// <summary>
/// 获取时间差
/// </summary>
/// <param name="dtStart"></param>
/// <param name="dtEnd"></param>
/// <returns></returns>
private TimeSpan dateDiff(DateTime dtStart,DateTime dtEnd)
{
TimeSpan tsStart = new TimeSpan(dtStart.Ticks);
TimeSpan tsEnd = new TimeSpan(dtEnd.Ticks);
TimeSpan ts = tsEnd.Subtract(tsStart).Duration();
//int dateDiffSecond = ts.Days * 24 * 60 * 60 + ts.Hours * 60 * 60 + ts.Minutes * 60 + ts.Seconds;
return ts;
}
/// <summary>
/// 根据属性选择要素
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="selSQL"></param>
/// <returns></returns>
private IFeatureLayer SelectFeatureLyByAttribute(IFeatureLayer culFeatLayer, string selSQL)
{
// ISSUE: variable of a compiler-generated type
IFeatureSelection featureSelection = culFeatLayer as IFeatureSelection;
// ISSUE: variable of a compiler-generated type
IQueryFilter Filter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
Filter.WhereClause = selSQL;
// ISSUE: reference to a compiler-generated method
featureSelection.SelectFeatures(Filter, esriSelectionResultEnum.esriSelectionResultNew, false);
// ISSUE: variable of a compiler-generated type
IFeatureLayer featureLayer = culFeatLayer;
return featureLayer;
}
/// <summary>
/// 属性计算--赋值int
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="FieldName"></param>
/// <param name="value"></param>
private void CaculValue(IFeatureLayer culFeatLayer, string strSQL, string FieldName, int myvalue)
{
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
pQueryFilter.SubFields = FieldName;
int field = culFeatLayer.FeatureClass.FindField(FieldName);
ITable table = culFeatLayer.FeatureClass as ITable;
IRowBuffer pBuffer = table.CreateRowBuffer();
pBuffer.Value[field] = myvalue;
table.UpdateSearchedRows(pQueryFilter, pBuffer);
Marshal.ReleaseComObject(pQueryFilter);
}
private void CaculValueGetCodeByNameXiang(IFeatureLayer culFeatLayer, string strSQL, string strNameField,string strCodeField)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int field = Row.Fields.FindField(strNameField);
int field2 = Row.Fields.FindField(strCodeField);
int fieldXQ= Row.Fields.FindField("xzqmc_xq");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
string calValue = Row.Value[field].ToString();
string culXQName = Row.Value[fieldXQ].ToString();
string strdbSQL = "select 乡镇代码 from 乡镇代码名称 where 乡镇名称='"+ calValue + "' and 县区名称='"+ culXQName + "'";
object tempcode= SQliteHelperCls.ExecuteScalar(strdbSQL, Connstr);
Row.Value[field2] = tempcode.ToString();
cursor.UpdateRow(Row);
Console.WriteLine(i);
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
tlSProgressBar.Value =0;
}
private void CaculValueGetCodeByNameQuXian(IFeatureLayer culFeatLayer, string strSQL, string strNameField, string strCodeField)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int field = Row.Fields.FindField(strNameField);
int field2 = Row.Fields.FindField(strCodeField);
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
string calValue = Row.Value[field].ToString();
string strdbSQL = "select 县区代码 from 县区代码名称 where 县区名称='"+ calValue+"'";
object tempcode = SQliteHelperCls.ExecuteScalar(strdbSQL, Connstr);
Row.Value[field2] = tempcode.ToString();
cursor.UpdateRow(Row);
Console.WriteLine(i);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
private void CaculValueGetCodeByNameShi(IFeatureLayer culFeatLayer, string strSQL, string strNameField, string strCodeField)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int field = Row.Fields.FindField(strNameField);
int field2 = Row.Fields.FindField(strCodeField);
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
string calValue = Row.Value[field].ToString();
string strdbSQL = "select 市州代码 from 市州代码名称 where 市州名称= '"+ calValue+"'";
object tempcode = SQliteHelperCls.ExecuteScalar(strdbSQL, Connstr);
Row.Value[field2] = tempcode.ToString()+"00";
cursor.UpdateRow(Row);
Console.WriteLine(i);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// 属性计算--赋值object
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="FieldName"></param>
/// <param name="value"></param>
private void CaculValue(IFeatureLayer culFeatLayer, string strSQL, string FieldName, object myvalue)
{
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
pQueryFilter.SubFields = FieldName;
int field = culFeatLayer.FeatureClass.FindField(FieldName);
ITable table = culFeatLayer.FeatureClass as ITable;
IRowBuffer pBuffer = table.CreateRowBuffer();
pBuffer.Value[field] = myvalue;
table.UpdateSearchedRows(pQueryFilter, pBuffer);
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// 属性计算----直接等于 String
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="caculFieldName"></param>
/// <param name="strFieldName"></param>
private void CaculValue2(IFeatureLayer culFeatLayer,string strSQL, string caculFieldName, string strFieldName)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int field = Row.Fields.FindField(caculFieldName);
int field2 = Row.Fields.FindField(strFieldName);
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
dynamic calValue = Row.Value[field2];
Row.Value[field] = calValue;
cursor.UpdateRow(Row);
Console.WriteLine(i);
}
catch { }
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// 属性计算----直接等于 double
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="caculFieldName"></param>
/// <param name="strFieldName"></param>
private void CaculValue3(IFeatureLayer culFeatLayer, string strSQL, string caculFieldName, string strFieldName)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// QueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = table.RowCount(pQueryFilter);
int field = Row.Fields.FindField(caculFieldName);
int field2 = Row.Fields.FindField(strFieldName);
for (int i = 0; i < table.RowCount(pQueryFilter); i++)
{
tlSProgressBar.Value = i;
try
{
// Row.set_Value(field, Row.get_Value(field2));
Row.Value[field] = Row.Value[field2];
cursor.UpdateRow(Row);
Row = cursor.NextRow();
}
catch{}
}
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// 属性计算----住宅类面积相加
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="caculFieldName"></param>
/// <param name="strFieldName"></param>
private void CaculValue4(IFeatureLayer culFeatLayer, string caculFieldName, string strFWMJ,string strFSSSMJ)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = null;
// QueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int field = Row.Fields.FindField(caculFieldName);
int field2 = Row.Fields.FindField(strFWMJ);
int field3 = Row.Fields.FindField(strFSSSMJ);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = table.RowCount(pQueryFilter);
for (int i = 0; i < table.RowCount(pQueryFilter); i++)
{
tlSProgressBar.Value = i;
try
{
// Row.set_Value(field, Row.get_Value(field2));
double fwmj=(double) Row.Value[field2];
double fsssmj= (double)Row.Value[field3];
Row.Value[field] = fwmj+ fsssmj;
cursor.UpdateRow(Row);
Row = cursor.NextRow();
}
catch { }
}
Marshal.ReleaseComObject(pQueryFilter);
}
private IFeatureCursor GetSelectedFeature(IFeatureLayer featureLayer)
{
try
{
if (featureLayer == null)
{
// ISSUE: variable of a compiler-generated type
IFeatureCursor featureCursor = (IFeatureCursor)null;
return featureCursor;
}
// ISSUE: variable of a compiler-generated type
IFeatureSelection featureSelection = (IFeatureSelection)featureLayer;
// ISSUE: variable of a compiler-generated type
ISelectionSet selectionSet = featureSelection.SelectionSet;
if (selectionSet.Count == 0)
{
// ISSUE: variable of a compiler-generated type
IFeatureCursor featureCursor = (IFeatureCursor)null;
return featureCursor;
}
// ISSUE: variable of a compiler-generated type
ICursor Cursor;
// ISSUE: reference to a compiler-generated method
selectionSet.Search((IQueryFilter)null, false, out Cursor);
// ISSUE: variable of a compiler-generated type
IFeatureCursor featureCursor1 = (IFeatureCursor)Cursor;
return featureCursor1;
}
catch (Exception ex)
{
int num = (int)MessageBox.Show("选择要素失败!", "警告");
// ISSUE: variable of a compiler-generated type
IFeatureCursor featureCursor = (IFeatureCursor)null;
return featureCursor;
}
}
/// <summary>
/// 转换前检查的GDB
/// </summary>
private string strZHQSelGDBPath = null;
/// <summary>
/// 转换前检查-加载数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_OpenData_Click(object sender, EventArgs e)
{
listBox_unck_FtLy.Items.Clear();
tspCombx_unck_SFZ.Items.Clear();
tspCombx_unck_SFZ.SelectedItem = null;
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
listFLayerZHQ_Check = new List<IFeatureLayer>();
string strGDB_Path = mfbd.DirectoryPath;
strZHQSelGDBPath = mfbd.DirectoryPath;
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
axMapControl1.Map.ClearLayers();
tslbStatus.Text = "正在加载要素...";
statusStrip1.Refresh();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
listFLayerZHQ_Check.Add(tempLayer);
listBox_unck_FtLy.Items.Add(tempLayer.FeatureClass.AliasName);
tspCombx_unck_SFZ.Items.Add(tempLayer.FeatureClass.AliasName);
pDs = pEnumDs.Next();
}
tslbStatus.Text = "加载完成!";
tlSpStLb.Text = " 选项:转换前属性质量检查 当前数据库:" + strGDB_Path;
//tlSpStLb.Text += " 当前数据库:" + Path.GetFileName(strGDB_Path);
statusStrip1.Refresh();
}
}
/// <summary>
/// 检查乡镇名称是否存在
/// </summary>
/// <param name="tempFtLy"></param>
/// <param name="strSQL"></param>
/// <param name="strSaveField"></param>
private void CheckUnStandardXiang(IFeatureLayer tempFtLy,string strSQL, string strSaveField)
{
ITable table = tempFtLy.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int fieldXZ = Row.Fields.FindField("xiang");//乡镇名称字段
int fieldXQ = Row.Fields.FindField("xian");//县区名称字段
int fieldSave = Row.Fields.FindField(strSaveField);//保存字段
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
//string strSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='息烽县'";
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strXZName = Row.Value[fieldXZ].ToString();
bool isChinaCode= CheckIsChineseCode.isLegalChinaCode(strXZName);
if(!isChinaCode)
{
Row.Value[fieldSave] = Row.Value[fieldSave].ToString()+";"+"非标准乡镇名;";
cursor.UpdateRow(Row);
}
else
{
string strSQLiteSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='" + Row.Value[fieldXQ].ToString() + "' and 乡镇名称='" + Row.Value[fieldXZ].ToString() + "'";
using (SQLiteConnection SqlConn = new SQLiteConnection(Connstr))
{
using (SQLiteCommand SqlCmd = new SQLiteCommand(strSQLiteSQL, SqlConn))
{
SqlConn.Open();
SQLiteDataReader reader = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
if (reader.HasRows==false)
{
Row.Value[fieldSave] = Row.Value[fieldSave].ToString() + ";" + "非标准乡镇名;";
cursor.UpdateRow(Row);
}
}
}
}
Row = cursor.NextRow();
}
}
//执行检查 eg名称(单户住宅类、多户住宅类、产业类、公共服务类)
/// <summary>
/// 转换前检查--执行检查
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_Excute_Click(object sender, EventArgs e)
{
unck_ExcuteFunc(null, false);
}
/// <summary>
/// 转换前检查
/// </summary>
/// <param name="culContextFtLy"></param>
/// <param name="isSingelCheck"></param>
private void unck_ExcuteFunc(IFeatureLayer culContextFtLy,bool isSingelCheck)
{
if (listFLayerZHQ_Check == null)
{
MessageBox.Show("没有数据可查!请先打开数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
DateTime dtStart = DateTime.Now;
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行检查");
splashScreenManager1.SetWaitFormDescription("请耐心等待...");
for (int i = 0; i < listFLayerZHQ_Check.Count; i++)
{
string strTxtPathes = String.Empty;
string selSQL = String.Empty;
//string strTxtPathes = Directory.GetCurrentDirectory() + "\检查项\转换前检查";
IFeatureLayer pFeatureLayer = listFLayerZHQ_Check[i];
string strFyLyName = pFeatureLayer.FeatureClass.AliasName;//要素类名称
if (isSingelCheck == true)
{
if (culContextFtLy.FeatureClass.AliasName != strFyLyName)
{
continue;
}
}
listBox_unck_FtLy.SelectedValue = strFyLyName;
listBox_unck_FtLy.Refresh();
if (strFyLyName != "单户住宅类" && strFyLyName != "多户住宅类" && strFyLyName != "产业类" && strFyLyName != "公共服务类")
{
continue;
}
splashScreenManager1.SetWaitFormDescription("请耐心等待... " + strFyLyName + " 初始化检查");
initValue(pFeatureLayer);
string strSetTxtPath = "";//保存检查项的TXT路径
if (strFyLyName == "单户住宅类")
{
strTxtPathes = Directory.GetCurrentDirectory() + "\检查项\转换前检查\单户住宅类";
strSetTxtPath = System.IO.Directory.GetCurrentDirectory() + "\checksettings\danhzzlSet.txt";
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_grxm")))
{
splashScreenManager1.SetWaitFormDescription("检查 单户住宅类 是否含非法字符" + "之个人姓名");
CkeckDataFunc(pFeatureLayer, null, "grxm", "grxm含非法字符");
}
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_cs")))
{
splashScreenManager1.SetWaitFormDescription("检查 单户住宅类 cs异常值检查");
selSQL = "cs<>'0' and cs<>'' and cs is not null";
CheckCSFunc(pFeatureLayer, selSQL);
}
}
else if (strFyLyName == "多户住宅类")
{
strSetTxtPath = System.IO.Directory.GetCurrentDirectory() + "\checksettings\duohzzlSet.txt";
strTxtPathes = Directory.GetCurrentDirectory() + "\检查项\转换前检查\多户住宅类";
}
else if (strFyLyName == "产业类")
{
strSetTxtPath = System.IO.Directory.GetCurrentDirectory() + "\checksettings\cylSet.txt";
strTxtPathes = Directory.GetCurrentDirectory() + "\检查项\转换前检查\产业类";
}
else if (strFyLyName == "公共服务类")
{
strSetTxtPath = System.IO.Directory.GetCurrentDirectory() + "\checksettings\ggfwlSet.txt";
strTxtPathes = Directory.GetCurrentDirectory() + "\检查项\转换前检查\公共服务类";
}
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_xian")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 是否含非法字符之xian");
CkeckDataFunc(pFeatureLayer, null, "xian", "xian含非法字符");
}
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_xiang")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 是否含非法字符之xiang");
CkeckDataFunc(pFeatureLayer, null, "xiang", "xiang含非法字符");
}
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_cun")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 是否含非法字符之cun");
CkeckDataFunc(pFeatureLayer, null, "cun", "cun含非法字符");
}
//SetCheck_zu
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_zu")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 是否含非法字符之zu");
selSQL = "zu <>'' and zu is not null";
CkeckIllegalCharFunc(pFeatureLayer, selSQL, "zu", "zu含非法字符");
}
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_xzName")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 非标准乡镇名称");
//检查非标准乡镇名称
CheckUnStandardXiang(pFeatureLayer, null, "CheckResult");
}
//
//检查开工时间值域
//
if (Convert.ToBoolean(XmlCls.ReadXml(XmlCls.strSettingsInfoXML, "SetCheck_kgsjZY")))
{
splashScreenManager1.SetWaitFormDescription("检查 " + strFyLyName + " 开工时间值域");
CheckKGSJFunc(pFeatureLayer, null);
}
listBoxCheckItems.Items.Clear();
this.Refresh();
string[] arrCheckPathes = Directory.GetFiles(strTxtPathes);
for (int j = 0; j < arrCheckPathes.Length; j++)
{
string strtxt = arrCheckPathes[j];
string strname = System.IO.Path.GetFileNameWithoutExtension(strtxt);
listBoxCheckItems.Items.Add(strname);
}
using (StreamReader sr = new StreamReader(strSetTxtPath, Encoding.UTF8))
{
while (!sr.EndOfStream)
{
string str = sr.ReadLine();
if (listBoxCheckItems.Items.Contains(str) == true)
{
int intIndex = listBoxCheckItems.Items.IndexOf(str);
//listBoxCheckItems.SetSelected(intIndex, true);
//listBoxCheckItems.
listBoxCheckItems.SetItemCheckState(intIndex, CheckState.Checked);
}
}
}
listBoxCheckItems.Refresh();
this.Refresh();
for (int j = 0; j < arrCheckPathes.Length; j++)
{
string strtxt = arrCheckPathes[j];
string strName = System.IO.Path.GetFileNameWithoutExtension(strtxt);
if (listBoxCheckItems.CheckedItems.Contains(strName) == false)
{
continue;
}
listBoxCheckItems.SelectedItem = strName;
splashScreenManager1.SetWaitFormDescription("正在检查... " + strFyLyName + " " + System.IO.Path.GetFileNameWithoutExtension(strtxt) + " " + (j + 1) + "/" + arrCheckPathes.Length);
using (StreamReader sr = new StreamReader(strtxt, Encoding.Default))
{
selSQL = sr.ReadToEnd();
}
try
{
string selSQLBJ = selSQL.Split('&')[0];//错误类型
selSQL = selSQL.Split('&')[1];//错误代码
CkeckDataOverCalcuFunc(pFeatureLayer, selSQL, selSQLBJ);
}
catch (Exception ex)
{
Console.WriteLine("出错" + ex.ToString());
MessageBox.Show("出错 " + ex.ToString());
}
}
listBoxCheckItems.Items.Clear();
this.Refresh();
}
DateTime dtEnd = DateTime.Now;
TimeSpan dtDiff = dateDiff(dtStart, dtEnd);
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
using (SpeechSynthesizer speech = new SpeechSynthesizer())
{
speech.Rate = 0; //语速
speech.Volume = 100; //音量
speech.Speak("检查完成");
}
MessageBox.Show("检查完成!耗时(" + dtDiff + ")
" + " 检查结果存放在矢量数据的CheckResult字段里", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 检查面积值域满足的条件
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strDescription"></param>
private void CheckMJValue(IFeatureLayer culFeatLayer, string strSQL, string strDescription)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
// int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + strDescription + ";";
cursor.UpdateRow(Row);
Row = cursor.NextRow();
}
}
/// <summary>
/// 非汉字--非法字符检查
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strFieldName"></param>
/// <param name="strDescription"></param>
private void CkeckDataFunc(IFeatureLayer culFeatLayer, string strSQL,string strFieldName,string strDescription)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
dynamic calValue = Row.Value[field2];
bool isChineseCode= CheckIsChineseCode.isLegalChinaCode(calValue);
if (isChineseCode==false)
{
string strCheckResult= (string) Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + strDescription + ";";
cursor.UpdateRow(Row);
}
//cursor.UpdateRow(Row);
}
catch { }
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// zu--非法字符检查
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strFieldName"></param>
/// <param name="strDescription"></param>
private void CkeckIllegalCharFunc(IFeatureLayer culFeatLayer, string strSQL, string strFieldName, string strDescription)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
dynamic calValue = Row.Value[field2];
//bool isIllegalChar = IllegalCharCheckCls.IsIllegalChar2(calValue);
bool isIllegalChar = IllegalCharCheckCls.ChkBadChar(calValue);
if (isIllegalChar == true)
{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + strDescription + ";";
cursor.UpdateRow(Row);
}
//cursor.UpdateRow(Row);
}
catch { }
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
private void initValue(IFeatureLayer temp)
{
try
{
AddStringField(temp.FeatureClass, "CheckResult");
}
catch
{
Console.WriteLine("添加字段失败");
}
CaculValue(temp, null, "CheckResult", ";");
}
/// <summary>
/// 添加字符串字段
/// </summary>
/// <param name="culFeatCls"></param>
/// <param name="strFieldName"></param>
private void AddStringField(IFeatureClass culFeatCls, string strFieldName)
{
IClass pClass = culFeatCls as IClass;
IFieldsEdit fldsE = culFeatCls.Fields as IFieldsEdit;
IField fld = new Field();
IFieldEdit2 fldE = fld as IFieldEdit2;
fldE.Type_2 = esriFieldType.esriFieldTypeString;
fldE.Length_2 = 500;
fldE.Name_2 = strFieldName;
pClass.AddField(fld);
}
/// <summary>
/// 根据名称得到要素类
/// </summary>
/// <param name="listFLayerZHH_Check"></param>
/// <param name="strFtLayerName"></param>
/// <returns></returns>
private IFeatureLayer GetFeatureLayerByName(List<IFeatureLayer> listFLayerZHH_Check,string strFtLayerName)
{
if (listFLayerZHH_Check.Count<=0|| listFLayerZHH_Check == null)
{
MessageBox.Show("请先打开数据");
return null;
}
IFeatureLayer temp = null;
for (int i = 0; i < listFLayerZHH_Check.Count; i++)
{
if (listFLayerZHH_Check[i].FeatureClass.AliasName== strFtLayerName)
{
temp = listFLayerZHH_Check[i];
break;
}
}
return temp;
}
//
//转换后检查
//
private void btn_iscked_OpenData_Click(object sender, EventArgs e)
{
listBox_iscked_FtLy.Items.Clear();
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
listFLayerZHH_Check = new List<IFeatureLayer>();
string strGDB_Path = mfbd.DirectoryPath;
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
tslbStatus.Text = "正在加载要素...";
statusStrip1.Refresh();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
listBox_iscked_FtLy.Items.Add(tempLayer.Name);
listFLayerZHH_Check.Add(tempLayer);
pDs = pEnumDs.Next();
}
tslbStatus.Text = "加载完成!";
tlSpStLb.Text = " 选项:转换后属性质量检查 当前数据库:" + strGDB_Path;
statusStrip1.Refresh();
}
}
private void btn_iscked_Excute_Click(object sender, EventArgs e)
{
if (listFLayerZHH_Check == null)
{
MessageBox.Show("没有数据可查!请先打开数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormDescription("请耐心等待...");
for (int i = 0; i < ModelDataCls.FeatureLayerNameModel.Count; i++)
{
string selSQL = String.Empty;
string strName = ModelDataCls.FeatureLayerNameModel[i];
listBox_iscked_FtLy.SelectedValue = strName;
listBox_iscked_FtLy.Refresh();
splashScreenManager1.SetWaitFormCaption("准备检查" + strName);
IFeatureLayer FtLayerZZL = GetFeatureLayerByName(listFLayerZHH_Check,strName);
if (FtLayerZZL==null)
{
continue;
}
initValue(FtLayerZZL);
string strCheckTXTPath = String.Empty;
splashScreenManager1.SetWaitFormCaption("检查 " + strName);
if (FtLayerZZL.FeatureClass.AliasName=="住宅类")
{
strCheckTXTPath = Directory.GetCurrentDirectory() + "\检查项\转换后检查\住宅类";
}
if (FtLayerZZL.FeatureClass.AliasName == "产业类")
{
strCheckTXTPath = Directory.GetCurrentDirectory() + "\检查项\转换后检查\产业类";
}
if (FtLayerZZL.FeatureClass.AliasName == "公共服务类")
{
strCheckTXTPath = Directory.GetCurrentDirectory() + "\检查项\转换后检查\公共服务类";
}
string[] arrCheckPathes = Directory.GetFiles(strCheckTXTPath);
for (int j = 0; j < arrCheckPathes.Length; j++)
{
string strtxt = arrCheckPathes[j];
splashScreenManager1.SetWaitFormDescription("正在检查... " + System.IO.Path.GetFileNameWithoutExtension(strtxt)+" "+(j+1)+"/"+ arrCheckPathes.Length);
using (StreamReader sr = new StreamReader(strtxt, Encoding.Default))
{
selSQL = sr.ReadToEnd();
}
try
{
string selSQLBJ = selSQL.Split('&')[0];//错误类型
selSQL = selSQL.Split('&')[1];//错误代码
CkeckDataOverCalcuFunc(FtLayerZZL, selSQL, selSQLBJ);
}
catch (Exception ex)
{
Console.WriteLine("出错"+ selSQL);
MessageBox.Show("出错 " + ex.ToString());
}
}
}
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
MessageBox.Show("检查完成! 检查结果存放在矢量数据的CheckResult字段里", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void btn_ViewCheckes_Click(object sender, EventArgs e)
{
string strCheckTXTPath = Directory.GetCurrentDirectory() + "\检查项\转换后检查";
Process.Start(strCheckTXTPath);
}
/// <summary>
/// 开工时间值域检查
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
private void CheckKGSJFunc(IFeatureLayer culFeatLayer, string strSQL)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
// int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int fieldkgsj = Row.Fields.FindField("kgsj");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
int intkgsj = Convert.ToInt32(Row.Value[fieldkgsj]);
if (intkgsj < 2000 || intkgsj > 2020)
{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + "kgsj不在值域;";
cursor.UpdateRow(Row);
}
}
catch
{}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
/// <summary>
/// 检查房屋层数异常
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strDescription"></param>
private void CheckCSFunc(IFeatureLayer culFeatLayer, string strSQL)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
// int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int fieldCS = Row.Fields.FindField("cs");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
string strCs = Row.Value[fieldCS].ToString();
double doubleCS = Convert.ToDouble(strCs);
int intCS = Convert.ToInt32(doubleCS);
double jg = doubleCS - intCS;
if (doubleCS<1.0|| doubleCS>=15.0)
{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + "cs值疑似异常;";
cursor.UpdateRow(Row);
}
if (jg!=0.0)
{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + "cs须为整数;";
cursor.UpdateRow(Row);
}
}
catch(Exception ex)
{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + "cs值疑似异常;";
cursor.UpdateRow(Row);
Console.WriteLine(ex.ToString());
}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
private void CkeckDataOverCalcuFunc(IFeatureLayer culFeatLayer, string strSQL, string strDescription)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
//int field = Row.Fields.FindField(caculFieldName);
// int field2 = Row.Fields.FindField(strFieldName);
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
// Row.set_Value(field, Row.get_Value(field2));
//object a1 = Row.Value[field];
//object a2 = Row.Value[field2];
tlSProgressBar.Value = i;
try
{
//dynamic calValue = Row.Value[field2];
//bool isChineseCode = CheckIsChineseCode.isLegalChinaCode(calValue);
//if (isChineseCode == false)
//{
string strCheckResult = (string)Row.Value[fieldCheckResult];
Row.Value[fieldCheckResult] = strCheckResult + strDescription + ";";
cursor.UpdateRow(Row);
//}
// cursor.UpdateRow(Row);
}
catch { }
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
}
private void btn_AddBH_Click(object sender, EventArgs e)
{
if (culFeatLayer == null)
{
MessageBox.Show("请先打开或选择数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("正在执行 透视统计");
splashScreenManager1.SetWaitFormDescription("请耐心等待...");
string strDBFPath= CommCls.GetStatistics(culFeatLayer);
DataTable dt= CommCls.dbfToDataTable(strDBFPath);
splashScreenManager1.CloseWaitForm();
FormAddBH formAddBH = new FormAddBH();
formAddBH.Text = culFeatLayer.FeatureClass.AliasName+"-添加编号";
formAddBH.dt = dt;
formAddBH.pFeatureLayer = culFeatLayer;
formAddBH.ShowDialog();
}
//private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
//{
// //tlSpStLb
// tlSpStLb.Text = " 选项:" + tabControl1.SelectedTab.Text;
//}
private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
if (this.WindowState==FormWindowState.Normal)
{
int intLocationX = this.Location.X;
int intLocationY = this.Location.Y;
XmlCls.UpdateXml(StrSaveXMLPath, "LocationX", intLocationX.ToString());
XmlCls.UpdateXml(StrSaveXMLPath, "LocationY", intLocationY.ToString());
int winWidth = this.Width;
int winHeight = this.Height;
XmlCls.UpdateXml(StrSaveXMLPath, "winWidth", winWidth.ToString());
XmlCls.UpdateXml(StrSaveXMLPath, "winHeight", winHeight.ToString());
}
Application.Exit();
}
/// <summary>
/// 重新计算代码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_CalculateXZDM_Click(object sender, EventArgs e)
{
if (culFeatLayer == null)
{
MessageBox.Show("请先打开或选择数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("正在计算 根据名称计算代码");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "city");
CaculValueGetCodeByNameShi(culFeatLayer, null, "city_name", "city");
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "xzqdm_xq");
CaculValueGetCodeByNameQuXian(culFeatLayer, null, "xzqmc_xq", "xzqdm_xq");
//计算乡镇代码
splashScreenManager1.SetWaitFormDescription("请耐心等待...计算 " + "xzqdm_xz");
CaculValueGetCodeByNameXiang(culFeatLayer, null, "xzqmc_xz", "xzqdm_xz");
splashScreenManager1.CloseWaitForm();
MessageBox.Show("计算完成", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 读取照片表数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtEdit_PhotoTable_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension == "")
{
MessageBox.Show("不能选择文件夹", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (strExtension != ".xlsx")
{
MessageBox.Show("请选择*.xlsx文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
txtEdit_PhotoTable.Text = files[0];
}
}
private void txtEdit_PhotoTable_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEdit_PhotoTable_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEdit_YSPhotoPath_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension != "")
{
MessageBox.Show("不能选择文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
txtEdit_YSPhotoPath.Text = files[0];
//foreach (string file in files)
//{
// //listBox1_AllPicturePath.Items.Add(file);
// textBox1.Text = file;
//}
}
}
private void txtEdit_YSPhotoPath_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEdit_YSPhotoPath_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEdit_NewPhotoPath_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension != "")
{
MessageBox.Show("不能选择文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
txtEdit_NewPhotoPath.Text = files[0];
//foreach (string file in files)
//{
// //listBox1_AllPicturePath.Items.Add(file);
// textBox1.Text = file;
//}
}
}
private void txtEdit_NewPhotoPath_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEdit_NewPhotoPath_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
/// <summary>
/// 用户存储原始照片表数据
/// </summary>
private List<ZPB_Cls> listZPB = null;
/// <summary>
/// 获取照片表数据
/// </summary>
/// <param name="strExcelPath"></param>
private void getZPB_FromPath(string strExcelPath)
{
listZPB = new List<ZPB_Cls>();
using (System.IO.FileStream fs = new System.IO.FileStream(strExcelPath, FileMode.Open, FileAccess.Read))
{
//XSSFWorkbook 适用XLSX格式,HSSFWorkbook 适用XLS格式
string fileExt = System.IO.Path.GetExtension(strExcelPath).ToLower();
IWorkbook workbook;
if (fileExt == ".xlsx") { workbook = new XSSFWorkbook(fs); } else if (fileExt == ".xls") { workbook = new HSSFWorkbook(fs); } else { workbook = null; }
ISheet sheet = workbook.GetSheetAt(0);
for (int i = 1; i <= sheet.LastRowNum; i++)
{
NPOI.SS.UserModel.IRow tempRow = sheet.GetRow(i);
ZPB_Cls tempZPB_Cls = new ZPB_Cls();
tempZPB_Cls.id = tempRow.GetCell(0).ToString();
tempZPB_Cls.name = tempRow.GetCell(1).ToString();
tempZPB_Cls.fwbh = tempRow.GetCell(2).ToString();
tempZPB_Cls.folder = tempRow.GetCell(3).ToString();
listZPB.Add(tempZPB_Cls);
}
}
// return listZPB;
}
/// <summary>
/// 读取照片表数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_PhotoTable_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "打开照片表";
ofd.Filter = "Excel文件(*.xlsx)|*.xlsx";
ofd.Multiselect = false;
if (ofd.ShowDialog()==DialogResult.OK)
{
txtEdit_PhotoTable.Text = ofd.FileName;
//getZPB_FromPath(ofd.FileName);
}
}
/// <summary>
/// 原始照片路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_YSPhotoPath_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
txtEdit_YSPhotoPath.Text = mfbd.DirectoryPath;
}
}
/// <summary>
/// 结果照片路径
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_NewPhotoPath_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
txtEdit_NewPhotoPath.Text = mfbd.DirectoryPath;
}
}
/// <summary>
/// 获取shp文件
/// </summary>
/// <param name="shpfilePath">shp文件路径</param>
/// <returns></returns>
private IFeatureClass GetShapefile(string shpfilePath)
{
IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactory();
IWorkspaceFactoryLockControl pWorkspaceFactoryLockControl = pWorkspaceFactory as IWorkspaceFactoryLockControl;
if (pWorkspaceFactoryLockControl.SchemaLockingEnabled)
{
pWorkspaceFactoryLockControl.DisableSchemaLocking();
}
string directoryPath = System.IO.Path.GetDirectoryName(shpfilePath);
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile(directoryPath, 0);
IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass(System.IO.Path.GetFileName(shpfilePath));
return pFeatureClass;
}
/// <summary>
/// 存储照片处理之照片要素类
/// </summary>
private List<IFeatureLayer> listZPFL = null;
/// <summary>
/// 照片处理之读取GDB数据
/// </summary>
/// <param name="strGDB_Path"></param>
/// <returns></returns>
private List<IFeatureLayer> getZHQ_FLFunc(string strGDB_Path)
{
comboBox1.Items.Clear();
List<IFeatureLayer> listFL = new List<IFeatureLayer>();
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
comboBox1.Items.Add(tempLayer.Name);
listFL.Add(tempLayer);
pDs = pEnumDs.Next();
}
return listFL;
}
private void textEdit1_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension != ".gdb")
{
MessageBox.Show("不能选择文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
textEdit1.Text = files[0];
//foreach (string file in files)
//{
// //listBox1_AllPicturePath.Items.Add(file);
// textBox1.Text = file;
//}
}
}
private void textEdit1_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void textEdit1_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void btn_ZPGDB_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
textEdit1.Text = mfbd.DirectoryPath;
//listZPFL = getZHQ_FLFunc(textEdit1.Text);
}
}
/// <summary>
/// 照片之要素类
/// </summary>
private IFeatureLayer pZP_FL = null;
/// <summary>
/// 多媒体之选择要素类
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
pZP_FL = listZPFL[comboBox1.SelectedIndex];
}
private void btn_ExcutePhoto_Click(object sender, EventArgs e)
{
if (pZP_FL==null)
{
return;
}
if (listZPB==null|| listZPB.Count<=0)
{
return;
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "处理结果";
sfd.Filter= "Excel文件|*.xlsx";
sfd.FileName = pZP_FL.FeatureClass.AliasName + "_处理结果";
sfd.AddExtension = true;
if (sfd.ShowDialog()==DialogResult.OK)
{
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行 照片处理");
splashScreenManager1.SetWaitFormDescription("请耐心等待...照片拷贝并重命名");
// listZPB_ZLJG = new List<ZPB_Cls>();
for (int i = 0; i < listZPB.Count; i++)
{
ZPB_Cls temp = listZPB[i];
string strZP_Path = txtEdit_YSPhotoPath.Text + "\" + temp.folder + "\" + temp.name;//原始照片路径
if(File.Exists(strZP_Path))
{
try
{
//string strZP_Path = txtEdit_YSPhotoPath.Text + "\" + temp.folder + "\" + temp.name;//原始照片路径
string NewFileName = Guid.NewGuid().ToString() + ".jpg";//新照片名称
temp.strNewName = NewFileName;
string strSQL = "fwbh='" + temp.fwbh + "'";
IFeature pFeature = getPointToZB(pZP_FL, strSQL);
ESRI.ArcGIS.Geometry.IPoint myPoint = pFeature.Shape as ESRI.ArcGIS.Geometry.IPoint;
int pBHField = pFeature.Fields.FindField("BH");
string pBHValue= pFeature.Value[pBHField].ToString();
string strNewZP_Folder = txtEdit_NewPhotoPath.Text + "\" + pBHValue;
try
{
Directory.CreateDirectory(strNewZP_Folder);
}
catch { }
string strNewZP_Path = txtEdit_NewPhotoPath.Text + "\" + pBHValue + "\" + NewFileName;//新照片路径
if (myPoint!=null)
{
temp.XZB = myPoint.X;
temp.YZB = myPoint.Y;
//listZPB_ZLJG.Add(temp);
//FileInfo fi = new FileInfo(strZP_Path);
//fi.CopyTo(strNewZP_Path,true);
File.Copy(strZP_Path, strNewZP_Path, true);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
//IWorkbook workbook = new XSSFWorkbook();
//ISheet sheet = workbook.CreateSheet("Sheet1");
splashScreenManager1.SetWaitFormDescription("请耐心等待...导出处理结果表");
string fileExt = System.IO.Path.GetExtension(sfd.FileName).ToLower();
IWorkbook workbook;
if (fileExt == ".xlsx") { workbook = new XSSFWorkbook(); } else if (fileExt == ".xls") { workbook = new HSSFWorkbook(); } else { workbook = null; }
var sheet = workbook.CreateSheet("Sheet1");
NPOI.SS.UserModel.IRow row = sheet.CreateRow(0);
row.CreateCell(0).SetCellValue("id");
row.CreateCell(1).SetCellValue("name");
row.CreateCell(2).SetCellValue("fwbh");
row.CreateCell(3).SetCellValue("NewName");
row.CreateCell(4).SetCellValue("XZB");
row.CreateCell(5).SetCellValue("YZB");
for (int i = 0; i < listZPB.Count; i++)
{
if (listZPB[i].XZB!=0.0)
{
NPOI.SS.UserModel.IRow rowData = sheet.CreateRow(i + 1);
rowData.CreateCell(0).SetCellValue(listZPB[i].id);
rowData.CreateCell(1).SetCellValue(listZPB[i].name);
rowData.CreateCell(2).SetCellValue(listZPB[i].fwbh);
rowData.CreateCell(3).SetCellValue(listZPB[i].strNewName);
rowData.CreateCell(4).SetCellValue(listZPB[i].XZB);
rowData.CreateCell(5).SetCellValue(listZPB[i].YZB);
}
}
splashScreenManager1.SetWaitFormDescription("请耐心等待...写入磁盘");
using (FileStream fs2 = File.OpenWrite(sfd.FileName))
{
workbook.Write(fs2);
//MessageBox.Show("Excel已经写入成功!");
}
splashScreenManager1.CloseWaitForm();
}
}
private IFeature getPointToZB(IFeatureLayer culFeatLayer, string strSQL)
{
//ESRI.ArcGIS.Geometry.IPoint pPoint = null;
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
IFeatureCursor pFCursor = culFeatLayer.FeatureClass.Search(pQueryFilter, false);
IFeature pFeature = pFCursor.NextFeature();
//ESRI.ArcGIS.Geometry.IPoint pPoint = new ESRI.ArcGIS.Geometry.Point();
//ESRI.ArcGIS.Geometry.IArea pArea = pFeature.Shape as ESRI.ArcGIS.Geometry.IArea;
//pArea.QueryCentroid(pPoint);
//pPoint = pFeature.Shape as ESRI.ArcGIS.Geometry.IPoint;
return pFeature;
}
private void txtEdit_PhotoTable_EditValueChanged(object sender, EventArgs e)
{
getZPB_FromPath(txtEdit_PhotoTable.Text);
}
private void textEdit1_EditValueChanged(object sender, EventArgs e)
{
listZPFL = getZHQ_FLFunc(textEdit1.Text);
}
/// <summary>
/// 转换前处理之乡镇名称最大匹配
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_XZPP_Click(object sender, EventArgs e)
{
if (listFLayerZHQ_Check == null)
{
MessageBox.Show("没有数据可查!请先打开数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
splashScreenManager1.ShowWaitForm();
for (int i = 0; i < listFLayerZHQ_Check.Count; i++)
{
IFeatureLayer culFeatLayer = listFLayerZHQ_Check[i];
string strFyLyName = culFeatLayer.FeatureClass.AliasName;
listBox_unck_FtLy.SelectedValue = strFyLyName;
listBox_unck_FtLy.Refresh();
splashScreenManager1.SetWaitFormCaption("执行检查 " + culFeatLayer.FeatureClass.AliasName + " 乡镇名称最大匹配");
//添加字段
try
{
AddStringField(culFeatLayer.FeatureClass, "CheckMaxMatch");
}
catch
{
Console.WriteLine("添加字段失败");
}
splashScreenManager1.SetWaitFormDescription("请耐心等待...准备检查");
CaculValue(culFeatLayer, null, "CheckMaxMatch", "1");
splashScreenManager1.SetWaitFormDescription("请耐心等待...乡镇名称是否标准");
CkeckXZMC(culFeatLayer, null, "xiang", "xian", "CheckMaxMatch");
splashScreenManager1.SetWaitFormDescription("请耐心等待...乡镇名称最大匹配");
string strSQL = "CheckMaxMatch<>'1'";
CheckXZNameMaxMatch(culFeatLayer, strSQL, "xiang", "xian", "CheckMaxMatch");
}
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
MessageBox.Show("匹配完成,结果存放在"CheckMaxMatch"字段中","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
private void CkeckXZMC(IFeatureLayer culFeatLayer, string strSQL, string strMhFieldXZ, string strMhFieldXQ, string strSaveField)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int fieldXZ = Row.Fields.FindField(strMhFieldXZ);//乡镇名称字段
int fieldXQ = Row.Fields.FindField(strMhFieldXQ);//县区名称字段
int fieldSave = Row.Fields.FindField(strSaveField);//保存最大匹配名称字段
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
//string strSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='息烽县'";
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strXZName = Row.Value[fieldXZ].ToString();
string strXQName = Row.Value[fieldXQ].ToString();
try
{
string strSQLiteSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='" + strXQName + "' and 乡镇名称 = '" + strXZName + "'";
using (SQLiteConnection SqlConn = new SQLiteConnection(Connstr))
{
using (SQLiteCommand SqlCmd = new SQLiteCommand(strSQLiteSQL, SqlConn))
{
SqlConn.Open();
using (SQLiteDataReader reader = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection))
{
if (reader.HasRows == false)
{
try
{
Row.Value[fieldSave] = "未找到乡镇名称";
cursor.UpdateRow(Row);
}
catch { }
}
}
}
}
}
catch { }
Console.WriteLine(i);
Row = cursor.NextRow();
}
//using (SQLiteConnection SqlConn = new SQLiteConnection(Connstr))
//{
// SqlConn.Open();
// for (int i = 0; i < maxCount; i++)
// {
// tlSProgressBar.Value = i;
// string strXZName = Row.Value[fieldXZ].ToString();
// string strXQName = Row.Value[fieldXQ].ToString();
// try
// {
// string strSQLiteSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='" + strXQName + "' and 乡镇名称 = '" + strXZName + "'";
// using (SQLiteCommand SqlCmd = new SQLiteCommand(strSQLiteSQL, SqlConn))
// {
// // SqlConn.Open();
// using (SQLiteDataReader reader = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection))
// {
// if (reader.HasRows == false)
// {
// try
// {
// Row.Value[fieldSave] = "false";
// cursor.UpdateRow(Row);
// }
// catch { }
// }
// }
// }
// }
// catch{}
// Console.WriteLine(i);
// Row = cursor.NextRow();
// }
//}
}
/// <summary>
/// 查找名称最大匹配
/// </summary>
/// <param name="culFeatLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strMhFieldXZ">乡镇名称字段</param>
/// <param name="strMhFieldXQ">县区名称字段</param>
/// <param name="strSaveField">保存最大匹配字段</param>
private void CheckXZNameMaxMatch(IFeatureLayer culFeatLayer, string strSQL,string strMhFieldXZ,string strMhFieldXQ,string strSaveField)
{
ITable table = culFeatLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int fieldXZ = Row.Fields.FindField(strMhFieldXZ);//乡镇名称字段
int fieldXQ = Row.Fields.FindField(strMhFieldXQ);//县区名称字段
int fieldSave = Row.Fields.FindField(strSaveField);//保存最大匹配名称字段
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
string Connstr = SQliteHelperCls.CustomerConnStr(SQliteHelperCls.strDBPath);
//string strSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='息烽县'";
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strXZName = Row.Value[fieldXZ].ToString();
//移除非法字符
strXZName = CheckIsChineseCode.GetNewChinaCode(strXZName);
strXZName = strXZName.Replace("办事处", "");
strXZName = strXZName.Replace("街道", "");
strXZName = strXZName.Replace("族", "");
//if (strXZName.Contains("街道")|| strXZName.Contains("族"))
//{
// try { strXZName = strXZName.Substring(0, 2); }
// catch { }
//}
string strXQName = Row.Value[fieldXQ].ToString();
string strZDPPName = "1";
string temp = String.Empty;//记录最终 最大匹配值
//string strSQLiteSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='"+ strXQName + "' and 乡镇名称 = '"+ strXZName + "'";
string strSQLiteSQL = "Select 乡镇名称 from 乡镇代码名称 where 县区名称='" + strXQName + "'";
using (SQLiteConnection SqlConn = new SQLiteConnection(Connstr))
{
using (SQLiteCommand SqlCmd = new SQLiteCommand(strSQLiteSQL, SqlConn))
{
SqlConn.Open();
SQLiteDataReader reader = SqlCmd.ExecuteReader(CommandBehavior.CloseConnection);
if (reader.HasRows)
{
while (reader.Read())
{
string str = reader.GetString(0);//标准乡镇名称
string strJG = LCS(str, strXZName);//最大匹配值
// string strJG = LCS(textBox1.Text, str);
if (String.IsNullOrEmpty(strJG) == false && strJG.Length >= 2)
{
if(temp.Length< strJG.Length)
{
temp = strJG;
strZDPPName = str;
}
}
// Console.WriteLine(str);
}
}
}
}
try
{
if (strZDPPName != "1")
{
Row.Value[fieldSave] = strZDPPName;
cursor.UpdateRow(Row);
}
Console.WriteLine(i);
}
catch { }
Row = cursor.NextRow();
}
}
#region LCS算法实现
/// <summary>
/// 最大公共字符串
/// LCS算法
/// Longest Common Subsequence
/// </summary>
/// <param name="str1">字符串A</param>
/// <param name="str2">字符串B</param>
/// <returns></returns>
private string LCS(string str1, string str2)
{
if (str1 == str2)
{
return str1;
}
else if (String.IsNullOrEmpty(str1) || String.IsNullOrEmpty(str2))
{
return null;
}
var d = new int[str1.Length, str2.Length];
var index = 0;
var length = 0;
for (int i = 0; i < str1.Length; i++)
{
for (int j = 0; j < str2.Length; j++)
{
//左上角
var n = i - 1 >= 0 && j - 1 >= 0 ? d[i - 1, j - 1] : 0;
//当前节点值 = “1 + 左上角的值”:“0”
d[i, j] = str1[i] == str2[j] ? 1 + n : 0;
//如果是最大值,则记录该值和行号
if (d[i, j] > length)
{
length = d[i, j];
index = i;
}
}
}
return str1.Substring(index - length + 1, length);
}
#endregion
/// <summary>
/// 添加双精度字段
/// </summary>
/// <param name="culFeatCls"></param>
/// <param name="strFieldName"></param>
private void AddDoubleField(IFeatureClass culFeatCls, string strFieldName)
{
IClass pClass = culFeatCls as IClass;
IFieldsEdit fldsE = culFeatCls.Fields as IFieldsEdit;
IField fld = new Field();
IFieldEdit2 fldE = fld as IFieldEdit2;
fldE.Type_2 = esriFieldType.esriFieldTypeDouble;
// fldE.Length_2 = 500;
fldE.Name_2 = strFieldName;
pClass.AddField(fld);
}
/// <summary>
/// 执行检查未完全采集
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BTN_BWQCJ_Excute_Click(object sender, EventArgs e)
{
if (culHBFtLy==null)
{
MessageBox.Show("请先打开或选择红斑数据", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (listCJDFylys==null)
{
MessageBox.Show("请打开采集点数据", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (comboBoxBHFields.SelectedIndex==-1)
{
MessageBox.Show("请选择图斑面积字段", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行 不完全采集核查");
splashScreenManager1.SetWaitFormDescription("请耐心等待..初始化计算...");
try
{
AddDoubleField(culHBFtLy.FeatureClass, "TotalMJ");//添加总面积字段
}
catch{}
CaculValue(culHBFtLy, null, "TotalMJ", 0.0);//初始化
for (int i = 0; i < listCJDFylys.Count; i++)
{
IFeatureLayer culCJDFtLy = listCJDFylys[i];
splashScreenManager1.SetWaitFormDescription("请耐心等待.. 计算 "+ culCJDFtLy.FeatureClass.AliasName);
if (culCJDFtLy.FeatureClass.AliasName=="单户住宅类"|| culCJDFtLy.FeatureClass.AliasName == "多户住宅类")
{
GetZZLAreaAddFunc(culHBFtLy, null, culCJDFtLy);
}
else
{
//GetFZZLAreaAddFunc(culHBFtLy, null, culCJDFtLy);
}
}
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
}
/// <summary>
/// 计算单户住宅类和多户住宅类的面积相加
/// </summary>
/// <param name="culHBFtLayer">红斑要素类</param>
/// <param name="strSQL"></param>
/// <param name="culCJDFtLayer">采集点</param>
private void GetZZLAreaAddFunc(IFeatureLayer culHBFtLayer, string strSQL, IFeatureLayer culCJDFtLayer)
{
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = "";
//pFeatureSelection = mianfeatureLayer as IFeatureSelection;
int maxCount= culHBFtLayer.FeatureClass.FeatureCount(pQueryFilter);
tlSProgressBar.Maximum = maxCount;
tlSProgressBar.Minimum = 0;
IFeatureCursor pfCursor = culHBFtLayer.Search(pQueryFilter, false);
IFeature pmianFeature = pfCursor.NextFeature();
int kk = 0;
while (pmianFeature != null)
{
Console.WriteLine(kk++);
tlSProgressBar.Value = kk;
int fieldTotal = pmianFeature.Fields.FindField("TotalMJ");//红斑-叠加的总面积字段索引
IGeometry pGeometry = pmianFeature.Shape;
ISpatialFilter spatialFilter = new SpatialFilter();
spatialFilter.Geometry = pGeometry;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureSelection pdianFeatureSelection = culCJDFtLayer as IFeatureSelection;
pdianFeatureSelection.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
ISelectionSet pSelectionSet = pdianFeatureSelection.SelectionSet;
int intCount = pSelectionSet.Count;
//定义ICursor接口的游标以遍历整个选择集
ICursor cursor;
//使用ISelectionSet接口的Search方法,使用null作为查询过滤器,cursor作为返回值获取整个选择集
pSelectionSet.Search(null, false, out cursor);
IFeatureCursor pdianEnumFeature = cursor as IFeatureCursor;
//IEnumFeature pdianEnumFeature = pSelectionSet as IEnumFeature;
IFeature pdianFeature = pdianEnumFeature.NextFeature();
while (pdianFeature != null)
{
int fieldFwzdMJ = pdianFeature.Fields.FindField("fwzdmj");//采集点-房屋占地面积字段索引
int fieldFsssMJ = pdianFeature.Fields.FindField("fsssmj");//采集点-附属设施面积字段索引
double dbTatalMJ = 0;
try
{
dbTatalMJ = Convert.ToDouble(pmianFeature.Value[fieldTotal]);
}
catch
{
dbTatalMJ = 0;
}
double dbFwzdMJ = Convert.ToDouble(pdianFeature.Value[fieldFwzdMJ]);
try
{
dbFwzdMJ = Convert.ToDouble(pdianFeature.Value[fieldFwzdMJ]);
}
catch
{
dbFwzdMJ = 0;
}
double FsssMJ = Convert.ToDouble(pdianFeature.Value[fieldFsssMJ]);
try
{
FsssMJ = Convert.ToDouble(pdianFeature.Value[fieldFsssMJ]);
}
catch
{
FsssMJ = 0;
}
double newTatalMJ = dbTatalMJ + dbFwzdMJ + FsssMJ;
pmianFeature.set_Value(fieldTotal, newTatalMJ);
pmianFeature.Store();
pdianFeature = pdianEnumFeature.NextFeature();
}
pmianFeature = pfCursor.NextFeature();
}
}
/// <summary>
/// 计算非住宅类的面积相加
/// </summary>
/// <param name="culHBFtLayer">红斑要素类</param>
/// <param name="strSQL"></param>
/// <param name="culCJDFtLayer">采集点</param>
private void GetFZZLAreaAddFunc(IFeatureLayer culHBFtLayer, string strSQL, IFeatureLayer culCJDFtLayer)
{
IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = "";
//pFeatureSelection = mianfeatureLayer as IFeatureSelection;
IFeatureCursor pfCursor = culHBFtLayer.Search(pQueryFilter, false);
IFeature pmianFeature = pfCursor.NextFeature();
while (pmianFeature != null)
{
int fieldTotal = pmianFeature.Fields.FindField("TotalMJ");//红斑-叠加的总面积字段索引
IGeometry pGeometry = pmianFeature.Shape;
ISpatialFilter spatialFilter = new SpatialFilter();
spatialFilter.Geometry = pGeometry;
spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureSelection pdianFeatureSelection = culCJDFtLayer as IFeatureSelection;
pdianFeatureSelection.SelectFeatures(spatialFilter, esriSelectionResultEnum.esriSelectionResultNew, false);
ISelectionSet pSelectionSet = pdianFeatureSelection.SelectionSet;
int intCount = pSelectionSet.Count;
//定义ICursor接口的游标以遍历整个选择集
ICursor cursor;
//使用ISelectionSet接口的Search方法,使用null作为查询过滤器,cursor作为返回值获取整个选择集
pSelectionSet.Search(null, false, out cursor);
IFeatureCursor pdianEnumFeature = cursor as IFeatureCursor;
//IEnumFeature pdianEnumFeature = pSelectionSet as IEnumFeature;
IFeature pdianFeature = pdianEnumFeature.NextFeature();
while (pdianFeature != null)
{
int fieldFwzdMJ = pdianFeature.Fields.FindField("fwzdmj");//采集点-房屋占地面积字段索引
double dbTatalMJ = 0;
try
{
dbTatalMJ = Convert.ToDouble(pmianFeature.Value[fieldTotal]);
}
catch
{
dbTatalMJ = 0;
}
double dbFwzdMJ = Convert.ToDouble(pdianFeature.Value[fieldFwzdMJ]);
try
{
dbFwzdMJ = Convert.ToDouble(pdianFeature.Value[fieldFwzdMJ]);
}
catch
{
dbFwzdMJ = 0;
}
double newTatalMJ = dbTatalMJ + dbFwzdMJ;
pmianFeature.set_Value(fieldTotal, newTatalMJ);
pmianFeature.Store();
pdianFeature = pdianEnumFeature.NextFeature();
}
pmianFeature = pfCursor.NextFeature();
}
}
#region 面要素所在GDB
private void txtEd_BWQCJ_MGDB_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension != ".gdb")
{
MessageBox.Show("不能选择文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
txtEd_BWQCJ_MGDB.Text = files[0];
}
}
private void txtEd_BWQCJ_MGDB_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEd_BWQCJ_MGDB_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
#endregion
#region 采集点要素所在GDB
private void txtEd_BWQCJ_DGDB_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (files.Length > 1)
{
MessageBox.Show("只允许拖拽一个文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
// Directory.
string strExtension = System.IO.Path.GetExtension(files[0]);
if (strExtension != ".gdb")
{
MessageBox.Show("不能选择文件", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
txtEd_BWQCJ_DGDB.Text = files[0];
}
}
private void txtEd_BWQCJ_DGDB_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
private void txtEd_BWQCJ_DGDB_DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.All;
}
#endregion
private void btn_BWQCJ_MGDB_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
txtEd_BWQCJ_MGDB.Text = mfbd.DirectoryPath;
}
}
private void BTN_BWQCJ_DGDB_Click(object sender, EventArgs e)
{
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
txtEd_BWQCJ_DGDB.Text = mfbd.DirectoryPath;
}
}
/// <summary>
/// 其他-读取红斑要素类
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtEd_BWQCJ_MGDB_EditValueChanged(object sender, EventArgs e)
{
listHBFylys = getHBFtLyFunc(txtEd_BWQCJ_MGDB.Text);
}
/// <summary>
/// 当前选择的红斑要素类
/// </summary>
private IFeatureLayer culHBFtLy = null;
/// <summary>
/// 其他-红斑要素类集合
/// </summary>
private List<IFeatureLayer> listHBFylys = null;
/// <summary>
/// 其他-获取红斑要素类集合非法
/// </summary>
/// <param name="strGDB_Path"></param>
/// <returns></returns>
private List<IFeatureLayer> getHBFtLyFunc(string strGDB_Path)
{
cmbx_BWQCJ_MGDB.Items.Clear();
List<IFeatureLayer> listFL = new List<IFeatureLayer>();
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
cmbx_BWQCJ_MGDB.Items.Add(tempLayer.Name);
listFL.Add(tempLayer);
pDs = pEnumDs.Next();
}
return listFL;
}
/// <summary>
/// 其他-采集点要素类集合
/// </summary>
private List<IFeatureLayer> listCJDFylys = null;
/// <summary>
/// 其他-获取采集点要素类集合
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtEd_BWQCJ_DGDB_EditValueChanged(object sender, EventArgs e)
{
listCJDFylys = getCJDFtLyFunc(txtEd_BWQCJ_DGDB.Text);
}
/// <summary>
/// 其他-获取采集点要素类集合非法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private List<IFeatureLayer> getCJDFtLyFunc(string strGDB_Path)
{
listBoxControlCJD.Items.Clear();
List<IFeatureLayer> listFL = new List<IFeatureLayer>();
FileGDBWorkspaceFactory fac = new FileGDBWorkspaceFactory();
IFeatureWorkspace pFtWS = (IFeatureWorkspace)fac.OpenFromFile(strGDB_Path, 0);
IWorkspace pWork = (IWorkspace)pFtWS;
IEnumDataset pEnumDs = pWork.get_Datasets(esriDatasetType.esriDTFeatureClass);
IDataset pDs = pEnumDs.Next();
while (pDs != null)
{
IFeatureClass temp = pDs as IFeatureClass;
IFeatureLayer tempLayer = new FeatureLayer();
tempLayer.FeatureClass = temp;
tempLayer.Name = tempLayer.FeatureClass.AliasName;
listBoxControlCJD.Items.Add(tempLayer.Name);
listFL.Add(tempLayer);
pDs = pEnumDs.Next();
}
return listFL;
}
///// <summary>
///// 当前选择的 要素字段集合
///// </summary>
//List<IField> listCulSelField = null;
/// <summary>
/// 其他-获取当前选择的红斑要素类
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void cmbx_BWQCJ_MGDB_SelectedIndexChanged(object sender, EventArgs e)
{
culHBFtLy = listHBFylys[cmbx_BWQCJ_MGDB.SelectedIndex];
comboBoxBHFields.Items.Clear();
comboBoxBHFields.SelectedItem = null;
int FieldCounts = culHBFtLy.FeatureClass.Fields.FieldCount;
for (int i = 0; i < FieldCounts; i++)
{
//listCulSelField.Add(culHBFtLy.FeatureClass.Fields.get_Field(i));
comboBoxBHFields.Items.Add(culHBFtLy.FeatureClass.Fields.get_Field(i).AliasName);
}
}
/// <summary>
/// 转换前检查-检查结果统计-按错误类型统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_JCJGTJ_Click(object sender, EventArgs e)
{
//JCJGTJ_ModelCls
if (listFLayerZHQ_Check == null)
{
MessageBox.Show("没有数据可统计!请先打开数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
MyFolderBrowserDialog mfbd = new MyFolderBrowserDialog();
if (mfbd.ShowDialog(this) == DialogResult.OK)
{
string strSaveFolder= mfbd.DirectoryPath;
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行 检查结果统计");
for (int i = 0; i < listFLayerZHQ_Check.Count; i++)
{
IFeatureLayer culTempFtLy = listFLayerZHQ_Check[i];
string strculFtLyName = culTempFtLy.FeatureClass.AliasName;
listBox_unck_FtLy.SelectedValue = strculFtLyName;
listBox_unck_FtLy.Refresh();
splashScreenManager1.SetWaitFormDescription("请耐心等待... 统计 " + strculFtLyName + " 中");
int kk = culTempFtLy.FeatureClass.FindField("CheckResult");
if (kk != -1)
{
string strSavePath = strSaveFolder + "\" + strculFtLyName + "_检查结果统计.xlsx";
try { File.Delete(strSavePath); }
catch { }
Dictionary<string, int> dicJCJGTJ=JCJGTJByLX_Func(culTempFtLy, null);
int intTotal = 0;
foreach (var temp in dicJCJGTJ)
{
intTotal += temp.Value;
}
dicJCJGTJ.Add("合计", intTotal);
splashScreenManager1.SetWaitFormDescription("请耐心等待... 保存中");
using (var excel = new ExcelPackage(new FileInfo(strSavePath)))
{
//创建一个工作表
var ws = excel.Workbook.Worksheets.Add("Sheet1");
ws.Cells[1, 1].Value = "问题描述";
//ws.Cells[1 + 2, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//ws.Cells[1 + 2, 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
ws.Cells[1, 2].Value = "数量";
//ws.Cells[1, 2].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//ws.Cells[1, 2].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
int bj = 0;
foreach (var temp in dicJCJGTJ)
{
ws.Cells[bj + 2, 1].Value = temp.Key;
//ws.Cells[bj + 2, 1].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//ws.Cells[bj + 2, 1].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
ws.Cells[bj + 2, 2].Value = temp.Value;
//ws.Cells[bj + 2, 2].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
//ws.Cells[bj + 2, 2].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
bj++;
}
ws.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
ws.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
ws.Column(1).AutoFit();
ws.Column(2).AutoFit();
//保存表格信息
excel.Save();
}
}
}
splashScreenManager1.CloseWaitForm();
tlSProgressBar.Value = 0;
DialogResult dirlt= MessageBox.Show("处理完成,是否打开?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dirlt==DialogResult.OK)
{
Process.Start(strSaveFolder);
}
}
}
/// <summary>
/// 按错误类型统计
/// </summary>
/// <param name="culTempFtLy"></param>
/// <param name="strSQL"></param>
/// <returns></returns>
private Dictionary<string, int> JCJGTJByLX_Func(IFeatureLayer culTempFtLy,string strSQL)
{
Dictionary<string, int> dicJCJGTJ = new Dictionary<string, int>();
ITable table = culTempFtLy.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return null;
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strCheckResult = Row.Value[fieldCheckResult].ToString();
if (!String.IsNullOrEmpty(strCheckResult))
{
string[] strArr= strCheckResult.Split(';');
for (int j = 0; j < strArr.Length; j++)
{
string strTemp = strArr[j];
if (!String.IsNullOrEmpty(strTemp))
{
if (dicJCJGTJ.ContainsKey(strTemp))
{
dicJCJGTJ[strTemp] = dicJCJGTJ[strTemp] + 1;
}
else
{
dicJCJGTJ.Add(strTemp, 1);
}
}
}
}
Row = cursor.NextRow();
}
Marshal.ReleaseComObject(pQueryFilter);
return dicJCJGTJ;
}
/// <summary>
/// 用于验证身份证的要素类
/// </summary>
private IFeatureLayer pcheckSFZ_FtLy = null;
/// <summary>
/// 身份证必填及合法性检查
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_ExcuteFSZ_Click(object sender, EventArgs e)
{
if (pcheckSFZ_FtLy == null)
{
MessageBox.Show("请打开数据或选择图层!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
try
{
AddStringField(pcheckSFZ_FtLy.FeatureClass, "sfzh_Check");
}
catch
{
Console.WriteLine("添加字段失败");
}
//CaculValue(pcheckSFZ_FtLy, null, "sfzh_Check", ";");
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行 sfzh验证");
splashScreenManager1.SetWaitFormDescription("请耐心等待...sfzh必填验证中");
string strSQL = "sfzh='' or sfzh is null";
CaculValue(pcheckSFZ_FtLy, strSQL, "sfzh_Check", "sfzh必填");
splashScreenManager1.SetWaitFormDescription("请耐心等待...sfzh合法验证中");
strSQL = "sfzh<>'' and sfzh is not null";
Check_SFZH_Islegal(pcheckSFZ_FtLy, strSQL, "sfzh_Check", "sfzh非法");
tlSProgressBar.Value = 0;
splashScreenManager1.CloseWaitForm();
MessageBox.Show("验证完成!验证结果保存在字段"sfzh_Check"中", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 验证身份证合法性
/// </summary>
/// <param name="tempLayer"></param>
/// <param name="strSQL"></param>
/// <param name="strSaveFieldName"></param>
/// <param name="strDiscription"></param>
private void Check_SFZH_Islegal(IFeatureLayer tempLayer,string strSQL,string strSaveFieldName,string strDiscription)
{
ITable table = tempLayer.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return;
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
int field = Row.Fields.FindField("sfzh");
int fieldSave = Row.Fields.FindField(strSaveFieldName);
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string sfzh_Value = Row.Value[field].ToString();
//验证
bool isRight=IDcardsNoVerifyCls.IDcards_isright(sfzh_Value);
//string strCheckBirthDay = Check_BirthDay_Islegal(sfzh_Value);
if (isRight==false)
{
string strCheckDiscrib=IDcardsNoVerifyCls.MyIDcards_isright(sfzh_Value);
if(strCheckDiscrib!="")
{
Row.Value[fieldSave] = strDiscription + " " + strCheckDiscrib;
}
else
{
Row.Value[fieldSave] = strDiscription;
}
//if (strCheckBirthDay!="")
//{
// Row.Value[fieldSave] = strDiscription + " " + strCheckBirthDay;
//}
//else
//{
// Row.Value[fieldSave] = strDiscription;
//}
cursor.UpdateRow(Row);
}
Row = cursor.NextRow();
}
}
private string Check_BirthDay_Islegal(string idNumber)
{
string birth = String.Empty;
if (idNumber.Length==18)
{
birth = idNumber.Substring(6, 8).Insert(6, "-").Insert(4, "-");
}
else if (idNumber.Length == 15)
{
birth = idNumber.Substring(6, 6).Insert(4, "-").Insert(2, "-");
}
DateTime time = new DateTime();
if (DateTime.TryParse(birth, out time) == false)
{
return "生日验证失败=" + birth;
//return false;//生日验证
}
return "";
}
/// <summary>
/// 获取待验证身份证的图层
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tspCombx_unck_SFZ_SelectedIndexChanged(object sender, EventArgs e)
{
if(tspCombx_unck_SFZ.SelectedIndex==-1)
{
return;
}
try
{
pcheckSFZ_FtLy = listFLayerZHQ_Check[tspCombx_unck_SFZ.SelectedIndex];
}
catch (System.Exception ex)
{
Console.WriteLine(ex.ToString());
}
int indexField= pcheckSFZ_FtLy.FeatureClass.FindField("sfzh");
if (indexField==-1)
{
MessageBox.Show("所选择的图层没有"sfzh"字段,请重新选择!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
tspCombx_unck_SFZ.SelectedItem = null;
pcheckSFZ_FtLy = null;
}
}
private string StrSaveXMLPath = null;
private void MainForm_Load(object sender, EventArgs e)
{
//barButtonItem1.Enabled = false;
//barButtonItem3.Enabled = false;
//barButtonItem5.Enabled = false;
//barButtonItem6.Enabled = false;
//barButtonItem7.Enabled = false;
//barButtonItem8.Enabled = false;
int winWidth = Convert.ToInt32(XmlCls.ReadXml(StrSaveXMLPath, "winWidth"));
int winHeight= Convert.ToInt32(XmlCls.ReadXml(StrSaveXMLPath, "winHeight"));
this.Width = winWidth;
this.Height = winHeight;
this.Location = new System.Drawing.Point(Convert.ToInt32(XmlCls.ReadXml(StrSaveXMLPath, "LocationX")), Convert.ToInt32(XmlCls.ReadXml(StrSaveXMLPath, "LocationY")));
bool IsMaxShowMainForn= Convert.ToBoolean(XmlCls.ReadXml(StrSaveXMLPath, "IsMaxShowMainForn"));
if(IsMaxShowMainForn==true)
{
this.WindowState = FormWindowState.Maximized;
}
else if (IsMaxShowMainForn == false)
{
this.WindowState = FormWindowState.Normal;
}
bool isShowAll= Convert.ToBoolean(XmlCls.ReadXml(StrSaveXMLPath, "showAll"));
bool isNotShowAll = Convert.ToBoolean(XmlCls.ReadXml(StrSaveXMLPath, "NotshowAll"));
bool isShowZHQ_Only = Convert.ToBoolean(XmlCls.ReadXml(StrSaveXMLPath, "showZHQ_Only"));
if (isShowAll == true)
{
xtraTabPage1.PageVisible = true;
xtraTabPage2.PageVisible = true;
xtraTabPage3.PageVisible = true;
xtraTabPage4.PageVisible = true;
xtraTabPage5.PageVisible = true;
xtraTabControl1.Show();
}
else
{
if (isNotShowAll == true)
{
xtraTabPage1.PageVisible = false;
xtraTabPage2.PageVisible = false;
xtraTabPage3.PageVisible = false;
xtraTabPage4.PageVisible = false;
xtraTabPage5.PageVisible = false;
xtraTabControl1.Hide();
}
else
{
if (isShowZHQ_Only == true)
{
xtraTabPage1.PageVisible = true;
xtraTabPage2.PageVisible = false;
xtraTabPage3.PageVisible = false;
xtraTabPage4.PageVisible = false;
xtraTabPage5.PageVisible = false;
xtraTabControl1.Show();
}
else if (isShowZHQ_Only == false)
{
xtraTabPage1.PageVisible = false;
xtraTabPage2.PageVisible = false;
xtraTabPage3.PageVisible = false;
xtraTabPage4.PageVisible = false;
xtraTabPage5.PageVisible = false;
xtraTabControl1.Hide();
}
}
}
}
private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
{
try
{
tlSpStLb.Text = " 选项:" + xtraTabControl1.SelectedTabPage.Text;
}
catch (System.Exception ex)
{
tlSpStLb.Text = "";
}
}
private void xtraTabControl1_CloseButtonClick(object sender, EventArgs e)
{
//xtraTabControl1.se
//xtraTabControl1.ShowHeaderFocus = DevExpress.Utils.DefaultBoolean.False;
//xtraTabControl1.SelectedTabPage.Hide();
//xtraTabControl1.SelectedTabPage.PageVisible = true;
//xtraTabControl1.SelectedTabPage.Dispose();
ClosePageButtonEventArgs arg=e as ClosePageButtonEventArgs;
(arg.Page as XtraTabPage).PageVisible = false;
if (xtraTabPage1.PageVisible == false&& xtraTabPage2.PageVisible == false&& xtraTabPage3.PageVisible == false && xtraTabPage4.PageVisible == false && xtraTabPage5.PageVisible == false)
{
xtraTabControl1.Hide();
}
}
private void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage1.PageVisible = true;
xtraTabControl1.SelectedTabPage = xtraTabPage1;
}
private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage2.PageVisible = true;
xtraTabControl1.SelectedTabPage = xtraTabPage2;
}
private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage3.PageVisible = true;
xtraTabControl1.SelectedTabPage = xtraTabPage3;
}
private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage4.PageVisible = true;
xtraTabControl1.SelectedTabPage = xtraTabPage4;
}
private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage5.PageVisible = true;
xtraTabControl1.SelectedTabPage = xtraTabPage5;
}
private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabControl1.Show();
xtraTabPage1.PageVisible = true;
xtraTabPage2.PageVisible = true;
xtraTabPage3.PageVisible = true;
xtraTabPage4.PageVisible = true;
xtraTabPage5.PageVisible = true;
}
private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
xtraTabPage1.PageVisible = false;
xtraTabPage2.PageVisible = false;
xtraTabPage3.PageVisible = false;
xtraTabPage4.PageVisible = false;
xtraTabPage5.PageVisible = false;
xtraTabControl1.Hide();
}
/// <summary>
/// 关于
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
FormAbout pFormAbout = new FormAbout();
pFormAbout.ShowDialog();
}
/// <summary>
/// 按错误条目统计
/// </summary>
/// <param name="culTempFtLy"></param>
/// <param name="strSQL"></param>
/// <returns></returns>
private int JCJGTJByTM_Func(IFeatureLayer culTempFtLy, string strSQL)
{
int defaultCount = 0;
ITable table = culTempFtLy.FeatureClass as ITable;
IQueryFilter pQueryFilter = (IQueryFilter)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("FDFEBD95-ED75-11D0-9A95-080009EC734B")));
//IQueryFilter pQueryFilter = new QueryFilter();
pQueryFilter.WhereClause = strSQL;
// pQueryFilter.SubFields = caculFieldName;
ICursor cursor = table.Update(pQueryFilter, false);
ESRI.ArcGIS.Geodatabase.IRow Row = cursor.NextRow();
if (Row == null)
return 0;
int fieldCheckResult = Row.Fields.FindField("CheckResult");
int maxCount = table.RowCount(pQueryFilter);
tlSProgressBar.Minimum = 0;
tlSProgressBar.Maximum = maxCount;
for (int i = 0; i < maxCount; i++)
{
tlSProgressBar.Value = i;
string strCheckResult = Row.Value[fieldCheckResult].ToString();
if (!String.IsNullOrEmpty(strCheckResult))
{
strCheckResult = strCheckResult.Replace("cjybz不能为空;","");
strCheckResult = strCheckResult.Replace("fhr不能为空;", "");
strCheckResult = strCheckResult.Replace("shr不能为空;", "");
if (strCheckResult!=";")
{
defaultCount++;
}
}
Row = cursor.NextRow();
}
return defaultCount;
}
/// <summary>
/// 转换前检查-检查结果统计-按错误条目统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_unck_JCJGTJByTM_Click(object sender, EventArgs e)
{
if (listFLayerZHQ_Check == null)
{
MessageBox.Show("没有数据可统计!请先打开数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "(Excel文件)|*.xlsx";
sfd.Title = "检查结果统计-按错误条目统计结果";
sfd.FileName = System.IO.Path.GetFileNameWithoutExtension(strZHQSelGDBPath) + "_" + "按错误条目统计结果";
sfd.AddExtension = true;
if (sfd.ShowDialog() == DialogResult.OK)
{
string strSavePath = sfd.FileName;
try { File.Delete(strSavePath); }
catch {
MessageBox.Show("文件存在并且被占用","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
List<StaticByTM_ModelCls> listStaticTMS = new List<StaticByTM_ModelCls>();
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("执行 检查结果统计-按错误条目");
for (int i = 0; i < listFLayerZHQ_Check.Count; i++)
{
StaticByTM_ModelCls tempModel = new StaticByTM_ModelCls();
IFeatureLayer culTempFtLy = listFLayerZHQ_Check[i];
string strculFtLyName = culTempFtLy.FeatureClass.AliasName;
tempModel.strLX = strculFtLyName;
splashScreenManager1.SetWaitFormDescription("请耐心等待... 统计 " + strculFtLyName + " 中");
tempModel.countTMS = culTempFtLy.FeatureClass.FeatureCount(null);
listBox_unck_FtLy.SelectedValue = strculFtLyName;
listBox_unck_FtLy.Refresh();
int kk = culTempFtLy.FeatureClass.FindField("CheckResult");
if (kk != -1)
{
tempModel.countCWTMS = JCJGTJByTM_Func(culTempFtLy, null);
}
tempModel.BL = (Convert.ToDouble(tempModel.countCWTMS) / tempModel.countTMS).ToString("P2");
listStaticTMS.Add(tempModel);
}
StaticByTM_ModelCls tempModelTotal = new StaticByTM_ModelCls();
for (int i = 0; i < listStaticTMS.Count; i++)
{
tempModelTotal.countTMS += listStaticTMS[i].countTMS;
tempModelTotal.countCWTMS += listStaticTMS[i].countCWTMS;
}
tempModelTotal.strLX = "合计";
tempModelTotal.BL = (Convert.ToDouble(tempModelTotal.countCWTMS) / tempModelTotal.countTMS).ToString("P2");
listStaticTMS.Add(tempModelTotal);
//写入Excel
using (var excel = new ExcelPackage(new FileInfo(strSavePath)))
{
//创建一个工作表
var ws = excel.Workbook.Worksheets.Add("Sheet1");
ws.Cells[1, 1].Value = "类型";
ws.Cells[1, 2].Value = "条目数";
ws.Cells[1, 3].Value = "属性错误条目数";
ws.Cells[1, 4].Value = "错误比例";
for (int i = 0; i < listStaticTMS.Count; i++)
{
ws.Cells[i + 2, 1].Value = listStaticTMS[i].strLX;
ws.Cells[i + 2, 2].Value = listStaticTMS[i].countTMS;
ws.Cells[i + 2, 3].Value = listStaticTMS[i].countCWTMS;
ws.Cells[i + 2, 4].Value = listStaticTMS[i].BL;
}
ws.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
ws.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
ws.Column(1).AutoFit();
ws.Column(2).AutoFit();
ws.Column(3).AutoFit();
ws.Column(4).AutoFit();
//保存表格信息
excel.Save();
}
splashScreenManager1.CloseWaitForm();
tlSProgressBar.Value = 0;
try
{
DialogResult dirlt = MessageBox.Show("处理完成,是否打开?", "提示信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dirlt == DialogResult.OK)
{
Process.Start(strSavePath);
}
}
catch (System.Exception ex)
{}
}
}
/// <summary>
/// 系统设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Settings_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
FormSettings tempForm = new FormSettings();
tempForm.getSkinDel = getSkinDel;
tempForm.ShowDialog();
}
/// <summary>
/// 帮助文档
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_OpenHelpDoc_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
try
{
Process.Start(Directory.GetCurrentDirectory() + "\帮助文档.pdf");
}
catch (System.Exception ex)
{
}
}
/// <summary>
/// 转换前检查项设置
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_CheckItemSet_Click(object sender, EventArgs e)
{
FormCheckSet formCheckSet = new FormCheckSet();
formCheckSet.ShowDialog();
}
private void tsBTN_TownManege_Click(object sender, EventArgs e)
{
FormTownSet formTownSet = new FormTownSet();
formTownSet.ShowDialog();
}
/// <summary>
/// 右键执行单独检查
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listBox_unck_FtLy_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
int posindex = listBox_unck_FtLy.IndexFromPoint(new System.Drawing.Point(e.X, e.Y));
listBox_unck_FtLy.ContextMenuStrip = null;
if (posindex>=0&&posindex<listBox_unck_FtLy.Items.Count)
{
listBox_unck_FtLy.SelectedIndex = posindex;
contextMenuStrip1.Show(listBox_unck_FtLy, new System.Drawing.Point(e.X, e.Y));
}
}
}
IFeatureLayer culContextFtLy = null;
private void listBox_unck_FtLy_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
culContextFtLy = listFLayerZHQ_Check[listBox_unck_FtLy.SelectedIndex];
}
catch (System.Exception ex)
{
}
}
private void 单独检查该项ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (culContextFtLy==null)
{
return;
}
unck_ExcuteFunc(culContextFtLy, true);
}
private void ts_BTNCalcuSet_Click(object sender, EventArgs e)
{
}
}
欢迎交流:18798835893