コード例 #1
0
        public IList <ServiceLinkInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ServiceItemId,PictureId,Named,Url,Sort,EnableStartTime,EnableEndTime,IsDisable,LastUpdatedDate 
			            from Service_Link
					    order by LastUpdatedDate desc "                    );

            IList <ServiceLinkInfo> list = new List <ServiceLinkInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ServiceLinkInfo model = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ServiceItemId   = reader.GetGuid(1);
                        model.PictureId       = reader.GetGuid(2);
                        model.Named           = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.EnableStartTime = reader.GetDateTime(6);
                        model.EnableEndTime   = reader.GetDateTime(7);
                        model.IsDisable       = reader.GetBoolean(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #2
0
        public IList <ServiceLinkInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select count(*) from Service_Link ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <ServiceLinkInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			          Id,ServiceItemId,PictureId,Named,Url,Sort,EnableStartTime,EnableEndTime,IsDisable,LastUpdatedDate
					  from Service_Link "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ServiceLinkInfo> list = new List <ServiceLinkInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ServiceLinkInfo model = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(1);
                        model.ServiceItemId   = reader.GetGuid(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.Named           = reader.GetString(4);
                        model.Url             = reader.GetString(5);
                        model.Sort            = reader.GetInt32(6);
                        model.EnableStartTime = reader.GetDateTime(7);
                        model.EnableEndTime   = reader.GetDateTime(8);
                        model.IsDisable       = reader.GetBoolean(9);
                        model.LastUpdatedDate = reader.GetDateTime(10);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #3
0
ファイル: MyServiceLink.cs プロジェクト: 2644783865/Infoztc
        public ServiceLinkInfo GetModelByJoin(object Id)
        {
            ServiceLinkInfo model = null;

            string       cmdText = @"select top 1 sl.Id,sl.ServiceItemId,sl.PictureId,sl.Named,sl.Url,sl.Sort,sl.EnableStartTime,sl.EnableEndTime,sl.IsDisable,sl.LastUpdatedDate, 
                               si.Named as ServiceItemName,psl.FileExtension,psl.FileDirectory,psl.RandomFolder
			                   from Service_Link sl
                               left join Service_Item si on si.Id = sl.ServiceItemId
                               left join Picture_ServiceLink psl on psl.Id = sl.PictureId 
							   where sl.Id = @Id "                            ;
            SqlParameter parm    = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, cmdText, parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ServiceItemId   = reader.GetGuid(1);
                        model.PictureId       = reader.GetGuid(2);
                        model.Named           = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.EnableStartTime = reader.GetDateTime(6);
                        model.EnableEndTime   = reader.GetDateTime(7);
                        model.IsDisable       = reader.GetBoolean(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        model.ServiceItemName = reader.IsDBNull(10) ? "" : reader.GetString(10);
                        model.FileExtension   = reader.IsDBNull(11) ? "" : reader.GetString(11);
                        model.FileDirectory   = reader.IsDBNull(12) ? "" : reader.GetString(12);
                        model.RandomFolder    = reader.IsDBNull(13) ? "" : reader.GetString(13);
                    }
                }
            }

            return(model);
        }
コード例 #4
0
        public int Update(ServiceLinkInfo model)
        {
            if (IsExist(model.Named, model.ServiceItemId, model.Id))
            {
                return(110);
            }

            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update Service_Link set ServiceItemId = @ServiceItemId,PictureId = @PictureId,Named = @Named,Url = @Url,Sort = @Sort,EnableStartTime = @EnableStartTime,EnableEndTime = @EnableEndTime,IsDisable = @IsDisable,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@ServiceItemId",   SqlDbType.UniqueIdentifier),
                new SqlParameter("@PictureId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@Named",           SqlDbType.NVarChar,           30),
                new SqlParameter("@Url",             SqlDbType.VarChar,           300),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@EnableStartTime", SqlDbType.DateTime),
                new SqlParameter("@EnableEndTime",   SqlDbType.DateTime),
                new SqlParameter("@IsDisable",       SqlDbType.Bit),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.ServiceItemId;
            parms[2].Value = model.PictureId;
            parms[3].Value = model.Named;
            parms[4].Value = model.Url;
            parms[5].Value = model.Sort;
            parms[6].Value = model.EnableStartTime;
            parms[7].Value = model.EnableEndTime;
            parms[8].Value = model.IsDisable;
            parms[9].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #5
0
        public IList <ServiceLinkInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ServiceItemId,PictureId,Named,Url,Sort,EnableStartTime,EnableEndTime,IsDisable,LastUpdatedDate
                        from Service_Link ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <ServiceLinkInfo> list = new List <ServiceLinkInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ServiceLinkInfo model = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ServiceItemId   = reader.GetGuid(1);
                        model.PictureId       = reader.GetGuid(2);
                        model.Named           = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.EnableStartTime = reader.GetDateTime(6);
                        model.EnableEndTime   = reader.GetDateTime(7);
                        model.IsDisable       = reader.GetBoolean(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #6
0
        public ServiceLinkInfo GetModel(object Id)
        {
            ServiceLinkInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,ServiceItemId,PictureId,Named,Url,Sort,EnableStartTime,EnableEndTime,IsDisable,LastUpdatedDate 
			            from Service_Link
						where Id = @Id "                        );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ServiceItemId   = reader.GetGuid(1);
                        model.PictureId       = reader.GetGuid(2);
                        model.Named           = reader.GetString(3);
                        model.Url             = reader.GetString(4);
                        model.Sort            = reader.GetInt32(5);
                        model.EnableStartTime = reader.GetDateTime(6);
                        model.EnableEndTime   = reader.GetDateTime(7);
                        model.IsDisable       = reader.GetBoolean(8);
                        model.LastUpdatedDate = reader.GetDateTime(9);
                    }
                }
            }

            return(model);
        }
コード例 #7
0
ファイル: ServiceLink.cs プロジェクト: 2644783865/Infoztc
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ServiceLinkInfo model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
ファイル: ServiceLink.cs プロジェクト: 2644783865/Infoztc
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ServiceLinkInfo model)
 {
     return(dal.Insert(model));
 }
コード例 #9
0
        private void SaveServiceLink(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                string scId           = context.Request.Form["hServiceLinkId"].Trim();
                string sServiceItemId = context.Request.Form["ServiceItemId"].Trim();
                string sNamed         = context.Request.Form["txtNamed_ServiceLink"].Trim();
                string sPictureId     = context.Request.Form["hPictureId_ServiceLink"].Trim();
                string sSort          = context.Request.Form["Sort"].Trim();

                if (string.IsNullOrWhiteSpace(sNamed))
                {
                    context.Response.Write("{\"success\": false,\"message\": \"" + MessageContent.Submit_Params_InvalidError + "\"}");
                    return;
                }

                Guid serviceItemId = Guid.Empty;
                Guid.TryParse(sServiceItemId, out serviceItemId);
                Guid pictureId = Guid.Empty;
                Guid.TryParse(sPictureId, out pictureId);
                int sort = 0;
                if (!string.IsNullOrWhiteSpace(sSort))
                {
                    int.TryParse(sSort, out sort);
                }

                string sUrl = context.Request.Form["txtUrl_ServiceLink"].Trim();

                Guid gId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(scId))
                {
                    Guid.TryParse(scId, out gId);
                }

                ServiceLinkInfo model = new ServiceLinkInfo();
                model.Id = gId;
                model.LastUpdatedDate = DateTime.Now;
                model.ServiceItemId   = serviceItemId;
                model.Named           = sNamed;
                model.PictureId       = pictureId;
                model.Url             = sUrl;
                model.Sort            = sort;

                ServiceLink bll   = new ServiceLink();
                ServiceItem siBll = new ServiceItem();

                var siModel = siBll.GetModel(serviceItemId);
                if (siModel == null)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"服务分类【" + serviceItemId + "】" + MessageContent.Submit_Data_NotExists + "\"}");
                    return;
                }

                int effect = -1;
                using (TransactionScope scope = new TransactionScope())
                {
                    if (!gId.Equals(Guid.Empty))
                    {
                        effect = bll.Update(model);
                        if ((!siModel.HasContent) && effect > 0)
                        {
                            siModel.HasLink = true;
                            siBll.Update(siModel);
                        }
                    }
                    else
                    {
                        effect = bll.Insert(model);
                        if ((!siModel.HasLink) && effect > 0)
                        {
                            siModel.HasLink = true;
                            siBll.Update(siModel);
                        }
                    }

                    scope.Complete();
                }

                if (effect < 1)
                {
                    context.Response.Write("{\"success\": false,\"message\": \"操作失败,请正确输入\"}");
                    return;
                }

                context.Response.Write("{\"success\": true,\"message\": \"操作成功\"}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{\"success\": false,\"message\": \"异常:" + ex.Message + "\"}");
            }
        }
コード例 #10
0
ファイル: MyServiceLink.cs プロジェクト: 2644783865/Infoztc
        public IList <ServiceLinkInfo> GetListByJoin(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select count(*) from Service_Link sl
                        left join Picture_ServiceLink psl on psl.Id = sl.PictureId
                        left join Service_Item si on si.Id = sl.ServiceItemId 
                      ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <ServiceLinkInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by sl.LastUpdatedDate desc,sl.Sort desc) as RowNumber,
			          sl.Id,sl.ServiceItemId,sl.PictureId,sl.Named,sl.Url,sl.Sort,sl.LastUpdatedDate,
                      si.Named as ServiceItemName,psl.FileExtension,psl.FileDirectory,psl.RandomFolder
					  from Service_Link sl
                      left join Picture_ServiceLink psl on psl.Id = sl.PictureId 
                      left join Service_Item si on si.Id = sl.ServiceItemId
                      ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ServiceLinkInfo> list = new List <ServiceLinkInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.SqlProviderConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ServiceLinkInfo model = new ServiceLinkInfo();
                        model.Id              = reader.GetGuid(1);
                        model.ServiceItemId   = reader.GetGuid(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.Named           = reader.GetString(4);
                        model.Url             = reader.GetString(5);
                        model.Sort            = reader.GetInt32(6);
                        model.LastUpdatedDate = reader.GetDateTime(7);

                        model.ServiceItemName = reader.IsDBNull(8) ? "" : reader.GetString(8);
                        model.FileExtension   = reader.IsDBNull(9) ? "" : reader.GetString(9);
                        model.FileDirectory   = reader.IsDBNull(10) ? "" : reader.GetString(10);
                        model.RandomFolder    = reader.IsDBNull(11) ? "" : reader.GetString(11);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }