public ActionResult Detail(int id, int? pageNo, string parm, OpenBidProjectQuery query)
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;

            if (sitemaster["istest"] == "1")
            {
                int uid = Int32.Parse(sitemaster["userid"]);
                IList<int> openprojectlist = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectopen", uid);
                //先检查一共看的数目
                if (openprojectlist.Count > 0)
                {
                    //如果有看得记录,先检查是否是看过的
                    Hashtable htt = new Hashtable();
                    htt["pid"] = id;
                    htt["uid"] = uid;
                    IList<int> sawid = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectopenpid", htt);
                    //如果没看过,就检查是否超过最大值
                    if (sawid.Count == 0)
                    {
                        if (openprojectlist.Count < 5)
                        {
                            //没超过就写入记录
                            OpenBidNumForTest ob = new OpenBidNumForTest();
                            ob.OpenprojectNum = id;
                            ob.UserID = uid;
                            new OpenBidNumForTestDao().Insert(ob);
                        }
                        else
                        {
                            //超过了
                            return RedirectToAction("List");
                        }
                    }
                }
                else
                {
                    //之前没有看过也写入记录
                    OpenBidNumForTest ob = new OpenBidNumForTest();
                    ob.OpenprojectNum = id;
                    ob.UserID = uid;
                    new OpenBidNumForTestDao().Insert(ob);
                }
            }

            DOpenProjectDao mDOpenProjectDao = new DOpenProjectDao();
            DOpenProject mDOpenProject = mDOpenProjectDao.Find(id);

            int interval = 0;
            if (EnterPriseMemberInfo.Memberlevel == 201)
                interval = 6;
            if (EnterPriseMemberInfo.Memberlevel == 301)
                interval = 12;
            DateTime limitedate = DateTime.Now.AddMonths(interval);

            if ((EnterPriseMemberInfo.Memberlevel == 201 || EnterPriseMemberInfo.Memberlevel == 301) && mDOpenProject.OpenDate > limitedate)
            {
                return RedirectToAction("MemberLevelError", "Base");
            }
            ViewData["ProjectDescription"] = mDOpenProject.NewProjectDescription;
            ViewData["Summary"] = mDOpenProject.Summary;
            ViewData["OID"] = mDOpenProject.OID;

            //如果有参数
            if (query.IsHaveProperty())
            {
                parm = query.GetParameter();
                ViewData["Query"] = query;
                return RedirectToAction("Detail", new { id = id, pageNo = 1, parm = parm });
            }
            else
            {
                int PageNo = pageNo ?? 1;
                //表明第一次进来
                if (query.CommonName != null)
                {
                    query.LoadProperties(parm);
                }
                if (string.IsNullOrEmpty(query.CommonName) && string.IsNullOrEmpty(query.ProductEnterpriseName) && string.IsNullOrEmpty(query.TenderEnterpriseName) && query.CommonName.Length < 3)
                {
                    pageNo = 1;
                }
                else
                {
                    query.IsSearched = "1";
                }
                //页码与记录数
                int count = 0;
                //是否竞品条件
                bool compete = false;
                //取数据与记录数
                List<string> th = new List<string>();
                DOpenMedicineDao m = new DOpenMedicineDao();
                DataTable data = m.GetData(id, PageNo, PageSizeDetail, query, out count, ref compete,ref th);

                #region 数据处理
                if (data == null)
                {
                    data = new DataTable();
                }
                if (!data.Columns.Contains("ID"))
                {
                    DataColumn dc = new DataColumn();
                    dc.ColumnName = "ID";
                    data.Columns.Add(dc);
                }

                int beginNo = 0;
                if (!compete)
                {
                    beginNo = (PageNo - 1) * PageSizeDetail;
                }

                for (int i = 1; i<= data.Rows.Count; i++)
                {
                    data.Rows[i-1]["ID"] =(beginNo+ i).ToString();
                }
                if (data.Columns.Contains("ROWID"))
                {
                    data.Columns.Remove("ROWID");
                }
                if (data.Columns.Contains("OID"))
                {
                    data.Columns.Remove("OID");
                }
                List<DataRow> listRow = new List<DataRow>();
                foreach (DataRow dr in data.Rows)
                {
                    listRow.Add(dr);
                }
                PagedList<DataRow> list;
                if (compete)
                {
                    list = new PagedList<DataRow>(listRow, PageNo, PageSizeDetail);
                }
                else
                {
                    list = new PagedList<DataRow>(listRow, PageNo, PageSizeDetail, count);
                }
                ViewData["Compete"] = compete;
                ViewData["Query"] = query;
                ViewData["Count"] = count;
                ViewData["Th"] = th;
                #endregion

                #region excel
                if (sitemaster["istest"] == "0" && query.Excel == "1")
                {
                    ExcelExport mx = new ExcelExport();
                    mx.InitTh();
                    if (query.CommonName != null)
                        mx._fileName = query.CommonName + DateTime.Now.ToShortDateString() + ".xls";
                    else
                    {
                        if (query.ProductEnterpriseName != null)
                            mx._fileName = query.ProductEnterpriseName + DateTime.Now.ToShortDateString() + ".xls";
                        else
                            mx._fileName = query.TenderEnterpriseName + DateTime.Now.ToShortDateString() + ".xls";
                    }

                    //项目名称
                    TableItemStyle tiName = new TableItemStyle();
                    tiName.Font.Size = 14;
                    tiName.ForeColor = System.Drawing.Color.Red;
                    tiName.HorizontalAlign = HorizontalAlign.Center;
                    mx.HeadExtrInfo.Add(mDOpenProject.NewProjectName, tiName);
                    //项目备注
                    TableItemStyle tiRemark = new TableItemStyle();
                    tiRemark.Font.Size = 13;
                    tiRemark.ForeColor = System.Drawing.Color.Red;
                    tiRemark.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add("项目备注说明:", tiRemark);
                    //项目备注
                    TableItemStyle tiRemarkContent = new TableItemStyle();
                    tiRemarkContent.Font.Size = 12;
                    tiRemarkContent.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add(mDOpenProject.NewProjectDescription, tiRemarkContent);

                    TableItemStyle tiCount = new TableItemStyle();
                    tiCount.Font.Size = 12;
                    tiCount.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add("共有" + count.ToString() + "条", tiCount);

                    if (data.Columns.Contains("ID"))
                    {
                        data.Columns.Remove("ID");
                    }
                    //20111019修改按显示表头导出,去掉多余列
                    if (data.Columns.Contains("Mine"))
                    {
                        data.Columns.Remove("Mine");
                    }
                    mx._thName = th.ToArray();//20111019修改按显示表头导出
                    mx.DataTableToExcel(data);
                }
                #endregion
                return View(list);

            }
        }
        public ActionResult Detail(int id, int? pageNo, string parm, FormCollection query)
        {
            Dictionary<string, string> sitemaster = GetSiteMaster();
            ViewData["SiteMaster"] = sitemaster;
            int uid = Int32.Parse(sitemaster["userid"]);

            if (sitemaster["istest"] == "1")
            {
                IList<int> openprojectlist = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectopen", uid);
                //先检查一共看的数目
                if (openprojectlist.Count > 0)
                {
                    //如果有看得记录,先检查是否是看过的
                    Hashtable htt = new Hashtable();
                    htt["pid"] = id;
                    htt["uid"] = uid;
                    IList<int> sawid = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectopenpid", htt);
                    //如果没看过,就检查是否超过最大值
                    if (sawid.Count == 0)
                    {
                        if (openprojectlist.Count < 5)
                        {
                            //没超过就写入记录
                            OpenBidNumForTest ob = new OpenBidNumForTest();
                            ob.OpenprojectNum = id;
                            ob.UserID = uid;
                            new OpenBidNumForTestDao().Insert(ob);
                        }
                        else
                        {
                            //超过了
                            return RedirectToAction("List");
                        }
                    }
                }
                else
                {
                    //之前没有看过也写入记录
                    OpenBidNumForTest ob = new OpenBidNumForTest();
                    ob.OpenprojectNum = id;
                    ob.UserID = uid;
                    new OpenBidNumForTestDao().Insert(ob);
                }
            }

            DOpenProjectDao mDOpenProjectDao = new DOpenProjectDao();
            DOpenProject mDOpenProject = mDOpenProjectDao.Find(id);

            int interval = 0;
            if (EnterPriseMemberInfo.Memberlevel == 201)
                interval = 6;
            if (EnterPriseMemberInfo.Memberlevel == 301)
                interval = 12;
            DateTime limitedate = DateTime.Now.AddMonths(interval);

            if ((EnterPriseMemberInfo.Memberlevel == 201 || EnterPriseMemberInfo.Memberlevel == 301) && mDOpenProject.OpenDate > limitedate)
            {
                return RedirectToAction("MemberLevelError", "Base");
            }
            ViewData["ProjectDescription"] = mDOpenProject.NewProjectDescription;
            ViewData["Summary"] = mDOpenProject.Summary;
            ViewData["OID"] = mDOpenProject.OID;

            Dictionary<string, string> dict = ParmHelper.Analysis(query);
            //如果有参数
            if (dict.Count != 0)
            {
                string parmeter = ParmHelper.BuildParm(dict);
                return RedirectToAction("Detail", new { id = id, pageNo = 1, parm = parmeter });
            }
            else
            {
                Hashtable memberkeys = new Hashtable();
                int PageNo = pageNo ?? 1;

                if (parm != null)
                {
                    dict = ParmHelper.AnalysisParm(parm);
                    Hashtable ht = new Hashtable();
                    ht.Add("ID", dict["CommonName"]);
                    ht.Add("UserID", uid);
                    memberkeys = CRMMapper.Get().QueryForObject<Hashtable>("MemberMedicineKey.FindByID", ht);
                    dict["IsSearched"] = "1";
                }
                else
                {
                    memberkeys.Add("KeyList", "");
                    dict.Add("excel", "");
                }

                string commonnames = memberkeys["KeyList"].ToString().Replace(" ", "").Replace(" ", "");

                //页码与记录数
                int count = 0;
                //是否竞品条件
                bool compete = false;
                //取数据与记录数
                List<string> th = new List<string>();
                DOpenMedicineDao m = new DOpenMedicineDao();
                DataTable data = m.GetExportData(id, PageNo, PageSizeDetail, commonnames, out count, ref th, dict["excel"]);

                #region 数据处理
                if (data == null)
                {
                    data = new DataTable();
                }
                if (!data.Columns.Contains("ID"))
                {
                    DataColumn dc = new DataColumn();
                    dc.ColumnName = "ID";
                    data.Columns.Add(dc);
                }

                int beginNo = 0;
                if (!compete)
                {
                    beginNo = (PageNo - 1) * PageSizeDetail;
                }

                for (int i = 1; i <= data.Rows.Count; i++)
                {
                    data.Rows[i - 1]["ID"] = (beginNo + i).ToString();
                }
                if (data.Columns.Contains("ROWID"))
                {
                    data.Columns.Remove("ROWID");
                }
                if (data.Columns.Contains("OID"))
                {
                    data.Columns.Remove("OID");
                }
                List<DataRow> listRow = new List<DataRow>();
                foreach (DataRow dr in data.Rows)
                {
                    listRow.Add(dr);
                }
                PagedList<DataRow> list;
                if (compete)
                {
                    list = new PagedList<DataRow>(listRow, PageNo, PageSizeDetail);
                }
                else
                {
                    list = new PagedList<DataRow>(listRow, PageNo, PageSizeDetail, count);
                }

                #endregion

                bool isExcel = dict["excel"] == "1" ? true : false;
                ViewData["Query"] = dict;
                ViewData["Count"] = count;
                ViewData["Th"] = th;
                ViewData["KeyList"] = memberkeys["KeyList"];

                IList<IDictionary> ownkeys = CRMMapper.Get().QueryForList<IDictionary>("MemberMedicineKey.FindByUserID", uid);
                ViewData["OwnKeys"] = ownkeys;

                #region excel
                if (sitemaster["istest"] == "0" && isExcel)
                {
                    ExcelExport mx = new ExcelExport();
                    mx.InitTh();
                    mx._fileName = memberkeys["ListName"] + DateTime.Now.ToShortDateString() + ".xls";
                    //if (query.CommonName != null)
                    //    mx._fileName = query.CommonName + DateTime.Now.ToShortDateString() + ".xls";
                    //else
                    //{
                    //    if (query.ProductEnterpriseName != null)
                    //        mx._fileName = query.ProductEnterpriseName + DateTime.Now.ToShortDateString() + ".xls";
                    //    else
                    //        mx._fileName = query.TenderEnterpriseName + DateTime.Now.ToShortDateString() + ".xls";
                    //}

                    //项目名称
                    TableItemStyle tiName = new TableItemStyle();
                    tiName.Font.Size = 14;
                    tiName.ForeColor = System.Drawing.Color.Red;
                    tiName.HorizontalAlign = HorizontalAlign.Center;
                    mx.HeadExtrInfo.Add(mDOpenProject.NewProjectName, tiName);
                    //项目备注
                    TableItemStyle tiRemark = new TableItemStyle();
                    tiRemark.Font.Size = 13;
                    tiRemark.ForeColor = System.Drawing.Color.Red;
                    tiRemark.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add("项目备注说明:", tiRemark);
                    //项目备注
                    TableItemStyle tiRemarkContent = new TableItemStyle();
                    tiRemarkContent.Font.Size = 12;
                    tiRemarkContent.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add(mDOpenProject.NewProjectDescription, tiRemarkContent);

                    TableItemStyle tiCount = new TableItemStyle();
                    tiCount.Font.Size = 12;
                    tiCount.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add("共有" + count.ToString() + "条", tiCount);

                    if (data.Columns.Contains("ID"))
                    {
                        data.Columns.Remove("ID");
                    }
                    //20111019修改按显示表头导出,去掉多余列
                    if (data.Columns.Contains("Mine"))
                    {
                        data.Columns.Remove("Mine");
                    }
                    mx._thName = th.ToArray();//20111019修改按显示表头导出
                    mx.DataTableToExcel(data);
                }
                #endregion

                return View(list);

            }
        }