public int AddHairShop(HairShop hairShop)
        {
            int newID = 0;
            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                string insertSQL = "INSERT INTO [hairshop] ([HairShopName], [HairShopCityID], [HairShopMapZoneID], [HairShopHotZoneID], [HairShopAddress], [HairShopPhoneNum], [HairShopEngineerNum], [HairShopOpenTime], [HairShopVisitNum], [HairShopWebSite], [HairShopEmail], [HairshopDiscount], [HairShopLogo], [HairShopCreateTime], [HairShopDescription], [ProductIDs], [HairShopTagIDs], [HairShopShortName], [IsJoin], [TypeID], [IsPostStation], [IsPostMachine], [HairShopGood], [HairShopBad],[HairCutPriceMin],[HairMarcelPriceMin],[HairDyePriceMin],[HairShapePriceMin],[HairConservationPriceMin]) VALUES ('" + hairShop.HairShopName + "', " + hairShop.HairShopCityID + ", " + hairShop.HairShopMapZoneID + ", " + hairShop.HairShopHotZoneID + ", '" + hairShop.HairShopAddress + "', '" + hairShop.HairShopPhoneNum +  "', " + hairShop.HairShopEngineerNum + ", '" + hairShop.HairShopOpenTime  + ", " + hairShop.HairShopVisitNum +  "', '" + hairShop.HairShopWebSite + "', '" + hairShop.HairShopEmail + "', '" + hairShop.HairShopDiscount + "', '" + hairShop.HairShopLogo +  ", '" + hairShop.HairShopCreateTime + "', '" + hairShop.HairShopDescription + "', '" + hairShop.ProductIDs + "', '" + hairShop.HairShopTagIDs + "', '" + hairShop.HairShopShortName  + "', '" + hairShop.IsJoin + "', " + hairShop.TypeID + ", '" + hairShop.IsPostStation + "', '" + hairShop.IsPostMachine + "', " + hairShop.HairShopGood + ", " + hairShop.HairShopBad + ","+hairShop.HairCutDiscountMin.ToString()+","+hairShop.HairMarcelDiscountMin.ToString()+","+hairShop.HairDyeDiscountMin.ToString()+","+hairShop.HairShapeDiscountMin.ToString()+","+hairShop.HairConservationDiscountMin.ToString()+");select @@identity;";

                SqlCommand cmd = new SqlCommand(insertSQL, conn);
                conn.Open();
                newID = int.Parse(cmd.ExecuteScalar().ToString());
                conn.Close();
                //��ʾ����Dispose�����ᵼ�´˷��������ڵ�һʱ�䱻GC����,�����Ѿ�ʹ��using,�˴�Ϊ����Dispose()??!!
                cmd.Dispose();
                cmd = null;
            }

            return newID;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="haiShop">haiShop</param>
        /// <returns></returns>
        public Int32 AddHairShopByUsingSP(HairShop hairShop)
        {
            SqlParameter[] Parameters = GetHairShopParameters();

            Parameters[0].Value = hairShop.HairShopID;
            Parameters[1].Value = hairShop.HairShopName;
            Parameters[2].Value = hairShop.HairShopCityID;
            Parameters[3].Value = hairShop.HairShopMapZoneID;
            Parameters[4].Value = hairShop.HairShopHotZoneID;
            Parameters[5].Value = hairShop.HairShopAddress;
            Parameters[6].Value = hairShop.HairShopPhoneNum;
            Parameters[7].Value = "";// hairShop.HairShopPictureStoreIDs;
            Parameters[8].Value = "";// hairShop.HairShopMainIDs;
            Parameters[9].Value = "";// hairShop.HairShopPartialIDs;
            Parameters[10].Value = hairShop.HairShopEngineerNum;
            Parameters[11].Value = hairShop.HairShopOpenTime;
            Parameters[12].Value = "";// hairShop.HairShopOrderNum;
            Parameters[13].Value = hairShop.HairShopVisitNum;
            Parameters[14].Value = "";// hairShop.WorkRangeIDs;
            Parameters[15].Value = hairShop.HairShopWebSite;
            Parameters[16].Value = hairShop.HairShopEmail;
            Parameters[17].Value = hairShop.HairShopDiscount;
            Parameters[18].Value = hairShop.HairShopLogo;
            Parameters[19].Value = "";// hairShop.HairShopRecommandNum;
            Parameters[20].Value = hairShop.HairShopCreateTime;
            Parameters[21].Value = hairShop.HairShopDescription;
            Parameters[22].Value = hairShop.ProductIDs;
            Parameters[23].Value = hairShop.HairShopTagIDs;
            Parameters[24].Value = hairShop.HairShopShortName;
            Parameters[25].Value = hairShop.HairShopShortName;
            Parameters[26].Value = "";// hairShop.IsBest;
            Parameters[27].Value = hairShop.IsJoin;
            Parameters[28].Value = hairShop.IsPostStation;
            Parameters[29].Value = hairShop.IsPostMachine;
            Parameters[30].Value = hairShop.HairShopGood;
            Parameters[31].Value = hairShop.HairShopBad;

            SqlHelper.ExecuteNonQuery(DataHelper2.SqlConnectionString, CommandType.StoredProcedure, "InsertHairShop", Parameters);

            return Int32.Parse(Parameters[32].Value.ToString());
        }
예제 #3
0
        protected void btnSubmit_OnClick(object sender, EventArgs e)
        {
            this.Response.Write("<script>enableButton();</script>");

            if (this.txtHairShopTag.Text.Trim() != string.Empty)
            {
                string[] tagCondition = this.txtHairShopTag.Text.Split(",".ToCharArray());
                this.lblRedInfo.Visible = false;

                for (int k = 0; k < tagCondition.Length; k++)
                {
                    if (tagCondition[k] == string.Empty)
                    {
                        this.lblRedInfo.Text = "TAG格式不正确(正确的格式&nbsp;&nbsp; 1,2,3)";
                        this.lblRedInfo.Visible = true;
                        return;
                    }
                }
            }

            HairShop hs = new HairShop();
            hs.HairShopName = txtHairShopName.Text.Trim();
            hs.HairShopShortName = txtHairShopShortName.Text.Trim();
            hs.TypeID = int.Parse(ddlTypeTable.SelectedValue);
            hs.TypeName = ddlTypeTable.SelectedItem.Text;
            hs.HairShopWebSite = txtHairShopWebSite.Text.Trim();
            hs.HairShopEmail = txtHairShopEmail.Text.Trim();
            hs.HairShopDiscount = txtHairShopDiscount.Text.Trim();
            hs.TravelInfo = txtTravelInfo.Text.Trim();

            if (fileLogo.Value != string.Empty)
            {
                //获取上传图片后的路径
                UpLoadClass upload = new UpLoadClass();

                if (!PicOperate.isPermission(StringHelper.GetExtraType(fileLogo.Value)))
                {
                    this.lblInfo.Text = "上传图片格式不对";
                    this.lblInfo.Visible = true;
                    return;
                }
                hs.HairShopLogo = upload.UpLoadImg(fileLogo, "/uploadfiles/logo/");
            }
            else
            {
                hs.HairShopLogo = string.Empty;
            }

            hs.HairShopCreateTime = txtHairShopCreateTime.Text.Trim();
            hs.HairShopCityID = int.Parse(ddlCity.SelectedValue);
            hs.HairShopMapZoneID = int.Parse(ddlMapZone.SelectedValue);
            hs.HairShopHotZoneID = int.Parse(ddlHotZone.SelectedValue);

            hs.HairShopAddress = txtHairShopAddress.Text.Trim();
            hs.HairShopPhoneNum = txtHairShopPhoneNum.Text.Trim();
            hs.HairShopOpenTime = txtHairShopOpenTime.Text.Trim();

            //TAG逻辑,先复制空,然后插入TAG表,然后UPDATE美发厅表
            hs.HairShopTagIDs = "";

            //List<string> IDs = new List<string>();
            //int chkI = chkListWorkRange.Items.Count;
            //for (int i = 0; i < chkI; i++)
            //{
            //    if (chkListWorkRange.Items[i].Selected)
            //    {
            //        IDs.Add(chkListWorkRange.Items[i].Value);
            //    }
            //}
            //IDs.Sort();
            //hs.WorkRangeIDs = string.Join(",", IDs.ToArray());

            //hs.IsBest = chkIsBest.Checked;
            hs.IsJoin = chkIsJoin.Checked;
            hs.IsPostMachine = chkIsPostMachine.Checked;
            hs.IsPostStation = chkIsPostStation.Checked;
            hs.HairShopDescription = txtDescription.Text.Trim();

            //Session["HairShopInfo"] = hs;

            try
            {
                hs.HairCutDiscountMin = Decimal.Parse(txtHairCutPriceMin.Text.Trim());
            }
            catch
            {
                hs.HairCutDiscountMin = 0;
            }

            try
            {
                hs.HairMarcelDiscountMin = Decimal.Parse(txtMarcelPriceMin.Text.Trim());
            }
            catch
            {
                hs.HairMarcelDiscountMin = 0;
            }

            try
            {
                hs.HairDyeDiscountMin = Decimal.Parse(txtHairDyePriceMin.Text.Trim());
            }
            catch
            {
                hs.HairDyeDiscountMin = 0;
            }

            try
            {
                hs.HairShapeDiscountMin = Decimal.Parse(txtShapePriceMin.Text.Trim());
            }
            catch
            {
                hs.HairShapeDiscountMin = 0;
            }

            try
            {
                hs.HairConservationDiscountMin = Decimal.Parse(txtConservationPriceMin.Text.Trim());
            }
            catch
            {
                hs.HairConservationDiscountMin = 0;
            }

            try
            {
                hs.HairCutDiscount = Decimal.Parse(tbHairCutDiscount.Text.Trim());
            }
            catch
            {
                hs.HairCutDiscount = 0;
            }
            try
            {
                hs.HairCutPirce = Decimal.Parse(tbHairCutPrice.Text.Trim());
            }
            catch
            {
                hs.HairCutPirce = 0;
            }
            try
            {
                hs.HairMarcelDiscount = Decimal.Parse(tbMarclDiscount.Text.Trim());
            }
            catch
            {
                hs.HairMarcelDiscount = 0;
            }
            try
            {
                hs.HairMarcelPrice = Decimal.Parse(tbMarcelPrice.Text.Trim());
            }
            catch
            {
                hs.HairMarcelPrice = 0;
            }

            try
            {
                hs.HairDyeDiscount = Decimal.Parse(tbHairDyeDiscount.Text.Trim());
            }
            catch
            {
                hs.HairDyeDiscount = 0;
            }
            try
            {

                hs.HairDyePrice = Decimal.Parse(tbHairDyePrice.Text.Trim());
            }
            catch
            {
                hs.HairDyePrice = 0;
            }

            try
            {
                hs.HairShapePrice = Decimal.Parse(tbShapePrice.Text.Trim());
            }
            catch
            {
                hs.HairShapePrice = 0;
            }
            try
            {
                hs.HairShapeDiscount = Decimal.Parse(tbShapeDiscount.Text.Trim());
            }
            catch
            {
                hs.HairShapeDiscount = 0;
            }
            try
            {
                hs.HairConservationPrice = Decimal.Parse(tbConservationPrice.Text.Trim());
            }
            catch
            {
                hs.HairConservationPrice = 0;
            }
            try
            {
                hs.HairConservationDiscount = Decimal.Parse(tbConservationDiscount.Text.Trim());
            }
            catch
            {
                hs.HairConservationDiscount = 0;
            }

            hs.LocationMapURL = tbLocation.Text.Trim();

            try
            {
                hs.Square = int.Parse(TextBox4.Text.Trim()).ToString();
            }
            catch
            {
                hs.Square = "0";
            }

            hs.IsServeHairCut = chkCut.Checked;
            hs.IsServeMarce = chkMarcel.Checked;
            hs.IsServeDye = chkDye.Checked;

            hs.MemberInfo = txtMemberInfo.Text.Trim();

            string productIDs = "";
            int num = 0;
            foreach (ListItem li in this.chkList.Items)
            {
                if (li.Selected)
                {
                    num++;
                    if (num == 1)
                    {
                        productIDs = li.Value;
                        hs.ProductsName = li.Text;
                    }
                    else
                    {
                        productIDs += ","+li.Value;
                        hs.ProductsName += "," + li.Text;
                    }
                }
            }
            hs.ProductIDs = productIDs;
            //InfoAdmin.AddHairShop(hs);
            int newid = 0;
            InfoAdmin.AddHairShopInfo(hs,out newid);
            Session["HairShop"] = hs;

            string id = newid.ToString();

            string tagIDs = "";
            string[] tagCollection = txtHairShopTag.Text.Split(",".ToCharArray());
            if (tagCollection[0] != string.Empty)
            {
                for (int k = 0; k < tagCollection.Length; k++)
                {
                    string tagID = "";
                    bool isExist = false;
                    HairShopTag hst = new HairShopTag();
                    using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ConnectionString))
                    {
                        string commString = "select * from HairShopTag where HairShopTagName='" + tagCollection[k] + "'";
                        using (SqlCommand comm = new SqlCommand())
                        {
                            comm.CommandText = commString;
                            comm.Connection = conn;
                            conn.Open();
                            using (SqlDataReader sdr = comm.ExecuteReader())
                            {
                                if (sdr.Read())
                                {
                                    try
                                    {
                                        hst.TagID = int.Parse(sdr["HairShopTagID"].ToString());
                                        hst.TagName = sdr["HairShopTagName"].ToString();
                                        hst.HairShopIDs = sdr["HairShopIDs"].ToString();
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                    }
                    if (hst.TagID == 0)
                    {
                        using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ConnectionString))
                        {
                            string commString = "insert HairShopTag(HairShopTagName,HairShopIDs) values('" + tagCollection[k] + "','" + id.ToString() + "');select @@identity;";
                            using (SqlCommand comm = new SqlCommand())
                            {
                                comm.CommandText = commString;
                                comm.Connection = conn;
                                conn.Open();

                                tagID = comm.ExecuteScalar().ToString();
                            }
                        }
                    }
                    else
                    {
                        tagID = hst.TagID.ToString();
                        if (hst.HairShopIDs == string.Empty)
                        {
                            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ConnectionString))
                            {
                                string commString = "update HairShopTag set HairShopIDs='" + id.ToString() + "' where HairShopTagID=" + hst.TagID.ToString();
                                using (SqlCommand comm = new SqlCommand())
                                {
                                    comm.CommandText = commString;
                                    comm.Connection = conn;
                                    conn.Open();
                                    try
                                    {
                                        comm.ExecuteNonQuery();
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                        else
                        {
                            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSqlServer"].ConnectionString))
                            {
                                string commString = "update HairShopTag set HairShopIDs=HairShopIDs+'," + id.ToString() + "' where HairShopTagID=" + hst.TagID.ToString();
                                using (SqlCommand comm = new SqlCommand())
                                {
                                    comm.CommandText = commString;
                                    comm.Connection = conn;
                                    conn.Open();
                                    try
                                    {
                                        comm.ExecuteNonQuery();
                                    }
                                    catch
                                    { }
                                }
                            }
                        }
                    }
                    if (k == 0)
                    {
                        tagIDs = tagID;
                    }
                    else
                    {
                        tagIDs += "," + tagID;
                    }
                }
            }
            hs.HairShopTagIDs = tagIDs;
            hs.HairShopID = int.Parse(id.ToString());
            int nnewid = 0;
            ProviderFactory.GetHairShopDataProviderInstance().HairShopCreateDeleteUpdate(hs, UserAction.Update,out nnewid);

            this.Response.Redirect("HairShopAddNext1.aspx?id="+id.ToString());

            //this.Response.Redirect("HairEngineerAdd.aspx");
        }
        //public HairShop GetHairShopByEntityID(Int32 HairShopID)
        //{ }
        /// <summary>
        /// ���������
        /// </summary>
        /// <param name="count">0 ȫ��</param>
        /// <returns></returns>
        public List<HairShop> GetHairShops(int count,OrderKey ok)
        {
            List<HairShop> list = new List<HairShop>();

            string orderKey = " order by ";
            switch (ok)
            {
                case OrderKey.ID:
                    orderKey += "hs.HairShopID desc";
                    break;
                case OrderKey.CommentNum:
                    orderKey += "hs.HairShopGood+hs.HairShopBad desc";
                    break;
                case OrderKey.RecommandNum:
                    orderKey += "hs.HairShopRecommandNum desc";
                    break;
                case OrderKey.HitNum:
                    orderKey += "hs.HairShopVisitNum desc";
                    break;
                case OrderKey.OrderNum:
                    orderKey += "hs.HairShopOrderNum desc";
                    break;
                default:
                    orderKey += "hs.HairShopID desc";
                    break;

            }

            string commText = "";
            switch (count)
            {
                case 0:
                    commText = "select * from HairShop hs left join City c on hs.HairShopCityID=c.cityID left join MapZone m on hs.HairShopMapZoneID = m.MapZoneID left join HotZone h on hs.HairShopHotZoneID = h.HotZoneID left join TypeTable tt on hs.TypeID=tt.TypeID"+orderKey;
                    break;
                default:
                    commText = "select top " + count.ToString() + " * from HairShop hs left join City c on hs.HairShopCityID=c.cityID left join MapZone m on hs.HairShopMapZoneID = m.MapZoneID left join HotZone h on hs.HairShopHotZoneID = h.HotZoneID left join TypeTable tt on hs.TypeID=tt.TypeID" + orderKey;
                    break;
            }

            using (SqlDataReader sdr = SqlHelper.ExecuteReader(DataHelper2.SqlConnectionString, CommandType.Text, commText))
            {
                while (sdr.Read())
                {
                    HairShop hairShop = new HairShop();

                    hairShop.HairShopID = int.Parse(sdr["HairShopID"].ToString());
                    hairShop.HairShopName = sdr["HairShopName"].ToString();
                    hairShop.HairShopCityID = int.Parse(sdr["HairShopCityID"].ToString());
                    hairShop.HairShopCityName = sdr["CityName"].ToString();
                    hairShop.HairShopMapZoneID = int.Parse(sdr["HairShopMapZoneID"].ToString());
                    hairShop.HairShopMapZoneName = sdr["MapZoneName"].ToString();
                    hairShop.HairShopHotZoneID = int.Parse(sdr["HairShopHotZoneID"].ToString());
                    hairShop.HairShopHotZoneName = sdr["HotZoneName"].ToString();
                    hairShop.HairShopAddress = sdr["HairShopAddress"].ToString();
                    hairShop.HairShopPhoneNum = sdr["HairShopPhoneNum"].ToString();
                    ///hairShop.HairShopPictureStoreIDs = sdr["HairShopPictureStoreIDs"].ToString();
                    //hairShop.HairShopMainIDs = sdr["HairShopMainIDs"].ToString();
                    //hairShop.HairShopPartialIDs = sdr["HairShopPartialIDs"].ToString();
                    hairShop.HairShopEngineerNum = int.Parse(sdr["HairShopEngineerNum"].ToString());
                    hairShop.HairShopOpenTime = sdr["HairShopOpenTime"].ToString();
                    //hairShop.HairShopOrderNum = int.Parse(sdr["HairShopOrderNum"].ToString());
                    hairShop.HairShopVisitNum = int.Parse(sdr["HairShopVisitNum"].ToString());
                    //hairShop.WorkRangeIDs = sdr["WorkRangeIDs"].ToString();
                    hairShop.HairShopWebSite = sdr["HairShopWebSite"].ToString();
                    hairShop.HairShopEmail = sdr["HairShopEmail"].ToString();
                    hairShop.HairShopDiscount = sdr["HairShopDiscount"].ToString();
                    hairShop.HairShopLogo = sdr["HairShopLogo"].ToString();
                    hairShop.TravelInfo = sdr["TravelInfo"].ToString();

                    //    try
                    //    {
                    //        hairShop.HairShopRecommandNum = int.Parse(sdr["HairShopRecommandNum"].ToString());
                    //    }
                    //catch
                    //    {
                    //    hairShop.HairShopRecommandNum = 0;

                    //}
                    hairShop.HairShopCreateTime = sdr["HairShopCreateTime"].ToString();
                    hairShop.HairShopDescription = sdr["HairShopDescription"].ToString();
                    hairShop.ProductIDs = sdr["ProductIDs"].ToString();
                    hairShop.HairShopTagIDs = sdr["HairShopTagIDs"].ToString();
                    hairShop.HairShopShortName = sdr["HairShopShortName"].ToString();
                    //hairShop.IsBest = bool.Parse(sdr["IsBest"].ToString());
                    hairShop.IsJoin = bool.Parse(sdr["IsJoin"].ToString());
                    hairShop.TypeID = int.Parse(sdr["TypeID"].ToString());
                    hairShop.TypeName = sdr["TypeName"].ToString();
                    hairShop.IsPostStation = bool.Parse(sdr["IsPostStation"].ToString());
                    hairShop.IsPostMachine = bool.Parse(sdr["IsPostMachine"].ToString());
                    hairShop.HairShopGood = int.Parse(sdr["HairShopGood"].ToString());
                    hairShop.HairShopBad = int.Parse(sdr["HairShopBad"].ToString());
                    hairShop.OutLogs = sdr["outLogs"].ToString();
                    hairShop.InnerLogs = sdr["innerLogs"].ToString();
                    Decimal parseValue;

                    Decimal.TryParse(sdr["HairCutPrice"].ToString(), out parseValue);
                    hairShop.HairCutPirce = parseValue;
                    Decimal.TryParse(sdr["HairCutDiscount"].ToString(), out parseValue);
                    hairShop.HairCutDiscount = parseValue;
                    Decimal.TryParse(sdr["HairMarcelPrice"].ToString(), out parseValue);
                    hairShop.HairMarcelPrice = parseValue;
                    Decimal.TryParse(sdr["HairMarcelDiscount"].ToString(), out parseValue);
                    hairShop.HairMarcelDiscount = parseValue;

                    Decimal.TryParse(sdr["HairDyePrice"].ToString(), out parseValue);
                    hairShop.HairDyePrice = parseValue;
                    Decimal.TryParse(sdr["HairDyeDiscount"].ToString(), out parseValue);
                    hairShop.HairDyeDiscount = parseValue;

                    Decimal.TryParse(sdr["HairShapePrice"].ToString(), out parseValue);
                    hairShop.HairShapePrice = parseValue;
                    Decimal.TryParse(sdr["HairShapeDiscount"].ToString(), out parseValue);
                    hairShop.HairShapeDiscount = parseValue;
                    Decimal.TryParse(sdr["HairConservationPrice"].ToString(), out parseValue);
                    hairShop.HairConservationPrice = parseValue;
                    Decimal.TryParse(sdr["HairConservationDiscount"].ToString(), out parseValue);
                    hairShop.HairConservationDiscount = parseValue;

                    hairShop.LocationMapURL = sdr["LocationMapURL"].ToString();

                    if (sdr["IsServeMarcel"] == null || bool.Parse(sdr["IsServeMarcel"].ToString()) == false)
                        hairShop.IsServeMarce = false;
                    else
                        hairShop.IsServeMarce = true;

                    if (sdr["IsServeDye"] == null || bool.Parse(sdr["IsServeDye"].ToString()) == false)
                        hairShop.IsServeDye = false;
                    else
                        hairShop.IsServeDye = true;

                    if (sdr["IsServeHairCut"] == null || bool.Parse(sdr["IsServeHairCut"].ToString()) == false)
                        hairShop.IsServeHairCut = false;
                    else
                        hairShop.IsServeHairCut = true;

                    hairShop.Square = sdr["Square"].ToString();
                    //zhh add check
                    int value=0;

                    int.TryParse(sdr["HairShopNormal"].ToString(),out value);
                    hairShop.HairShopNormal = value;

                    int.TryParse(sdr["postid"].ToString(), out value);
                    hairShop.Postid = value;
                    list.Add(hairShop);
                }
            }

            return list;
        }
        /// <summary>
        /// ������,�ϵģ�������
        /// </summary>
        /// <param name="hairShop"></param>
        /// <param name="ua"></param>
        /// <returns></returns>
        public bool HairShopDataPrividerCreateDeleteUpdate(HairShop hairShop, UserAction ua)
        {
            bool result = false;
            string commandText = string.Empty;
            switch (ua)
            {
                case UserAction.Create:
                    commandText = "insert into HairShop(HairShopName,HairShopCityID,HairShopMapZoneID,HairShopHotZoneID,HairShopAddress,HairShopPhoneNum,"+
                        "HairShopEngineerNum,HairShopOpenTime,HairShopWebSite,HairShopEmail,"+
                        "HairShopDiscount,HairShopLogo,HairShopCreateTime,HairShopDescription,ProductIDs,HairShopTagIDs,HairShopShortName,"+
                        "IsJoin,TypeID,IsPostStation,IsPostMachine) values('"
                        + hairShop.HairShopName +
                        "'," + hairShop.HairShopCityID.ToString() +
                        "," + hairShop.HairShopMapZoneID.ToString() +
                        "," + hairShop.HairShopHotZoneID.ToString() +
                        ",'" + hairShop.HairShopAddress +
                        "','" + hairShop.HairShopPhoneNum +

                        "'," + hairShop.HairShopEngineerNum.ToString() +
                        ",'" + hairShop.HairShopOpenTime +

                        "','" + hairShop.HairShopWebSite +
                        "','" + hairShop.HairShopEmail +
                        "','" + hairShop.HairShopDiscount +
                        "','" + hairShop.HairShopLogo +
                        "','" + hairShop.HairShopCreateTime +
                        "','" + hairShop.HairShopDescription +
                        "','" + hairShop.ProductIDs +
                        "','" + hairShop.HairShopTagIDs +
                        "','" + hairShop.HairShopShortName +

                        "," + hairShop.IsJoin.CompareTo(false).ToString() +
                        "," + hairShop.TypeID.ToString() +
                        "," + hairShop.IsPostStation.CompareTo(false).ToString() +
                        "," + hairShop.IsPostMachine.CompareTo(false).ToString() + ")";
                    break;
                case UserAction.Delete:
                    commandText = "delete from HairShop where HairShopID="+hairShop.HairShopID.ToString();
                    break;
                case UserAction.Update:
                    commandText = "update HairShop set HairShopName='" + hairShop.HairShopName + "',HairShopCityID=" + hairShop.HairShopCityID.ToString() +
                        ",HairShopMapZoneID=" + hairShop.HairShopMapZoneID.ToString() + ",HairShopHotZoneID=" + hairShop.HairShopHotZoneID.ToString() +
                        ",HairShopAddress='" + hairShop.HairShopAddress + "',HairShopPhoneNum='" + hairShop.HairShopPhoneNum +

                        "',HairShopEngineerNum=" + hairShop.HairShopEngineerNum.ToString() + ",HairShopOpenTime='" + hairShop.HairShopOpenTime +
                        "',HairShopWebSite='" + hairShop.HairShopWebSite + "',HairShopEmail='" +
                        hairShop.HairShopEmail + "',HairShopDiscount='" + hairShop.HairShopDiscount + "',HairShopLogo='" + hairShop.HairShopLogo +
                        "',HairShopCreateTime='" + hairShop.HairShopCreateTime + "',HairShopDescription='" + hairShop.HairShopDescription +
                        "',ProductIDs='" + hairShop.ProductIDs + "',HairShopTagIDs='" + hairShop.HairShopTagIDs + "',HairShopShortName='" +
                        hairShop.HairShopShortName + ",IsJoin=" + hairShop.IsJoin.CompareTo(false).ToString() + ",TypeID=" + hairShop.TypeID.ToString() + ",IsPostStation=" + hairShop.IsPostStation.CompareTo(false).ToString() + ",IsPostMachine=" + hairShop.IsPostMachine.CompareTo(false).ToString() + " where HairShopID = " + hairShop.HairShopID.ToString();
                    break;
            }
            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                using (SqlCommand comm = new SqlCommand())
                {
                    comm.CommandText = commandText;
                    comm.Connection = conn;
                    conn.Open();
                    try
                    {
                        comm.ExecuteNonQuery();
                        result = true;
                    }
                    catch(Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }

                }
            }
            if (ua == UserAction.Delete)
            {
                using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
                {
                    result = false;
                    commandText = "delete from HairShopRecommand where HairShopRawID=" + hairShop.HairShopID.ToString();
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.CommandText = commandText;
                        comm.Connection = conn;
                        conn.Open();
                        try
                        {
                            comm.ExecuteNonQuery();
                            result = true;
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }

                    }
                }
            }
            return result;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hairShop"></param>
        /// <param name="acion"></param>
        public void HairShopCreateDeleteUpdate(HairShop hairShop, UserAction action, out int newid)
        {
            newid = 0;
            if (action == UserAction.Create)
            {
                StringBuilder cmdBuilder = new StringBuilder();
                cmdBuilder.Append("insert into HairShop(HairShopName,HairShopCityID,HairShopMapZoneID,HairShopHotZoneID,HairShopAddress,HairShopPhoneNum,HairShopEngineerNum,HairShopOpenTime,HairShopWebSite,HairShopEmail,HairShopDiscount,HairShopLogo,HairShopCreateTime,HairShopDescription,ProductIDs,HairShopTagIDs,HairShopShortName,IsJoin,TypeID,IsPostStation,IsPostMachine,");
                cmdBuilder.Append("HairCutPrice, HairMarcelPrice, HairDyePrice, HairCutDiscount, HairMarcelDiscount, HairDyeDiscount,");
                cmdBuilder.Append("HairShapePrice, HairShapeDiscount, HairConservationPrice, HairConservationDiscount,");
                cmdBuilder.Append("LocationMapURL, IsServeMarcel, IsServeDye, IsServeHairCut, [Square],MemberInfo,travelInfo,HairCutPriceMin,HairMarcelPriceMin,HairDyePriceMin,HairShapePriceMin,HairConservationPriceMin) ");

                cmdBuilder.Append(" VALUES(' ");

                #region
                cmdBuilder.Append(hairShop.HairShopName + "','");
                cmdBuilder.Append(hairShop.HairShopCityID.ToString() + "','");
                cmdBuilder.Append(hairShop.HairShopMapZoneID.ToString() + "','");
                cmdBuilder.Append(hairShop.HairShopHotZoneID.ToString() + "','");
                cmdBuilder.Append(hairShop.HairShopAddress + "','");
                cmdBuilder.Append(hairShop.HairShopPhoneNum + "','");
                //cmdBuilder.Append(hairShop.HairShopPictureStoreIDs + "','");
                //cmdBuilder.Append(hairShop.HairShopMainIDs + "','");
                //cmdBuilder.Append(hairShop.HairShopPartialIDs + "','");
                cmdBuilder.Append(hairShop.HairShopEngineerNum.ToString() + "','");
                cmdBuilder.Append(hairShop.HairShopOpenTime + "','");
                //cmdBuilder.Append(hairShop.WorkRangeIDs + "','");
                cmdBuilder.Append(hairShop.HairShopWebSite + "','");
                cmdBuilder.Append(hairShop.HairShopEmail + "','");
                cmdBuilder.Append(hairShop.HairShopDiscount + "','");
                cmdBuilder.Append(hairShop.HairShopLogo + "','");
                cmdBuilder.Append(hairShop.HairShopCreateTime + "','");
                cmdBuilder.Append(hairShop.HairShopDescription + "','");
                cmdBuilder.Append(hairShop.ProductIDs + "','");
                cmdBuilder.Append(hairShop.HairShopTagIDs + "','");
                cmdBuilder.Append(hairShop.HairShopShortName + "','");
                //cmdBuilder.Append(hairShop.IsBest.CompareTo(false).ToString() + "','");
                cmdBuilder.Append(hairShop.IsJoin.CompareTo(false).ToString() + "','");
                cmdBuilder.Append(hairShop.TypeID.ToString() + "','");
                cmdBuilder.Append(hairShop.IsPostStation.CompareTo(false).ToString() + "','");
                cmdBuilder.Append(hairShop.IsPostMachine.CompareTo(false).ToString() + "','");
                #endregion
                cmdBuilder.Append(hairShop.HairCutPirce.ToString() + "','");
                cmdBuilder.Append(hairShop.HairMarcelPrice.ToString() + "','");
                cmdBuilder.Append(hairShop.HairDyePrice.ToString() + "','");
                cmdBuilder.Append(hairShop.HairCutDiscount.ToString() + "','");
                cmdBuilder.Append(hairShop.HairMarcelDiscount.ToString() + "','");
                cmdBuilder.Append(hairShop.HairDyeDiscount.ToString() + "','");

                cmdBuilder.Append(hairShop.HairShapePrice.ToString() + "','");
                cmdBuilder.Append(hairShop.HairShapeDiscount.ToString() + "','");
                cmdBuilder.Append(hairShop.HairConservationPrice.ToString() + "','");
                cmdBuilder.Append(hairShop.HairConservationDiscount.ToString() + "','");

                cmdBuilder.Append(hairShop.LocationMapURL + "','");
                cmdBuilder.Append(hairShop.IsServeMarce.CompareTo(false).ToString() + "','");
                cmdBuilder.Append(hairShop.IsServeDye.CompareTo(false).ToString() + "','");
                cmdBuilder.Append(hairShop.IsServeHairCut.CompareTo(false).ToString() + " ',");
                cmdBuilder.Append(hairShop.Square.ToString() + ",'" + hairShop.MemberInfo + "' ,'" + hairShop.TravelInfo);
                cmdBuilder.Append("', " + hairShop.HairCutDiscountMin.ToString());
                cmdBuilder.Append(", " +hairShop.HairMarcelDiscountMin.ToString());
                cmdBuilder.Append(", " + hairShop.HairDyeDiscountMin.ToString());
                cmdBuilder.Append(", " + hairShop.HairShapeDiscountMin.ToString());
                cmdBuilder.Append(", " +hairShop.HairConservationDiscountMin.ToString()+");select @@identity;");

                using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.CommandText = cmdBuilder.ToString();
                        comm.Connection = conn;
                        conn.Open();
                        try
                        {
                            try
                            {
                                newid = Convert.ToInt32(comm.ExecuteScalar());
                            }
                            catch (InvalidCastException)
                            {
                                newid = 0;
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }
                    }
                }

                //newid = int.Parse(SqlHelper.ExecuteScalar(DataHelper2.SqlConnectionString, CommandType.Text, cmdBuilder.ToString()).ToString());
            }

            if (action == UserAction.Update)
            {
                string commandText = "update HairShop set HairShopName='" + hairShop.HairShopName + "',HairShopCityID=" + hairShop.HairShopCityID.ToString() + ",HairShopMapZoneID=" + hairShop.HairShopMapZoneID.ToString() + ",HairShopHotZoneID=" + hairShop.HairShopHotZoneID.ToString() + ",HairShopAddress='" + hairShop.HairShopAddress + "',HairShopPhoneNum='" + hairShop.HairShopPhoneNum + "',HairShopEngineerNum=" + hairShop.HairShopEngineerNum.ToString() + ",HairShopOpenTime='" + hairShop.HairShopOpenTime +  "',HairShopWebSite='" + hairShop.HairShopWebSite + "',HairShopEmail='" + hairShop.HairShopEmail + "',HairShopDiscount='" + hairShop.HairShopDiscount + "',HairShopLogo='" + hairShop.HairShopLogo + "',HairShopCreateTime='" + hairShop.HairShopCreateTime + "',HairShopDescription='" + hairShop.HairShopDescription + "',ProductIDs='" + hairShop.ProductIDs + "',HairShopTagIDs='" + hairShop.HairShopTagIDs + "',HairShopShortName='" + hairShop.HairShopShortName + "',IsJoin=" + hairShop.IsJoin.CompareTo(false).ToString() + ",TypeID=" + hairShop.TypeID.ToString() + ",IsPostStation=" + hairShop.IsPostStation.CompareTo(false).ToString() + ",IsPostMachine=" + hairShop.IsPostMachine.CompareTo(false).ToString();
                StringBuilder cmdBuilder = new StringBuilder();

                cmdBuilder.Append(commandText);

                cmdBuilder.Append(",HaircutPrice = " + hairShop.HairCutPirce.ToString());
                cmdBuilder.Append(",HairMarcelPrice = " + hairShop.HairMarcelPrice.ToString());
                cmdBuilder.Append(",HairDyePrice = " + hairShop.HairDyePrice.ToString());
                cmdBuilder.Append(",HairShapePrice = " + hairShop.HairShapePrice.ToString());
                cmdBuilder.Append(",HairConservationPrice = " + hairShop.HairConservationPrice.ToString());
                cmdBuilder.Append(",HairCutDiscount = " + hairShop.HairCutDiscount.ToString());
                cmdBuilder.Append(",HairMarcelDiscount = " + hairShop.HairMarcelDiscount.ToString());
                cmdBuilder.Append(",HairDyeDiscount = " + hairShop.HairDyeDiscount.ToString());
                cmdBuilder.Append(",HairShapeDiscount = " + hairShop.HairShapeDiscount.ToString());
                cmdBuilder.Append(",HairConservationDiscount = " + hairShop.HairConservationDiscount.ToString());
                cmdBuilder.Append(",LocationMapURL = '" + hairShop.LocationMapURL.ToString());
                cmdBuilder.Append("',IsServeMarcel = " + hairShop.IsServeMarce.CompareTo(false).ToString());
                cmdBuilder.Append(",IsServeDye = " + hairShop.IsServeDye.CompareTo(false).ToString());
                cmdBuilder.Append(",IsServeHairCut = " + hairShop.IsServeHairCut.CompareTo(false).ToString());
                cmdBuilder.Append(",Square = " + hairShop.Square.ToString());

                cmdBuilder.Append(",HairCutPriceMin = " + Convert.ToDecimal(hairShop.HairCutDiscountMin.ToString()));
                cmdBuilder.Append(",HairMarcelPriceMin = " + Convert.ToDecimal(hairShop.HairMarcelDiscountMin.ToString()));
                cmdBuilder.Append(",HairDyePriceMin = " + Convert.ToDecimal(hairShop.HairDyeDiscountMin.ToString()));
                cmdBuilder.Append(",HairShapePriceMin = " + Convert.ToDecimal(hairShop.HairShapeDiscountMin.ToString()));
                cmdBuilder.Append(",HairConservationPriceMin = " + Convert.ToDecimal(hairShop.HairConservationDiscountMin.ToString()));

                cmdBuilder.Append(",MemberInfo='"+hairShop.MemberInfo+"',TravelInfo='"+hairShop.TravelInfo+"'");

                cmdBuilder.Append(" where HairShopID = " + hairShop.HairShopID.ToString());

                SqlHelper.ExecuteNonQuery(DataHelper2.SqlConnectionString, CommandType.Text, cmdBuilder.ToString());
            }

            if (action == UserAction.Delete)
            {
                HairShopDataPrividerCreateDeleteUpdate(hairShop, UserAction.Delete);
            }
            //if (newid == 0)
            //{
            //    newid = 0;
            //}
            //else
            //{
            //    newid = newid;
            //}
        }
        /// <summary>
        /// ͨ��������ID���������ʵ��
        /// </summary>
        /// <param name="hairShopID"></param>
        /// <returns></returns>
        public HairShop GetHairShopByHairShopID(int hairShopID)
        {
            HairShop hairShop = new HairShop();

            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                string commText = "select * from HairShop hs left join City c on hs.HairShopCityID=c.cityID left join MapZone m on hs.HairShopMapZoneID = m.MapZoneID left join HotZone h on hs.HairShopHotZoneID = h.HotZoneID left join TypeTable tt on hs.TypeID=tt.TypeID where hs.HairShopID = " + hairShopID.ToString();

                using (SqlCommand comm = new SqlCommand())
                {
                    comm.Connection = conn;
                    comm.CommandText = commText;
                    conn.Open();

                    using (SqlDataReader sdr = comm.ExecuteReader())
                    {
                        if (sdr.Read())
                        {
                            hairShop.HairShopID = int.Parse(sdr["HairShopID"].ToString());
                            hairShop.HairShopName = sdr["HairShopName"].ToString();
                            hairShop.HairShopCityID = int.Parse(sdr["HairShopCityID"].ToString());
                            hairShop.HairShopCityName = sdr["CityName"].ToString();
                            hairShop.HairShopMapZoneID = int.Parse(sdr["HairShopMapZoneID"].ToString());
                            hairShop.HairShopMapZoneName = sdr["MapZoneName"].ToString();
                            hairShop.HairShopHotZoneID = int.Parse(sdr["HairShopHotZoneID"].ToString());
                            hairShop.HairShopHotZoneName = sdr["HotZoneName"].ToString();
                            hairShop.HairShopAddress = sdr["HairShopAddress"].ToString();
                            hairShop.HairShopPhoneNum = sdr["HairShopPhoneNum"].ToString();
                            //hairShop.HairShopPictureStoreIDs = sdr["HairShopPictureStoreIDs"].ToString();
                            //hairShop.HairShopMainIDs = sdr["HairShopMainIDs"].ToString();
                            //hairShop.HairShopPartialIDs = sdr["HairShopPartialIDs"].ToString();
                            hairShop.HairShopEngineerNum = int.Parse(sdr["HairShopEngineerNum"].ToString());
                            hairShop.HairShopOpenTime = sdr["HairShopOpenTime"].ToString();
                            //hairShop.HairShopOrderNum = int.Parse(sdr["HairShopOrderNum"].ToString());
                            hairShop.HairShopVisitNum = int.Parse(sdr["HairShopVisitNum"].ToString());
                            //hairShop.WorkRangeIDs = sdr["WorkRangeIDs"].ToString();
                            hairShop.HairShopWebSite = sdr["HairShopWebSite"].ToString();
                            hairShop.HairShopEmail = sdr["HairShopEmail"].ToString();
                            hairShop.HairShopDiscount = sdr["HairShopDiscount"].ToString();
                            hairShop.HairShopLogo = sdr["HairShopLogo"].ToString();
                            //hairShop.HairShopRecommandNum = int.Parse(sdr["HairShopRecommandNum"].ToString());
                            hairShop.HairShopCreateTime = sdr["HairShopCreateTime"].ToString();
                            hairShop.HairShopDescription = sdr["HairShopDescription"].ToString();
                            hairShop.ProductIDs = sdr["ProductIDs"].ToString();
                            hairShop.HairShopTagIDs = sdr["HairShopTagIDs"].ToString();
                            hairShop.HairShopShortName = sdr["HairShopShortName"].ToString();
                            //hairShop.IsBest = bool.Parse(sdr["IsBest"].ToString());
                            hairShop.IsJoin = bool.Parse(sdr["IsJoin"].ToString());
                            hairShop.TypeID = int.Parse(sdr["TypeID"].ToString());
                            hairShop.TypeName = sdr["TypeName"].ToString();
                            hairShop.IsPostStation = bool.Parse(sdr["IsPostStation"].ToString());
                            hairShop.IsPostMachine = bool.Parse(sdr["IsPostMachine"].ToString());
                            hairShop.HairShopGood = int.Parse(sdr["HairShopGood"].ToString());
                            hairShop.HairShopBad = int.Parse(sdr["HairShopBad"].ToString());
                            hairShop.MemberInfo = sdr["MemberInfo"].ToString();
                            hairShop.CouponNum = int.Parse(sdr["CouponNum"].ToString());
                            hairShop.OutLogs = sdr["outLogs"].ToString();
                            hairShop.InnerLogs = sdr["InnerLogs"].ToString();
                            hairShop.TravelInfo = sdr["TravelInfo"].ToString();
                            try
                            {
                                hairShop.HairCutDiscountMin = Convert.ToDecimal(sdr["HairCutPriceMin"].ToString());
                            }
                            catch
                            {
                                hairShop.HairCutDiscountMin = 0;
                            }
                            try
                            {
                                hairShop.HairMarcelDiscountMin = Convert.ToDecimal(sdr["HairMarcelPriceMin"].ToString());
                            }
                            catch
                            {
                                hairShop.HairMarcelDiscountMin = 0;
                            }
                            try
                            {
                                hairShop.HairDyeDiscountMin = Convert.ToDecimal(sdr["HairDyePriceMin"].ToString());
                            }
                            catch
                            {
                                hairShop.HairDyeDiscountMin = 0;
                            }
                            try
                            {
                                hairShop.HairShapeDiscountMin = Convert.ToDecimal(sdr["HairShapePriceMin"].ToString());
                            }
                            catch
                            {
                                hairShop.HairShapeDiscountMin = 0;
                            }
                            try
                            {
                                hairShop.HairConservationDiscountMin = Convert.ToDecimal(sdr["HairConservationPriceMin"].ToString());
                            }
                            catch
                            {
                                hairShop.HairConservationDiscountMin = 0;
                            }
                            try
                            {
                                hairShop.HairShopNormal = int.Parse(sdr["HairShopNormal"].ToString());
                            }
                            catch
                            {
                                hairShop.HairShopNormal = 0;
                            }
                            Decimal parseValue;

                            Decimal.TryParse(sdr["HairCutPrice"].ToString(), out parseValue);
                            hairShop.HairCutPirce = parseValue;
                            Decimal.TryParse(sdr["HairCutDiscount"].ToString(), out parseValue);
                            hairShop.HairCutDiscount = parseValue;
                            Decimal.TryParse(sdr["HairMarcelPrice"].ToString(), out parseValue);
                            hairShop.HairMarcelPrice = parseValue;
                            Decimal.TryParse(sdr["HairMarcelDiscount"].ToString(), out parseValue);
                            hairShop.HairMarcelDiscount = parseValue;

                            Decimal.TryParse(sdr["HairDyePrice"].ToString(), out parseValue);
                            hairShop.HairDyePrice = parseValue;
                            Decimal.TryParse(sdr["HairDyeDiscount"].ToString(), out parseValue);
                            hairShop.HairDyeDiscount = parseValue;

                            Decimal.TryParse(sdr["HairShapePrice"].ToString(), out parseValue);
                            hairShop.HairShapePrice = parseValue;
                            Decimal.TryParse(sdr["HairShapeDiscount"].ToString(), out parseValue);
                            hairShop.HairShapeDiscount = parseValue;
                            Decimal.TryParse(sdr["HairConservationPrice"].ToString(), out parseValue);
                            hairShop.HairConservationPrice = parseValue;
                            Decimal.TryParse(sdr["HairConservationDiscount"].ToString(), out parseValue);
                            hairShop.HairConservationDiscount = parseValue;

                            hairShop.LocationMapURL = sdr["LocationMapURL"].ToString();

                            if (sdr["IsServeMarcel"] == null || bool.Parse(sdr["IsServeMarcel"].ToString()) == false)
                                hairShop.IsServeMarce = false;
                            else
                                hairShop.IsServeMarce = true;

                            if (sdr["IsServeDye"] == null || bool.Parse(sdr["IsServeDye"].ToString()) == false )
                                hairShop.IsServeDye = false;
                            else
                                hairShop.IsServeDye = true;

                            if (sdr["IsServeHairCut"] == null || bool.Parse(sdr["IsServeHairCut"].ToString()) == false)
                                hairShop.IsServeHairCut = false;
                            else
                                hairShop.IsServeHairCut = true;

                            hairShop.Square = sdr["Square"].ToString();

                            int value;
                            int.TryParse(sdr["postid"].ToString(), out value);
                            hairShop.Postid = value;
                        }
                    }
                }
            }

            return hairShop;
        }
        public List<HairShop> GetHairShops(int count, string selectCondition, OrderKey ok,Sort sort)
        {
            List<HairShop> list = new List<HairShop>();

            string orderKey = " order by ";
            switch (ok)
            {
                case OrderKey.ID:
                    orderKey += "hs.HairShopID";
                    break;
                case OrderKey.CommentNum:
                    orderKey += "hs.HairShopGood+hs.HairShopBad";
                    break;
                case OrderKey.RecommandNum:
                    orderKey += "hs.HairShopRecommandNum";
                    break;
                case OrderKey.HitNum:
                    orderKey += "hs.HairShopVisitNum";
                    break;
                case OrderKey.OrderNum:
                    orderKey += "hs.HairShopOrderNum";
                    break;
                default:
                    orderKey += "hs.HairShopID";
                    break;

            }

            string commText = "";
            switch (count)
            {
                case 0:
                    commText = "select * from HairShop hs left join City c on hs.HairShopCityID=c.cityID left join MapZone m on hs.HairShopMapZoneID = m.MapZoneID left join HotZone h on hs.HairShopHotZoneID = h.HotZoneID left join TypeTable tt on hs.TypeID=tt.TypeID " + selectCondition + orderKey + " " + sort.ToString();
                    break;
                default:
                    commText = "select top " + count.ToString() + " * from HairShop hs left join City c on hs.HairShopCityID=c.cityID left join MapZone m on hs.HairShopMapZoneID = m.MapZoneID left join HotZone h on hs.HairShopHotZoneID = h.HotZoneID left join TypeTable tt on hs.TypeID=tt.TypeID " + selectCondition + orderKey + " " + sort.ToString();
                    break;
            }

            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                {
                    using (SqlCommand comm = new SqlCommand())
                    {
                        comm.Connection = conn;
                        comm.CommandText = commText;
                        conn.Open();

                        using (SqlDataReader sdr = comm.ExecuteReader())
                        {
                            while (sdr.Read())
                            {
                                HairShop hairShop = new HairShop();

                                hairShop.HairShopID = int.Parse(sdr["HairShopID"].ToString());
                                hairShop.HairShopName = sdr["HairShopName"].ToString();
                                hairShop.HairShopCityID = int.Parse(sdr["HairShopCityID"].ToString());
                                hairShop.HairShopCityName = sdr["CityName"].ToString();
                                hairShop.HairShopMapZoneID = int.Parse(sdr["HairShopMapZoneID"].ToString());
                                hairShop.HairShopMapZoneName = sdr["MapZoneName"].ToString();
                                hairShop.HairShopHotZoneID = int.Parse(sdr["HairShopHotZoneID"].ToString());
                                hairShop.HairShopHotZoneName = sdr["HotZoneName"].ToString();
                                hairShop.HairShopAddress = sdr["HairShopAddress"].ToString();
                                hairShop.HairShopPhoneNum = sdr["HairShopPhoneNum"].ToString();
                                //hairShop.HairShopPictureStoreIDs = sdr["HairShopPictureStoreIDs"].ToString();
                                //hairShop.HairShopMainIDs = sdr["HairShopMainIDs"].ToString();
                                //hairShop.HairShopPartialIDs = sdr["HairShopPartialIDs"].ToString();
                                hairShop.HairShopEngineerNum = int.Parse(sdr["HairShopEngineerNum"].ToString());
                                hairShop.HairShopOpenTime = sdr["HairShopOpenTime"].ToString();
                                //hairShop.HairShopOrderNum = int.Parse(sdr["HairShopOrderNum"].ToString());
                                hairShop.HairShopVisitNum = int.Parse(sdr["HairShopVisitNum"].ToString());
                                //hairShop.WorkRangeIDs = sdr["WorkRangeIDs"].ToString();
                                hairShop.HairShopWebSite = sdr["HairShopWebSite"].ToString();
                                hairShop.HairShopEmail = sdr["HairShopEmail"].ToString();
                                hairShop.HairShopDiscount = sdr["HairShopDiscount"].ToString();
                                hairShop.HairShopLogo = sdr["HairShopLogo"].ToString();
                                hairShop.TravelInfo = sdr["TravelInfo"].ToString();
                                //try
                                //{
                                //    hairShop.HairShopRecommandNum = int.Parse(sdr["HairShopRecommandNum"].ToString());
                                //}
                                //catch
                                //{
                                //    hairShop.HairShopRecommandNum = 0;
                                //}
                                hairShop.HairShopCreateTime = sdr["HairShopCreateTime"].ToString();
                                hairShop.HairShopDescription = sdr["HairShopDescription"].ToString();
                                hairShop.ProductIDs = sdr["ProductIDs"].ToString();
                                hairShop.HairShopTagIDs = sdr["HairShopTagIDs"].ToString();
                                hairShop.HairShopShortName = sdr["HairShopShortName"].ToString();
                                //hairShop.IsBest = bool.Parse(sdr["IsBest"].ToString());
                                hairShop.IsJoin = bool.Parse(sdr["IsJoin"].ToString());
                                hairShop.TypeID = int.Parse(sdr["TypeID"].ToString());
                                hairShop.TypeName = sdr["TypeName"].ToString();
                                hairShop.IsPostStation = bool.Parse(sdr["IsPostStation"].ToString());
                                hairShop.IsPostMachine = bool.Parse(sdr["IsPostMachine"].ToString());
                                hairShop.HairShopGood = int.Parse(sdr["HairShopGood"].ToString());
                                hairShop.HairShopBad = int.Parse(sdr["HairShopBad"].ToString());
                                try
                                {
                                    hairShop.Postid = int.Parse(sdr["postid"].ToString());
                                }
                                catch
                                {
                                    hairShop.Postid = 0;
                                }
                                hairShop.OutLogs = sdr["outLogs"].ToString();
                                hairShop.InnerLogs = sdr["innerLogs"].ToString();
                                hairShop.HairShopNormal = int.Parse(sdr["HairShopNormal"].ToString());
                                try
                                {
                                    hairShop.HairConservationDiscountMin = decimal.Parse(sdr["HairConservationPriceMin"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairConservationDiscountMin = 0;
                                }
                                try
                                {
                                    hairShop.HairConservationPrice = decimal.Parse(sdr["HairConservationPrice"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairConservationPrice = 0;
                                }
                                try
                                {
                                    hairShop.HairCutDiscountMin = decimal.Parse(sdr["HairCutPriceMin"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairCutDiscountMin = 0;
                                }
                                try
                                {
                                    hairShop.HairCutPirce = decimal.Parse(sdr["HairCutPrice"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairCutPirce = 0;
                                }
                                try
                                {
                                    hairShop.HairDyeDiscountMin = decimal.Parse(sdr["HairDyePriceMin"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairDyeDiscountMin = 0;
                                }
                                try
                                {
                                    hairShop.HairDyePrice = decimal.Parse(sdr["HairDyePrice"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairDyePrice = 0;
                                }
                                try
                                {
                                    hairShop.HairMarcelDiscountMin = decimal.Parse(sdr["HairMarcelPriceMin"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairMarcelDiscountMin = 0;
                                }
                                try
                                {
                                    hairShop.HairMarcelPrice = decimal.Parse(sdr["HairMarcelPrice"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairMarcelPrice = 0;
                                }
                                try
                                {
                                    hairShop.HairShapeDiscountMin = decimal.Parse(sdr["HairShapePriceMin"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairShapeDiscountMin = 0;
                                }
                                try
                                {
                                    hairShop.HairShapePrice = decimal.Parse(sdr["HairShapePrice"].ToString());
                                }
                                catch
                                {
                                    hairShop.HairShapePrice = 0;
                                }

                                list.Add(hairShop);
                            }
                        }
                    }
                }
            }

            return list;
        }