protected void ibtnAdd_Click(object sender, EventArgs e) { //验证代码 try { if (string.IsNullOrEmpty(Request.QueryString["type"] + "")) { Category model = new Category(); model.codeNo = txtCode.Text.Trim().Replace(" ", ""); model.id = int.Parse(hdfnodeID.Value); model.parentID = int.Parse(hdfparentID.Value); model.title = txtTitle.Text; model.orderId = int.Parse(hdforderID.Value); model.description = hdfDes.Value; model.stateID = ddlState.SelectedIndex; model.imgPath = hdfImg.Value; model.typeID = int.Parse(rbtType.SelectedItem.Value + ""); model.outLink = txtLink.Text; bll.Update(model); Response.Redirect("Default.aspx?id=" + model.id, false); } else { if (!string.IsNullOrEmpty(Request.QueryString["type"] + "")) { Category model = new Category(); model.title = txtTitle.Text; model.codeNo = txtCode.Text; // 防止网页重复提交 if (!bll.ExistsCode(model.codeNo)) { try { model.parentID = int.Parse(Request.QueryString["pid"]); } catch { Msg.Show("参数错误!"); } model.orderId = bll.GetChildNum(model.parentID); model.description = ""; model.stateID = ddlState.SelectedIndex; model.typeID = rbtType.SelectedIndex; model.outLink = txtLink.Text; // model.imgPath = int res = bll.Add(model); Response.Redirect("Default.aspx?id=" + res, false); } else { Msg.Show("编码已存在!"); } } } } catch (Exception ex) { log.Error(ex.Message); Msg.Show("网络错误!原因:" + ex.Message); } }