コード例 #1
0
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[5].Text == "0")
            {
                e.Row.Cells[5].Text = "Cash/Cheque";
                e.Row.Cells[6].Text = e.Row.Cells[6].Text == "1" ? "Paid" : "Unpaid";

                if (e.Row.Cells[6].Text == "Unpaid" && lblClassStatus.Text != "Cancelled")
                {
                    ((Button)e.Row.Cells[7].FindControl("btnPayment")).Visible = true;
                }
            }
            else
            {
                try
                {
                    DBManager manager = new DBManager("table");
                    manager.AddParameter(int.Parse(lblID.Text));
                    DataTable table = manager.queryTable(
                        @"select 'Credit/ATTID:' + convert(varchar, reg.intIdAttendance) + ' CID:' + convert(varchar,ClassSchedule.intIdClassSchedule) + ' (' + convert(varchar, s.strNameSubject) + ' ' + convert(varchar, l.strNameLevel) + ')' from MakeupAttendance
                        inner join Attendance ot on ot.intIdAttendance = MakeupAttendance.intIdAttendanceOnetimeMakeupAttendance
                        inner join Attendance reg on reg.intIdAttendance = MakeupAttendance.intIdAttendanceRegularMakeupAttendance
                        inner join ClassSchedule on ClassSchedule.intIdClassSchedule = reg.intIdClassAttendance
                        inner join [Subject] s on s.intIdSubject = ClassSchedule.intIdSubjectClassSchedule
                        inner join [Level] l on l.intIdLevel = ClassSchedule.intIdLevelClassSchedule
                        where ot.intIdClassAttendance = @p0 ");

                    if (table.Rows.Count > 0)
                        e.Row.Cells[5].Text = table.Rows[0][0].ToString();
                    else
                        e.Row.Cells[5].Text = "Undetected";
                }
                catch (Exception ex)
                {
                    e.Row.Cells[5].Text = "Undetected";
                }

                e.Row.Cells[6].Text = "Paid";
            }
        }
    }
コード例 #2
0
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            if (e.Row.Cells[9].Text == "1")
            {
                e.Row.Cells[9].Text = "Cancelled";
                e.Row.Cells[10].FindControl("btnCancel").Visible = false;
            }
            else
                e.Row.Cells[9].Text = "Running";

            Label l = ((Label)e.Row.Cells[10].FindControl("lblCount"));
            try
            {
                DBManager manager = new DBManager("Table");
                manager.AddParameter(int.Parse(e.Row.Cells[0].Text));
                l.Text =
                    manager.queryTable(
                    "select COUNT(*) from ASP_IntensiveClassContainer where intIntensiveClassID = @p0")
                    .Rows[0][0].ToString();

            }
            catch (Exception ex)
            {
                l.Text = "Undetected";
            }

            if (e.Row.Cells[9].Text == "Cancelled")
            {
                e.Row.BackColor = System.Drawing.Color.DarkBlue;
                e.Row.ForeColor = System.Drawing.Color.White;
            }
            else
                if (l.Text == "Undetected")
                {
                    e.Row.BackColor = System.Drawing.Color.Red;
                    e.Row.ForeColor = System.Drawing.Color.White;
                }
                else if (int.Parse(l.Text) >= int.Parse(e.Row.Cells[8].Text))
                {
                    e.Row.BackColor = System.Drawing.Color.Gold;
                    e.Row.ForeColor = System.Drawing.Color.Brown;
                }
                else if (int.Parse(l.Text) < int.Parse(e.Row.Cells[7].Text))
                {
                    e.Row.BackColor = System.Drawing.Color.Tomato;
                    e.Row.ForeColor = System.Drawing.Color.White;
                }
        }
    }