Exemple #1
0
        private void Bind()
        {
            if (!Id.Equals(Guid.Empty))
            {
                ServiceVote bll   = new ServiceVote();
                var         model = bll.GetModelByJoin(Id);
                if (model != null)
                {
                    myDataAppend.Append("<div code=\"myDataForModel\">[{\"Id\":\"" + model.Id + "\",\"ServiceItemId\":\"" + model.ServiceItemId + "\",\"ServiceItemName\":\"" + model.ServiceItemName + "\",\"Sort\":\"" + model.Sort + "\"}]</div>");

                    hServiceVoteId.Value       = model.Id.ToString();
                    txtNamed_ServiceVote.Value = model.Named;
                    string pictureUrl = "";
                    if (!string.IsNullOrWhiteSpace(model.FileDirectory))
                    {
                        pictureUrl = PictureUrlHelper.GetMPicture(model.FileDirectory, model.RandomFolder, model.FileExtension);
                    }
                    imgHeadPicture_ServiceVote.Src       = string.IsNullOrWhiteSpace(pictureUrl) ? "../../Images/nopic.gif" : pictureUrl;
                    hHeadPictureId_ServiceVote.Value     = model.HeadPictureId.ToString();
                    txtaDescr_ServiceVote.Value          = model.Descr;
                    txtaContent_ServiceVote.Value        = model.ContentText;
                    txtEnableStartTime_ServiceVote.Value = model.EnableStartTime == DateTime.MinValue ? "" : model.EnableStartTime.ToString("yyyy-MM-dd HH:mm:ss");
                    txtEnableEndTime_ServiceVote.Value   = model.EnableStartTime == DateTime.MinValue ? "" : model.EnableStartTime.ToString("yyyy-MM-dd HH:mm:ss");
                    var li = rbtnList_ServiceVote.Items.FindByValue(model.IsDisable.ToString().ToLower());
                    if (li != null)
                    {
                        li.Selected = true;
                    }
                }
            }
        }
        public string DelServiceVote(string itemAppend)
        {
            string errorMsg = string.Empty;

            try
            {
                itemAppend = itemAppend.Trim();
                if (string.IsNullOrEmpty(itemAppend))
                {
                    return(MessageContent.Submit_InvalidRow);
                }

                string[] items = itemAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

                ServiceVote bll = new ServiceVote();
                bll.DeleteBatch(items.ToList <object>());
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            if (!string.IsNullOrEmpty(errorMsg))
            {
                return(MessageContent.AlertTitle_Ex_Error + ":" + errorMsg);
            }
            return("1");
        }
        private void Bind()
        {
            if (!Id.Equals(Guid.Empty))
            {
                ServiceVote bll   = new ServiceVote();
                var         model = bll.GetModelByJoin(Id);
                if (model != null)
                {
                    myDataAppend.Append("<div code=\"myDataForModel\">[{\"Id\":\"" + model.Id + "\",\"ServiceItemId\":\"" + model.ServiceItemId + "\",\"ServiceItemName\":\"" + model.ServiceItemName + "\",\"Sort\":\"" + model.Sort + "\"}]</div>");

                    hServiceVoteId.Value             = model.Id.ToString();
                    txtNamed_ServiceVote.Value       = model.Named;
                    imgHeadPicture_ServiceVote.Src   = string.IsNullOrWhiteSpace(model.MPicture) ? "../../Images/nopic.gif" : model.MPicture;
                    hHeadPictureId_ServiceVote.Value = model.HeadPictureId.ToString();
                    txtaDescr_ServiceVote.Value      = model.Descr;
                    txtaContent_ServiceVote.Value    = model.ContentText;
                }
            }
        }
Exemple #4
0
        public string GetServiceVoteById(Guid Id)
        {
            try
            {
                if (Id.Equals(Guid.Empty))
                {
                    return("");
                }

                ServiceVote svBll = new ServiceVote();
                var         model = svBll.GetModelByJoin(Id);
                if (model == null)
                {
                    return("");
                }

                Regex r = new Regex("(<img)(.*)src=\"([^\"]*?)\"(.*)/>");
                model.ContentText = r.Replace(model.ContentText, "$1$2src=\"" + WebSiteHost + "$3\" />");

                StringBuilder sb = new StringBuilder(500);
                sb.Append("<Rsp>");

                Dictionary <string, string> dic = null;
                if (!string.IsNullOrWhiteSpace(model.FileDirectory) && !string.IsNullOrWhiteSpace(model.RandomFolder) && !string.IsNullOrWhiteSpace(model.FileExtension))
                {
                    EnumData.Platform platform = EnumData.Platform.Android;
                    dic = PictureUrlHelper.GetUrlByPlatform(model.FileDirectory, model.RandomFolder, model.FileExtension, platform);
                }

                sb.AppendFormat("<Id>{0}</Id><Name>{1}</Name><Descr>{2}</Descr><Content><![CDATA[{3}]]></Content><LastUpdatedDate>{4}</LastUpdatedDate>", model.Id, model.Named, model.Descr, model.ContentText, model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm"));
                sb.AppendFormat("<OriginalPicture>{0}</OriginalPicture><BPicture>{1}</BPicture><MPicture>{2}</MPicture><SPicture>{3}</SPicture>", dic == null ? "" : WebSiteHost + dic["OriginalPicture"], dic == null ? "" : WebSiteHost + dic["BPicture"], dic == null ? "" : WebSiteHost + dic["MPicture"], dic == null ? "" : WebSiteHost + dic["SPicture"]);

                sb.Append("</Rsp>");

                return(sb.ToString());
            }
            catch (Exception ex)
            {
                new CustomException(string.Format("服务-接口:string GetServiceVoteById,异常:{0}", ex.Message), ex);
                return("");
            }
        }
        private void GetDatagridForServiceVote(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            int totalRecords = 0;
            int pageIndex    = 1;
            int pageSize     = 10;

            int.TryParse(context.Request.Form["page"], out pageIndex);
            int.TryParse(context.Request.Form["rows"], out pageSize);

            Guid serviceItemId = Guid.Empty;

            if (!string.IsNullOrWhiteSpace(context.Request.Form["serviceItemId"]))
            {
                Guid.TryParse(context.Request.Form["serviceItemId"], out serviceItemId);
            }
            if (serviceItemId.Equals(Guid.Empty))
            {
                context.Response.Write("{\"total\":0,\"rows\":[]}");
                return;
            }
            string keyword = context.Request.Form["keyword"];

            string       sqlWhere = string.Empty;
            ParamsHelper parms    = null;

            if (!serviceItemId.Equals(Guid.Empty))
            {
                sqlWhere += "and sv.ServiceItemId = @ServiceItemId ";
                SqlParameter parm = new SqlParameter("@ServiceItemId", SqlDbType.UniqueIdentifier);
                parm.Value = serviceItemId;
                if (parms == null)
                {
                    parms = new ParamsHelper();
                }
                parms.Add(parm);
            }
            if (!string.IsNullOrWhiteSpace(keyword))
            {
                if (parms == null)
                {
                    parms = new ParamsHelper();
                }
                sqlWhere += "and (sv.Named like @Named or sv.Descr like @Descr) ";
                SqlParameter parm = new SqlParameter("@Named", SqlDbType.NVarChar, 30);
                parm.Value = "%" + keyword.Trim() + "%";
                parms.Add(parm);
                parm       = new SqlParameter("@Descr", SqlDbType.NVarChar, 300);
                parm.Value = "%" + keyword.Trim() + "%";

                parms.Add(parm);
            }

            ServiceVote bll  = new ServiceVote();
            var         list = bll.GetListByJoin(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());

            if (list == null || list.Count == 0)
            {
                ServiceItem siBll = new ServiceItem();
                siBll.UpdateHasVote(serviceItemId, false);
                context.Response.Write("{\"total\":0,\"rows\":[]}");
                return;
            }
            StringBuilder sb = new StringBuilder();

            foreach (var model in list)
            {
                sb.Append("{\"Id\":\"" + model.Id + "\",\"ServiceItemId\":\"" + model.ServiceItemId + "\",\"ServiceItemName\":\"" + model.ServiceItemName + "\",\"Named\":\"" + model.Named + "\",\"Descr\":\"" + model.Descr + "\",\"Sort\":\"" + model.Sort + "\",\"OriginalPicture\":\"" + model.OriginalPicture.Replace("~", "") + "\",\"BPicture\":\"" + model.BPicture + "\",\"MPicture\":\"" + model.MPicture + "\",\"SPicture\":\"" + model.SPicture + "\",\"OtherPicture\":\"" + model.OtherPicture + "\",\"LastUpdatedDate\":\"" + model.LastUpdatedDate.ToString("yyyy-MM-dd HH:mm") + "\"},");
            }
            context.Response.Write("{\"total\":" + totalRecords + ",\"rows\":[" + sb.ToString().Trim(',') + "]}");
        }
        private void SaveServiceVote(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            try
            {
                string svId           = context.Request.Form["hServiceVoteId"].Trim();
                string sServiceItemId = context.Request.Form["ServiceItemId"].Trim();
                string sNamed         = context.Request.Form["txtNamed_ServiceVote"].Trim();
                string sHeadPictureId = context.Request.Form["hHeadPictureId_ServiceVote"].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 headPictureId = Guid.Empty;
                Guid.TryParse(sHeadPictureId, out headPictureId);
                int sort = 0;
                if (!string.IsNullOrWhiteSpace(sSort))
                {
                    int.TryParse(sSort, out sort);
                }

                string sDescr  = context.Request.Form["txtaDescr_ServiceVote"].Trim();
                string content = context.Request.Form["content"].Trim();
                content = HttpUtility.HtmlDecode(content);

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

                ServiceVoteInfo model = new ServiceVoteInfo();
                model.Id = gId;
                model.LastUpdatedDate = DateTime.Now;
                model.ServiceItemId   = serviceItemId;
                model.Named           = sNamed;
                model.HeadPictureId   = headPictureId;
                model.Descr           = sDescr;
                model.ContentText     = content;
                model.Sort            = sort;

                ServiceVote bll   = new ServiceVote();
                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.HasVote) && effect > 0)
                        {
                            siModel.HasVote = true;
                            siBll.Update(siModel);
                        }
                    }
                    else
                    {
                        effect = bll.Insert(model);
                        if ((!siModel.HasVote) && effect > 0)
                        {
                            siModel.HasVote = 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 + "\"}");
            }
        }
Exemple #7
0
        /// <summary>
        /// 增加一条投票信息
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public static int Insert_ServiceVote(ServiceVote vote)
        {
            string sqlStr = "insert into T_ServiceVote(SV_ZH,SV_GY,SV_SF,SV_HJ,SV_TC,SV_GL,SV_YJ,SV_ZA,SV_SS,SV_GC,SV_CS,SV_CY,SV_KF,SV_JY,SV_QX,SV_Remark,SV_SID) values('" + vote.SV_ZH + "','" + vote.SV_GY + "','" + vote.SV_SF + "','" + vote.SV_HJ + "','" + vote.SV_TC + "','" + vote.SV_GL + "','" + vote.SV_YJ + "','" + vote.SV_ZA + "','" + vote.SV_SS + "','" + vote.SV_GC + "','" + vote.SV_CS + "','" + vote.SV_CY + "','" + vote.SV_KF + "','" + vote.SV_JY + "','" + vote.SV_QX + "','" + vote.SV_Remark + "','" + vote.SV_SID + "')";

            return(DBHelper.ExecuteCommand(sqlStr));
        }