private void save() { this.commodityTypeModel.TypeName = this.tbCommodityTypeName.Text; int order = 0; int.TryParse(this.tbOrder.Text, out order); this.commodityTypeModel.OderSart = order; if (this.maintainType == MaintainType.New) { var addResult = WebRequestUtil.AddCommodityType(JsonUtil.Serialize(this.commodityTypeModel)); if (addResult == null || addResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("新建商品类型失败"); } } else { var updateResult = WebRequestUtil.UpdateCommodityType(this.commodityTypeModel.TypeId, JsonUtil.Serialize(this.commodityTypeModel)); if (updateResult == null || updateResult.StatusCode != System.Net.HttpStatusCode.OK) { MessageBox.Show("更新商品类型失败"); } } }