/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">WebMeta对象</param> /// <returns>影响行数</returns> public int Update(ClassLibrary.Model.WebMeta model) { StringBuilder strSql = new StringBuilder(); strSql.Append(string.Format("UPDATE {0} SET ", table)); strSql.Append("Title=@Title,"); strSql.Append("Keyword=@Keyword,"); strSql.Append("Description=@Description,"); strSql.Append("Telphone=@Telphone,"); strSql.Append("QQ=@QQ,"); strSql.Append("OnlineService=@OnlineService,"); strSql.Append("CreatedTime=@CreatedTime"); strSql.Append(" WHERE ID=@ID"); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int, 4), new SqlParameter("@Title", SqlDbType.NVarChar, 100), new SqlParameter("@Keyword", SqlDbType.NVarChar, 500), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@Telphone", SqlDbType.NVarChar, 50), new SqlParameter("@QQ", SqlDbType.NVarChar, 500), new SqlParameter("@OnlineService", SqlDbType.NVarChar, 1000), new SqlParameter("@CreatedTime", SqlDbType.DateTime, 8) }; parameters[0].Value = model.ID; parameters[1].Value = model.Title; parameters[2].Value = model.Keyword; parameters[3].Value = model.Description; parameters[4].Value = model.Telphone; parameters[5].Value = model.QQ; parameters[6].Value = model.@OnlineService; parameters[7].Value = model.CreatedTime; return(SQLHelper.Execute(strSql.ToString(), parameters)); }
/// <summary> /// 得到一个对象实体 /// </summary> /// <param name="ID">主键ID</param> /// <returns>WebMeta对象</returns> public ClassLibrary.Model.WebMeta GetModel(int ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * "); strSql.Append(" FROM "); strSql.Append(table); strSql.Append(string.Format(" WHERE {0}=@{0}", pk)); SqlParameter[] parameters = { new SqlParameter("@" + pk, SqlDbType.Int, 4) }; parameters[0].Value = ID; ClassLibrary.Model.WebMeta model = new ClassLibrary.Model.WebMeta(); DataTable dt = SQLHelper.Query(strSql.ToString(), parameters); model.ID = ID; if (dt.Rows.Count > 0) { if (dt.Rows[0]["Title"] != DBNull.Value) { model.Title = Convert.ToString(dt.Rows[0]["Title"]); } if (dt.Rows[0]["Keyword"] != DBNull.Value) { model.Keyword = Convert.ToString(dt.Rows[0]["Keyword"]); } if (dt.Rows[0]["Description"] != DBNull.Value) { model.Description = Convert.ToString(dt.Rows[0]["Description"]); } if (dt.Rows[0]["Telphone"] != DBNull.Value) { model.Telphone = Convert.ToString(dt.Rows[0]["Telphone"]); } if (dt.Rows[0]["QQ"] != DBNull.Value) { model.QQ = Convert.ToString(dt.Rows[0]["QQ"]); } if (dt.Rows[0]["OnlineService"] != DBNull.Value) { model.OnlineService = Convert.ToString(dt.Rows[0]["OnlineService"]); } if (dt.Rows[0]["CreatedTime"] != DBNull.Value) { model.CreatedTime = Convert.ToDateTime(dt.Rows[0]["CreatedTime"]); } } return(model); }
//修改信息 private void Edit() { ClassLibrary.Model.WebMeta webMetaModel = new ClassLibrary.Model.WebMeta(); webMetaModel.ID = Convert.ToInt32(Request.Form["ID"]); webMetaModel.QQ = Request.Form["QQ"]; webMetaModel.OnlineService = Request.Form["OnlineService"]; webMetaModel.Title = Request.Form["Title"]; webMetaModel.Telphone = Request.Form["Telphone"]; webMetaModel.Keyword = Request.Form["Keyword"].Replace(" ", "").Replace("\r\n", "").Replace("\n", ""); webMetaModel.Description = Request.Form["Description"].Replace(" ", "").Replace("\r\n", "").Replace("\n", ""); if (webMetaBLL.Update(webMetaModel) > 0) { Function.goMessagePage("更新网站信息", "操作成功", "SystemSet/WebMeta.aspx?id=" + webMetaModel.ID); } else { Function.goMessagePage("更新网站信息", "操作失败", "SystemSet/WebMeta.aspx?id=" + webMetaModel.ID); } }
//绑定信息 private void BindInfo() { string strid = Request.QueryString["id"]; if (Function.IsNumber(strid)) { id = Convert.ToInt32(strid); } else { Function.goMessagePage("添加网站信息", "操作失败"); } ClassLibrary.Model.WebMeta webMetaModel = webMetaBLL.GetModel(id); QQ = webMetaModel.QQ; OnlineService = webMetaModel.OnlineService; title = webMetaModel.Title; keyword = webMetaModel.Keyword; telphone = webMetaModel.Telphone; description = webMetaModel.Description; }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">WebMeta对象</param> public int Add(ClassLibrary.Model.WebMeta model) { StringBuilder strSql = new StringBuilder(); strSql.Append(string.Format("INSERT INTO {0}(", table)); strSql.Append("Title,Keyword,Description,Telphone,CreatedTime"); strSql.Append(") VALUES ("); strSql.Append("@Title,@Keyword,@Description,@Telphone,@CreatedTime)"); SqlParameter[] parameters = { new SqlParameter("@Title", SqlDbType.NVarChar, 100), new SqlParameter("@Keyword", SqlDbType.NVarChar, 500), new SqlParameter("@Description", SqlDbType.NVarChar, 500), new SqlParameter("@Telphone", SqlDbType.NVarChar, 50), new SqlParameter("@CreatedTime", SqlDbType.DateTime, 8) }; parameters[0].Value = model.Title; parameters[1].Value = model.Keyword; parameters[2].Value = model.Description; parameters[3].Value = model.Telphone; parameters[4].Value = model.CreatedTime; return(SQLHelper.Execute(strSql.ToString(), parameters)); }
//保存订单 protected void SaveOrder() { string orderNumber = DateTime.Now.ToString("yyMMddHHssmmff"); ClassLibrary.BLL.Orders orderBLL = new ClassLibrary.BLL.Orders(); ClassLibrary.BLL.OrderDetail detailBLL = new ClassLibrary.BLL.OrderDetail(); try { string[] products = Request.Form["productList"].Split('|'); ClassLibrary.Model.Orders orderModel = new ClassLibrary.Model.Orders(); orderModel.OrderNumber = orderNumber; orderModel.UserName = ""; orderModel.proQuantity = Request.Form["adultnum"] + "," + Request.Form["childnum"]; orderModel.proTotalPrice = Convert.ToDecimal(Request.Form["totalPrice"]); orderModel.Linkman = Request.Form["Linkman"]; orderModel.Fax = ""; orderModel.Mobile = Request.Form["Mobile"]; orderModel.Telphone = Request.Form["Mobile"]; orderModel.Email = ""; orderModel.IdentityCard = ""; orderModel.ContractType = Request.Form["ContractType"]; orderModel.Payment = Request.Form["Payment"]; orderModel.Remark = string.Empty; orderModel.Status = SysConfig.OrderType.未付款待处理.ToString(); orderModel.CreatedTime = DateTime.Now; if (orderBLL.Add(orderModel) > 0) { ClassLibrary.Model.OrderDetail detailModel; //依次将订单详情信息插入表中 foreach (string pro in products) { if (pro == "") { continue; } detailModel = new ClassLibrary.Model.OrderDetail(); detailModel.orderNumber = orderModel.OrderNumber; detailModel.UserName = orderModel.UserName; detailModel.routeID = Convert.ToInt32(pro.Split(',')[0]); //string tempNum = pro.Split(',')[2]; //detailModel.Number = tempNum.Substring(0, tempNum.IndexOf("大")) + ","; //tempNum = tempNum.Substring(tempNum.IndexOf("大") + 1); //detailModel.Number += tempNum.Substring(0, tempNum.IndexOf("小")); detailModel.Number = Request.Form["adultnum"] + "," + Request.Form["childnum"]; detailModel.RouteName = pro.Split(',')[1]; detailModel.RoutePrice = Convert.ToDecimal(Request.Form["totalPrice"]); detailModel.RouteTime = pro.Split(',')[4]; detailModel.StartTime = pro.Split(',')[5]; detailBLL.Add(detailModel); } //扣钱 if (orderModel.Payment != SysConfig.Payment.支付宝.ToString()) { Response.Redirect("/success/o" + orderModel.OrderNumber + ".html", false); //Response.Redirect("/WebApp/appOrder.aspx?order=" + orderModel.OrderNumber, false); } else { //---use pay string payURL = string.Format("/onlinepayment/alipay/default.aspx?order_no={0}&total_fee={1}", orderModel.OrderNumber, orderModel.proTotalPrice); Response.Redirect(payURL, false); //--- } } //发送短信 ClassLibrary.BLL.MsgLinks msg = new ClassLibrary.BLL.MsgLinks(); string customMsg = "尊敬的用户:您的订单" + orderNumber + "已提交成功,我们将尽快联系您,或拨打400-017-5761。"; string webRoutName = products[0].Split(',')[1].Replace("【", "").Replace("】", "").Replace("[", "").Replace("]", "") .Replace("(", "").Replace(")", "").Replace("(", "").Replace(")", "").Replace("...", ""); string webMsg = "您有新订单" + orderNumber.Substring(10) + "!\n姓名:" + orderModel.Linkman + "\n电话:" + orderModel.Mobile + "\n日期:" + products[0].Split(',')[5] + "\n线路:" + Function.Clip(webRoutName, 16, false) + "。"; string backMsg = msg.sendMsg(orderModel.Mobile, customMsg); ClassLibrary.BLL.WebMeta bll = new ClassLibrary.BLL.WebMeta(); ClassLibrary.Model.WebMeta webMeta = bll.GetModelList(string.Empty)[0]; msg.sendMsg(webMeta.Telphone, webMsg); } catch (Exception ex) { //回滚数据 orderBLL.Deletes("OrderNumber='" + orderNumber + "'"); detailBLL.Deletes("orderNumber='" + orderNumber + "'"); Response.Write("<script>alert('订单提交失败!');location.href='/shopcart/'</script>"); } }