/// <summary> /// 更新游戏 /// </summary> /// <param name="id"></param> /// <param name="collection"></param> /// <returns></returns> public ActionResult UpdateProductType(int id, FormCollection collection) { String Description =collection.Get("Description"); String Name = collection.Get("ProductTypeName"); ProductType info = new ProductType(); info.ID = id; info.ProductTypeName = Name; info.Description = Description; Message msg; if (productTypeBLL.UpdateProductType(info)) { msg = new Message(true, "修改成功!"); } else { msg = new Message(false, "修改失败!"); } JavaScriptSerializer json = new JavaScriptSerializer(); return Content(json.Serialize(msg), "text/html;charset=UTF-8"); }
/// <summary> /// 增加产品类型 /// </summary> /// <param name="collection"></param> /// <returns></returns> public ActionResult CreateProductType(FormCollection collection) { //int ProductTypeId = Convert.ToInt32(collection.Get("Id")); String ProductTypeName = collection.Get("ProductTypeName");//是控件的Name属性而不是id属性 String Description = collection.Get("Description"); ProductType info = new ProductType(); info.ProductTypeName = ProductTypeName; info.Description = Description; Message msg; if (productTypeBLL.GreateProductType(info)) { msg = new Message(true, "添加" + ProductTypeName + "信息成功!"); } else { msg = new Message(false, "添加产品类型失败,操作有误"); } JavaScriptSerializer json = new JavaScriptSerializer(); string Str = json.Serialize(msg);// return Content(Str, "text/html;charset=UTF-8"); }
private void SaveItem(object sender, EventArgs e) { if (CustomValidation()) { var item = new ProductType(); item.Name = textName.Text; if (itemId > 0) { item.Id = itemId; item.Created = created; item.CreatedByUserId = createdBy; item.Modified = DateTime.Now; item.ModifiedByUserId = currentUser; var biz = new ProductTypeBiz(); biz.UpdateItem(item); } else { item.Created = DateTime.Now; item.CreatedByUserId = currentUser; item.Modified = DateTime.Now; item.ModifiedByUserId = currentUser; var biz = new ProductTypeBiz(); biz.SaveItem(item); } this.Close(); } else { this.DialogResult = System.Windows.Forms.DialogResult.None; } }