protected void btn2Select_Click(object sender, EventArgs e) { Goodss goods = null; if (txt2GoodsId.Text != "") { goods = data.selectGoodsFromId(txt2GoodsId.Text); } else if (txt2GoodsName.Text != "") { goods = data.selectGoodsFromName(txt2GoodsName.Text); } if (goods == null) { Response.Write(new ShowMessageBox("查询为空.").Text); return; } txt2GoodsBatching.Text = goods.batching; txt2GoodsColor.Text = goods.color; txt2GoodsId.Text = goods.goodsId; txt2GoodsIntroduce.Text = goods.introduce; txt2GoodsName.Text = goods.goodsName; txt2GoodsPrice.Text = goods.price.ToString(); txt2GoodsTatse.Text = goods.tatse; txt2GoodsNewType.SelectedIndex = goods.type - 1; listFlag.SelectedIndex = goods.flag; listSize.SelectedIndex = goods.size; string toBadTime = goods.toBadTime; string[] year = toBadTime.Split(new char[1] { '天' }); txt2Year.Text = year[0]; }
public int size; //大号1、中号2、小号3 public PageGoodsData(Goodss goods) { this.goodsId = goods.goodsId; this.goodsName = goods.goodsName; this.batching = goods.batching; this.introduce = goods.introduce; this.toBadTime = goods.toBadTime; this.price = goods.price; //this.type = goods.type; this.size = goods.size; }
protected void btn2Update_Click(object sender, EventArgs e) { string date = txt2Year.Text + "天"; Goodss goods = new Goodss(txt2GoodsId.Text, txt2GoodsName.Text, double.Parse(txt2GoodsPrice.Text), int.Parse(txt2GoodsNewType.SelectedValue), txt2GoodsColor.Text, txt2GoodsTatse.Text, listSize.SelectedIndex + 1, txt2GoodsBatching.Text, txt2GoodsIntroduce.Text, date, listFlag.SelectedIndex); if (!data.reGoods(goods)) { Response.Write(new ShowMessageBox("修改失败,数据格式有误...").Text); } else { Response.Write(new ShowMessageBox("数据库修改成功...").Text); } }
protected void btn2Add_Click(object sender, EventArgs e) { try { int type = int.Parse(txt2GoodsNewType.SelectedValue); int head = type * 10000 + data.getGoodsNum(type) + 1; string goodId = "" + head; string date = txt2Year.Text + "天"; Goodss goods = new Goodss(goodId, txt2GoodsName.Text, double.Parse(txt2GoodsPrice.Text), type, txt2GoodsColor.Text, txt2GoodsTatse.Text, listSize.SelectedIndex + 1, txt2GoodsBatching.Text, txt2GoodsIntroduce.Text, date, listFlag.SelectedIndex); if (!data.addGoods(goods)) { throw new Exception(); } string nowPath = Server.MapPath(".") + "\\img\\"; string img1 = nowPath + goodId + "_main.jpg"; imageMain.SaveAs(img1); string img2 = nowPath + goodId + "_1.jpg"; image1.SaveAs(img2); string img3 = nowPath + goodId + "_2.jpg"; image2.SaveAs(img3); string img4 = nowPath + goodId + "_3.jpg"; image3.SaveAs(img4); string img5 = nowPath + goodId + "_4.jpg"; image4.SaveAs(img5); Response.Write(new ShowMessageBox("添加成功...").Text); } catch { //... Response.Write(new ShowMessageBox("数据填写有误,不要调皮捣蛋...").Text); } }
public void ProcessRequest(HttpContext content) { string JsonString = ""; string key = content.Request["KEY"].ToString(); string id = ""; if (content.Request["ID"] != null) { id = content.Request["ID"].ToString(); } if (key == "1") //根据userId获取单个用户所有信息 { DataManager data = new DataManager("i"); Users user = data.selectUsersFromId(id); JsonString = JsonConvert.SerializeObject(user); } else if (key == "2") //获取所有商品信息 { PageData pageData = new PageData(); JsonString = JsonConvert.SerializeObject(pageData); } else if (key == "3") //根据goodsId获取单个商品所有信息 { DataManager data = new DataManager("i"); Goodss goods = data.selectGoodsFromId(id); JsonString = JsonConvert.SerializeObject(goods); } else if (key == "4") //根据userId获取该用户所有订单信息 { DataManager data = new DataManager("i"); List <Orders> order = data.selectOrdersFromId(id); JsonString = JsonConvert.SerializeObject(order); } else if (key == "5") { DataManager data = new DataManager("i"); JsonString = data.selectUserNameFromId(id); } else if (key == "6") //返回cookies,当前登录 { //login s = new login(); //JsonString = s.Request.Cookies["userId"].Value; //s = null; JsonString = content.Request.Cookies["userId"].Value; } else if (key == "7") //下单 { DataManager data = new DataManager("i"); int goodsNum = int.Parse(content.Request["goodsNum"]); string userName = content.Request["userName"]; double price = double.Parse(content.Request["price"]); string userId = content.Request.Cookies["userId"].Value; string phone = content.Request["phone"]; string address = content.Request["address"]; string goodsName = content.Request["goodsName"]; string goodsId = content.Request["goodsId"]; string hour = DateTime.Now.Hour.ToString(); if (hour.Length < 2) { hour = "0" + hour; } string minute = DateTime.Now.Minute.ToString(); if (minute.Length < 2) { minute = "0" + minute; } string second = DateTime.Now.Second.ToString(); if (second.Length < 2) { second = "0" + second; } string orderId = goodsId + hour + minute + second; Orders order = new Orders(goodsNum, userName, orderId, userId, goodsId, address, phone, price, goodsName, 0); if (data.addOrder(order)) { JsonString = "s"; } else { JsonString = "f"; } } else if (key == "8") //下单 { DataManager data = new DataManager("i"); if (data.receiveGoods(id)) { JsonString = "s"; } else { JsonString = "f"; } } content.Response.Write(JsonString); }