コード例 #1
0
        private void RptBind(string _strWhere, string _order)
        {
            int pageSize    = GetPageSize(30); //每页数量
            int page        = MyRequest.GetQueryInt("page", 1);
            int start_index = pageSize * (page - 1) + 1;
            int end_index   = pageSize * page;

            BLL.CCOM.View_User_CEE bll = new BLL.CCOM.View_User_CEE();

            //计算数量
            int totalCount = bll.GetRecordCount(_strWhere);

            //   txtSearchResult.Text = "本次命中" + totalCount.ToString() + "条";

            //绑定当页
            this.rptList.DataSource = bll.GetListByPage(_strWhere, _order, start_index, end_index);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("CEEScoreList.aspx", "fun_id={0}&page={1}&keywords={2}&pro_id={3}", DESEncrypt.Encrypt(this.fun_id), "__id__",
                                              this.txtKeywords.Text, DESEncrypt.Encrypt(this.ddlProvince.SelectedValue));

            this.PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8, true);
        }
コード例 #2
0
        protected void exportexcel_ServerClick(object sender, EventArgs e)
        {
            string order    = "UP_CCOM_number asc";
            string strWhere = CombSqlTxt(this.keywords);

            try
            {
                var bll = new BLL.CCOM.View_User_CEE();
                List <Model.CCOM.View_User_CEE> modelList = bll.GetModelList(strWhere + " order by " + order);

                DataSet ds = new DataSet();
                ds.Tables.Clear();

                DataTable  dt = ds.Tables.Add("Sheet1");
                DataRow    dr;
                DataColumn column;

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "序号";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "考生号";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "姓名";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "高考报名号";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "专业方向";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "考生类型:文/理";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "语文";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "数学";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "外语";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "综合分";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "附加分";
                ds.Tables["Sheet1"].Columns.Add(column);

                column            = new DataColumn();
                column.DataType   = System.Type.GetType("System.String");
                column.ColumnName = "总分";
                ds.Tables["Sheet1"].Columns.Add(column);

                /*
                 * //增加只导出选择部分学生的功能
                 * bool exprotAll = true;
                 * for (int i = 0; i < rptList.Items.Count; i++)
                 * {
                 *  CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                 *  if (cb.Checked == true)
                 *  {
                 *      exprotAll = false;
                 *      break;
                 *  }
                 * }
                 */

                //int count = exprotAll == true ? modelList.Count : rptList.Items.Count;
                int count = modelList.Count;
                for (int i = 0, num = 1; i < count; i++, num++)
                {
                    /*
                     * //如果只导出部分学生且未选中,则跳过
                     * if (exprotAll == false)
                     * {
                     *  CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                     *  if (cb.Checked == false)
                     *  {
                     *      //增加序号
                     *      num--;
                     *      continue;
                     *  }
                     * }
                     */

                    dr             = ds.Tables["Sheet1"].NewRow();
                    dr["序号"]       = num.ToString();
                    dr["考生号"]      = modelList[i].UP_CCOM_number;
                    dr["姓名"]       = modelList[i].User_realname;
                    dr["高考报名号"]    = modelList[i].UP_CEE_number;
                    dr["专业方向"]     = GetAgencyName(modelList[i].Agency_id.ToString());
                    dr["考生类型:文/理"] = GetWenOrLi(modelList[i].CEE_type.ToString());

                    if (modelList[i].CEE_Chinese_score.ToString() != "" && modelList[i].CEE_Chinese_score.ToString() != null)
                    {
                        dr["语文"] = ((decimal)modelList[i].CEE_Chinese_score).ToString("#.##");
                    }
                    if (modelList[i].CEE_Math_score.ToString() != "" && modelList[i].CEE_Math_score.ToString() != null)
                    {
                        dr["数学"] = ((decimal)modelList[i].CEE_Math_score).ToString("#.##");
                    }
                    if (modelList[i].CEE_English_score.ToString() != "" && modelList[i].CEE_English_score.ToString() != null)
                    {
                        dr["外语"] = ((decimal)modelList[i].CEE_English_score).ToString("#.##");
                    }
                    if (modelList[i].CEE_comprehensive_score.ToString() != "" && modelList[i].CEE_comprehensive_score.ToString() != null)
                    {
                        dr["综合"] = ((decimal)modelList[i].CEE_comprehensive_score).ToString("#.##");
                    }
                    if (modelList[i].CEE_extra_score.ToString() != "" && modelList[i].CEE_extra_score.ToString() != null)
                    {
                        dr["附加分"] = ((decimal)modelList[i].CEE_extra_score).ToString("#.##");
                    }
                    if (modelList[i].CEE_score.ToString() != "" && modelList[i].CEE_score.ToString() != null)
                    {
                        dr["总分"] = ((decimal)modelList[i].CEE_score).ToString("#.##");
                    }

                    ds.Tables["Sheet1"].Rows.Add(dr);
                }

                DataToExcel.ExportToExcel(ds, Server.MapPath("/upload/excel/"), this.ddlProvince.SelectedItem.Text + "_高考分数_" + DateTime.Now.ToFileTime().ToString() + ".xlsx", this.Page);
            }
            catch
            {
                JscriptMsg("导出高考分数出错", "", "Error");
            }
        }