예제 #1
0
    public void MyDataBind()
    {
        string    str = "select GeneralID,Title,CreateTime,NodeID,Inputer,xmdd,xmlx,sjfg,xmgm,sjfy,jffs,jyyq,sjryszd,sjsxb from ZL_CommonModel left join ZL_C_faxmmx on ItemID=ID where ModelID=50 And Status=99 UNION select GeneralID,Title,CreateTime,NodeID,Inputer,xmdd,xmlx,sjfg,xmgm,sjfy,jffs,jyyq,sjryszd,sjsxb from ZL_CommonModel left join ZL_C_sgtxmmx on ItemID=ID where ModelID=51 And Status=99 Union select GeneralID,Title,CreateTime,NodeID,Inputer,xmdd,xmlx,sjfg,xmgm,sjfy,jffs,jyyq,sjryszd,sjsxb from ZL_CommonModel left join ZL_C_sgfwxm on ItemID=ID where ModelID=54 And Status=99 order By CreateTime DESC";
        DataTable dt  = SqlHelper.ExecuteTable(str, null);

        RPT.DataSource = dt;
        RPT.DataBind();

        DataTable dts = SqlHelper.ExecuteTable("select top 1 * from ZL_CommonModel left join ZL_C_Designer on ItemID=ID where ModelID=48 And inputer='" + buser.GetLogin().UserName + "' And Status=99", null);
        string    szdq = "", gzjy = "", sex = "";

        if (dts.Rows.Count > 0)
        {
            szdq = dts.Rows[0]["szdq"].ToString().Split('|')[0];
            gzjy = dts.Rows[0]["gzjy"].ToString();
            sex  = dts.Rows[0]["sex"].ToString();
        }
        DataTable dt1 = dt;

        dt1.DefaultView.RowFilter = "jyyq<='" + gzjy + "'";
        dt1 = dt1.DefaultView.ToTable();
        dt1.DefaultView.RowFilter = "sjsxb='" + sex + "'";
        dt1 = dt1.DefaultView.ToTable();
        dt1.DefaultView.RowFilter = "sjryszd like '%" + szdq + "%'";
        dt1             = dt1.DefaultView.ToTable();
        RPT1.DataSource = dt1;
        RPT1.DataBind();
    }
        private void CompNameCBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            crystalReportViewer1.Visible = true;
            RPT1   rpt      = new RPT1();
            string comp_num = "";

            foreach (Competition i in competitions)
            {
                if (i.comp_Name == CompNameCBox.SelectedItem.ToString())
                {
                    comp_num = i.comp_Code;
                }
            }
            /********************************************************/
            TextObject Comp_NameTxt;

            Comp_NameTxt      = (TextObject)rpt.ReportDefinition.ReportObjects["compNameTtx"];
            Comp_NameTxt.Text = CompNameCBox.SelectedItem.ToString();
            /******************************************************/
            TextObject DateTxt;

            DateTxt      = (TextObject)rpt.ReportDefinition.ReportObjects["Date"];
            DateTxt.Text = DateTime.Now.ToString("yyyy/dd/MMMM", new System.Globalization.CultureInfo("ar-SA"));
            /*******************************************************/
            Competition c  = new Competition();
            DataTable   dt = c.getReport(comp_num);

            rpt.SetDataSource(dt);
            rpt.Refresh();
            crystalReportViewer1.Refresh();
            crystalReportViewer1.ReportSource = rpt;
            crystalReportViewer1.Refresh();
        }