private void IniPage()
        {
            try
            {
                BLL.SupplierImport imp = new SupplierImport();
                this.lblFieldDesc.Text = imp.GetDefineFieldDesc();

                //取所有的系统类别及其全名
                QueryAgent qa = new Rms.ORMap.QueryAgent();
                try
                {
                    DataTable tbAllSystemGroup = qa.ExecSqlForDataSet("select dbo.GetSystemGroupFullName(GroupCode) as FullName, * from SystemGroup where ClassCode = '1401'").Tables[0];
                    Session["tbAllSystemGroup"] = tbAllSystemGroup;
                }
                finally
                {
                    qa.Dispose();
                }
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(JavaScript.Alert(true, "初始化页面出错:" + ex.Message));
            }
        }
        /// <summary>
        /// 另存为csv
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDownloadCsv_ServerClick(object sender, System.EventArgs e)
        {
            try
            {
                if (Session["entityImportSupplier"] == null)
                {
                    throw new Exception("超时,请重新导入");
                }

                EntityData entity = (EntityData)Session["entityImportSupplier"];
                DataView   dv     = new DataView(entity.CurrentTable, "IsImport = 1", "rowid", DataViewRowState.CurrentRows);

                RmsPM.BLL.FileIO io = new FileIO(Response, Request, Server, Session);
                io.SaveFileName = "SupplierImportPrepare.csv";

                StreamWriter w = new StreamWriter(io.SaveFileNamePhy, false, System.Text.Encoding.Default);
                try
                {
                    BLL.SupplierImport imp = new SupplierImport();
                    string             s;

                    //第1行是列标题
                    s  = imp.GetDefineFieldDesc();
                    s += ",预导入结果,错误提示";
                    w.WriteLine(s);

                    int count = imp.tbDefine.Rows.Count;

                    //数据
                    foreach (DataRowView drv in dv)
                    {
                        DataRow dr = drv.Row;
                        s = "";

                        s = BLL.ConvertRule.ToString(dr["text"]);
                        string[] arr = BLL.ImportRule.SplitCsvLine(s);

                        //用“,”补足列数
                        for (int k = arr.Length; k < count; k++)
                        {
                            s += ",";
                        }

                        /*
                         * //按字段定义重新写入
                         * for (int i=0;i<count;i++)
                         * {
                         *      DataRow drDefine = imp.tbDefine.Rows[i];
                         *      string FieldName = drDefine["FieldName"].ToString();
                         *
                         *      if (i > 0)
                         *              s += ",";
                         *
                         *      if (FieldName != "")
                         *      {
                         *              s += BLL.ConvertRule.ToString(dr[FieldName]);
                         *      }
                         * }
                         */

                        //写入预导入结果
                        s += "," + BLL.ConvertRule.ToString(dr["ImportResultName"]);

                        s += "," + BLL.ConvertRule.ToString(dr["ImportHint"]);

                        w.WriteLine(s);
                    }
                }
                finally
                {
                    w.Close();
                }

                io.ShowClient();
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLog(this.ToString(), ex, "");
                Response.Write(JavaScript.Alert(true, "另存为csv出错:" + ex.Message));
            }
        }