public string Stock_Add() { int ProID = DataConvert.CLng(Request["ProID"]); string action = DataConverter.CStr(Request.QueryString["action"]); M_CommonData storeMod = conBll.SelMyStore_Ex(ref err); if (!string.IsNullOrEmpty(err)) { function.WriteErrMsg(err); return(""); } M_Product proMod = Stock_GetProByID(mu, ProID); M_Stock stockMod = new M_Stock(); stockMod.proid = ProID; stockMod.proname = proMod.Proname; stockMod.Pronum = DataConverter.CLng(Request.Form["Pronum"]); stockMod.stocktype = DataConverter.CLng(Request.Form["stocktype_rad"]); string code = storeMod.GeneralID + DateTime.Now.ToString("yyyyMMddHHmmss"); stockMod.danju = (stockMod.stocktype == 0 ? "RK" : "CK") + code; stockMod.UserID = mu.UserID; stockMod.adduser = mu.UserName; stockMod.StoreID = storeMod.GeneralID; if (stockMod.Pronum < 1) { function.WriteErrMsg("出入库数量不能小于1"); return(""); } switch (stockMod.stocktype) { case 0: proMod.Stock += stockMod.Pronum; break; case 1: proMod.Stock -= stockMod.Pronum; if (proMod.Stock < 0) { function.WriteErrMsg("出库数量不能大于库存!"); return(""); } break; default: throw new Exception("出入库操作错误"); } stockBll.insert(stockMod); proBll.updateinfo(proMod); if (action.Equals("addpro")) { int num = stockMod.stocktype == 0 ? stockMod.Pronum : -stockMod.Pronum; return("<script>parent.addStock(" + num + ");</script>"); } function.WriteSuccessMsg("库存操作成功", "StockList"); return(""); }
/// <summary> /// 产生幸运码,并返回用于输出的Html /// </summary> public string CreateLuckCode(M_OrderList orderMod) { List <M_Product> proList = new List <M_Product>(); B_Product proBll = new B_Product(); B_Order_LuckCode codeBll = new B_Order_LuckCode(); B_CartPro cartBll = new B_CartPro(); string result = ""; //*一个购物车中,可能会有多个商品, DataTable cartDT = cartBll.GetCartProOrderID(orderMod.id);//购物车记录 //判断出购物车中哪些是云购商品 for (int i = 0; i < cartDT.Rows.Count; i++) { int proID = Convert.ToInt32(cartDT.Rows[i]["ProID"]); M_Product proMod = proBll.GetproductByid(proID); if (proMod.ProClass == 5) { //减去相应的库存 proMod.Stock = proMod.Stock - Convert.ToInt32(cartDT.Rows[i]["ProNum"]); proBll.updateinfo(proMod); proMod.Class = Convert.ToInt32(cartDT.Rows[i]["ProNum"]);//购买数量,用备用字段存着 proList.Add(proMod); } } //根据购买的数量与信息,生成对应条数的幸运码,与上面分离开,便于后期扩展 for (int i = 0; i < proList.Count; i++) { //获取该商品在数据库中的最大幸运码数 int code = codeBll.GetMaxLuckCode(proList[i].ID); M_Order_LuckCode codeMod = new M_Order_LuckCode(); codeMod.ProID = proList[i].ID; codeMod.UserID = orderMod.Userid; codeMod.OrderID = orderMod.id; codeMod.OrderNO = orderMod.OrderNo; DateTime now = DateTime.Now; codeMod.CreateTime = now.ToString("yyyy/MM/dd HH:mm:ss:fff"); codeMod.CreateTime2 = now.ToString("yyyyMMddHHmmssfff"); result += "商品名:" + proList[i].Proname + "<br/>幸运码:"; for (int j = 1; j <= proList[i].Class; j++) { codeMod.Code = (code + j); codeBll.Insert(codeMod); result += codeMod.Code + ","; } result += "<br/>"; } return(result.TrimEnd(','));; }
protected void Button1_Click(object sender, EventArgs e) { int NodeID = DataConverter.CLng(Request.Form["node_dp"]); string Ids = this.TxtContentID.Text; string[] arrlist = null; string nodemodeid = nll.GetNodeXML(NodeID).ContentModel.ToString(); string pslist = ""; arrlist = Ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (arrlist != null && arrlist.Length > 0) { for (int i = 0; i < arrlist.Length; i++) { int pid = DataConverter.CLng(arrlist[i]); string modid = pll.GetproductByid(pid).ModelID.ToString(); if (("," + nodemodeid + ",").IndexOf("," + modid + ",") > -1) { M_Product pinfo = pll.GetproductByid(pid); pinfo.Nodeid = DataConverter.CLng(NodeID); pll.updateinfo(pinfo); pslist = pslist + pinfo.ComModelID + ","; } } } if (pslist.Length > 0) { string IIds = pslist.Substring(0, pslist.Length - 1); bool flag = this.bll.MoveContent(IIds, NodeID); if (flag) { function.WriteSuccessMsg("商品移动成功", "../shop/ProductManage.aspx"); } } else { function.WriteSuccessMsg("商品移动失败", "../shop/ProductManage.aspx"); } }
protected void Page_Load(object sender, EventArgs e) { if (ItemID < 1) { function.WriteErrMsg("产生错误的可能原因:内容信息不存在或未开放!"); } M_Product proMod = pll.GetproductByid(ItemID); OrderCommon.ProductCheck(proMod); M_ModelInfo modelinfo = bmode.GetModelById(proMod.ModelID); proMod.AllClickNum = proMod.AllClickNum + 1; pll.updateinfo(proMod); string TempNode = nodeBll.GetModelTemplate(proMod.Nodeid, proMod.ModelID); string TempContent = proMod.ModeTemplate; string TemplateDir = "/" + modelinfo.ContentModule; if (!string.IsNullOrEmpty(TempContent)) { TemplateDir = TempContent; } else if (!string.IsNullOrEmpty(TempNode)) { TemplateDir = TempNode; } if (string.IsNullOrEmpty(TemplateDir)) { function.WriteErrMsg("产生错误的可能原因:该商品所属模型未绑定模板!"); } TemplateDir = base.Request.PhysicalApplicationPath + SiteConfig.SiteOption.TemplateDir + "/" + TemplateDir; TemplateDir = TemplateDir.Replace("/", @"\"); if (!FileSystemObject.IsExist(TemplateDir, FsoMethod.File)) { ErrToClient("[产生错误的可能原因:(" + function.PToV(TemplateDir) + ")不存在或未开放!]"); } string Templatestr = FileSystemObject.ReadFile(TemplateDir); string ContentHtml = this.bll.CreateHtml(Templatestr, 0, ItemID, 0); Response.Write(ContentHtml); }
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); }