示例#1
0
        public bool HomeInfo_Insert(HomeInfo data)
        {
            using (DbCommand cmd = db.GetStoredProcCommand("Home_Insert"))
            {
                //cmd.Parameters.Add(new SqlParameter("@HomeID", data.HomeID));
                cmd.Parameters.Add(new SqlParameter("@HomeTypeID", data.HomeTypeID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersID", data.RealEstateOwnersID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersName", data.RealEstateOwnersName));
                cmd.Parameters.Add(new SqlParameter("@RealEstateID", data.RealEstateID));
                cmd.Parameters.Add(new SqlParameter("@CityID", data.CityID));
                cmd.Parameters.Add(new SqlParameter("@DistrictID", data.DistrictID));
                cmd.Parameters.Add(new SqlParameter("@LocationID", data.LocationID));


                cmd.Parameters.Add(new SqlParameter("@Name", data.Name));
                cmd.Parameters.Add(new SqlParameter("@Title", data.Title));
                cmd.Parameters.Add(new SqlParameter("@CreateDate", data.CreateDate));
                cmd.Parameters.Add(new SqlParameter("@CreateBy", data.CreateBy));
                cmd.Parameters.Add(new SqlParameter("@TransactionType", data.TransactionType));
                cmd.Parameters.Add(new SqlParameter("@Tag", data.Tag));
                cmd.Parameters.Add(new SqlParameter("@Description", data.Description));
                cmd.Parameters.Add(new SqlParameter("@Address", data.Address));
                cmd.Parameters.Add(new SqlParameter("@Price", data.Price));
                cmd.Parameters.Add(new SqlParameter("@TotalArea", data.TotalArea));
                cmd.Parameters.Add(new SqlParameter("@FloorArea", data.FloorArea));
                cmd.Parameters.Add(new SqlParameter("@GargenArea", data.GargenArea));
                cmd.Parameters.Add(new SqlParameter("@HomeArea", data.HomeArea));
                cmd.Parameters.Add(new SqlParameter("@BedroomNumber", data.BedroomNumber));
                cmd.Parameters.Add(new SqlParameter("@TierNumber", data.TierNumber));
                cmd.Parameters.Add(new SqlParameter("@Image1", data.Image1));
                cmd.Parameters.Add(new SqlParameter("@Image2", data.Image2));
                cmd.Parameters.Add(new SqlParameter("@Image3", data.Image3));
                cmd.Parameters.Add(new SqlParameter("@Image4", data.Image4));
                cmd.Parameters.Add(new SqlParameter("@Image5", data.Image5));
                cmd.Parameters.Add(new SqlParameter("@Image6", data.Image6));
                try
                {
                    db.ExecuteNonQuery(cmd);
                    return(true);
                }
                catch (Exception ex)
                {
                    return(false);

                    throw ex;
                }
                finally
                {
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                }
            }
        }
示例#2
0
        public HomeInfo HomeInfoIDataReader(IDataReader dr)
        {
            HomeInfo obj = new HomeInfo();

            obj.HomeID             = (dr["HomeID"] is DBNull) ? string.Empty : dr["HomeID"].ToString();
            obj.HomeTypeID         = (dr["HomeTypeID"] is DBNull) ? string.Empty : dr["HomeTypeID"].ToString();
            obj.RealEstateOwnersID = (dr["RealEstateOwnersID"] is DBNull) ? string.Empty : dr["RealEstateOwnersID"].ToString();
            //obj.RealEstateOwnersTypeID = (dr["RealEstateOwnersTypeID"] is DBNull) ? string.Empty : dr["RealEstateOwnersTypeID"].ToString();
            obj.RealEstateID         = (dr["RealEstateID"] is DBNull) ? string.Empty : dr["RealEstateID"].ToString();
            obj.Name                 = (dr["Name"] is DBNull) ? string.Empty : dr["Name"].ToString();
            obj.RealEstateOwnersName = (dr["RealEstateOwnersName"] is DBNull) ? string.Empty : dr["RealEstateOwnersName"].ToString();
            obj.Title                = (dr["Title"] is DBNull) ? string.Empty : dr["Title"].ToString();
            obj.CreateDate           = (dr["CreateDate"] is DBNull) ? string.Empty : dr["CreateDate"].ToString();
            obj.TransactionType      = (dr["TransactionType"] is DBNull) ? string.Empty : dr["TransactionType"].ToString();
            obj.Tag           = (dr["Tag"] is DBNull) ? string.Empty : dr["Tag"].ToString();
            obj.Description   = (dr["Description"] is DBNull) ? string.Empty : dr["Description"].ToString();
            obj.Address       = (dr["Address"] is DBNull) ? string.Empty : dr["Address"].ToString();
            obj.Price         = (dr["Price"] is DBNull) ? string.Empty : dr["Price"].ToString();
            obj.TotalArea     = (dr["TotalArea"] is DBNull) ? string.Empty : dr["TotalArea"].ToString();
            obj.FloorArea     = (dr["FloorArea"] is DBNull) ? string.Empty : dr["FloorArea"].ToString();
            obj.GargenArea    = (dr["GargenArea"] is DBNull) ? string.Empty : dr["GargenArea"].ToString();
            obj.HomeArea      = (dr["HomeArea"] is DBNull) ? string.Empty : dr["HomeArea"].ToString();
            obj.BedroomNumber = (dr["BedroomNumber"] is DBNull) ? string.Empty : dr["BedroomNumber"].ToString();
            obj.TierNumber    = (dr["TierNumber"] is DBNull) ? string.Empty : dr["TierNumber"].ToString();
            obj.CreateBy      = (dr["CreateBy"] is DBNull) ? string.Empty : dr["CreateBy"].ToString();
            obj.CityID        = (dr["CityID"] is DBNull) ? string.Empty : dr["CityID"].ToString();
            obj.DistrictID    = (dr["DistrictID"] is DBNull) ? string.Empty : dr["DistrictID"].ToString();
            obj.LocationID    = (dr["LocationID"] is DBNull) ? string.Empty : dr["LocationID"].ToString();
            obj.Image1        = (dr["Image1"] is DBNull) ? string.Empty : dr["Image1"].ToString();
            obj.Image2        = (dr["Image2"] is DBNull) ? string.Empty : dr["Image2"].ToString();
            obj.Image3        = (dr["Image3"] is DBNull) ? string.Empty : dr["Image3"].ToString();
            obj.Image4        = (dr["Image4"] is DBNull) ? string.Empty : dr["Image4"].ToString();
            obj.Image5        = (dr["Image5"] is DBNull) ? string.Empty : dr["Image5"].ToString();
            obj.Image6        = (dr["Image6"] is DBNull) ? string.Empty : dr["Image6"].ToString();
            return(obj);
        }
示例#3
0
        public int HomeInfo_InsertGetID(HomeInfo data, int ID)
        {
            using (SqlCommand cmd = new SqlCommand("Home_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                //cmd.Parameters.Add(new SqlParameter("@HomeID", data.HomeID));
                cmd.Parameters.Add(new SqlParameter("@HomeTypeID", data.HomeTypeID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersID", data.RealEstateOwnersID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersName", data.RealEstateOwnersName));
                cmd.Parameters.Add(new SqlParameter("@RealEstateID", data.RealEstateID));
                cmd.Parameters.Add(new SqlParameter("@CityID", data.CityID));
                cmd.Parameters.Add(new SqlParameter("@DistrictID", data.DistrictID));
                cmd.Parameters.Add(new SqlParameter("@LocationID", data.LocationID));
                cmd.Parameters.Add(new SqlParameter("@Name", data.Name));
                cmd.Parameters.Add(new SqlParameter("@Title", data.Title));
                cmd.Parameters.Add(new SqlParameter("@CreateDate", data.CreateDate));
                cmd.Parameters.Add(new SqlParameter("@CreateBy", data.CreateBy));
                cmd.Parameters.Add(new SqlParameter("@TransactionType", data.TransactionType));
                cmd.Parameters.Add(new SqlParameter("@Tag", data.Tag));
                cmd.Parameters.Add(new SqlParameter("@Description", data.Description));
                cmd.Parameters.Add(new SqlParameter("@Address", data.Address));
                cmd.Parameters.Add(new SqlParameter("@Price", data.Price));
                cmd.Parameters.Add(new SqlParameter("@TotalArea", data.TotalArea));
                cmd.Parameters.Add(new SqlParameter("@FloorArea", data.FloorArea));
                cmd.Parameters.Add(new SqlParameter("@GargenArea", data.GargenArea));
                cmd.Parameters.Add(new SqlParameter("@HomeArea", data.HomeArea));
                cmd.Parameters.Add(new SqlParameter("@BedroomNumber", data.BedroomNumber));
                cmd.Parameters.Add(new SqlParameter("@TierNumber", data.TierNumber));
                cmd.Parameters.Add(new SqlParameter("@Image1", data.Image1));
                cmd.Parameters.Add(new SqlParameter("@Image2", data.Image2));
                cmd.Parameters.Add(new SqlParameter("@Image3", data.Image3));
                cmd.Parameters.Add(new SqlParameter("@Image4", data.Image4));
                cmd.Parameters.Add(new SqlParameter("@Image5", data.Image5));
                cmd.Parameters.Add(new SqlParameter("@Image6", data.Image6));
                try
                {
                    ID = (int)cmd.ExecuteScalar();
                    //cmd.ExecuteNonQuery();
                    ////SqlDataReader reader = cmd.ExecuteReader();
                    ////if (reader.HasRows)
                    ////{
                    ////    while (reader.Read())
                    ////    {
                    ////        ID = int.Parse(reader[0].ToString());
                    ////    }
                    ////}
                    ////reader.Close();
                }
                catch (Exception ex)
                {
                    throw ex;
                    return(-1);
                }
                finally
                {
                    if (cmd != null)
                    {
                        cmd.Dispose();
                    }
                }
                return(ID);
            }
        }