/// <summary> /// 保存方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { string delStr = Request.Form["checkbox"]; if (!string.IsNullOrEmpty(delStr)) { string areaNames = ""; string areaIds = ""; Session["OrgAreaIds"] = delStr.ToString(); if (!string.IsNullOrEmpty(delStr)) { var area = delStr.Split(','); if (area != null) { for (int i = 0; i < area.Length; i++) { var areaInfo = orgAreaDal.GetModel(area[i]); areaNames += areaInfo.AreaName + ","; areaIds += areaInfo.AreaId + ","; } } } StringBuilder strBuilder = new StringBuilder(); if (!string.IsNullOrEmpty(areaNames)) { var areaName = areaNames.Split(','); var areaId = areaIds.Split(','); for (int i = 0; i < areaName.Length - 1; i++) { strBuilder.Append(" <tr id=\"tr2\">"); strBuilder.Append(" <td>" + areaName[i] + "</td>"); strBuilder.Append(" <td style=\"width: 15%; text-align: center\">"); strBuilder.Append(" <a href=\"javascript:void(0);\" data-backdrop=\"false\" onclick=\"delTrAIds(this," + areaId[i] + ");return false;\">删除</a>"); strBuilder.Append(" </td>"); strBuilder.Append(" </tr>"); } } Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>window.top.$op.$('#divAreaSelect').html(window.top.$op.$('#divAreaSelect').html()+'" + strBuilder.ToString() + "');window.top.$modal.destroy();</script>"); return; } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择区域信息!')</script>"); return; } } catch (Exception) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('请选择区域信息!')</script>"); return; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } try { if (string.IsNullOrEmpty(Request.Form["id"])) { return; } var id = Request.Form["id"]; if (string.IsNullOrEmpty(Request.Form["name"])) { return; } var pcname = Request.Form["name"]; var bll = new OrgArea(); var model = bll.GetModel(id); model.AreaName = pcname; List <SqlParameter> parameters = new List <SqlParameter>(); var parameter = new SqlParameter("@AreaName", DbType.AnsiString) { Value = pcname }; parameters.Add(parameter); var parameter1 = new SqlParameter("@AreaId", DbType.AnsiString) { Value = id }; parameters.Add(parameter1); var parameter2 = new SqlParameter("@ParentId", DbType.AnsiString) { Value = model.ParentId }; parameters.Add(parameter2); if (bll.GetList(" AreaName=@AreaName and Status=1 and AreaId!=@AreaId ", parameters).Tables[0].Rows.Count > 0) { Response.Write("区域名称已存在"); Response.End(); } Response.Write(bll.Update(model) ? "修改成功" : "修改失败"); Response.End(); } catch (System.Threading.ThreadAbortException ex) { } catch (Exception) { Response.Write("修改失败"); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } try { if (!string.IsNullOrEmpty(Request.Form["id"])) { var orgid = Request.Form["id"]; var sql = "SELECT COUNT(1) FROM OrgOrganize cpl JOIN (SELECT * FROM dbo.getOrgAreaChild('" + orgid + "') ) b ON cpl.[AreaId]=b.[AreaId] and cpl.[Status]=1 "; Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetSqlStringCommand(sql); int cmdresult; object obj = db.ExecuteScalar(dbCommand); if ((Object.Equals(obj, null)) || (Object.Equals(obj, global::System.DBNull.Value))) { cmdresult = 0; } else { cmdresult = int.Parse(obj.ToString()); } if (cmdresult == 0) { var model = _dalOrgArea.GetModel(orgid); if (null == model) { Response.Write("删除失败!区域不存在!"); Response.End(); } model.Status = 0; if (_dalOrgArea.Update(model)) { Response.Write("删除成功"); Response.End(); } else { Response.Write("删除失败"); Response.End(); } } else { Response.Write("删除失败,该区域下还有组织机构"); Response.End(); } } else { Response.Write("删除失败"); Response.End(); } } catch (System.Threading.ThreadAbortException ex) { } catch (Exception) { Response.Write("删除失败"); Response.End(); } }