Пример #1
0
    string BindPictures()
    {
        List <ProductPicture> pics = ProductPictures.GetPictures(productID);

        if (pics.Count > 0)
        {
            return(Newtonsoft.Json.JavaScriptConvert.SerializeObject(pics));
        }
        else
        {
            return("null");
        }
    }
Пример #2
0
    void BindPicture()
    {
        if (p == null)
        {
            p = GetProduct();
        }
        List <ProductPicture> pics = ProductPictures.GetPictures(p.ProductID);
        string picStr = "''";

        if (pics != null && pics.Count > 0)
        {
            picStr = Newtonsoft.Json.JavaScriptConvert.SerializeObject(pics);
        }
        base.ExecuteJs("var pictures=" + picStr + ";var _infos={l:" + User.Identity.IsAuthenticated.ToString().ToLower() + ",d:" + p.ProductID + "}", true);
    }
Пример #3
0
    public void RaiseCallbackEvent(string eventArgument)
    {
        Guid id;
        TemporaryAttachment ta;

        if (eventArgument == "refreshBinder")
        {
            switch (action)
            {
            case OperateType.Add:
                result = BindAttachment();
                break;

            case OperateType.Edit:
                result = BindPictures();
                break;
            }
        }
        if (eventArgument.StartsWith("deleteAttach"))
        {
            try
            {
                switch (action)
                {
                case OperateType.Add:
                    id = new Guid(eventArgument.Split(':')[1]);
                    TemporaryAttachments.Delete(id);
                    break;

                case OperateType.Edit:
                    ProductPictures.Delete(int.Parse(eventArgument.Split(':')[1]));
                    break;
                }
                result = "0";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
        }
        if (eventArgument.StartsWith("setDefault"))
        {
            try
            {
                switch (action)
                {
                case OperateType.Add:
                    id = new Guid(eventArgument.Split(':')[1]);
                    ta = TemporaryAttachments.GetTemporaryAttachments(Profile.AccountInfo.UserID, AttachmentType.ProductPhoto)[0];
                    ta.DisplayOrder = 100;
                    TemporaryAttachments.Update(ta);

                    ta = TemporaryAttachments.GetTemporaryAttachment(id);
                    ta.DisplayOrder = 0;
                    TemporaryAttachments.Update(ta);

                    result = BindAttachment();
                    break;

                case OperateType.Edit:
                    int            picId = int.Parse(eventArgument.Split(':')[1]);
                    ProductPicture pics  = ProductPictures.GetPictures(productID)[0];
                    pics.DisplayOrder = 100;
                    ProductPictures.Update(pics);

                    pics = ProductPictures.GetPicture(picId);
                    pics.DisplayOrder = 0;
                    ProductPictures.Update(pics);

                    result = BindPictures();
                    break;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
        }
    }