/// <summary> /// 添加收货地址 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddDA(MSDeliveryAddress model) { string sql = @"INSERT INTO [MS_DeliveryAddress] ([ID],[UID],[DaName],[DaPhone],[DaAddress],[AddressDetail],[DaZipCode],[IsDefault],[IsDel]) VALUES (@ID,@UID,@DaName,@DaPhone,@DaAddress,@AddressDetail,@DaZipCode,@IsDefault,@IsDel)"; System.Data.SqlClient.SqlParameter[] paras = new System.Data.SqlClient.SqlParameter[] { new System.Data.SqlClient.SqlParameter("@ID", model.ID), new System.Data.SqlClient.SqlParameter("@UID", model.UID), new System.Data.SqlClient.SqlParameter("@DaName", model.DaName), new System.Data.SqlClient.SqlParameter("@DaPhone", model.DaPhone), new System.Data.SqlClient.SqlParameter("@DaAddress", model.DaAddress), new System.Data.SqlClient.SqlParameter("@AddressDetail", model.AddressDetail), new System.Data.SqlClient.SqlParameter("@DaZipCode", model.DaZipCode), new System.Data.SqlClient.SqlParameter("@IsDefault", (model.IsDefault == 1?1:0)), new System.Data.SqlClient.SqlParameter("@IsDel", (model.IsDel == 1?1:0)) }; int rowsAffected = DbHelperSQL.ExecuteSql(sql.ToString(), paras); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新收货地址 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateDA(MSDeliveryAddress model) { string safeslq = ""; safeslq = "UPDATE MS_DeliveryAddress SET "; if (model.DaName != null && model.DaName != "") { safeslq += "DaName='" + model.DaName + "',"; } if (model.DaPhone != null && model.DaPhone != "") { safeslq += "DaPhone='" + model.DaPhone + "',"; } if (model.DaAddress != null && model.DaAddress != "") { safeslq += "DaAddress='" + model.DaAddress + "',"; } if (model.AddressDetail != null && model.AddressDetail.ToString() != "") { safeslq += "AddressDetail='" + model.AddressDetail + "',"; } if (model.DaZipCode != null && model.DaZipCode.ToString() != "") { safeslq += "DaZipCode='" + model.DaZipCode + "',"; } safeslq += " IsDefault=" + (model.IsDefault == 1 ? 1 : 0) + ", "; safeslq += " IsDel=" + (model.IsDel == 1 ? 1 : 0) + " "; safeslq += " where ID='" + model.ID + "' and [UID]='" + model.UID + "' "; int rowsAffected = DbHelperSQL.ExecuteSql(safeslq.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 设置收货地址 /// </summary> void setUserAddress() { string uname = string.Empty; string uphone = string.Empty; string address = string.Empty; string zipcode = string.Empty; string dadetail = string.Empty; string updaid = string.Empty; #region -------------------获取请求信息---------------------- 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["dadetail"] != null && Request["dadetail"] != "") { dadetail = Common.Common.NoHtml(Request["dadetail"]); } if (Request["zipcode"] != null && Request["zipcode"] != "") { zipcode = Common.Common.NoHtml(Request["zipcode"]); } if (Request["daid"] != null && Request["daid"] != "") { updaid = Common.Common.NoHtml(Request["daid"]); } #endregion MSDeliveryAddress daModel = new MSDeliveryAddress(); MSDeliveryAddressDAL daDal = new MSDeliveryAddressDAL(); #region ---------------设置Model属性--------------------------- if (uname != null && uname != "") { daModel.DaName = uname; } if (uphone != null && uphone != "") { daModel.DaPhone = uphone; } if (address != null && address != "") { daModel.DaAddress = address; } if (dadetail != null && dadetail != "") { daModel.AddressDetail = dadetail; } if (zipcode != null && zipcode != "") { daModel.DaZipCode = zipcode; } daModel.UID = customid; #endregion if (action != null && action != "" && action.Trim().ToLower() == "updalist" && updaid != null && updaid != "") { daModel.ID = updaid; if (daDal.UpdateDA(daModel)) { Response.Write("{\"success\":true}"); } else { Response.Write("{\"error\":true}"); } } else { daModel.ID = Guid.NewGuid().ToString("N").ToUpper(); if (daDal.AddDA(daModel)) { Response.Write("{\"success\":true}"); } else { Response.Write("{\"error\":true}"); } } Response.End(); }
/// <summary> /// 获取购物信息 /// </summary> void GetInfo() { #region 产品详细 MSProductDAL productDal = new MSProductDAL(); MSProduct productModel = new MSProduct(); DataSet productds = productDal.GetProductDetail(strpid); MSProductAtlasDAL atlasDal = new MSProductAtlasDAL(); MSProductAtlas atlasdetailmodel = null; DataSet atlasDs = null; if (null != productds && productds.Tables.Count > 0 && productds.Tables[0].Rows.Count > 0) { productModel = DataConvert.DataRowToModel <MSProduct>(productds.Tables[0].Rows[0]); } #endregion #region 获取产品默认展示图 atlasDs = atlasDal.GetDefaultAtlasByPid(strpid); foreach (DataRow atlasrow in atlasDs.Tables[0].Rows) { atlasdetailmodel = DataConvert.DataRowToModel <MSProductAtlas>(atlasrow); } #endregion #region -----------获取型号尺码---------------- MSProductPara paraModel = new MSProductPara(); MSProductParaDAL paraDal = new MSProductParaDAL(); DataSet parads = paraDal.GetParaDetail(mid); if (parads != null && parads.Tables.Count > 0 && parads.Tables[0].Rows.Count > 0) { paraModel = DataConvert.DataRowToModel <MSProductPara>(parads.Tables[0].Rows[0]); } #endregion #region 获取收货地址 MSDeliveryAddressDAL addressDal = new MSDeliveryAddressDAL(); MSDeliveryAddress defaultadModel = new MSDeliveryAddress(); List <MSDeliveryAddress> damodellist = new List <MSDeliveryAddress>(); string stradwhere = string.Empty; stradwhere = "and [UID]='" + customid + "' "; DataSet addressds = addressDal.GetDAList(3, stradwhere); if (null != addressds && addressds.Tables.Count > 0 && addressds.Tables[0].Rows.Count > 0) { foreach (DataRow row in addressds.Tables[0].Rows) { MSDeliveryAddress damodel = DataConvert.DataRowToModel <MSDeliveryAddress>(row); damodellist.Add(damodel); } } #endregion string customerphone = string.Empty; MSCustomers customerModel = new MSCustomers(); if (customid != null && customid != "") { MSCustomersDAL CustomerDal = new MSCustomersDAL(); DataSet customerds = CustomerDal.GetCustomerDetail(customid); if (customerds != null && customerds.Tables.Count > 0 && customerds.Tables[0].Rows.Count > 0) { customerModel = DataConvert.DataRowToModel <MSCustomers>(customerds.Tables[0].Rows[0]); } } string text = System.IO.File.ReadAllText(Server.MapPath("../ShopPage/setOrder.html")); JinianNet.JNTemplate.TemplateContext context = new JinianNet.JNTemplate.TemplateContext(); context.TempData["productdetail"] = productModel; context.TempData["atlas"] = atlasdetailmodel; context.TempData["paramodel"] = paraModel; context.TempData["errorscript"] = errorscript; context.TempData["dalist"] = damodellist; context.TempData["customer"] = customerModel; context.TempData["openid"] = openid; context.TempData["footer"] = "奥琦微商易"; JinianNet.JNTemplate.Template t = new JinianNet.JNTemplate.Template(context, text); t.Render(Response.Output); }