Exemplo n.º 1
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
 {
     StaffList rpt = new StaffList();
     rpt.Site = this.Site;
     return rpt;
 }
Exemplo n.º 2
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            ds = new StaffDataSet();
            DataTable dt = (DataTable)Cache["StaffList"];

            if (!Page.IsPostBack)
            {
                staffname     = Session["staffname"].ToString();
                positionid    = Int32.Parse(Session["positionid"].ToString());
                mobile        = Session["mobile"].ToString();
                email         = Session["email"].ToString();
                gender        = Session["gender"].ToString();
                bound         = Session["bound"].ToString();
                displayfields = (string[])Session["displayfieldsname"];

                ViewState["staffname"]     = staffname;
                ViewState["positionid"]    = positionid.ToString();
                ViewState["mobile"]        = mobile.ToString();
                ViewState["email"]         = email.ToString();
                ViewState["gender"]        = gender.ToString();
                ViewState["bound"]         = bound.ToString();
                ViewState["displayfields"] = displayfields;

                Session["staffname"]         = null;
                Session["positionid"]        = null;
                Session["mobile"]            = null;
                Session["gender"]            = null;
                Session["displayfieldsname"] = null;
                Session["bound"]             = null;
            }
            else
            {
                staffname     = ViewState["staffname"].ToString();
                positionid    = Int32.Parse(ViewState["positionid"].ToString());
                mobile        = ViewState["mobile"].ToString();
                email         = ViewState["email"].ToString();
                gender        = ViewState["gender"].ToString();
                bound         = ViewState["bound"].ToString();
                displayfields = (string[])ViewState["displayfields"];
            }

            if (dt == null)
            {
                //得不到缓存的内容,重新获取
                SqlDataReader        dr;
                UDS.Components.Staff staff = new UDS.Components.Staff();
                dr = staff.Find(staffname, positionid, mobile, email, gender, bound);
                dt = UDS.Components.Tools.ConvertDataReaderToDataTable(dr);

                Cache["StaffList"] = dt;
            }

            //添加datatable中的数据
            foreach (DataRow row in dt.Rows)
            {
                DataRow staffviewrow = ds.StaffView.NewRow();
                staffviewrow["Staff_Name"]    = row["Staff_Name"].ToString();
                staffviewrow["RealName"]      = row["RealName"].ToString();
                staffviewrow["Mobile"]        = row["Mobile"].ToString();
                staffviewrow["SexName"]       = row["SexName"].ToString();
                staffviewrow["Email"]         = row["Email"].ToString();
                staffviewrow["Position_Name"] = row["Position_Name"].ToString();
                ds.StaffView.AddStaffViewRow((StaffDataSet.StaffViewRow)staffviewrow);
            }

            stafflistreport = new StaffList();
            stafflistreport.SetDataSource(ds);
            crv_StaffList.ReportSource = stafflistreport;
            //根据用户选择隐藏字段
            foreach (string fieldname in displayfields)
            {
                stafflistreport.ReportDefinition.ReportObjects["ttl" + fieldname].ObjectFormat.EnableSuppress = false;
                stafflistreport.ReportDefinition.ReportObjects[fieldname].ObjectFormat.EnableSuppress         = false;
            }

            crv_StaffList.DataBind();
        }
Exemplo n.º 3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            ds = new StaffDataSet();
            DataTable dt =(DataTable)Cache["StaffList"];
            if(!Page.IsPostBack)
            {
                staffname = Session["staffname"].ToString();
                positionid = Int32.Parse(Session["positionid"].ToString());
                mobile = Session["mobile"].ToString();
                email = Session["email"].ToString();
                gender = Session["gender"].ToString();
                dept = Session["dept"].ToString();
                bound = Session["bound"].ToString();
                displayfields = (string[])Session["displayfieldsname"];

                ViewState["staffname"] = staffname;
                ViewState["positionid"] = positionid.ToString();
                ViewState["mobile"] = mobile.ToString();
                ViewState["email"] = email.ToString();
                ViewState["gender"] = gender.ToString();
                ViewState["dept"] = dept.ToString();
                ViewState["bound"] = bound.ToString();
                ViewState["displayfields"] = displayfields;

                Session["staffname"] = null;
                Session["positionid"] = null;
                Session["mobile"] = null;
                Session["gender"] = null;
                Session["dept"] = null;
                Session["displayfieldsname"] = null;
                Session["bound"] = null;
            }
            else
            {
                staffname = ViewState["staffname"].ToString();
                positionid = Int32.Parse(ViewState["positionid"].ToString());
                mobile = ViewState["mobile"].ToString();
                email = ViewState["email"].ToString();
                gender = ViewState["gender"].ToString();
                dept = ViewState["dept"].ToString();
                bound = ViewState["bound"].ToString();
                displayfields = (string[])ViewState["displayfields"];
            }

            if(dt==null)
            {
                //�ò�����������ݣ����»�ȡ
                SqlDataReader dr;
                UDS.Components.Staff staff = new UDS.Components.Staff();
                dr = staff.Find(staffname, positionid, mobile, email, gender, dept,bound);
                dt = UDS.Components.Tools.ConvertDataReaderToDataTable(dr);

                Cache["StaffList"] = dt;

            }

            //���datatable�����
            foreach(DataRow row in dt.Rows)
            {
                DataRow staffviewrow = ds.StaffView.NewRow();
                staffviewrow["Staff_Name"] = row["Staff_Name"].ToString();
                staffviewrow["RealName"] = row["RealName"].ToString();
                staffviewrow["Mobile"] = row["Mobile"].ToString();
                staffviewrow["SexName"] = row["SexName"].ToString();
                staffviewrow["Email"] = row["Email"].ToString();
                staffviewrow["Position_Name"] = row["Position_Name"].ToString();
                ds.StaffView.AddStaffViewRow((StaffDataSet.StaffViewRow)staffviewrow);
            }

            stafflistreport = new StaffList();
            stafflistreport.SetDataSource(ds);
            crv_StaffList.ReportSource = stafflistreport;
            //�����û�ѡ�������ֶ�
            foreach(string fieldname in displayfields)
            {
                stafflistreport.ReportDefinition.ReportObjects["ttl"+fieldname].ObjectFormat.EnableSuppress = false;
                stafflistreport.ReportDefinition.ReportObjects[fieldname].ObjectFormat.EnableSuppress = false;
            }

            crv_StaffList.DataBind();
        }
Exemplo n.º 4
0
 public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() {
     StaffList rpt = new StaffList();
     rpt.Site = this.Site;
     return rpt;
 }