コード例 #1
0
        public int MotelInfo_InsertGetID(MotelInfo data, int ID)
        {
            using (SqlCommand cmd = new SqlCommand("Motel_Insert", GetConnection()))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                //cmd.Parameters.Add(new SqlParameter("@MotelID", data.MotelID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersID", data.RealEstateOwnersID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateID", data.RealEstateID));
                cmd.Parameters.Add(new SqlParameter("@MotelTypeID", data.MotelTypeID));
                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("@RealEstateOwnersName", data.RealEstateOwnersName));
                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("@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("@IsClosed", data.IsClosed));
                cmd.Parameters.Add(new SqlParameter("@IsCooker", data.IsCooker));
                cmd.Parameters.Add(new SqlParameter("@Furniture", data.Furniture));
                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
                {
                    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);
            }
        }
コード例 #2
0
        public bool MotelInfo_Update(MotelInfo data)
        {
            using (DbCommand cmd = db.GetStoredProcCommand("Motel_Update"))
            {
                cmd.Parameters.Add(new SqlParameter("@MotelID", data.MotelID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateOwnersID", data.RealEstateOwnersID));
                cmd.Parameters.Add(new SqlParameter("@RealEstateID", data.RealEstateID));
                cmd.Parameters.Add(new SqlParameter("@MotelTypeID", data.MotelTypeID));
                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("@RealEstateOwnersName", data.RealEstateOwnersName));
                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("@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("@IsClosed", data.IsClosed));
                cmd.Parameters.Add(new SqlParameter("@IsCooker", data.IsCooker));
                cmd.Parameters.Add(new SqlParameter("@Furniture", data.Furniture));
                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();
                    }
                }
            }
        }