Beispiel #1
0
        public List <Model.HouseModel> queryHouse(String user_id)
        {
            List <Model.HouseModel> list = new List <Model.HouseModel>();

            try
            {
                string           sql    = "select house_id,city_id,address,limitation,info,state from house where user_id = '" + user_id + "'";
                MySqlCommand     cmd    = new MySqlCommand(sql, sqlCon);
                MySqlDataReader  reader = cmd.ExecuteReader();
                Model.HouseModel hm     = null;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        hm            = new HouseModel();
                        hm.house_id   = reader[0].ToString();
                        hm.city_id    = reader[1].ToString();
                        hm.address    = reader[2].ToString();
                        hm.limitation = reader[3].ToString();
                        hm.info       = reader[4].ToString();
                        hm.state      = reader[5].ToString().ElementAt(0);
                        hm.user_id    = user_id;
                        list.Add(hm);
                    }
                }
                reader.Close();
                cmd.Dispose();
            }
            catch (Exception e)
            {
            }
            return(list);
        }
        public bool insertHouse(String user_id, String password, String city, String address, String limitation, String info)
        {
            int count = 0;

            Model.HouseModel hm = new Model.HouseModel();
            if (dbOperation.queryExistUser(user_id, password))
            {
                count = dbOperation.countHouse(user_id);
                if (count != -1)
                {
                    string id = count.ToString();
                    while (id.Length < 5)
                    {
                        id = "0" + id;
                    }
                    id            = "H" + user_id.Substring(1) + id;
                    hm.user_id    = user_id;
                    hm.house_id   = id;
                    hm.city_id    = city;
                    hm.address    = address;
                    hm.limitation = limitation;
                    hm.info       = info;
                    if (dbOperation.insertHouse(hm))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        public bool updateHouse(String user_id, String password, String house_id, String city, String address, String limitation, String info)
        {
            if (dbOperation.queryExistUserHouse(user_id, house_id, password))
            {
                Model.HouseModel hm = new Model.HouseModel();
                hm.user_id    = user_id;
                hm.house_id   = house_id;
                hm.city_id    = city;
                hm.address    = address;
                hm.limitation = limitation;
                hm.info       = info;

                return(dbOperation.updateHouse(hm));
            }
            return(false);
        }