Beispiel #1
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "")
     {
         bool             rowcount = false;
         MSProductParaDAL paraDal  = new MSProductParaDAL();
         rowcount = paraDal.ExistMSPPara("", strID);
         if (pname.Text.Trim() != null && pname.Text.Trim() != "" &&
             price.Text.Trim() != null && price.Text.Trim() != "")
         {
             MSProductDAL productdal   = new MSProductDAL();
             MSProduct    productmodel = new MSProduct();
             productmodel.Pstate = 0;
             productmodel.ID     = strID;
             productmodel.Ptitle = pname.Text;
             if (rowcount == true)
             {
                 productmodel.Price = 0;
             }
             else
             {
                 productmodel.Price = decimal.Parse(price.Text);
             }
             productmodel.Pcontent  = hd_content.Value;
             productmodel.IsSecHand = isstateno.Checked ? 0 : 1;
             if (productdal.UpdateMSProduct(productmodel))
             {
                 MessageBox.Show(this, "操作成功!");
             }
             else
             {
                 MessageBox.Show(this, "操作失败!");
             }
         }
         else
         {
             MessageBox.Show(this, "请输入相应标题或价格!");
         }
     }
     else
     {
         return;
     }
 }
Beispiel #2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     if (Session["strLoginName"].ToString() != null && Session["strLoginName"].ToString() != "")
     {
         if (paraname.Text.Trim() != null && paraname.Text.Trim() != "" &&
             paravalue.Text.Trim() != null && paravalue.Text.Trim() != "" &&
             setpvalue.Value.Trim() != null && setpvalue.Value.Trim() != "")
         {
             MSProductParaDAL ParaDal = new MSProductParaDAL();
             if (ParaDal.ExistMSPPara(paraname.Text, setpvalue.Value))
             {
                 MessageBox.Show(this, "该参数已经存在!");
             }
             else
             {
                 MSProductPara paraModel = new MSProductPara();
                 paraModel.PID     = setpvalue.Value;
                 paraModel.ParName = paraname.Text;
                 //paraModel.ParValue = paravalue.Text;
                 paraModel.ParState = 0;
                 paraModel.ID       = Guid.NewGuid().ToString("N").ToUpper();
                 if (ParaDal.AddMSPPara(paraModel))
                 {
                     MessageBox.Show(this, "操作成功!");
                 }
                 else
                 {
                     MessageBox.Show(this, "操作失败!");
                 }
             }
         }
         else
         {
             MessageBox.Show(this, "请选择相应产品或参数值!");
         }
     }
     else
     {
         return;
     }
 }
Beispiel #3
0
        /// <summary>
        /// 把购物车添加到订单
        /// </summary>
        void setAddOrder()
        {
            string uname = string.Empty; string uphone = string.Empty; string address = string.Empty;
            string payway = string.Empty; string carryway = string.Empty; string countcost = string.Empty;
            string leavemsg = string.Empty; string zipcode = string.Empty; string num = string.Empty;

            #region --------------获取请求信息---------------
            if (Request["num"] != null && Request["num"] != "")
            {
                num = Request["num"];
            }
            if (Request["uname"] != null && Request["uname"] != "")
            {
                uname = Common.Common.NoHtml(Request["uname"]);
            }
            if (Request["uphone"] != null && Request["uphone"] != "")
            {
                uphone = Common.Common.NoHtml(Request["uphone"]);
            }
            if (Request["address"] != null && Request["address"] != "")
            {
                address = Request["address"];
            }
            if (Request["payway"] != null && Request["payway"] != "")
            {
                payway = Common.Common.NoHtml(Request["payway"]);
            }
            if (Request["carryway"] != null && Request["carryway"] != "")
            {
                carryway = Common.Common.NoHtml(Request["carryway"]);
            }
            if (Request["countcost"] != null && Request["countcost"] != "")
            {
                countcost = Common.Common.NoHtml(Request["countcost"]);
            }
            if (Request["leavemsg"] != null && Request["leavemsg"] != "")
            {
                leavemsg = Common.Common.NoHtml(Request["leavemsg"]);
            }
            if (Request["zipcode"] != null && Request["zipcode"] != "")
            {
                zipcode = Common.Common.NoHtml(Request["zipcode"]);
            }
            #endregion
            if (customid.Trim() != null && customid.Trim() != "")
            {
                MSShoppingCartDAL cartDal  = new MSShoppingCartDAL();
                MSProductOrderDAL OrderDal = new MSProductOrderDAL();
                if (OrderDal.ExistOrderByUID(customid, strpid))
                {
                    Response.Write("{\"error\":true,\"exist\":true}");
                }
                else
                {
                    try
                    {
                        string strOrdernum = cartDal.SubOrder(customid, uname, uphone, leavemsg,
                                                              address, zipcode, strpid, countcost, num, mid);
                        if (strOrdernum != null && strOrdernum != "")
                        {
                            strSiteCode = "VYIGO";
                            MSOrderLogDAL.AddMSOrderLog("客户【" + customid + "】下单成功,订单号为【" + strOrdernum + "】");
                            MSProductDAL productDal = new MSProductDAL();
                            string       pnam       = string.Empty;
                            if (strpid != null && strpid != "")
                            {
                                pnam = productDal.GetMSProductVaueByID("Ptitle", strpid).ToString();
                            }

                            #region -发消息到店铺注册用户
                            string p_uid = string.Empty; string p_openid = string.Empty;
                            if (strpid != null && strpid != "")
                            {
                                try
                                {
                                    p_uid = productDal.GetMSProductVaueByID("CustomerID", strpid).ToString();
                                }
                                catch (Exception)
                                {
                                }
                            }
                            if (p_uid != null && p_uid != "")
                            {
                                MSCustomersDAL P_UDal = new MSCustomersDAL();
                                try
                                {
                                    p_openid = P_UDal.GetCustomerValueByID("OpenID", p_uid).ToString();
                                }
                                catch (Exception)
                                {
                                }
                            }
                            if (p_openid != null && p_openid != "" && strSiteCode != null && strSiteCode != "")
                            {
                                JQDialog.SendWeiXinMsg(strSiteCode, p_openid,
                                                       "亲爱的店长大人,您的宝贝【" + pnam + "】已于" +
                                                       DateTime.Now.ToString("yyyy年MM月dd日 HH:mm:ss") +
                                                       "被" + uname + "成功买下,单号【" + strOrdernum + "】赶紧去小店看看吧!");
                            }
                            MSOrderLogDAL.AddMSOrderLog("下单成功,通知到OpenID为【" + p_openid + "】的店长");
                            #endregion

                            #region -产品属性
                            MSProductParaDAL paraDal = new MSProductParaDAL();
                            int stock = 0;
                            if (paraDal.ExistMSPPara("", strpid) && mid != null && mid != "")
                            {
                                try
                                {
                                    stock = int.Parse(paraDal.GetMSPParaValueByID("Stock", mid).ToString());
                                }
                                catch (Exception)
                                {
                                }
                                if (stock > 0)
                                {
                                    int buynum = 0;
                                    try
                                    {
                                        buynum = Convert.ToInt32(quantity);
                                    }
                                    catch (Exception)
                                    {
                                    }
                                    if (buynum != 0 && buynum < stock)
                                    {
                                        stock = stock - buynum;
                                        paraDal.UpdateStock(stock, mid);
                                    }
                                }
                            }
                            #endregion
                            DataSet orderds     = cartDal.GetMyOrderDetail(strOrdernum);
                            string  payinfo     = string.Empty;
                            string  productname = string.Empty; //用户购买的商品名称
                            string  ordernum    = string.Empty; //订单号
                            if (orderds != null && orderds.Tables.Count > 0 && orderds.Tables[0].Rows.Count > 0)
                            {
                                productname = orderds.Tables[0].Rows[0]["Ptitle"].ToString();
                                ordernum    = orderds.Tables[0].Rows[0]["ID"].ToString();
                                //payinfo= WapPayHelper.BuildRequest(productname, ordernum, countcost, customid);
                            }
                            if (productname.Trim() != null && productname.Trim() != "" && ordernum != null && ordernum != "")
                            {
                                //Response.Write("{\"success\":true,\"payinfo\":\"" + payinfo + "\"}");
                                Response.Write("{\"success\":true,\"pname\":\"" + productname +
                                               "\",\"ordernum\":\"" + ordernum + "\",\"countcost\":\"" + countcost +
                                               "\",\"customid\":\"" + customid + "\",\"openid\":\"" + openid + "\"}");
                            }
                        }
                        else
                        {
                            Response.Write("{\"error\":true,\"msg\":\"操作失败,重新操作\"}");
                        }
                    }
                    catch (Exception)
                    {
                        Response.Write("{\"error\":true,\"msg\":\"操作失败,重新操作\"}");
                    }
                }
            }
            else
            {
                setCookies();
                Response.Write("{\"error\":true,\"msg\":\"操作失败,请登录后再操作\",\"loginurl\":\"UserLogin.aspx\"}");
            }
            Response.End();
        }