コード例 #1
0
        /// <summary>
        /// ͨ���������Ƽ�ID����������Ƽ�ʵ��
        /// </summary>
        /// <param name="hairShopRecommandID"></param>
        /// <returns></returns>
        public HairShopRecommand GetHairShopRecommandByHairShopRecommandID(int hairShopRecommandID)
        {
            HairShopRecommand hairShopRecommand = new HairShopRecommand();

            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                string commText = "select * from HairShopRecommand hsr left join HairShop hs on hsr.HairShopRawID = hs.HairShopID 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 hsr.HairShopRecommandID = " + hairShopRecommandID.ToString();

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

                    using (SqlDataReader sdr = comm.ExecuteReader())
                    {
                        if (sdr.Read())
                        {
                            hairShopRecommand.HairShopRecommandID = int.Parse(sdr["HairShopRecommandID"].ToString());
                            hairShopRecommand.HairShopRawID = int.Parse(sdr["HairShopRawID"].ToString());
                            hairShopRecommand.HairShopName = sdr["HairShopName"].ToString();
                            //hairShopRecommand.HairShopCityID = int.Parse(sdr["HairShopCityID"].ToString());
                            //hairShopRecommand.HairShopCityName = sdr["CityName"].ToString();
                            //hairShopRecommand.HairShopMapZoneID = int.Parse(sdr["HairShopMapZoneID"].ToString());
                            //hairShopRecommand.HairShopMapZoneName = sdr["MapZoneName"].ToString();
                            //hairShopRecommand.HairShopHotZoneID = int.Parse(sdr["HairShopHotZoneID"].ToString());
                            //hairShopRecommand.HairShopHotZoneName = sdr["HotZoneName"].ToString();
                            //hairShopRecommand.HairShopAddress = sdr["HairShopAddress"].ToString();
                            //hairShopRecommand.HairShopPhoneNum = sdr["HairShopPhoneNum"].ToString();
                            //hairShopRecommand.HairShopPictureStoreIDs = sdr["HairShopPictureStoreIDs"].ToString();
                            //hairShopRecommand.HairShopMainIDs = sdr["HairShopMainIDs"].ToString();
                            //hairShopRecommand.HairShopPartialIDs = sdr["HairShopPartialIDs"].ToString();
                            //hairShopRecommand.HairShopEngineerNum = int.Parse(sdr["HairShopEngineerNum"].ToString());
                            //hairShopRecommand.HairShopOpenTime = sdr["HairShopOpenTime"].ToString();
                            //hairShopRecommand.HairShopOrderNum = int.Parse(sdr["HairShopOrderNum"].ToString());
                            //hairShopRecommand.HairShopVisitNum = int.Parse(sdr["HairShopVisitNum"].ToString());
                            //hairShopRecommand.WorkRangeIDs = sdr["WorkRangeIDs"].ToString();
                            //hairShopRecommand.HairShopWebSite = sdr["HairShopWebSite"].ToString();
                            //hairShopRecommand.HairShopEmail = sdr["HairShopEmail"].ToString();
                            //hairShopRecommand.HairShopDiscount = sdr["HairShopDiscount"].ToString();
                            //hairShopRecommand.HairShopLogo = sdr["HairShopLogo"].ToString();
                            //hairShopRecommand.HairShopRecommandNum = int.Parse(sdr["HairShopRecommandNum"].ToString());
                            //hairShopRecommand.HairShopCreateTime = sdr["HairShopCreateTime"].ToString();
                            //hairShopRecommand.HairShopDescription = sdr["HairShopDescription"].ToString();
                            //hairShopRecommand.ProductIDs = sdr["ProductIDs"].ToString();
                            //hairShopRecommand.HairShopTagIDs = sdr["HairShopTagIDs"].ToString();
                            //hairShopRecommand.HairShopShortName = sdr["HairShopShortName"].ToString();
                            //hairShopRecommand.IsBest = bool.Parse(sdr["IsBest"].ToString());
                            //hairShopRecommand.IsJoin = bool.Parse(sdr["IsJoin"].ToString());
                            //hairShopRecommand.TypeID = int.Parse(sdr["TypeID"].ToString());
                            //hairShopRecommand.TypeName = sdr["TypeName"].ToString();
                            //hairShopRecommand.IsPostStation = bool.Parse(sdr["IsPostStation"].ToString());
                            //hairShopRecommand.IsPostMachine = bool.Parse(sdr["IsPostMachine"].ToString());
                            //hairShopRecommand.HairShopGood = int.Parse(sdr["HairShopGood"].ToString());
                            //hairShopRecommand.HairShopBad = int.Parse(sdr["HairShopBad"].ToString());
                            hairShopRecommand.HairShopRecommandEx = sdr["HairShopRecommandEx"].ToString();
                            hairShopRecommand.HairShopRecommandInfo = sdr["HairShopRecommandInfo"].ToString();
                        }
                    }
                }
            }

            return hairShopRecommand;
        }
コード例 #2
0
        /// <summary>
        /// ����������Ƽ�
        /// </summary>
        /// <param name="count">0 ȫ��</param>
        /// <returns></returns>
        public List<HairShopRecommand> GetHairShopRecommands(int count)
        {
            List<HairShopRecommand> list = new List<HairShopRecommand>();

            string commText = "";
            switch (count)
            {
                case 0:
                    commText = "select * from HairShopRecommand hsr left join HairShop hs on hsr.HairShopRawID = hs.HairShopID 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 order by hsr.HairShopRecommandID desc";
                    break;
                default:
                    commText = "select top " + count.ToString() + " * from HairShopRecommand hsr left join HairShop hs on hsr.HairShopRawID = hs.HairShopID 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 order by hsr.HairShopRecommandID desc";
                    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())
                            {
                                HairShopRecommand hairShopRecommand = new HairShopRecommand();

                                hairShopRecommand.HairShopRecommandID = int.Parse(sdr["HairShopRecommandID"].ToString());
                                hairShopRecommand.HairShopRawID = int.Parse(sdr["HairShopRawID"].ToString());
                                hairShopRecommand.HairShopName = sdr["HairShopName"].ToString();
                                //hairShopRecommand.HairShopCityID = int.Parse(sdr["HairShopCityID"].ToString());
                                //hairShopRecommand.HairShopCityName = sdr["CityName"].ToString();
                                //hairShopRecommand.HairShopMapZoneID = int.Parse(sdr["HairShopMapZoneID"].ToString());
                                //hairShopRecommand.HairShopMapZoneName = sdr["MapZoneName"].ToString();
                                //hairShopRecommand.HairShopHotZoneID = int.Parse(sdr["HairShopHotZoneID"].ToString());
                                //hairShopRecommand.HairShopHotZoneName = sdr["HotZoneName"].ToString();
                                //hairShopRecommand.HairShopAddress = sdr["HairShopAddress"].ToString();
                                //hairShopRecommand.HairShopPhoneNum = sdr["HairShopPhoneNum"].ToString();
                                //hairShopRecommand.HairShopPictureStoreIDs = sdr["HairShopPictureStoreIDs"].ToString();
                                //hairShopRecommand.HairShopMainIDs = sdr["HairShopMainIDs"].ToString();
                                //hairShopRecommand.HairShopPartialIDs = sdr["HairShopPartialIDs"].ToString();
                                //hairShopRecommand.HairShopEngineerNum = int.Parse(sdr["HairShopEngineerNum"].ToString());
                                //hairShopRecommand.HairShopOpenTime = sdr["HairShopOpenTime"].ToString();
                                //try
                                //{
                                //    hairShopRecommand.HairShopOrderNum = int.Parse(sdr["HairShopOrderNum"].ToString());
                                //}
                                //catch
                                //{
                                //    hairShopRecommand.HairShopOrderNum = 0;
                                //}
                                //try
                                //{
                                //    hairShopRecommand.HairShopVisitNum = int.Parse(sdr["HairShopVisitNum"].ToString());
                                //}
                                //catch
                                //{
                                //    hairShopRecommand.HairShopVisitNum = 0;
                                //}
                                //hairShopRecommand.WorkRangeIDs = sdr["WorkRangeIDs"].ToString();
                                //hairShopRecommand.HairShopWebSite = sdr["HairShopWebSite"].ToString();
                                //hairShopRecommand.HairShopEmail = sdr["HairShopEmail"].ToString();
                                //hairShopRecommand.HairShopDiscount = sdr["HairShopDiscount"].ToString();
                                //hairShopRecommand.HairShopLogo = sdr["HairShopLogo"].ToString();
                                //try
                                //{
                                //    hairShopRecommand.HairShopRecommandNum = int.Parse(sdr["HairShopRecommandNum"].ToString());
                                //}
                                //catch
                                //{
                                //    hairShopRecommand.HairShopRecommandNum = 0;
                                //}
                                //hairShopRecommand.HairShopCreateTime = sdr["HairShopCreateTime"].ToString();
                                //hairShopRecommand.HairShopDescription = sdr["HairShopDescription"].ToString();
                                //hairShopRecommand.ProductIDs = sdr["ProductIDs"].ToString();
                                //hairShopRecommand.HairShopTagIDs = sdr["HairShopTagIDs"].ToString();
                                //hairShopRecommand.HairShopShortName = sdr["HairShopShortName"].ToString();
                                //hairShopRecommand.IsBest = bool.Parse(sdr["IsBest"].ToString());
                                //hairShopRecommand.IsJoin = bool.Parse(sdr["IsJoin"].ToString());
                                //hairShopRecommand.TypeID = int.Parse(sdr["TypeID"].ToString());
                                //hairShopRecommand.TypeName = sdr["TypeName"].ToString();
                                //hairShopRecommand.IsPostStation = bool.Parse(sdr["IsPostStation"].ToString());
                                //hairShopRecommand.IsPostMachine = bool.Parse(sdr["IsPostMachine"].ToString());
                                //try
                                //{
                                //    hairShopRecommand.HairShopGood = int.Parse(sdr["HairShopGood"].ToString());
                                //}
                                //catch
                                //{
                                //    hairShopRecommand.HairShopGood = 0;
                                //}

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

                                hairShopRecommand.HairShopRecommandEx = sdr["HairShopRecommandEx"].ToString();

                                hairShopRecommand.HairShopRecommandInfo = sdr["HairShopRecommandInfo"].ToString();

                                list.Add(hairShopRecommand);
                            }
                        }
                    }
                }
            }

            return list;
        }
コード例 #3
0
        /// <summary>
        /// �������Ƽ�
        /// </summary>
        /// <param name="hairShopRecommand"></param>
        /// <param name="ua"></param>
        /// <returns></returns>
        public bool HairShopRecommandCreateDeleteUpdate(HairShopRecommand hairShopRecommand, UserAction ua)
        {
            bool result = false;
            string commandText = string.Empty;
            switch (ua)
            {
                case UserAction.Create:
                    commandText = "insert into HairShopRecommand(HairShopRawID,HairShopName,HairShopCityID,HairShopMapZoneID,HairShopHotZoneID,HairShopAddress,HairShopPhoneNum,HairShopPictureStoreIDs,HairShopMainIDs,HairShopPartialIDs,HairShopEngineerNum,HairShopOpenTime,WorkRangeIDs,HairShopWebSite,HairShopEmail,HairShopDiscount,HairShopLogo,HairShopCreateTime,HairShopDescription,ProductIDs,HairShopTagIDs,HairShopShortName,IsBest,IsJoin,TypeID,IsPostStation,IsPostMachine,HairShopRecommandEx,HairShopRecommandInfo) values(" + hairShopRecommand.HairShopRawID.ToString() + ",'" + hairShopRecommand.HairShopName + "'," + hairShopRecommand.HairShopCityID.ToString() + "," + hairShopRecommand.HairShopMapZoneID.ToString() + "," + hairShopRecommand.HairShopHotZoneID.ToString() + ",'" + hairShopRecommand.HairShopAddress + "','" + hairShopRecommand.HairShopPhoneNum + "','" + hairShopRecommand.HairShopPictureStoreIDs + "','" + hairShopRecommand.HairShopMainIDs + "','" + hairShopRecommand.HairShopPartialIDs + "'," + hairShopRecommand.HairShopEngineerNum.ToString() + ",'" + hairShopRecommand.HairShopOpenTime + "','" + hairShopRecommand.WorkRangeIDs + "','" + hairShopRecommand.HairShopWebSite + "','" + hairShopRecommand.HairShopEmail + "','" + hairShopRecommand.HairShopDiscount + "','" + hairShopRecommand.HairShopLogo + "','" + hairShopRecommand.HairShopCreateTime + "','" + hairShopRecommand.HairShopDescription + "','" + hairShopRecommand.ProductIDs + "','" + hairShopRecommand.HairShopTagIDs + "','" + hairShopRecommand.HairShopShortName + "'," + hairShopRecommand.IsBest.CompareTo(false).ToString() + "," + hairShopRecommand.IsJoin.CompareTo(false).ToString() + "," + hairShopRecommand.TypeID.ToString() + "," + hairShopRecommand.IsPostStation.CompareTo(false).ToString() + "," + hairShopRecommand.IsPostMachine.CompareTo(false).ToString() + ",'" + hairShopRecommand.HairShopRecommandEx + "','" + hairShopRecommand.HairShopRecommandInfo + "')";
                    break;
                case UserAction.Delete:
                    commandText = "delete from HairShopRecommand where HairShopRecommandID=" + hairShopRecommand.HairShopRecommandID.ToString();
                    break;
                case UserAction.Update:
                    commandText = "update HairShopRecommand set HairShopRawID="+hairShopRecommand.HairShopRawID.ToString()+",HairShopName='" + hairShopRecommand.HairShopName + "',HairShopCityID=" + hairShopRecommand.HairShopCityID.ToString() + ",HairShopMapZoneID=" + hairShopRecommand.HairShopMapZoneID.ToString() + ",HairShopHotZoneID=" + hairShopRecommand.HairShopHotZoneID.ToString() + ",HairShopAddress='" + hairShopRecommand.HairShopAddress + "',HairShopPhoneNum='" + hairShopRecommand.HairShopPhoneNum + "',HairShopPictureStoreIDs='" + hairShopRecommand.HairShopPictureStoreIDs + "',HairShopMainIDs='" + hairShopRecommand.HairShopMainIDs + "',HairShopPartialIDs='" + hairShopRecommand.HairShopPartialIDs + "',HairShopEngineerNum=" + hairShopRecommand.HairShopEngineerNum.ToString() + ",HairShopOpenTime='" + hairShopRecommand.HairShopOpenTime + "',WorkRangeIDs='" + hairShopRecommand.WorkRangeIDs + "',HairShopWebSite='" + hairShopRecommand.HairShopWebSite + "',HairShopEmail='" + hairShopRecommand.HairShopEmail + "',HairShopDiscount='" + hairShopRecommand.HairShopDiscount + "',HairShopLogo='" + hairShopRecommand.HairShopLogo + "',HairShopCreateTime='" + hairShopRecommand.HairShopCreateTime + "',HairShopDescription='" + hairShopRecommand.HairShopDescription + "',ProductIDs='" + hairShopRecommand.ProductIDs + "',HairShopTagIDs='" + hairShopRecommand.HairShopTagIDs + "',HairShopShortName='" + hairShopRecommand.HairShopShortName + "',IsBest=" + hairShopRecommand.IsBest.CompareTo(false).ToString() + ",IsJoin=" + hairShopRecommand.IsJoin.CompareTo(false).ToString() + ",TypeID=" + hairShopRecommand.TypeID.ToString() + ",IsPostStation=" + hairShopRecommand.IsPostStation.CompareTo(false).ToString() + ",IsPostMachine=" + hairShopRecommand.IsPostMachine.CompareTo(false).ToString() + ",HairShopRecommandEx='"+hairShopRecommand.HairShopRecommandEx+"',HairShopRecommandInfo='"+hairShopRecommand.HairShopRecommandInfo+"' where HairShopRecommandID = " + hairShopRecommand.HairShopRecommandID.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);
                    }

                }
            }
            return result;
        }