public terrarecord ReadTerra(string itemid) { terrarecord item = new terrarecord(); string selectsql = String.Concat("SELECT * FROM terra WHERE TId ='", itemid, "'"); MySqlConnection con = new MySqlConnection(ConnectionString); con.Open(); MySqlCommand command = new MySqlCommand(selectsql, con); MySqlDataReader reader = command.ExecuteReader(); DataTable result = new DataTable(); result.Load(reader); item.Tid = Convert.ToInt32(itemid); item.Tcity = result.Rows[0][1].ToString(); item.Tdistrict_region = result.Rows[0][2].ToString(); item.Tstreet = result.Rows[0][3].ToString(); try { item.Thaggle = Convert.ToInt32(result.Rows[0][4]); } catch { item.Thaggle = 0; } item.Tproperty_type = result.Rows[0][5].ToString(); item.Ttitle = result.Rows[0][6].ToString(); item.Tdescription_detail = result.Rows[0][7].ToString(); item.Twater_supply = result.Rows[0][8].ToString(); item.Tgas_supply = result.Rows[0][9].ToString(); item.Tcondition2 = result.Rows[0][10].ToString(); item.Tsewerage = result.Rows[0][11].ToString(); try { item.Tdistance_to_city = Convert.ToDouble(result.Rows[0][12]); } catch { item.Tdistance_to_city = 0; } item.Tdescription_short = result.Rows[0][13].ToString(); try { item.Tfence = Convert.ToInt32(result.Rows[0][14]); } catch { item.Tfence = 0; } try { item.Tprice = Convert.ToDouble(result.Rows[0][15]); } catch { item.Tprice = 0; } try { item.Tground_area = Convert.ToDouble(result.Rows[0][16]); } catch { item.Tground_area = 0; } item.Tnote = result.Rows[0][17].ToString(); item.Tsite_space = result.Rows[0][18].ToString(); item.Touthhouse = result.Rows[0][19].ToString(); try { item.Telectricity = Convert.ToInt32(result.Rows[0][20]); } catch { item.Telectricity = 0; } item.Tpurpose_land = result.Rows[0][21].ToString(); try { item.Tis_special_proposal = Convert.ToInt32(result.Rows[0][22]); } catch { item.Tis_special_proposal = 0; } item.Tagent_code = result.Rows[0][23].ToString(); try { item.Tdate_add = Convert.ToDateTime(result.Rows[0][24]); } catch { item.Tdate_add = DateTime.Now; } try { item.Tdate_change = Convert.ToDateTime(result.Rows[0][25]); } catch { item.Tdate_change = DateTime.Now; } item.Tstatus = result.Rows[0][26].ToString(); item.Toperation = result.Rows[0][27].ToString(); item.Tphoto = result.Rows[0][28].ToString(); item.Twidth = result.Rows[0][29].ToString(); item.Theight = result.Rows[0][30].ToString(); try { item.Ttrade_date = Convert.ToDateTime(result.Rows[0][31]); } catch { item.Ttrade_date = DateTime.Now; } try { item.Ttrade_price = Convert.ToDouble(result.Rows[0][32]); } catch { item.Ttrade_price = 0; } con.Close(); return(item); }
public void UpdateTerra(terrarecord item) { string updatesql = @"UPDATE realestate SET Tcity = @Tcity, Tdistrict_region = @Tdistrict_region, Tstreet = @Tstreet, Thaggle = @Thaggle, Tproperty_type = @Tproperty_type, Ttitle = @Ttitle, Tdescription_detail = @Tdescription_detail, Twater_supply = @Twater_supply, Tgas_supply = @Tgas_supply, Tcondition2 = @Tcondition2, Tsewerage = @Tsewerage, Tdistance_to_city = @Tdistance_to_city, Tdescription_short = @Tdescription_short, Tfence = @Tfence, Tprice = @Tprice, Tground_area = @Tground_area ,Tnote = @Tnote, Tsite_space = @Tsite_space, Touthhouse = @Touthouse, Telectricity = @Telectricity, Tpurpose_land = @Tpurpose_land, Tis_special_proposal = @Tis_special_proposal, Tagent_code = @Tagent_add, Tdate_add = @Tdate_add, Tdate_change = @Tdate_change, Tstatus = @Tstatus, Toperation = @Toperation, Tphoto = @Tphoto, Twidth = @Twidth, Theight = @Theight, Ttrade_date = @Ttrade_date, Ttrade_price = @Ttrade_price WHERE TId = @TId"; MySqlConnection con = new MySqlConnection(ConnectionString); con.Open(); MySqlCommand command = new MySqlCommand(updatesql, con); command.Parameters.AddWithValue("@TId", item.Tid); command.Parameters.AddWithValue("@Tcity", item.Tcity); command.Parameters.AddWithValue("@Tdistrict_region", item.Tdistrict_region); command.Parameters.AddWithValue("@Tstreet", item.Tstreet); command.Parameters.AddWithValue("@Thaggle", item.Thaggle); command.Parameters.AddWithValue("@Tproperty_type", item.Tproperty_type); command.Parameters.AddWithValue("@Ttitle", item.Ttitle); command.Parameters.AddWithValue("@Tdescription_short", item.Tdescription_short); command.Parameters.AddWithValue("@Tdescription_detail", item.Tdescription_detail); command.Parameters.AddWithValue("@Twater_supply", item.Twater_supply); command.Parameters.AddWithValue("@Tgas_supply", item.Tgas_supply); command.Parameters.AddWithValue("@Tcondition2", item.Tcondition2); command.Parameters.AddWithValue("@Tsewerage", item.Tsewerage); command.Parameters.AddWithValue("@Tdistance_to_city", item.Tdistance_to_city); command.Parameters.AddWithValue("@Tfence", item.Tfence); command.Parameters.AddWithValue("@Tprice", item.Tprice); command.Parameters.AddWithValue("@Tground_area", item.Tground_area); command.Parameters.AddWithValue("@Tnote", item.Tnote); command.Parameters.AddWithValue("@Tsite_space", item.Tsite_space); command.Parameters.AddWithValue("@Touthhouse", item.Touthhouse); command.Parameters.AddWithValue("@Telectricity", item.Telectricity); command.Parameters.AddWithValue("@Tpurpose_land", item.Tpurpose_land); command.Parameters.AddWithValue("@Tis_special_proposal", item.Tis_special_proposal); command.Parameters.AddWithValue("@Tagent_code", item.Tagent_code); command.Parameters.AddWithValue("@Tdate_add", item.Tdate_add); command.Parameters.AddWithValue("@Tdate_change", item.Tdate_change); command.Parameters.AddWithValue("@Tstatus", item.Tstatus); command.Parameters.AddWithValue("@Toperation", item.Toperation); command.Parameters.AddWithValue("@Tphoto", item.Tphoto); command.Parameters.AddWithValue("@Twidth", item.Twidth); command.Parameters.AddWithValue("@Theight", item.Theight); command.Parameters.AddWithValue("@Ttrade_date", item.Ttrade_date); command.Parameters.AddWithValue("@Ttrade_price", item.Ttrade_price); command.ExecuteNonQuery(); int id = Convert.ToInt32(command.LastInsertedId); //add photo upload and comments insertion con.Close(); }
public void InsertNewTerra(terrarecord item) { string insertsql = String.Concat("INSERT INTO realestate(Tcity, Tdistrict_region, Tstreet, ", "Thaggle, Tproperty_type, Ttitle, Tdescription_detail,", "Twater_supply, Tgas_supply, Tcondition2, Tsewerage, Tdistance_to_city, Tdescription_short, Tfence, Tprice, "); insertsql = String.Concat(insertsql, "Tground_area ,Tnote, Tsite_space, Touthhouse, Telectricity, Tpurpose_land, Tis_special_proposal, ", "Tagent_code, Tdate_add, Tdate_change, Tstatus, Toperation, Tphoto, Twidth, Theight, Ttrade_date, Ttrade_price ) VALUES ("); insertsql = String.Concat(insertsql, "@Tcity, @Tdistrict_region, @Tstreet, @Thaggle, @Tproperty_type, @Ttitle, @Tdescription_detail, ", "@Twater_supply, @Tgas_supply, @Tcondition2, @Tsewerage, @Tdistance_to_city, @Tdescription_short, @Tfence, @Tprice"); insertsql = String.Concat(insertsql, "@Tground_area, @Tnote, @Tsite_space, @Touthhouse, @Telectricity, @Tpurpose_land, @Tis_special_proposal, ", "@Tagent_code, @Tdate_add, @Tdate_change, @Tstatus, @Toperation, @Tphoto, @Twidth, @Theight, @Ttrade_date, @Ttrade_price)"); MySqlConnection con = new MySqlConnection(ConnectionString); con.Open(); MySqlCommand command = new MySqlCommand(insertsql, con); command.Parameters.AddWithValue("@Tcity", item.Tcity); command.Parameters.AddWithValue("@Tdistrict_region", item.Tdistrict_region); command.Parameters.AddWithValue("@Tstreet", item.Tstreet); command.Parameters.AddWithValue("@Thaggle", item.Thaggle); command.Parameters.AddWithValue("@Tproperty_type", item.Tproperty_type); command.Parameters.AddWithValue("@Ttitle", item.Ttitle); command.Parameters.AddWithValue("@Tdescription_short", item.Tdescription_short); command.Parameters.AddWithValue("@Tdescription_detail", item.Tdescription_detail); command.Parameters.AddWithValue("@Twater_supply", item.Twater_supply); command.Parameters.AddWithValue("@Tgas_supply", item.Tgas_supply); command.Parameters.AddWithValue("@Tcondition2", item.Tcondition2); command.Parameters.AddWithValue("@Tsewerage", item.Tsewerage); command.Parameters.AddWithValue("@Tdistance_to_city", item.Tdistance_to_city); command.Parameters.AddWithValue("@Tfence", item.Tfence); command.Parameters.AddWithValue("@Tprice", item.Tprice); command.Parameters.AddWithValue("@Tground_area", item.Tground_area); command.Parameters.AddWithValue("@Tnote", item.Tnote); command.Parameters.AddWithValue("@Tsite_space", item.Tsite_space); command.Parameters.AddWithValue("@Touthhouse", item.Touthhouse); command.Parameters.AddWithValue("@Telectricity", item.Telectricity); command.Parameters.AddWithValue("@Tpurpose_land", item.Tpurpose_land); command.Parameters.AddWithValue("@Tis_special_proposal", item.Tis_special_proposal); command.Parameters.AddWithValue("@Tagent_code", item.Tagent_code); command.Parameters.AddWithValue("@Tdate_add", item.Tdate_add); command.Parameters.AddWithValue("@Tdate_change", item.Tdate_change); command.Parameters.AddWithValue("@Tstatus", item.Tstatus); command.Parameters.AddWithValue("@Toperation", item.Toperation); command.Parameters.AddWithValue("@Tphoto", item.Tphoto); command.Parameters.AddWithValue("@Twidth", item.Twidth); command.Parameters.AddWithValue("@Theight", item.Theight); command.Parameters.AddWithValue("@Ttrade_date", item.Ttrade_date); command.Parameters.AddWithValue("@Theight", item.Ttrade_price); command.ExecuteNonQuery(); int id = Convert.ToInt32(command.LastInsertedId); //add photo upload and comments insertion con.Close(); }
public terrarecord ReadTerra(string itemid) { terrarecord item = new terrarecord(); string selectsql = String.Concat("SELECT * FROM terra WHERE TId ='", itemid, "'"); MySqlConnection con = new MySqlConnection(ConnectionString); con.Open(); MySqlCommand command = new MySqlCommand(selectsql, con); MySqlDataReader reader = command.ExecuteReader(); DataTable result = new DataTable(); result.Load(reader); item.Tid = Convert.ToInt32(itemid); item.Tcity = result.Rows[0][1].ToString(); item.Tdistrict_region = result.Rows[0][2].ToString(); item.Tstreet = result.Rows[0][3].ToString(); try { item.Thaggle = Convert.ToInt32(result.Rows[0][4]); } catch { item.Thaggle = 0; } item.Tproperty_type = result.Rows[0][5].ToString(); item.Ttitle = result.Rows[0][6].ToString(); item.Tdescription_detail = result.Rows[0][7].ToString(); item.Twater_supply = result.Rows[0][8].ToString(); item.Tgas_supply = result.Rows[0][9].ToString(); item.Tcondition2 = result.Rows[0][10].ToString(); item.Tsewerage = result.Rows[0][11].ToString(); try { item.Tdistance_to_city = Convert.ToDouble(result.Rows[0][12]); } catch { item.Tdistance_to_city = 0; } item.Tdescription_short = result.Rows[0][13].ToString(); try { item.Tfence = Convert.ToInt32(result.Rows[0][14]); } catch { item.Tfence = 0; } try { item.Tprice = Convert.ToDouble(result.Rows[0][15]); } catch { item.Tprice = 0; } try { item.Tground_area = Convert.ToDouble(result.Rows[0][16]); } catch { item.Tground_area = 0; } item.Tnote = result.Rows[0][17].ToString(); item.Tsite_space = result.Rows[0][18].ToString(); item.Touthhouse = result.Rows[0][19].ToString(); try { item.Telectricity = Convert.ToInt32(result.Rows[0][20]); } catch { item.Telectricity = 0; } item.Tpurpose_land = result.Rows[0][21].ToString(); try { item.Tis_special_proposal = Convert.ToInt32(result.Rows[0][22]); } catch { item.Tis_special_proposal = 0; } item.Tagent_code = result.Rows[0][23].ToString(); try { item.Tdate_add = Convert.ToDateTime(result.Rows[0][24]); } catch { item.Tdate_add = DateTime.Now; } try { item.Tdate_change = Convert.ToDateTime(result.Rows[0][25]); } catch { item.Tdate_change = DateTime.Now; } item.Tstatus = result.Rows[0][26].ToString(); item.Toperation = result.Rows[0][27].ToString(); item.Tphoto = result.Rows[0][28].ToString(); item.Twidth = result.Rows[0][29].ToString(); item.Theight = result.Rows[0][30].ToString(); try { item.Ttrade_date = Convert.ToDateTime(result.Rows[0][31]); } catch { item.Ttrade_date = DateTime.Now; } try { item.Ttrade_price = Convert.ToDouble(result.Rows[0][32]); } catch { item.Ttrade_price = 0; } con.Close(); return item; }