Beispiel #1
0
        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 Admin.DAL.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"])) return;
                var id = Request.Form["id"];
                if (string.IsNullOrEmpty(Request.Form["name"])) return;
                var pcname = Request.Form["name"];
                var bll = new Admin.DAL.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();
            }
        }
Beispiel #3
0
 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();
     }
 }