Ejemplo n.º 1
0
        /// <summary>
        /// �����ҵ
        /// </summary>
        /// <param name="mAssignment">����ӵ���ҵ����</param>
        /// <returns>�Ƿ���ӳɹ����ɹ��򷵻������¼��ID�����򷵻�-1</returns>
        public int AddAssignment(AssignmentInfo mAssignment, string courseName)
        {
            SqlParameter[] parms = {
                new SqlParameter("@title",mAssignment.StrTitle),
                new SqlParameter("@contents",mAssignment.StrContents),
                new SqlParameter("@deadline",mAssignment.DtDeadline),
                new SqlParameter("@teacherUserName",mAssignment.StrTeacherUserName),
                new SqlParameter("@courseName", courseName),
                new SqlParameter("@identity",SqlDbType.Int)
            };

            parms[5].Direction = ParameterDirection.ReturnValue;
            int id = 0;
            int affectRows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys,
                CommandType.StoredProcedure, "SP_AddAssmt", parms);
            if (affectRows > 0)
            {
                id = Convert.ToInt32(parms[5].Value);

                AssignmentGroupInfo mAssignmentGroup = new AssignmentGroupInfo();
                mAssignmentGroup.IAssignmentId = id;
                mAssignmentGroup.INewMsgNum = 0;
                mAssignmentGroup.IState = 0;
                mAssignmentGroup.StrCourseName = courseName;
                mAssignmentGroup.StrTeacherName = mAssignment.StrTeacherUserName;
                if (AddAssignmentGroup(mAssignmentGroup))
                    return id;
                else
                    DelAssignmentByID(id);
            }
            return -1;
        }
    //添加对应的作业-组信息
    protected void AddAssignmentGroup(Control topctrl, Assignment EditAssignment, int assignmentID)
    {
        foreach (Control c in topctrl.Controls)
        {
            if (c.GetType().ToString().Equals("System.Web.UI.WebControls.CheckBoxList"))
            {
                CheckBoxList cb = (CheckBoxList)c;

                //从1开始,因为第0项是班级
                for (int i = 1; i < cb.Items.Count; i++)
                {
                    if (cb.Items[i].Selected == true)
                    {
                        //new AssignmentGroupInfo对象
                        AssignmentGroupInfo newAssignmentGroupInfo = new AssignmentGroupInfo();
                        //初始化newAssignmentGroupInfo
                        newAssignmentGroupInfo.IAssignmentId = assignmentID;
                        //Items[i].Value保存的是组的ID,这是在动态生成的时候绑定的
                        newAssignmentGroupInfo.IGroupId = Convert.ToInt32(cb.Items[i].Value);
                        newAssignmentGroupInfo.INewMsgNum = 0;
                        newAssignmentGroupInfo.IState = 0;
                        //添加相应的组
                        EditAssignment.AddAssignmentGroup(newAssignmentGroupInfo);
                    }
                }
            }
            if (c.HasControls())
            {
                AddAssignmentGroup(c, EditAssignment, assignmentID);
            }
        }
    }
Ejemplo n.º 3
0
        /// <summary>
        /// ��ӷ�������ҵ-���Ӧ��Ϣ
        /// </summary>
        /// <param name="mAssignmentGroup">��ҵ-����Ϣ</param>
        /// <returns>�Ƿ���ӳɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
        public bool AddAssignmentGroup(AssignmentGroupInfo mAssignmentGroup)
        {
            SqlParameter[] parms = {
                new SqlParameter("@assignmentID",mAssignmentGroup.IAssignmentId),
                new SqlParameter("@courseName",mAssignmentGroup.StrCourseName),
                new SqlParameter("@teacherUserName",mAssignmentGroup.StrTeacherName),
                new SqlParameter("@newMsgNum",mAssignmentGroup.INewMsgNum),
                new SqlParameter("@state",mAssignmentGroup.IState)
            };

            bool isSuccess = false;

                int affectRows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionStringSTEduSys,
                    CommandType.StoredProcedure, "SP_AddAssignmentGroup", parms);
                if (affectRows > 0)
                {
                    isSuccess = true;
                }
                return isSuccess;
        }
Ejemplo n.º 4
0
 /// <summary>
 /// ��ӷ�������ҵ-���Ӧ��Ϣ
 /// </summary>
 /// <param name="mAssignmentGroup">��ҵ-����Ϣ</param>
 /// <returns>�Ƿ���ӳɹ����ɹ��򷵻�true,ʧ���򷵻�false</returns>
 public bool AddAssignmentGroup(AssignmentGroupInfo mAssignmentGroup)
 {
     return dal.AddAssignmentGroup(mAssignmentGroup);
 }