public List<OpportunityEntity> GetOpportunityaByCustomerID(string customerid, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string userid, string agentid, string clientid)
        {
            List<OpportunityEntity> list = new List<OpportunityEntity>();
            DataTable dt = CommonBusiness.GetPagerData("Opportunity", "*", "CustomerID='" + customerid + "' and Status <> 9 ", "AutoID", pageSize, pageIndex, out totalCount, out pageCount, false);
            foreach (DataRow dr in dt.Rows)
            {
                OpportunityEntity model = new OpportunityEntity();
                model.FillData(dr);
                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.Stage = SystemBusiness.BaseBusiness.GetOpportunityStageByID(model.StageID, model.AgentID, model.ClientID);
                model.StatusStr = CommonBusiness.GetEnumDesc((EnumOpportunityStatus)model.Status);

                list.Add(model);
            }
            return list;
        }
        public List<OpportunityEntity> GetOpportunitys(EnumSearchType searchtype, string typeid, int status, string stageid, string searchuserid, string searchteamid, string searchagentid,
                                  string begintime, string endtime, string keyWords, string orderBy, int pageSize, int pageIndex, ref int totalCount, ref int pageCount, string userid, string agentid, string clientid)
        {
            List<OpportunityEntity> list = new List<OpportunityEntity>();
            DataSet ds = OpportunityDAL.BaseProvider.GetOpportunitys((int)searchtype, typeid, status, stageid, searchuserid, searchteamid, searchagentid, begintime, endtime, keyWords, orderBy, pageSize, pageIndex, ref totalCount, ref pageCount, userid, agentid, clientid);
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                OpportunityEntity model = new OpportunityEntity();
                model.FillData(dr);
                model.OrderType = SystemBusiness.BaseBusiness.GetOrderTypeByID(model.TypeID, model.AgentID, model.ClientID);
                model.Stage = SystemBusiness.BaseBusiness.GetOpportunityStageByID(model.StageID, model.AgentID, model.ClientID);
                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);

                list.Add(model);
            }
            return list;
        }
        public OpportunityEntity GetOpportunityByID(string opportunityid, string agentid, string clientid)
        {
            DataSet ds = OpportunityDAL.BaseProvider.GetOpportunityByID(opportunityid, agentid, clientid);
            OpportunityEntity model = new OpportunityEntity();
            if (ds.Tables["Opportunity"].Rows.Count > 0)
            {

                model.FillData(ds.Tables["Opportunity"].Rows[0]);
                model.OrderType = SystemBusiness.BaseBusiness.GetOrderTypeByID(model.TypeID, model.AgentID, model.ClientID);
                model.Owner = OrganizationBusiness.GetUserByUserID(model.OwnerID, model.AgentID);
                model.CreateUser = OrganizationBusiness.GetUserByUserID(model.CreateUserID, model.AgentID);

                model.StatusStr = CommonBusiness.GetEnumDesc((EnumOrderStatus)model.Status);

                model.Stage = SystemBusiness.BaseBusiness.GetOpportunityStageByID(model.StageID, agentid, clientid);

                model.City = CommonBusiness.GetCityByCode(model.CityCode);

                if (ds.Tables["Customer"].Rows.Count > 0)
                {
                    model.Customer = new CustomerEntity();
                    model.Customer.FillData(ds.Tables["Customer"].Rows[0]);
                }
                model.Details = new List<OrderDetail>();
                if (ds.Tables["Details"].Rows.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables["Details"].Rows)
                    {
                        OrderDetail detail = new OrderDetail();
                        detail.FillData(dr);
                        model.Details.Add(detail);
                    }
                }
            }
            return model;
        }