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> bidprojectlist = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectbid", uid);
                //先检查一共看的数目
                if (bidprojectlist.Count > 0)
                {
                    //如果有看得记录,先检查是否是看过的
                    Hashtable htt = new Hashtable();
                    htt["pid"] = id;
                    htt["uid"] = uid;
                    IList<int> sawid = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectbidpid", htt);
                    //如果没看过,就检查是否超过最大值
                    if (sawid.Count == 0)
                    {
                        if (bidprojectlist.Count < 5)
                        {
                            //没超过就写入记录
                            OpenBidNumForTest ob = new OpenBidNumForTest();
                            ob.BidprojectNum = id;
                            ob.UserID = uid;
                            new OpenBidNumForTestDao().Insert(ob);
                        }
                        else
                        {
                            //超过了
                            return RedirectToAction("List");
                        }
                    }
                }
                else
                {
                    //之前没有看过也写入记录
                    OpenBidNumForTest ob = new OpenBidNumForTest();
                    ob.BidprojectNum = id;
                    ob.UserID = uid;
                    new OpenBidNumForTestDao().Insert(ob);
                }
            }
            DBiddingProjectDao mDBiddingProjectDao = new DBiddingProjectDao();
            DBiddingProject mDBiddingProject = mDBiddingProjectDao.Find(id);
            int interval = 0;
            if (EnterPriseMemberInfo.Memberlevel == 299)
                interval = 6;
            if (EnterPriseMemberInfo.Memberlevel == 301)
                interval = 12;
            DateTime limitedate = DateTime.Now.AddMonths(interval);

            if ((EnterPriseMemberInfo.Memberlevel == 201 || EnterPriseMemberInfo.Memberlevel == 301) && mDBiddingProject.BidDate > limitedate)
            {
                return RedirectToAction("MemberLevelError", "Base");
            }

            ViewData["ProjectDescription"] = mDBiddingProject.NewProjectDescription;
            ViewData["Summary"] = mDBiddingProject.Summary;
            ViewData["OID"] = mDBiddingProject.OID;
            //如果有参数
            if (query.IsHaveProperty())
            {
                parm = query.GetParameter();
                ViewData["Query"] = query;
                return RedirectToAction("Detail", new { id = id, pageNo = 1, parm = parm });
            }
            else
            {
                //表明第一次进来
                if (query.CommonName != null)
                {
                    query.LoadProperties(parm);
                }
                //页码与记录数
                int PageNo = pageNo ?? 1;
                if (string.IsNullOrEmpty(query.CommonName) && string.IsNullOrEmpty(query.ChineseSpecification) && string.IsNullOrEmpty(query.ProductEnterpriseName) && string.IsNullOrEmpty(query.TenderEnterpriseName) && query.CommonName.Length < 3)
                {
                    PageNo = 1;
                }
                else
                {
                    query.IsSearched = "1";
                }
                //是否竞品条件
                bool compete = false;

                int count;
                //取数据与记录数
                List<string> th = new List<string>();
                DBiddingMedicineDao m = new DBiddingMedicineDao();
                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("IsCancel") && (!data.Columns.Contains("IsCancelText")))
                {
                    DataColumn dc = new DataColumn();
                    dc.ColumnName = "IsCancelText";
                    data.Columns.Add(dc);
                    foreach (DataRow dr in data.Rows)
                    {
                        if (dr["IsCancel"].ToString() == "True")
                            dr["IsCancelText"] = "是";
                        else
                            dr["IsCancelText"] = "";
                    }
                    //data.Columns.Remove("IsCancel");
                }
                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 = query.Excel == "1" ? true : false;
                query.Excel = "";
                ViewData["Query"] = query;
                ViewData["Count"] = count;
                ViewData["Th"] = th;

                #region 导出excel
                if (sitemaster["istest"] == "0" && isExcel)
                {
                    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(mDBiddingProject.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(mDBiddingProject.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> bidprojectlist = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectbid", uid);
                //先检查一共看的数目
                if (bidprojectlist.Count > 0)
                {
                    //如果有看得记录,先检查是否是看过的
                    Hashtable htt = new Hashtable();
                    htt["pid"] = id;
                    htt["uid"] = uid;
                    IList<int> sawid = CRMMapper.Get().QueryForList<int>("OpenBidNumForTest.myselectbidpid", htt);
                    //如果没看过,就检查是否超过最大值
                    if (sawid.Count == 0)
                    {
                        if (bidprojectlist.Count < 5)
                        {
                            //没超过就写入记录
                            OpenBidNumForTest ob = new OpenBidNumForTest();
                            ob.BidprojectNum = id;
                            ob.UserID = uid;
                            new OpenBidNumForTestDao().Insert(ob);
                        }
                        else
                        {
                            //超过了
                            return RedirectToAction("List");
                        }
                    }
                }
                else
                {
                    //之前没有看过也写入记录
                    OpenBidNumForTest ob = new OpenBidNumForTest();
                    ob.BidprojectNum = id;
                    ob.UserID = uid;
                    new OpenBidNumForTestDao().Insert(ob);
                }
            }
            DBiddingProjectDao mDBiddingProjectDao = new DBiddingProjectDao();
            DBiddingProject mDBiddingProject = mDBiddingProjectDao.Find(id);
            int interval = 0;
            if (EnterPriseMemberInfo.Memberlevel == 299)
                interval = 6;
            if (EnterPriseMemberInfo.Memberlevel == 301)
                interval = 12;
            DateTime limitedate = DateTime.Now.AddMonths(interval);

            if ((EnterPriseMemberInfo.Memberlevel == 201 || EnterPriseMemberInfo.Memberlevel == 301) && mDBiddingProject.BidDate > limitedate)
            {
                return RedirectToAction("MemberLevelError", "Base");
            }

            ViewData["ProjectDescription"] = mDBiddingProject.NewProjectDescription;
            ViewData["Summary"] = mDBiddingProject.Summary;
            ViewData["OID"] = mDBiddingProject.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";
                    //commonnames=
                }
                else
                {
                    memberkeys.Add("KeyList", "");
                    dict.Add("excel", "");
                }
                string commonnames = memberkeys["KeyList"].ToString().Replace(" ", "").Replace(" ", "");

                int count;
                //取数据与记录数
                List<string> th = new List<string>();
                DBiddingMedicineDao m = new DBiddingMedicineDao();
                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;

                for (int i = 1; i <= data.Rows.Count; i++)
                {
                    data.Rows[i - 1]["ID"] = (beginNo + i).ToString();
                }
                if (data.Columns.Contains("IsCancel") && (!data.Columns.Contains("IsCancelText")))
                {
                    DataColumn dc = new DataColumn();
                    dc.ColumnName = "IsCancelText";
                    data.Columns.Add(dc);
                    foreach (DataRow dr in data.Rows)
                    {
                        if (dr["IsCancel"].ToString() == "True")
                            dr["IsCancelText"] = "是";
                        else
                            dr["IsCancelText"] = "";
                    }
                    //data.Columns.Remove("IsCancel");
                }
                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 = new PagedList<DataRow>(listRow, PageNo, PageSizeDetail, count); ;

                #endregion

                bool isExcel = dict["excel"] == "1" ? true : false;
                //dict["excel"] = "";
                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(mDBiddingProject.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(mDBiddingProject.NewProjectDescription, tiRemarkContent);

                    TableItemStyle tiCount = new TableItemStyle();
                    tiCount.Font.Size = 12;
                    tiCount.HorizontalAlign = HorizontalAlign.Left;
                    mx.HeadExtrInfo.Add(memberkeys["ListName"] + "共有" + 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);
            }
        }