コード例 #1
0
        /// <summary>
        /// 删除学生
        /// </summary>
        /// <param name="stu"></param>
        /// <returns></returns>
        public int DeleteStudent(student stu)
        {
            SqlConnection con = new SqlConnection(@"Data Source=WIN-L8SRCUH9LF2\JACK;Initial Catalog=StudentroomDB;Persist Security Info=True;User ID=sa;pwd=720713");

            int ret=-1;
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "pro_deletestudent";
            cmd.Parameters.Add("@StudentId", SqlDbType.Int).Value = stu.StudentId;
            try
            {
                con.Open();
                ret = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            finally
            {
              con.Close();
            }
            return ret;
        }
コード例 #2
0
        /// <summary>
        /// 是否缺勤
        /// </summary>
        /// <returns></returns>
        public int cheackfee(student stu)
        {
            int ret = -1;
            SqlConnection con = new SqlConnection(@"Data Source=WIN-L8SRCUH9LF2\JACK;Initial Catalog=StudentroomDB;Persist Security Info=True;User ID=sa;pwd=720713");
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "dbo.StoredProcedure2";
            cmd.Parameters.Add("@StudentId", SqlDbType.Int).Value = stu.StudentId;
            SqlParameter parret = new SqlParameter("@retvalues", SqlDbType.Int);
            parret.Direction = ParameterDirection.ReturnValue;
            cmd.Parameters.Add(parret);
            try
            {
                con.Open();
                cmd.ExecuteNonQuery();
                ret = (int)parret.Value;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);

            }
            finally
            {
                con.Close();
            }
            return ret;
        }
コード例 #3
0
 public bool DeleteStudent(student stu)
 {
     int ret= studens.DeleteStudent(stu);
       if (ret == 1)
       {
       return true;
       }
       else
       return false;
 }
コード例 #4
0
 /// <summary>
 /// 查询具体学生缴费
 /// </summary>
 /// <param name="fee"></param>
 /// <returns></returns>
 public bool cheackfee(student stu)
 {
     int ret = studens.cheackfee(stu);
        if (ret == 1)
        {
        return true;
        }
        else
        return false;
 }
コード例 #5
0
 public int GetStudent(student stu)
 {
     return studens.GetStudent(stu);
 }
コード例 #6
0
 public DataSet getallinfo(student stu)
 {
     return studens.getallinfo(stu);
 }
コード例 #7
0
        //////////////////////////////////////////////////////////////////////////
        public DataSet getallinfo(student stu)
        {
            SqlConnection con = new SqlConnection(@"Data Source=WIN-L8SRCUH9LF2\JACK;Initial Catalog=StudentroomDB;Persist Security Info=True;User ID=sa;pwd=720713");
            DataSet dt = new DataSet();
            SqlCommand cmd = new SqlCommand("dbo.GetAllInfo", con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@studentid", SqlDbType.Int).Value = stu.StudentId;
            //返回值
            SqlDataAdapter adp = new SqlDataAdapter();
            try
            {

                adp.SelectCommand = cmd;
                adp.Fill(dt, "infostudent");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            // int rettu = (int)parret.Value;
            return dt;
        }