Exemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int StreetId = int.Parse(hdStreetId.Value.ToString());
            AreaEntity Area = new AreaEntity();
            Area.StreetName = txtStreetName.Text;

            if (hdStreetId.Value == "0")
            {
                if (Ctrl_Area.AddStreet(Area) > 0)
                {
                    MessageBox.ShowAndRedirect(this, "成功添加一条数据!", "StreetList.aspx");
                }
                else
                {
                    MessageBox.Show(this, "添加数据失败,请与管理员联系!");
                }
            }
            else
            {
                Area.StreetId = StreetId;
                if (Ctrl_Area.UpdateStreet(Area))
                {
                    MessageBox.ShowAndRedirect(this, "成功修改一条数据!", "StreetList.aspx");
                }
                else
                {
                    MessageBox.Show(this, "修改数据失败,请与管理员联系!");
                }
            }
        }
Exemplo n.º 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int CommunityId = int.Parse(hdCommunityId.Value.ToString());
            AreaEntity Area = new AreaEntity();
            Area.CommunityName = txtCommunityName.Text;
            Area.StreetId = int.Parse(drpParentStreet.SelectedValue);

            if (hdCommunityId.Value == "0")
            {
                if (Ctrl_Area.AddCommunity(Area) > 0)
                {
                    Area.CommunityId = Ctrl_Area.GetMaxCommunityId()-1;
                    if (Ctrl_Area.AddRelation(Area) > 0)
                        MessageBox.ShowAndRedirect(this, "成功添加一条数据!", "CommunityList.aspx");
                    else
                        MessageBox.Show(this, "添加数据失败,请与管理员联系!");
                }
                else
                {
                    MessageBox.Show(this, "添加数据失败,请与管理员联系!");
                }
            }
            else
            {
                Area.CommunityId = CommunityId;
                if (Ctrl_Area.UpdateCommunity(Area) && Ctrl_Area.UpdateRelation(Area))
                {
                    MessageBox.ShowAndRedirect(this, "成功修改一条数据!", "CommunityList.aspx");
                }
                else
                {
                    MessageBox.Show(this, "修改数据失败,请与管理员联系!");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 添加街道社区联系
        /// </summary>
        public static int AddRelation(AreaEntity Area)
        {
            int iExecute = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into Area_Relation(");
                strSql.Append("Sid,Cid)");
                strSql.Append(" values (");
                strSql.Append("@StreetId,@CommunityId)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters = {
                    new SqlParameter("@StreetId", SqlDbType.Int),
                    new SqlParameter("@CommunityId", SqlDbType.Int),
                                            };
                parameters[0].Value = Area.StreetId;
                parameters[1].Value = Area.CommunityId;

                object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "SysAccessData.SysManage.UserManage\\DacUserInfo\\AddUserRole" + e.Message);
            }
            return iExecute;
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一个社区
        /// </summary>
        /// <returns>成功返回1  否则返回0</returns>
        public static int AddCommunity(AreaEntity Area)
        {
            int iExecute = 0;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into Area_Community(");
                strSql.Append("Name)");
                strSql.Append(" values (");
                strSql.Append("@Name)");
                strSql.Append(";select @@IDENTITY");

                SqlParameter[] parameters = {
                    new SqlParameter("@Name", SqlDbType.NVarChar,50)
                                            };
                parameters[0].Value = Area.CommunityName;

                object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
                if (obj != null)
                {
                    iExecute = Convert.ToInt32(obj);
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "Controler.Ctrl_Approve.AddUser:" + e.Message);
            }
            return iExecute;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 修改街道信息
        /// </summary>
        /// <returns>成功返回true  否则返回false</returns>
        public static bool UpdateStreet(AreaEntity Area)
        {
            bool iExecute = false;
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update Area_Street set ");
                strSql.Append("Name=@Name");
                strSql.Append(" where Id=@Id");
                SqlParameter[] parameters = {
                    new SqlParameter("@Name", SqlDbType.NVarChar,50),
                    new SqlParameter("@Id", SqlDbType.Int)};

                parameters[0].Value = Area.StreetName;
                parameters[1].Value = Area.StreetId;

                int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                if (rows > 0)
                {
                    iExecute = true;
                }
            }
            catch (Exception e)
            {
                Log4Net.LogWrite("err", "SysAccessData.SysManage.UserManage\\DacUserInfo\\Update" + e.Message);
            }
            return iExecute;
        }