/*--------------------------------------StuParent------------------------------------------*/
        public int AddStuParent(StuParent ld)
        {
            string sqlstr = "INSERT INTO db_p2_stupar (STU_NUM, STP_MORD, STP_STUPAR, SP_ID)VALUES(" +
                            ld.Stnum + ", " +
                            ld.Mord + ", " +
                            ld.Stpar + ", " +
                            ld.Spnum + ");";
            int result = MySqlHelper.ExecuteNonQuery(sqlstr);

            return(result);
        }
        public StuParent SearchStuParent(uint stnum, bool mod)
        {
            string    sqlstr = "SELECT STU_NUM, STP_MORD, STP_STUPAR, SP_ID FROM db_p2_stupar WHERE STU_NUM=";
            string    sqlend = " and STP_MORD=";
            DataSet   ds     = MySqlHelper.ExecuteQuery(sqlstr + stnum + sqlend + mod);
            DataTable dt     = ds.Tables[0];

            StuParent temp = new StuParent();

            temp.Stnum = uint.Parse(dt.Rows[0][0].ToString());
            temp.Mord  = dt.Rows[0][1].ToString() == "1";
            temp.Stpar = dt.Rows[0][2].ToString() == "1";
            temp.Spnum = uint.Parse(dt.Rows[0][3].ToString());

            return(temp);
        }
示例#3
0
        static void Main(string[] args)
        {
            SqlFuns sf = new SqlFuns();

            for (int i = 4; i <= 30; i++)
            {
                StuParent sp0 = new StuParent();
                StuParent sp1 = new StuParent();
                sp0.Stnum = uint.Parse(i + "");
                sp1.Stnum = uint.Parse(i + "");
                sp0.Mord  = true;
                sp1.Mord  = false;
                Random r    = new Random();
                double seed = r.NextDouble();
                if (seed > 0.5)
                {
                    sp0.Stpar = true;
                    double stmp = r.NextDouble() * 30;
                    sp0.Spnum = (uint)(stmp % 30);
                }
                else
                {
                    sp0.Stpar = false;
                    double stmp = r.NextDouble() * 10;
                    sp0.Spnum = (uint)(stmp % 10);
                }
                sf.AddStuParent(sp0);

                double sed = r.NextDouble();
                if (sed > 0.5)
                {
                    sp0.Stpar = true;
                    double stmp = r.NextDouble() * 30;
                    sp0.Spnum = (uint)(stmp % 30);
                }
                else
                {
                    sp0.Stpar = false;
                    double stmp = r.NextDouble() * 10;
                    sp0.Spnum = (uint)(stmp % 10);
                }
                sf.AddStuParent(sp1);
            }
        }
        public IList <StuParent> SearchStuParent(uint stnum)
        {
            string    sqlstr = "SELECT STU_NUM, STP_MORD, STP_STUPAR, SP_ID FROM db_p2_stupar WHERE STU_NUM=";
            DataSet   ds     = MySqlHelper.ExecuteQuery(sqlstr + stnum);
            DataTable dt     = ds.Tables[0];

            IList <StuParent> result = new List <StuParent>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                StuParent temp = new StuParent();

                temp.Stnum = uint.Parse(dt.Rows[i][0].ToString());
                temp.Mord  = dt.Rows[i][1].ToString() == "1";
                temp.Stpar = dt.Rows[i][2].ToString() == "1";
                temp.Spnum = uint.Parse(dt.Rows[i][3].ToString());

                result.Add(temp);
            }
            return(result);
        }