Ejemplo n.º 1
0
        private void GetJsonForDatagrid(HttpContext context)
        {
            int totalRecords = 0;
            int pageIndex    = 1;
            int pageSize     = 10;

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

            SizePicture bll  = new SizePicture();
            var         list = bll.GetList(pageIndex, pageSize, out totalRecords, "", null);

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

            foreach (var model in list)
            {
                sb.Append("{\"Id\":\"" + model.Id + "\",\"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(',') + "]}");
        }
Ejemplo n.º 2
0
        private void Bind()
        {
            if (!string.IsNullOrEmpty(funName))
            {
                int totalRecords = 0;
                switch (funName)
                {
                case "CategoryPicture":
                    CategoryPicture categorypBll = new CategoryPicture();
                    rpData.DataSource = categorypBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();

                    break;

                case "ProductPicture":
                    ProductPicture ppBll = new ProductPicture();
                    rpData.DataSource = ppBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();

                    break;

                case "SizePicture":
                    SizePicture spBll = new SizePicture();
                    rpData.DataSource = spBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "ContentPicture":
                    ContentPicture cpBll = new ContentPicture();
                    rpData.DataSource = cpBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                case "ServicePicture":
                    ServicePicture servepBll = new ServicePicture();
                    rpData.DataSource = servepBll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());
                    rpData.DataBind();
                    break;

                default:
                    break;
                }

                myDataAppend.Replace("{TotalRecord}", totalRecords.ToString());
                myDataAppend.Replace("{PageIndex}", pageIndex.ToString());
                myDataAppend.Replace("{PageSize}", pageSize.ToString());

                //myDataAppend.Append("<div code=\"myDataForPage\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\"}]</div>");
                //myDataAppend.Append("<div code=\"myDataForDlg\">[{\"DlgId\":\"" + dlgId + "\",\"DlgHref\":\"/a/tyy.html\",\"IsMutilSelect\":\"" + isMutilSelect + "\"}]</div>");
            }
        }
Ejemplo n.º 3
0
        private void Bind()
        {
            GetSearchItem();

            List <SizePictureInfo> list = null;
            int totalRecords            = 0;

            SizePicture bll = new SizePicture();

            list = bll.GetList(pageIndex, pageSize, out totalRecords, sqlWhere, parms == null ? null : parms.ToArray());

            rpData.DataSource = list;
            rpData.DataBind();

            myDataAppend += "<div id=\"myDataForPage\" style=\"display:none;\">[{\"PageIndex\":\"" + pageIndex + "\",\"PageSize\":\"" + pageSize + "\",\"TotalRecord\":\"" + totalRecords + "\",\"QueryStr\":\"" + queryStr + "\"}]</div>";
        }
Ejemplo n.º 4
0
        public string DelSizePicture(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);
                string   inIds = "";
                foreach (string item in items)
                {
                    inIds += string.Format("'{0}',", item);
                }

                SizePicture bll    = new SizePicture();
                var         spList = bll.GetList(" and Id in (" + inIds.Trim(',') + ")");
                if (spList != null || spList.Count() > 0)
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        foreach (var model in spList)
                        {
                            if (!string.IsNullOrWhiteSpace(model.OriginalPicture))
                            {
                                string fullPath = Server.MapPath("~" + model.OriginalPicture);
                                if (File.Exists(fullPath))
                                {
                                    File.Delete(fullPath);
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(model.BPicture))
                            {
                                string fullPath = Server.MapPath("~" + model.BPicture);
                                if (File.Exists(fullPath))
                                {
                                    File.Delete(fullPath);
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(model.MPicture))
                            {
                                string fullPath = Server.MapPath("~" + model.MPicture);
                                if (File.Exists(fullPath))
                                {
                                    File.Delete(fullPath);
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(model.SPicture))
                            {
                                string fullPath = Server.MapPath("~" + model.SPicture);
                                if (File.Exists(fullPath))
                                {
                                    File.Delete(fullPath);
                                }
                            }
                            if (!string.IsNullOrWhiteSpace(model.OtherPicture))
                            {
                                string fullPath = Server.MapPath("~" + model.OtherPicture);
                                if (File.Exists(fullPath))
                                {
                                    File.Delete(fullPath);
                                }
                            }
                        }

                        bll.DeleteBatch(items.ToList <object>());

                        scope.Complete();
                    }
                }

                return("1");
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }
            if (!string.IsNullOrEmpty(errorMsg))
            {
                return(MessageContent.AlertTitle_Ex_Error + ":" + errorMsg);
            }
            return("1");
        }