⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addnotice.aspx.cs

📁 物业管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class admin_notice : System.Web.UI.Page
{
    BaseClass bc = new BaseClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Convert.ToString(Session["UID"]) == "")
        {
            Response.Redirect("login.aspx");

        }
        else
        {
            DataSet ds = null;
            int p_int_newCode = 0;
            string P_string_newcode = "";
            ds = bc.ExecDS("select * from notice order by ID");
            if (ds.Tables[0].Rows.Count == 0)
            {
                ID.Text = DateTime.Now.ToString("yyyy-MM-dd") + "GG100001";
            }
            else
            {
                //   Response.Write(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["fixID"]) ;
                // Response.End();


                P_string_newcode = Convert.ToString(ds.Tables[0].Rows[ds.Tables[0].Rows.Count - 1]["ID"]);
                //  Response.Write(P_string_newcode);
                //Response.End();
                p_int_newCode = Convert.ToInt32(P_string_newcode.Substring(12, 6)) + 1;

                P_string_newcode = DateTime.Now.ToString("yyyy-MM-dd") + "GG" + p_int_newCode.ToString();
                ID.Text = P_string_newcode;
            }

            if (!IsPostBack)
            {

                addname.Text = Session["UID"].ToString();
                addname.ReadOnly = true;


            }
        }

        
        
    }



    protected void Button1_Click(object sender, EventArgs e)
    {
        string noticeID = ID.Text;
        string noticetitle = title.Text;//公告标题
        string date = selectdate.Text;//发布日期
       // Response.Write(date);
       // Response.End();
        string content = FreeTextBox1.Text;//内容
        string addperson = Session["UID"].ToString();
        string valsql = "select count(*) from notice where title='" + noticetitle +"' and noticeDate='" + date + "'";
        int count = (int)bc.ExecCscalar(valsql);
        if(count>0)
        {
             Response.Write("<script>alert('今天您添加过此公告!');</script>");
            return;
 
        }

        string sql = "insert into notice(ID,title,noticeDate,notiContent,noticePerson)values('" + noticeID + "','" + noticetitle + "','" + date + "','" + content + "','" + addperson + "')";
        //   Response.Write(sql);
        // Response.End();



        if (bc.ExecSql(sql))
        {

            Response.Write("<script language=javascript>alert('添加物业公告成功!');location='notice.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('添加物业公告失败,请重试!');</script>");
        }

    } 
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -