/**
         * @return String
         * @roseuid 5C28579902CE
         */
        public bool alterEtmsg(sqlconnection1 conn, ArrayList alist)
        {
            string constr = "update sushe set door='" + int.Parse(alist[1].ToString()) + "',fan='" + int.Parse(alist[2].ToString()) + "',window='" + int.Parse(alist[3].ToString()) + "',air='" + int.Parse(alist[4].ToString()) + "',light='" + int.Parse(alist[5].ToString()) + "',heat='" + int.Parse(alist[6].ToString()) + "',et='" + (alist[7].ToString()) + "' where id='" + int.Parse(alist[0].ToString()) + "'";

            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    conn.close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        /**
         * @return int
         * @roseuid 5C285B4D0025
         */
        public bool setAmount(sqlconnection1 conn, int number)
        {
            int    n      = getAmount(conn, number) + 1;
            string constr = "update sushe set amount='" + n + "' where id='" + number + "'";

            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    conn.close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        /**
         * @return String
         * @roseuid 5C285747014A
         */
        public ArrayList getssushe(sqlconnection1 conn)
        {
            ArrayList alist = new ArrayList();

            conn.connection();
            string     constr = "select sname,snumber,ssushe from student";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                while (read.Read())
                {
                    if (read["ssushe"].ToString() != "0")
                    {
                        alist.Add(read["snumber"]);
                        alist.Add(read["sname"]);
                        alist.Add(read["ssushe"]);
                    }
                }
                read.Close();
                conn.close();
                return(alist);
            }
            catch (Exception ex)
            {
                alist.Clear();
                alist.Add("出现错误!");
                return(alist);
            }
        }
        /**
         * @return String
         * @roseuid 5C28578600C4
         */
        public bool alterStmsg(sqlconnection1 conn, ArrayList alist)
        {
            string constr = "update student set sname='" + alist[1].ToString() + "',sage='" + int.Parse(alist[2].ToString()) + "',sin='" + int.Parse(alist[3].ToString()) + "',sout='" + int.Parse(alist[4].ToString()) + "',szhuanye='" + (alist[5].ToString()) + "',class='" + int.Parse(alist[6].ToString()) + "',ssex='" + (alist[7].ToString()) + "' where snumber='" + int.Parse(alist[0].ToString()) + "'";

            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    conn.connection();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        /**
         * @return String
         * @roseuid 5C28576A03E6
         */
        public ArrayList searchEtmsg(sqlconnection1 conn, int id)
        {
            ArrayList alist  = new ArrayList();
            string    constr = "select * from sushe where id='" + id + "'";

            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                read.Read();
                alist.Add(read["door"]);
                alist.Add(read["fan"]);
                alist.Add(read["window"]);
                alist.Add(read["air"]);
                alist.Add(read["light"]);
                alist.Add(read["heat"]);
                alist.Add(read["et"]);
                read.Close();
                conn.close();
                return(alist);
            }
            catch (Exception ex)
            {
                alist.Clear();
                for (int i = 0; i < 7; i++)
                {
                    alist.Add("出现错误!");
                }
                return(alist);
            }
        }
        /**
         * @return String
         * @roseuid 5C28575A0231
         */
        public bool addnewst(sqlconnection1 conn, int number, int bed, int snumber)
        {
            bool    b = false;
            student a = new student(snumber);
            sushe   c = new sushe(number);

            if (a.getMessage(conn)[10].Equals(c.getsex(conn)))
            {
                b = true;
            }
            conn.close();
            if (b)
            {
                if (c.setBed(conn, number, bed, snumber))
                {
                    if (c.setAmount(conn, number))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        /**
         * @return int
         * @roseuid 5C285B420017
         */
        public int getAmount(sqlconnection1 conn, int number)
        {
            string constr = "select amount from sushe where id='" + number + "'";

            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                read.Read();
                if (read.HasRows)
                {
                    int a = (int)read["amount"];
                    read.Close();
                    conn.close();
                    return(a);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public ArrayList getdatastudent(sqlconnection1 conn, int data)
        {
            ArrayList  alist  = new ArrayList();
            string     constr = "select snumber from student where sout='" + data + "'";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                while (read.Read())
                {
                    alist.Add((string)read["snumber"].ToString());
                    alist[0] = 1;
                }
                read.Close();
                conn.close();
                return(alist);
            }
            catch (Exception ex)
            {
                alist.Clear();
                alist.Add(0);
                return(alist);
            }
        }
        /**
         * @return String
         * @roseuid 5C28573E0342
         */
        public bool setssushe(sqlconnection1 conn, int snumber)
        {
            conn.connection();
            string     constr = "update student set ssushe='0' where snumber='" + snumber + "'";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    conn.close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        /**
         * @return String
         * @roseuid 5C28575302C1
         */
        public ArrayList getallbed(sqlconnection1 conn, int a)
        {
            ArrayList alist = new ArrayList();

            conn.connection();
            string     constr = "select * from sushe";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                while (read.Read())
                {
                    if (a == 0)
                    {
                        alist.Add(read["id"]);
                        alist.Add(read["bed1"]);
                        alist.Add(read["bed2"]);
                        alist.Add(read["bed3"]);
                        alist.Add(read["bed4"]);
                    }
                    else
                    {
                        if (int.Parse(read["amount"].ToString()) < 4)
                        {
                            alist.Add(read["id"]);
                            alist.Add(read["bed1"]);
                            alist.Add(read["bed2"]);
                            alist.Add(read["bed3"]);
                            alist.Add(read["bed4"]);
                        }
                    }
                }
                read.Close();
                conn.close();
                return(alist);
            }
            catch (Exception ex)
            {
                alist.Clear();
                alist.Add("没有空寝室!");
                return(alist);
            }
        }
        /**
         * @return String
         * @roseuid 5C28595B0253
         */
        public bool alterPsw(sqlconnection1 conn, string passwords)
        {
            conn.connection();
            string     constr = "update student set spasswords='" + passwords + "' where snumber='" + snumber + "'";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
        /**
         * @return String
         * @roseuid 5C2859610376
         */
        public ArrayList getMessage(sqlconnection1 conn)
        {
            ArrayList alist = new ArrayList();

            conn.connection();
            string     constr = "select * from student where snumber='" + snumber + "'";
            SqlCommand comm   = new SqlCommand(constr, conn.con);

            try
            {
                SqlDataReader read = comm.ExecuteReader();
                read.Read();
                if (read.HasRows)
                {
                    for (int i = 0; i < 11; i++)
                    {
                        alist.Add(read.GetValue(i));
                    }
                }
                else
                {
                    for (int i = 0; i < 11; i++)
                    {
                        alist.Add("获取失败!");
                    }
                }
                read.Close();
                conn.close();
            }
            catch (Exception ex)
            {
                for (int i = 0; i < 12; i++)
                {
                    alist.Add("获取失败!");
                }
                return(alist);
            }
            conn.connection();
            string     constr1 = "select et from sushe where id='" + alist[6] + "'";
            SqlCommand comm1   = new SqlCommand(constr1, conn.con);

            try
            {
                SqlDataReader read1 = comm1.ExecuteReader();
                read1.Read();
                if (read1.HasRows)
                {
                    alist.Add(read1["et"]);
                }
                else
                {
                    alist.Add("获取失败!");
                }
                read1.Close();
                conn.close();
                return(alist);
            }
            catch (Exception ex)
            {
                alist.Add("获取失败!");
                return(alist);
            }
        }
 /**
  * @return String
  * @roseuid 5C285760030C
  */
 public int deletegdu(sqlconnection1 conn, int data1, int data2, int number)
 {
     if (number == 0)
     {
         if (data2 - data1 == 4)
         {
             ArrayList alist = conn.getdatastudent(conn, data2);
             if (alist[0].ToString() != "0")
             {
                 for (int i = 0; i < alist.Count; i++)
                 {
                     conn.connection();
                     string     constr = "delete from student where snumber='" + int.Parse(alist[i].ToString()) + "'";
                     SqlCommand comm   = new SqlCommand(constr, conn.con);
                     try
                     {
                         if (comm.ExecuteNonQuery() > 0)
                         {
                             conn.close();
                         }
                         else
                         {
                             conn.close();
                         }
                     }
                     catch (Exception ex)
                     {
                         return(0);
                     }
                 }
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     else
     {
         if (data1 <= data2)
         {
             for (int i = data1; i <= data2; i++)
             {
                 conn.connection();
                 string     constr = "delete from student where snumber='" + i + "'";
                 SqlCommand comm   = new SqlCommand(constr, conn.con);
                 try
                 {
                     if (comm.ExecuteNonQuery() > 0)
                     {
                         conn.close();
                     }
                     else
                     {
                         return(i);
                     }
                 }
                 catch (Exception ex)
                 {
                     return(0);
                 }
             }
             return(1);
         }
         else
         {
             return(0);
         }
     }
 }
        /**
         * @return int
         * @roseuid 5C285B3C004A
         */
        public bool setBed(sqlconnection1 conn, int number, int bed, int snumber)
        {
            string constr;
            string constr1;

            switch (bed)
            {
            case 1:
                constr = "update sushe set bed1='" + snumber + "' where id='" + number + "'";
                break;

            case 2:
                constr = "update sushe set bed2='" + snumber + "' where id='" + number + "'";
                break;

            case 3:
                constr = "update sushe set bed3='" + snumber + "' where id='" + number + "'";
                break;

            case 4:
                constr = "update sushe set bed4='" + snumber + "' where id='" + number + "'";
                break;

            default:
                return(false);
            }
            conn.connection();
            SqlCommand comm = new SqlCommand(constr, conn.con);

            try
            {
                if (comm.ExecuteNonQuery() > 0)
                {
                    conn.close();
                }
                else
                {
                    conn.close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            constr1 = "update student set sbed='" + bed + "',s#='" + number + "' where snumber='" + snumber + "'";
            conn.connection();
            SqlCommand comm1 = new SqlCommand(constr1, conn.con);

            try
            {
                if (comm1.ExecuteNonQuery() > 0)
                {
                    conn.close();
                    return(true);
                }
                else
                {
                    conn.close();
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }