Ejemplo n.º 1
0
        /// <summary>
        /// 编辑批次
        /// </summary>
        public void EditorPlan()
        {
            string   planName  = Context.Request["editorPlanName"].ToString();
            DateTime startTime = Convert.ToDateTime(Context.Request["editorStartTime"].ToString()),
                     endTime   = Convert.ToDateTime(Context.Request["editorEndTime"].ToString());
            int state          = int.Parse(Context.Request["editorState"].ToString()),
                planId         = int.Parse(Context.Request["editorPlanId"].ToString());
            //collegeId = int.Parse(Context.Request["planCollegeId"].ToString());

            //获取院系id
            Teacher    teacher    = (Teacher)Session["user"];
            string     account    = teacher.TeaAccount;
            TeacherBll teacherBll = new TeacherBll();

            loginUser = teacherBll.GetModel(account);
            College ColID = loginUser.college;

            Plan plan = new Plan()
            {
                PlanId    = planId,
                PlanName  = planName,
                StartTime = startTime,
                EndTime   = endTime,
                State     = state,
                college   = ColID
            };

            try
            {
                PlanBll pBll         = new PlanBll();
                Result  EditorResult = pBll.Update(plan);
                //字符串转日期
                string   start   = Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss");
                DateTime startdt = Convert.ToDateTime(start);
                string   end     = Convert.ToDateTime(endTime).ToString("yyyy-MM-dd HH:mm:ss");
                DateTime enddt   = Convert.ToDateTime(end);
                TimeSpan ts      = enddt - startdt;
                //间隔天数小于1则不能
                if (ts.Days >= 1)
                {
                    if (EditorResult == Result.更新成功)
                    {
                        LogHelper.Info(this.GetType(), loginUser.TeaAccount + " - " + loginUser.TeaName + " - 编辑" + planId + "批次");
                        Response.Write("更新成功");
                        //Response.End();
                    }
                    else
                    {
                        Response.Write("更新失败");
                        //Response.End();
                    }
                }
                else
                {
                    Response.Write("开始与结束时间间隔必须大于1天");
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(this.GetType(), ex);
            }
            finally
            {
                Response.End();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 执行选题操作
        /// </summary>
        public void StusecltTitle()
        {
            //string stuId = Context.Request["stuId"].ToString();
            int      titleid     = int.Parse(Context.Request.QueryString["titleId"]);
            Title    dstitle     = new Title();
            Plan     plan        = new Plan();
            TitleBll titleSelect = new TitleBll();
            PlanBll  planBll     = new PlanBll();

            dstitle = titleSelect.GetTitle(titleid);

            int limited  = int.Parse(dstitle.Limit.ToString());
            int selected = int.Parse(dstitle.Selected.ToString());

            //获取截止时间
            int pid = dstitle.plan.PlanId;

            plan = planBll.Select(pid);
            string   now     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            DateTime nowTime = Convert.ToDateTime(now);
            string   end     = plan.EndTime.ToString("yyyy-MM-dd HH:mm:ss");
            DateTime endTime = Convert.ToDateTime(end);

            try
            {
                if (nowTime <= endTime)
                {
                    if (selected < limited)
                    {
                        Result row = isExist();
                        if (row == Result.记录不存在)
                        {
                            TitleRecord titleRecord = new TitleRecord();
                            titleRecord.student = stu;
                            Title title = new Title();
                            title.TitleId     = titleid;
                            titleRecord.title = title;

                            int rows = pbll.AddTitlerecord(titleRecord);
                            if (rows > 0)
                            {
                                LogHelper.Info(this.GetType(), stu.StuAccount + " - " + stu.RealName + " - 学生选题 - " + dstitle.TitleId + dstitle.title);
                                Response.Write("选题成功");
                                Response.End();
                            }
                            else
                            {
                                Response.Write("选题失败");
                                Response.End();
                            }
                        }
                        else
                        {
                            Response.Write("已选题");
                            Response.End();
                        }
                    }
                    else
                    {
                        Response.Write("已达上限");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("选题时间已截止");
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(this.GetType(), ex);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 添加批次
        /// </summary>
        public void savePlan()
        {
            //获取参数
            string planName  = Context.Request["planName"].ToString(),
                   startTime = Context.Request["startTime"].ToString(),
                   endTime   = Context.Request["endTime"].ToString(),
            //college = Context.Request["college"].ToString(),
                   planstate = Context.Request["state"].ToString();

            try
            {
                //获取院系id
                Teacher    teacher    = (Teacher)Session["user"];
                string     account    = teacher.TeaAccount;
                TeacherBll teacherBll = new TeacherBll();
                loginUser = teacherBll.GetModel(account);
                College ColID = loginUser.college;

                if (planName != "" && startTime != "" && endTime != "" && state.ToString() != "")
                {
                    //int collegeId = int.Parse(college),
                    int state = int.Parse(planstate);
                    //字符串转日期
                    string   start   = Convert.ToDateTime(startTime).ToString("yyyy-MM-dd HH:mm:ss");
                    DateTime startdt = Convert.ToDateTime(start);
                    string   end     = Convert.ToDateTime(endTime).ToString("yyyy-MM-dd HH:mm:ss");
                    DateTime enddt   = Convert.ToDateTime(end);

                    //判断当开始时间在结束时间之后时,不能执行添加
                    TimeSpan ts = enddt - startdt;
                    if (ts.Days >= 1)
                    {
                        Plan plan = new Plan()
                        {
                            PlanName  = planName,
                            StartTime = startdt,
                            EndTime   = enddt,
                            State     = state,
                            college   = ColID
                        };
                        PlanBll pBll   = new PlanBll();
                        Result  result = pBll.Insert(plan);
                        if (result == Result.添加成功)
                        {
                            LogHelper.Info(this.GetType(), loginUser.TeaAccount + loginUser.TeaName + "-添加批次");
                            Response.Write("添加成功");
                            Response.End();
                        }
                        else
                        {
                            Response.Write("添加失败");
                            Response.End();
                        }
                    }
                    else
                    {
                        Response.Write("开始与结束时间间隔必须大于1天");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("以上内容不能出现未填项");
                    Response.End();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(this.GetType(), ex);
            }
        }