コード例 #1
0
    protected void btSave_Click(object sender, EventArgs e)
    {
        for (int i = 0; i < rptList.Items.Count; i++)
        {
            TextBox txtRoyalties = (TextBox)rptList.Items[i].FindControl("txtRoyalties");
            TextBox txtPoints    = (TextBox)rptList.Items[i].FindControl("txtPoints");
            TextBox txtClass     = (TextBox)rptList.Items[i].FindControl("txtClass");
            TextBox txtFullName  = (TextBox)rptList.Items[i].FindControl("txtFullName");
            Label   lbl          = (Label)rptList.Items[i].FindControl("lblNewsID");

            NewsRoyalties _NewsRoyalties = new NewsRoyalties()
            {
                NewsID = Convert.ToInt32(lbl.Text)
            };
            _NewsRoyalties           = _NewsRoyalties.Get();
            _NewsRoyalties.Royalties = Convert.ToInt32(txtRoyalties.Text);
            _NewsRoyalties.Points    = Convert.ToInt32(txtPoints.Text);
            _NewsRoyalties.Class     = txtClass.Text.Trim();
            _NewsRoyalties.FullName  = txtFullName.Text.Trim();
            _NewsRoyalties.Update();
        }
    }
コード例 #2
0
    private void BindData()
    {
        NewsRoyalties _NewsRoyalties = new NewsRoyalties();
        int           year           = Convert.ToInt32(drpYear.SelectedValue);
        int           month          = Convert.ToInt32(drpMonth.SelectedValue);
        int           day            = Convert.ToInt32(drpDay.SelectedValue);
        int           totalRecord    = 0;
        int           totalRoyalty   = 0;
        int           pageSize       = Convert.ToInt32(drpPageSize.SelectedValue);
        int           pageIndex      = Convert.ToInt32(drpPage.SelectedValue);
        int           userID         = Convert.ToInt32(drpAuthor.SelectedValue);

        rptList.DataSource = _NewsRoyalties.Report(year, month, day, userID, pageIndex, pageSize, ref totalRecord, ref totalRoyalty);
        rptList.DataBind();

        lblTotalRecord.Text  = "Bài viết: " + totalRecord.ToString();
        lblTotalRoyalty.Text = "Nhuận bút: " + totalRoyalty.ToString("#,#").Replace(",", ".");
        totalRecord          = (totalRecord - 1) / pageSize + 1;
        if (totalRecord == 0)
        {
            totalRecord = 1;
        }
        drpPage.Items.Clear();
        for (int i = 1; i <= totalRecord; i++)
        {
            drpPage.Items.Add(new ListItem(i.ToString()));
        }

        try
        {
            drpPage.SelectedValue = pageIndex.ToString();
        }
        catch
        {
        }
    }