Exemplo n.º 1
0
        public int InsertStuInfo(StuInfo stu)
        {
            string sql = @"INSERT INTO
                                scoremanagement.`stu_info`(`id`, `name`, `major_id`, `gender`, `remark`, `birth`, `totalscore`)
                            VALUES
                                (@para1, @para2, (
                                SELECT 
                                    id 
                                FROM 
                                    scoremanagement.`major` ma 
                                WHERE 
                                    ma.`name` = @para3
                                ), @para4, @para5, STR_TO_DATE(@para6,'%Y/%m/%d'), @para7);";

            return(this.ExecNonQuery(sql, stu.id, stu.name, stu.major, stu.gender, stu.remark, stu.birth, stu.totalScore.ToString()));
        }
Exemplo n.º 2
0
        public bool GetOneStuInfoStruct(string id, ref StuInfo stu)
        {
            DataSet dataSet = this.GetAllStuInfo(id, "%", "%");

            try
            {
                stu.id         = dataSet.Tables[0].Rows[0][0].ToString();
                stu.name       = dataSet.Tables[0].Rows[0][1].ToString();
                stu.major      = dataSet.Tables[0].Rows[0][2].ToString();
                stu.gender     = dataSet.Tables[0].Rows[0][3].ToString();
                stu.birth      = dataSet.Tables[0].Rows[0][4].ToString();
                stu.totalScore = Convert.ToSingle(dataSet.Tables[0].Rows[0][5]);
                stu.remark     = dataSet.Tables[0].Rows[0][6].ToString();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        public int UpdateStuInfo(StuInfo stu)
        {
            string sql = @"UPDATE
                            scoremanagement.`stu_info` st
                        SET
                            st.`name` = @para1,
                            st.`gender` = @para2,
                            st.`birth` = STR_TO_DATE(@para3,'%Y/%m/%d'),
                            st.`major_id` = (
                            SELECT 
                                id 
                            FROM 
                                scoremanagement.`major` ma 
                            WHERE 
                                ma.`NAME` = @para4
                            ),
                            st.`totalscore` = @para5,
                            st.`remark` = @para6
                        WHERE
                            st.`id` = @para7;"    ;

            return(this.ExecNonQuery(sql, stu.name, stu.gender, stu.birth, stu.major,
                                     stu.totalScore.ToString(), stu.remark, stu.id));
        }
Exemplo n.º 4
0
        private void buttonCancel_Click(object sender, EventArgs e)
        {
            StuInfo stu = new StuInfo();

            this.setStuInfo(stu);
        }