Ejemplo n.º 1
0
    protected void Save_B_Click(object sender, EventArgs e)
    {
        //存商品表中,这样只有显示的逻辑需要扩展,其他逻辑可不变
        //商品增加筛选模型,便于扩展
        M_UserInfo mu     = buser.GetLogin();
        M_Product  proMod = proBll.GetproductByid(Mid);

        if (proMod == null)
        {
            proMod = new M_Product();
        }
        proMod.Proname = Name_T.Text.Trim();
        //proMod.BindIDS = UProIDS_Hid.Value;
        proMod.Procontent = UProIDS_Hid.Value;
        if (SFileUp.HasFile)
        {
            SFileUp.SaveUrl   = ZLHelper.GetUploadDir_System("shop", "product", "yyyyMMdd");
            proMod.Thumbnails = SFileUp.SaveFile();
        }
        proMod.LinPrice = DataConverter.CDouble(Price_T.Text);
        //proMod.BookPrice = DataConverter.CDouble(BookPrice_T.Text);
        proMod.ShiPrice = proMod.LinPrice;
        //proMod.Istrue = ZStatus_Chk.Checked ? 1 : 0;
        proMod.Proinfo    = Remind_T.Text;
        proMod.Nodeid     = 16;
        proMod.ModelID    = 20;
        proMod.GuessXML   = Request.Form["GuessXML"];
        proMod.UserShopID = mu.SiteID;
        if (proMod.ID > 0)
        {
            proBll.UpdateByID(proMod);
        }
        else
        {
            proMod.FirstNodeID = nodeBll.SelFirstNodeID(proMod.Nodeid);
            proMod.Class       = 2;
            proMod.ProClass    = 1;
            proMod.UserID      = mu.UserID;
            proMod.AddUser     = mu.UserName;
            proBll.Insert(proMod);
        }
        function.WriteSuccessMsg("操作成功", "SuitPro.aspx");
    }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            M_UserInfo mu = buser.GetLogin();

            retMod.retcode = M_APIResult.Failed;
            if (mu.IsNull)
            {
                retMod.retmsg = "用户未登录"; RepToClient(retMod);
            }
            int siteID = DataConvert.CLng(Req("SiteID"));

            //retMod.callback = CallBack;//暂不开放JsonP
            try
            {
                switch (Action)
                {
                case "mb_list":
                    #region
                {
                    string    fields = "wxico,wxsize,wxbk,flag,wxlink,content,dbtype";
                    DataTable dt     = GetListDT();
                    foreach (DataRow dr in dt.Rows)
                    {
                        M_CommonData conMod = conBll.SelReturnModel(Convert.ToInt32(dr["id"]));
                        //if (!conMod.Inputer.Equals(mu.UserName)) { continue; }
                        List <SqlParameter> sp1 = GetSPByDR(dr, "title");
                        List <SqlParameter> sp2 = GetSPByDR(dr, fields);
                        DBCenter.UpdateSQL("ZL_CommonModel", GetSet(sp1), "GeneralID=" + conMod.GeneralID, sp1);
                        DBCenter.UpdateSQL("ZL_C_Article", GetSet(sp2), "ID=" + conMod.ItemID, sp2);
                    }
                    retMod.retcode = M_APIResult.Success;
                }
                    #endregion
                    break;

                case "mb_nav":
                {
                    DataTable dt = GetListDT();
                    foreach (DataRow dr in dt.Rows)
                    {
                        M_CommonData conMod = conBll.SelReturnModel(Convert.ToInt32(dr["id"]));
                        //if (!conMod.Inputer.Equals(mu.UserName)) { continue; }
                        List <SqlParameter> sp1 = new List <SqlParameter>()
                        {
                            new SqlParameter("title", dr["title"].ToString())
                        };
                        List <SqlParameter> sp2 = new List <SqlParameter>()
                        {
                            new SqlParameter("wxico", dr["wxico"].ToString())
                        };
                        DBCenter.UpdateSQL("ZL_CommonModel", "Title=@title", "GeneralID=" + conMod.GeneralID, sp1);
                        DBCenter.UpdateSQL("ZL_C_Article", "wxico=@wxico", "ID=" + conMod.ItemID, sp2);
                    }
                    retMod.retcode = M_APIResult.Success;
                }
                break;

                case "mg_footbar":
                {
                    DataTable dt = GetListDT();
                    foreach (DataRow dr in dt.Rows)
                    {
                        M_CommonData conMod = conBll.SelReturnModel(Convert.ToInt32(dr["id"]));
                        //if (!conMod.Inputer.Equals(mu.UserName)) { continue; }
                        List <SqlParameter> sp1 = new List <SqlParameter>()
                        {
                            new SqlParameter("title", dr["title"].ToString())
                        };
                        List <SqlParameter> sp2 = new List <SqlParameter>()
                        {
                            new SqlParameter("wxico", dr["wxico"].ToString())
                        };
                        DBCenter.UpdateSQL("ZL_CommonModel", "Title=@title", "GeneralID=" + conMod.GeneralID, sp1);
                        DBCenter.UpdateSQL("ZL_C_Article", "wxico=@wxico", "ID=" + conMod.ItemID, sp2);
                    }
                    retMod.retcode = M_APIResult.Success;
                }
                break;

                case "mb_image":                  //更新单个内容的指定字段,是否需要扩展为,根据字段更新目标表,以减少代码
                {
                    string    flag = Req("flag"); //传了该值,则代表单条数据更新
                    DataTable dt   = GetListDT();
                    foreach (DataRow dr in dt.Rows)
                    {
                        List <SqlParameter> sp2 = new List <SqlParameter>()
                        {
                            new SqlParameter("wxico", dr["wxico"].ToString()),
                            new SqlParameter("flag", dr["flag"].ToString())
                        };
                        DBCenter.UpdateSQL("ZL_C_Article", "wxico=@wxico", "Flag=@flag", sp2);
                    }
                    retMod.retcode = M_APIResult.Success;
                }
                break;

                case "mb_byid":                                                        //主用于内容更新
                {
                    string    fields = "wxico,wxsize,wxbk,flag,wxlink,content,dbtype"; //dbtype
                    DataTable dt     = GetListDT();
                    foreach (DataRow dr in dt.Rows)
                    {
                        M_CommonData        conMod = conBll.SelReturnModel(Convert.ToInt32(dr["id"]));
                        List <SqlParameter> sp1    = GetSPByDR(dr, "title");
                        List <SqlParameter> sp2    = GetSPByDR(dr, fields);
                        DBCenter.UpdateSQL("ZL_CommonModel", GetSet(sp1), "GeneralID=" + conMod.GeneralID, sp1);
                        DBCenter.UpdateSQL("ZL_C_Article", GetSet(sp2), "ID=" + conMod.ItemID, sp2);
                    }
                    retMod.retcode = M_APIResult.Success;
                }
                break;

                case "mb_new":
                {
                    B_CodeModel codeBll  = new B_CodeModel("ZL_C_Article");
                    string      nodeName = Req("type").Equals("nav") ? "微站图片" : "微站内容";
                    DataTable   nodedt   = DBCenter.Sel("ZL_Node", "NodeBySite=" + siteID + " AND NodeName='" + nodeName + "'");
                    if (nodedt.Rows.Count < 1)
                    {
                        retMod.retmsg = nodeName + "节点不存在";
                    }
                    else
                    {
                        DataRow      dr     = GetListDT().Rows[0];
                        M_CommonData conMod = new M_CommonData();
                        DataRow      artdr  = codeBll.NewModel();
                        conMod.Title     = dr["title"].ToString();
                        conMod.Inputer   = mu.UserName;
                        conMod.Status    = (int)ZLEnum.ConStatus.Audited;
                        conMod.TableName = "ZL_C_Article";
                        conMod.ModelID   = 2;                                         //文章ID
                        conMod.NodeID    = Convert.ToInt32(nodedt.Rows[0]["NodeID"]); //放入微内容处
                                                                                      //-----------------------------
                        artdr["content"] = "ajax添加";
                        artdr["wxico"]   = dr["wxico"];
                        artdr["wxsize"]  = dr["wxsize"];
                        artdr["wxbk"]    = dr["wxbk"];
                        artdr["flag"]    = dr["flag"];
                        artdr["dbtype"]  = dr["dbtype"];
                        conMod.ItemID    = codeBll.Insert(artdr);
                        conMod.GeneralID = conBll.insert(conMod);
                        retMod.retcode   = M_APIResult.Success;
                        retMod.result    = conMod.GeneralID.ToString();
                    }
                }
                break;

                case "mb_del":
                {
                    int          id     = Convert.ToInt32(Req("id"));
                    M_CommonData conMod = conBll.SelReturnModel(id);
                    if (conMod == null)
                    {
                        retMod.retmsg = "内容[" + id + "]不存在";
                    }
                    else if (!conMod.Inputer.Equals(mu.UserName))
                    {
                        retMod.retmsg = "你无权删除[" + id + "]内容";
                    }
                    else
                    {
                        conBll.SetDel(conMod.GeneralID);
                        retMod.retcode = M_APIResult.Success;
                    }
                }
                break;

                case "mb_pro_update":    //新建,或更新
                {
                    DataRow   dr     = GetListDT().Rows[0];
                    M_Product proMod = new M_Product();
                    if (DataConvert.CLng(dr["id"]) > 0)
                    {
                        int id = Convert.ToInt32(dr["id"]);
                        proMod = proBll.GetproductByid(id);
                        if (proMod == null)
                        {
                            retMod.retmsg = "商品[" + id + "]不存在"; RepToClient(retMod);
                        }
                        else if (proMod.UserID != mu.UserID)
                        {
                            retMod.retmsg = "无权修改[" + id + "]商品"; RepToClient(retMod);
                        }
                    }
                    proMod.Proname    = dr["proname"].ToString();
                    proMod.ActPrice   = dr["price"].ToString();
                    proMod.LinPrice   = DataConvert.CDouble(dr["price"]);
                    proMod.UserID     = mu.UserID;
                    proMod.AddUser    = mu.UserName;
                    proMod.Nodeid     = B_Design_MBSite.UserShopNodeID;
                    proMod.ParentID   = siteID;
                    proMod.Proinfo    = dr["proinfo"].ToString();
                    proMod.Procontent = dr["content"].ToString();
                    proMod.Clearimg   = dr["pics"].ToString();
                    proMod.Thumbnails = proMod.Clearimg;
                    if (proMod.ID > 0)
                    {
                        proBll.updateinfo(proMod);
                    }
                    else
                    {
                        proMod.ID = proBll.Insert(proMod);
                    }
                    retMod.retmsg  = proMod.ID.ToString();
                    retMod.retcode = M_APIResult.Success;
                }
                break;

                case "mb_pro_del":
                {
                    int       id     = Convert.ToInt32(Req("id"));
                    M_Product proMod = proBll.GetproductByid(id);
                    if (proMod == null)
                    {
                        retMod.retmsg = "商品[" + id + "]不存在";
                    }
                    else if (proMod.UserID != mu.UserID)
                    {
                        retMod.retmsg = "你无权删除[" + id + "]商品";
                    }
                    else
                    {
                        proBll.RealDelByIDS(id.ToString());
                        retMod.retcode = M_APIResult.Success;
                    }
                }
                break;

                default:
                    retMod.retmsg = "[" + Action + "]接口不存在";
                    break;
                }
            }
            catch (Exception ex) { retMod.retmsg = ex.Message; retMod.retcode = M_APIResult.Failed; }
            RepToClient(retMod);
        }
Ejemplo n.º 3
0
        //----------Logical
        ////用户无微站信息,则自动创建
        //public M_Design_MBSite AutoCreate(M_UserInfo mu)
        //{
        //    if (mu == null || mu.IsNull) { return null; }
        //    if (DBCenter.IsExist(TbName, "UserID=" + mu.UserID)) { return null; }
        //    M_Design_MBSite mbMod = new M_Design_MBSite();
        //    mbMod.UserID = mu.UserID;
        //    mbMod.TlpID = 1;
        //    mbMod.SiteID = mu.SiteID;
        //    mbMod.ID = Insert(mbMod);
        //    return mbMod;
        //}
        /// <summary>
        /// 根据用户与模板信息,创建站点
        /// </summary>
        public M_Design_MBSite CreateSite(M_UserInfo mu, M_Design_MBSite mbMod, out string err)
        {
            B_Design_Node desNodeBll = new B_Design_Node();
            B_Node        nodeBll    = new B_Node();
            B_Product     proBll     = new B_Product();
            //int mbsitecount = SiteConfig.SiteOption.DN_MBSiteCount;
            int mbsitecount = 10000;//取消数量限制

            if (mu == null || mu.IsNull)
            {
                err = "用户不存在"; return(null);
            }
            else if (mbMod.TlpID < 1 || mbMod.TlpID > 8)
            {
                err = "未指定模板或模板[" + mbMod.TlpID + "]不存在"; return(null);
            }
            else if (GetSiteCount(mu.UserID) >= mbsitecount)
            {
                err = "用户只能创建" + mbsitecount + "个微站"; return(null);
            }
            if (string.IsNullOrEmpty(mbMod.SiteName))
            {
                mbMod.SiteName = B_User.GetUserName(mu.HoneyName, mu.UserName) + "的微站" + DBCenter.Count(TbName, "UserID=" + mu.UserID) + 1;
            }
            mbMod.UserID = mu.UserID;
            mbMod.ID     = Insert(mbMod);
            //-----建立微站节点信息,从指定的模板处拷节点数据,父节点需要自建
            M_Node pnode = desNodeBll.GetUserRootNode(mu);

            if (pnode.IsNull)
            {
                pnode = desNodeBll.CreateUserRootNode(mu);
            }
            M_Node nodeMod = new M_Node();

            nodeMod.NodeName   = "微建站";
            nodeMod.NodeDir    = function.GetRandomString(6);
            nodeMod.CUser      = mu.UserID;
            nodeMod.CUName     = mu.UserName;
            nodeMod.NodeBySite = mbMod.ID;
            nodeMod.NodeType   = 1;//标识自身为主栏目
            nodeMod.ParentID   = pnode.NodeID;
            nodeMod.NodeID     = nodeBll.Insert(nodeMod);
            //---导入对应的模板节点数据
            string    nodename = "微建站" + mbMod.TlpID;
            DataTable nodeDT   = SelNodeByPName(nodename);

            CopyNodeAndContent(nodeDT, nodeMod);
            //---如果有商品数据,则导入商品
            DataTable proDT = SelProByPName(nodename);

            foreach (DataRow dr in proDT.Rows)
            {
                M_Product proMod = new M_Product().GetModelFromReader(dr);
                proMod.ID         = 0;
                proMod.ParentID   = mbMod.ID;//所属哪个站点
                proMod.UserID     = mu.UserID;
                proMod.AddUser    = mu.UserName;
                proMod.Nodeid     = UserShopNodeID;
                proMod.AddTime    = DateTime.Now;
                proMod.UpdateTime = DateTime.Now;
                proBll.Insert(proMod);
            }
            err = "";
            return(mbMod);
        }