You are on page 1of 3

#region Tha t cp GCN (B-HS): 16

case 16:
{
if (cb_Xa.SelectedIndex != -1 && cb_Xa.SelectedIndex !
= 0)
{
dt_Maxa = this.GetTable("select maxa from xa where
xaid=" + int.Parse(cb_Xa.SelectedValue.ToString()));
string maxa = "";
if (dt_Maxa.Rows.Count > 0) maxa = dt_Maxa.Rows[0]
["maxa"].ToString();
N'U') IS NOT NULL " +

string SDE = "IF OBJECT_ID(N'LIS.dbo.BangKT1',


" DROP TABLE LIS.dbo.BangKT1";
this.Exe(Connect, SDE);

9.3

//kim tra c bng SDE ?


if (radioGroup_ArcGIS.SelectedIndex == 0) //ArcGIS
{

name LIKE 'TD_" + maxa + "'";

string s = "SELECT * FROM sys.Tables WHERE

DataTable dt_temp = GetTableSDE(s);


if (dt_temp.Rows.Count > 0)
{
SDE = "select DISTINCT
SoHieuToBanDo*10000+SoThuTuThua as keyword," +
"
SoHieuToBanDo,SoThuTuThua,DienTich,KyHieuMucDichSuDung, TenChu into
LIS.dbo.BangKT1 " +
" from sde.TD_" + maxa;
this.Exe(ConnectSDE, SDE);
}
else
{
MessageBox.Show("Khng c bn " +
cb_Xa.Text + ". Xin vui lng chn phin bn ArcGIS", "Li",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
else //ArcGIS 10.1
{
string str_TD = "";
//Lu :
//Cc x cha o c cp i t NN th lu
CSDL vo TDCU,
//Cc x o mi th lu vo TD
string str_Xa =
MaXa(cb_Xa.SelectedValue.ToString());
if (str_Xa == "30646" || str_Xa == "30652" ||
str_Xa == "30655" || str_Xa == "30658" || str_Xa == "30664" || str_Xa ==
"30670" || str_Xa == "30673" || str_Xa == "30676" || str_Xa == "30679")
str_TD = "TDCU";
else str_TD = "TD";
//Kim tra c Table sde.TD hoc sde.TDCu ?

string s = "SELECT * FROM sys.Tables WHERE

name LIKE '" + str_TD + "'";

DataTable dt_temp = GetTableSDE(s);


if (dt_temp.Rows.Count > 0)
{
SDE = "select DISTINCT
SoHieuToBanDo*10000+SoThuTuThua as keyword," +
"
SoHieuToBanDo,SoThuTuThua,DienTich,KyHieuMucDichSuDung, TenChu into
LIS.dbo.BangKT1 " +
" from sde." + str_TD +
" where sde." + str_TD + ".MaXa=" +
this.MaXa(cb_Xa.SelectedValue.ToString());
this.Exe(ConnectSDE, SDE);
}
else
{
MessageBox.Show("Khng c bn " +
cb_Xa.Text + ". Xin vui lng chn phin bn ArcGIS", "Li",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
N'U') IS NOT NULL " +

string LIS = "IF OBJECT_ID(N'LIS.dbo.BangKT2',


" DROP TABLE LIS.dbo.BangKT2";
this.Exe(Connect, LIS);

LIS = "select DISTINCT


ThuaDat.SoHieuToBanDo*10000+ThuaDat.SoThuTuThua as keyword, " +
" ThuaDat.SoHieuToBanDo as SoHieuToBanDo_GCN,"
+
" ThuaDat.SoThuTuThua as SoThuTuThua_GCN, " +
"ThuaDat.DienTich as DienTich_GCN," +
" ThuaDat.MucDichSuDungGhep as
MucDichSuDungGhep_GCN, " +
" Nguoi.HoTen as HoTen_GCN, " +
" GiayChungNhan.SoHieuGiayChungNhan " +
" INTO LIS.dbo.BangKT2 " +
" from ThuaDat inner join DangKyThua on
ThuaDat.ThuaDatId=DangKyThua.ThuaDatId " +
" inner join GiayChungNhan on
DangKyThua.GiayChungNhanId=GiayChungNhan.GiayChungNhanId " +
" inner join Nguoi on
DangKyThua.NguoiId=Nguoi.NguoiId " +
" Inner join LoaiDoiTuong L On L.LoaiDoiTuongId
= Nguoi.LoaiDoiTuongId " +
" where ThuaDat.TrangThai=1 and " +
" DangKyThua.TrangThai=1 and " +
" GiayChungNhan.TrangThai=1 and " +
" Nguoi.TrangThai=1 and " +
" L.TrangThai=1 and " +
" ThuaDat.XaID=" +
int.Parse(cb_Xa.SelectedValue.ToString());
if (chk_All.Checked == false) //Kim tra xem t
chc hay h gia nh c nhn

if (radioGroup_ToChuc.SelectedIndex == 0)//t

t chc

LIS = LIS + " and


(L.KyHieuLoaiDoiTuong<>'GDC') "; //H gia nh, c nhn;
else //c nhn
LIS = LIS + " and
(L.KyHieuLoaiDoiTuong='GDC') "; ;
}
this.Exe(Connect, LIS)
str = " select DISTINCT
BangKT1.keyword,BangKT1.SoHieuToBanDo,BangKT1.SoThuTuThua," +
" round(BangKT1.DienTich,1)as
DienTich,BangKT1.KyHieuMucDichSuDung,BangKT2.HoTen_GCN,
BangKT2.SoHieuGiayChungNhan" +
" from BangKT1,BangKT2 WHERE " +
" BangKT1.keyword =BangKT2.keyword and " +
" BangKT1.KyHieuMucDichSuDung NOT LIKE 'DTL'
and " +
" BangKT1.KyHieuMucDichSuDung NOT LIKE 'DGT'"
+
" order by BangKT1.SoHieuToBanDo,
BangKT1.SoThuTuThua";
//loi thm: sng, BCS, i ni
//nu t t chc: AND b ra : ODT, ONT, LNK, LUC,
dt = this.GetTable(str);
if (dt.Rows.Count > 0)
{
this.Load_Grid(str);
}
else
{
MessageBox.Show("Khng c tha no cha cp
GCN", "Thng bo", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
else MessageBox.Show("Chn n v hnh chnh cp x",
"Thng bo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
break;
}
#endregion