Exemple #1
0
    private void loadData()
    {
        SqlDataSource sds = new SqlDataSource();

        sds.ConnectionString  = connectionString;
        sds.SelectCommand     = "dbo.getSchedules";
        sds.SelectCommandType = SqlDataSourceCommandType.StoredProcedure;
        DataView dv = sds.Select(DataSourceSelectArguments.Empty) as DataView;

        if (dv.Count > 0)
        {
            for (int i = 0; i < dv.Count; i++)
            {
                CSchedule schedule = new CSchedule();
                schedule.id         = (int)dv.Table.Rows[i]["ID_Schedule"];
                schedule.user_id    = dv.Table.Rows[i]["ID_User"].ToString();
                schedule.patient_id = dv.Table.Rows[i]["ID_Patient"].ToString();
                schedule.assess_id  = (int)dv.Table.Rows[i]["ID_Assess"];
                schedule.deadLine   = DateTime.Parse(dv.Table.Rows[i]["deadLine"].ToString());
                schedule.isFinished = (bool)dv.Table.Rows[i]["isFinished"];

                schedule.assess_name = assessFactoryLite.getById(schedule.assess_id).name;
                schedules.Add(schedule);
            }
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["loginName"] != null)
        {
            user = userFactory.getByAccount(Session["loginName"].ToString());
        }


        int assess_id = 0;

        if (Request.QueryString["pid"] != null && Request.QueryString["aid"] != null && Request.QueryString["sid"] != null)
        {
            assess_id   = Convert.ToInt32(Request.QueryString["aid"]);
            patient_id  = Request.QueryString["pid"];
            schedule_id = Convert.ToInt32(Request.QueryString["sid"]);
        }


        myAssess           = assessFactory.getById(assess_id);
        isFinished         = scheduleFactory.getById(schedule_id).isFinished;
        lblAssessName.Text = myAssess.name;

        CGroup group = new CGroup();

        group.id = 0;

        int groupCount = 0;

        foreach (CItem item in myAssess.items)
        {
            if (item.group != null)
            {
                //item有group
                if (!item.group.id.Equals(group.id))
                {
                    //不同group
                    if (groupCount > 0)
                    {
                        if (isFinished)
                        {
                            Label lblGroupScore = new Label();
                            lblGroupScore.Text = "分數:" + groupScore.ToString();

                            PlaceHolder1.Controls.Add(new LiteralControl("<div class='panel-primary panel-footer'><span class='glyphicon glyphicon-ok' aria-hidden='true'></span>"));
                            PlaceHolder1.Controls.Add(lblGroupScore);
                            PlaceHolder1.Controls.Add(new LiteralControl("</div>"));
                        }
                        PlaceHolder1.Controls.Add(new LiteralControl("</div>"));
                    }

                    group.id = item.group.id;

                    Label lblGroupName = new Label();
                    lblGroupName.Text     = item.group.name;
                    lblGroupName.CssClass = "label";

                    PlaceHolder1.Controls.Add(new LiteralControl("<div class='panel panel-primary' style='font-size:X-large'><div class='panel-heading'>"));
                    PlaceHolder1.Controls.Add(lblGroupName);
                    PlaceHolder1.Controls.Add(new LiteralControl("</div>"));
                    groupCount++;
                    groupScore = 0;
                }
            }
            else
            {
                //item沒group
                groupCount = 0;
                if (groupCount > 0)
                {
                    PlaceHolder1.Controls.Add(new LiteralControl("</div>"));
                }
            }
            //加入項目
            addItem(item);
        }
        PlaceHolder1.Controls.Add(new LiteralControl("</div>"));

        Button btnSubmit = new Button();

        if (isFinished)
        {
            lbltotalScore.Visible = true;
            lbltotalScore.Text    = "總分:" + totalScore.ToString();

            btnSubmit.Text     = "上一頁";
            btnSubmit.Click   += btnBack_Click;
            btnSubmit.CssClass = "btn btn-large btn-block btn-danger";
        }
        else
        {
            btnSubmit.Text     = "送出";
            btnSubmit.Click   += btnSubmit_Click;
            btnSubmit.CssClass = "btn btn-large btn-block btn-success";
        }
        btnSubmit.Height    = 60;
        btnSubmit.Font.Size = 18;
        btnSubmit.ForeColor = Color.Black;

        PlaceHolder1.Controls.Add(btnSubmit);
    }