Пример #1
0
        private void lswDK_SelectedIndexChanged(object sender, EventArgs e)
        {
            lswGDDK.Items.Clear();
            //dgvGDDK.DataSource = null;
            if (lswDK.SelectedItems.Count > 0)
            {
                nzydk = (NZYDK)lswDK.SelectedItems[0].Tag;
                DataOperation.MySQLGDRead(nzydk);

                //dgvGDDK.DataSource = nzydk.Gddk;
                //dgvGDDK.Columns[0].DataPropertyName = "dzjgh";
                //dgvGDDK.Columns[1].DataPropertyName = "xmmc";
                //dgvGDDK.Columns[2].DataPropertyName = "gdmj";
                //dgvGDDK.Columns[3].DataPropertyName = "dgmj";
                foreach (GDDK gddk in nzydk.Gddk)
                {
                    string[]     str  = new string[] { gddk.Dzjgh, gddk.Xmmc, gddk.Gdmj.ToString(), gddk.Dgmj.ToString() };
                    ListViewItem item = new ListViewItem(str);
                    item.Tag = gddk;

                    //DataGridViewRow row = new DataGridViewRow();


                    lswGDDK.Items.Add(item);
                }
                cbxCZFS.SelectedIndex   = 1;
                cbxCZFS.SelectedIndex   = 0;
                comboBox1.SelectedIndex = nzydk.Sx;
                tbxBZ.Text        = nzydk.Bz;
                lblCurrentDk.Text = nzydk.Dkmc;
            }
        }
Пример #2
0
        public static void MySQLDKRead(Data data)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append(@"SELECT * FROM info.dkqk where NZY='");
            sql.Append(data.Guid);
            sql.Append(@"'");
            //MySqlParameter[] pt = new MySqlParameter[] {
            //    new MySqlParameter("@NZY", data.Guid)
            //};

            MySqlDataReader reader;

            try {
                reader  = Helper.MySqlHelper.ExecuteReader(Method.Conntection(), CommandType.Text, sql.ToString(), null);
                data.Dk = new List <NZYDK>();
                while (reader.Read())
                {
                    NZYDK nzydk = new NZYDK();
                    nzydk.Dkmc = reader.GetString("DKMC");
                    nzydk.Guid = reader.GetGuid("GUID");
                    nzydk.Dkmj = reader.GetDecimal("DKMJ");
                    nzydk.Bz   = (reader.IsDBNull(5)) ? "" : reader.GetString("BZ");

                    data.Dk.Add(nzydk);
                }
            } catch (Exception ex) {
                if (ex.Message.Contains("Timeout"))
                {
                    MySQLDKRead(data);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 盘活批次导出生成行
        /// </summary>
        /// <param name="data">源数据</param>
        /// <param name="index">序号</param>
        /// <param name="dt">表</param>
        /// <returns></returns>
        private static DataRow DataRowPHInitialize(Data data, NZYDK nzydk, GDDK gddk, int index, DataTable dt)
        {
            DataRow row = dt.NewRow();//读至供地数据开始写入行

            row[0]  = index;
            row[1]  = "海宁市";
            row[3]  = data.GetArea() * 15;
            row[4]  = data.Nzy;
            row[5]  = nzydk.Dkmc;
            row[6]  = "是";
            row[7]  = nzydk.Dkmj * 15;
            row[10] = nzydk.SYMJ() * 15;//地块剩面积
            if (gddk != null)
            {
                row[11] = gddk.Dzjgh;
                row[12] = gddk.Xmmc;
                row[13] = gddk.Gdmj * 15;
                row[15] = gddk.Tdyt;
                row[14] = gddk.Tdzl;
            }
            else
            {
            }
            return(row);
        }
Пример #4
0
        /// <summary>
        /// 农转用地块写入数据库
        /// </summary>
        /// <param name="nzydk"></param>
        private static void NzydkToMySQL(Guid guid, NZYDK nzydk)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("insert into dkqk (");
            sql.Append("GUID,");
            sql.Append("NZY,");
            sql.Append("DKMC,");
            sql.Append("DKMJ,");
            sql.Append("BZ");
            sql.Append(") values (");
            sql.Append("@GUID,");
            sql.Append("@NZY,");
            sql.Append("@DKMC,");
            sql.Append("@DKMJ,");
            sql.Append("@BZ)");
            MySqlParameter[] pt = new MySqlParameter[] {
                new MySqlParameter("@GUID", nzydk.Guid),
                new MySqlParameter("@NZY", guid),
                new MySqlParameter("@DKMC", nzydk.Dkmc),
                new MySqlParameter("@DKMJ", nzydk.Dkmj),
                new MySqlParameter("@BZ", nzydk.Bz)
            };
            try {
                Helper.MySqlHelper.ExecuteNonQuery(Method.Conntection(), CommandType.Text, sql.ToString(), pt);
            } catch (Exception) {
                throw;
            }
        }
Пример #5
0
        public static void UpdateCZFS(NZYDK nzydk)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("SELECT count(*) from czfs where GUID=@GUID");
            MySqlParameter[] pt = new MySqlParameter[] { new MySqlParameter("@GUID", nzydk.Guid) };
            int exist           = Int32.Parse(Helper.MySqlHelper.ExecuteScalar(Method.Conntection(), CommandType.Text, sql.ToString(), pt).ToString());

            if (exist == 0)
            {
                sql = new StringBuilder();
                sql.Append(@"INSERT INTO `info`.`czfs` (`");
                for (int i = 0; i < nzydk.Czfs.Length; i++)
                {
                    sql.Append(i + 20);
                    sql.Append("`, `");
                }
                sql.Append(nzydk.Czfs.Length + 20);
                sql.Append("`, `GUID`");
                sql.Append(") VALUES('");
                for (int i = 0; i < nzydk.Czfs.Length; i++)
                {
                    sql.Append(nzydk.Czfs[i]);
                    sql.Append("', '");
                }
                sql.Append(nzydk.Sx);
                sql.Append("','");
                sql.Append(nzydk.Guid);
                sql.Append("')");
            }
            else
            {
                sql = new StringBuilder();
                sql.Append("UPDATE `info`.`czfs` SET ");
                for (int i = 0; i < nzydk.Czfs.Length; i++)
                {
                    sql.Append("`");
                    sql.Append(i + 20);
                    sql.Append("`= '");
                    sql.Append(nzydk.Czfs[i]);
                    sql.Append("', ");
                }
                sql.Append("`");
                sql.Append(nzydk.Czfs.Length + 20);
                sql.Append("`= '");
                sql.Append(nzydk.Sx);
                sql.Append("' where( ");
                sql.Append("`GUID`= '");
                sql.Append(nzydk.Guid);
                sql.Append("')");
            }

            try {
                Helper.MySqlHelper.ExecuteNonQuery(Method.Conntection(), CommandType.Text, sql.ToString(), null);
            } catch (MySqlException ex) {
                throw ex;
            }
        }
Пример #6
0
        public static void MySQLGDRead(NZYDK nzydk)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append(@"SELECT * FROM info.gdqk where DKGUID='");
            sql.Append(nzydk.Guid);
            sql.Append(@"'");
            //MySqlParameter[] pt = new MySqlParameter[] {
            //    new MySqlParameter("@NZY", data.Guid)
            //};
            MySqlDataReader reader;

            try {
                reader = Helper.MySqlHelper.ExecuteReader(Method.Conntection(), CommandType.Text, sql.ToString(), null);
            } catch (Exception) {
                throw;
            }
            nzydk.Gddk = new List <GDDK>();
            while (reader.Read())
            {
                GDDK gddk = new GDDK();
                gddk.Guid  = nzydk.Guid;
                gddk.Dzjgh = reader.GetString("DZJGH");
                gddk.Gdmj  = reader.GetDecimal("GDMJ");
                gddk.Xmmc  = reader.GetString("YDDW");
                gddk.Dgmj  = reader.GetDecimal("DG");
                gddk.Bz    = (reader.IsDBNull(6)) ? "" : reader.GetString("BZ");
                gddk.Id    = reader.GetInt32("ID");
                gddk.Tdyt  = (reader.IsDBNull(4)) ? "":reader.GetString("TDYT");
                gddk.Tdzl  = (reader.IsDBNull(8)) ? "":reader.GetString("TDZL");
                nzydk.Gddk.Add(gddk);
            }


            sql = new StringBuilder();
            sql.Append(@"SELECT * FROM info.czfs where GUID='");
            sql.Append(nzydk.Guid);
            sql.Append(@"'");

            try {
                reader = Helper.MySqlHelper.ExecuteReader(Method.Conntection(), CommandType.Text, sql.ToString(), null);
            } catch (Exception) {
                throw;
            }
            while (reader.Read())
            {
                for (int i = 0; i < nzydk.Czfs.Length; i++)
                {
                    nzydk.Czfs[i] = reader.GetDecimal((i + 20).ToString());
                }
                nzydk.Sx = reader.GetInt32(34.ToString());
            }
        }
Пример #7
0
        /// <summary>
        /// 生成行
        /// </summary>
        /// <param name="data">源数据</param>
        /// <param name="index">序号</param>
        /// <param name="dt">表</param>
        /// <returns></returns>
        private static DataRow DataRowInitialize(Data data, NZYDK nzydk, GDDK gddk, int index, DataTable dt)
        {
            DataRow row = dt.NewRow();//读至供地数据开始写入行

            row[0]  = index;
            row[1]  = "海宁市";
            row[2]  = data.Nzy;
            row[3]  = ChangePCMC(data.Nzy);
            row[4]  = data.Pzwh;
            row[5]  = data.Pzrq.ToString("yyyy/M/d");
            row[6]  = nzydk.Dkmc;
            row[7]  = nzydk.Dkmj * 15;
            row[8]  = "是";
            row[14] = nzydk.SYMJ() * 15;//地块剩余面积
            row[36] = "周青峰";
            row[37] = "0573-87289249";
            if (gddk != null)
            {
                row[9]  = gddk.Dzjgh;
                row[10] = gddk.Xmmc;
                row[11] = gddk.Gdmj * 15;
                row[12] = gddk.Tdyt;

                row[13] = data.GetSYMJ() * 15;//批次剩余面积

                row[38] = nzydk.Bz + @"|" + gddk.Bz;
            }
            else
            {
                row[13] = data.GetSYMJ() * 15;//批次剩余面积

                row[38] = nzydk.Bz;
            }

            for (int i = 0; i < 14; i++)
            {
                row[i + 19] = nzydk.Czfs[i] * 15;
            }
            if (nzydk.Sx != 0)
            {
                row[32 + nzydk.Sx] = "√";
            }

            return(row);
        }
Пример #8
0
        public static void UpdateNzydk(NZYDK nzydk)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update ");
            sql.Append("dkqk");
            sql.Append(" set ");
            sql.Append("BZ=@bz ");
            sql.Append("where ");
            sql.Append("GUID= @GUID ");
            MySqlParameter[] pt = new MySqlParameter[] {
                new MySqlParameter("@GUID", nzydk.Guid),
                new MySqlParameter("@BZ", nzydk.Bz)
            };

            try {
                Helper.MySqlHelper.ExecuteNonQuery(Method.Conntection(), CommandType.Text, sql.ToString(), pt);
            } catch (MySqlException ex) {
                throw ex;
            }
        }
Пример #9
0
        private static List <Data> MySQLViewRead()
        {
            //Hashtable datas = new Hashtable();
            List <Data>   datas = new List <Data>();
            StringBuilder sql   = new StringBuilder();

            sql.Append(@"SELECT * FROM info.nzy_view;");
            MySqlDataReader reader;

            try {
                reader = Helper.MySqlHelper.ExecuteReader(Method.Conntection(), CommandType.Text, sql.ToString(), null);
            } catch (Exception ex) {
                throw new Exception(ex.Message);
            }
            while (reader.Read())
            {
                ///初始化DATA
                Data data = new Data();
                ///读取批次GUID
                Guid guid        = reader.GetGuid("GUID");
                bool unExistData = true;//判断是是否存在该批次

                foreach (Data origin in datas)
                {
                    if (origin.Guid == guid)
                    {
                        data        = origin;
                        unExistData = false;
                        break;
                    }
                }



                if (unExistData)  //如果该批次存在
                {
                    data.Guid = guid;
                    data.Nzy  = reader.GetString("PCMC");   //批次名称
                    data.Pzwh = reader.GetString("PZWH");   //批准文号
                    data.Pzrq = reader.GetDateTime("PZRQ"); //批准日期
                    data.Pzmj = reader.GetDecimal("PZMJ");  //批准面积
                    datas.Add(data);
                }


                string dkmc = reader.GetString("DKMC");//地块名称
                //NZYDK nzydk = data.IsExist(dkmc);//是否已存在该地块
                NZYDK nzydk   = new NZYDK();
                bool  unExist = true;//判断是否已存在该 农转用地块
                foreach (NZYDK new_nzydk in data.Dk)
                {
                    if (new_nzydk.Dkmc == dkmc)
                    {
                        nzydk   = new_nzydk;
                        unExist = false;
                    }
                }
                if (unExist)                                //如果不存在
                {
                    nzydk.Guid = reader.GetGuid("DKGUID");  //农转用地块GUID
                    nzydk.Dkmc = reader.GetString("DKMC");  //地块名称
                    nzydk.Dkmj = reader.GetDecimal("DKMJ"); //地块面积
                    ///读取处置方式内容20-34列
                    for (int i = 20; i < 34; i++)
                    {
                        nzydk.Czfs[i - 20] = (reader.IsDBNull(i - 4)) ? 0 : reader.GetDecimal(i.ToString());
                    }
                    nzydk.Sx = (reader.IsDBNull(30)) ? 0 : reader.GetInt32("34");
                    data.Dk.Add(nzydk);
                }
                string yddw = (reader.IsDBNull(11)) ? "" : reader.GetString("YDDW"); //获取用地单位,如果不存在则为空
                if (!string.IsNullOrEmpty(yddw))                                     //始果用地单位存在
                {
                    GDDK gddk = new GDDK();
                    gddk.Xmmc  = yddw;
                    gddk.Dzjgh = (reader.IsDBNull(10)) ? "" : reader.GetString("DZJGH"); //获取电子监管号,如果不存在则为空
                    gddk.Gdmj  = reader.GetDecimal("GDMJ");                              //获取供地面积
                    gddk.Dgmj  = reader.GetDecimal("DG");                                //获取带供面积
                    gddk.Tdzl  = (reader.IsDBNull(31)) ? "" : reader.GetString("TDZL");  //土地坐落
                    gddk.Tdyt  = (reader.IsDBNull(13)) ? "" : reader.GetString("TDYT");  //获取电子监管号,如果不存在则为空
                    gddk.Bz    = ((reader.IsDBNull(8)) ? "" : reader.GetString("DKBZ"))
                                 + "|" +
                                 ((reader.IsDBNull(15)) ? "" : reader.GetString("BZ"));//获取备注,如果不存在则为空
                    nzydk.Gddk.Add(gddk);
                }
            }


            //List<Data> result = new List<Data>();
            //foreach (Data data in datas.Values) {
            //    result.Add(data);
            //}

            return(datas);
        }
Пример #10
0
        private static List <Data> DatatableRead(DataTable dt)
        {
            List <Data> result = new List <Data>();
            Data        data   = new Data();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr   = dt.Rows[i];
                string  pzwh = dr["批准文号"].ToString();
                #region 如果不存在该批准文号并且该栏不为空
                if (!IsExist(result, pzwh) && !String.IsNullOrWhiteSpace(pzwh))
                {
                    data = new Data(pzwh);
                    //data.Pzwh = pzwh;
                    data.Nzy = dr["批次名称"].ToString();
                    try {
                        DateTime pzrq = new DateTime();
                        if (DateTime.TryParse(dr["批准时间"].ToString(), out pzrq))
                        {
                            data.Pzrq = pzrq;
                        }
                    } catch (Exception) {
                        throw new Exception("wrong datetime");
                    }
                    result.Add(data);
                }
                #endregion


                NZYDK  nzydk = new NZYDK();
                string dkmc  = dr["地块名称"].ToString();
                #region 如果该栏不为空
                if (!String.IsNullOrWhiteSpace(dkmc))
                {
                    nzydk = data.IsExist(dkmc);
                    //nzydk.Dkmc = dkmc;
                    Decimal dkmj = new decimal();
                    try {
                        if (Decimal.TryParse(dr["地块面积"].ToString(), out dkmj))
                        {
                            nzydk.Dkmj = dkmj;
                        }
                    } catch (Exception) {
                        throw new Exception(dkmc);
                    }
                    //data.Dk.Add(nzydk);
                }
                #endregion

                if (!string.IsNullOrEmpty(dr["出让面积"].ToString()))
                {
                    GDDK gddk = new GDDK();
                    gddk.Dzjgh = dr["供地文号"].ToString();
                    gddk.Xmmc  = dr["用地单位"].ToString();

                    gddk.Gdmj = Decimal.Parse(dr["出让面积"].ToString());
                    if (string.IsNullOrWhiteSpace(dr["带供"].ToString()))
                    {
                        gddk.Dgmj = 0;
                    }
                    else
                    {
                        gddk.Dgmj = Decimal.Parse(dr["带供"].ToString());
                    }
                    gddk.Bz = dr["备注"].ToString();
                    nzydk.Gddk.Add(gddk);
                }
            }


            return(result);
        }