Exemple #1
0
 /// <summary>
 /// Page_Load
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //判断是否存在该id的公告
         int id = int.Parse(Request.QueryString["id"].ToString());
         AnnouncementEntity ae = AnnouncementOperation.GetAM(int.Parse(Request.QueryString["id"].ToString()));
         if (ae == null)
         {
             SmallScript.MessageBox(Page, "不存在该公告!点击返回!");
             SmallScript.GoBack(Page);
             return;
         }
         else
         {
             //在表单中显示数据
             DataBase db   = new DataBase();
             DataSet  sql  = db.ExCommand(string.Format("SELECT tb_announcement.id, tb_announcement.uid, tb_announcement.amtitle, tb_announcement.essay, tb_announcement.uptime, tb_user.userName FROM  tb_announcement INNER JOIN  tb_user ON tb_announcement.uid = tb_user.id  WHERE (tb_announcement.id ={0} )", id));
             string   User = sql.Tables[0].Rows[0]["userName"].ToString();
             lb_ID.Text      = ae.Id.ToString();
             tb_amtitle.Text = ae.AmTitle;
             lb_User.Text    = User;
             lb_essay.Text   = ae.Essay;
             lb_UpTime.Text  = ae.Time.ToString();
         }
     }
 }
Exemple #2
0
 /// <summary>
 /// 确认删除按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Button1_Click(object sender, EventArgs e)
 {
     try
     {
         //调用AnnouncementOperation类里的DelAnnouncement方法,通过传入id,进行删除操作
         AnnouncementOperation.DelAnnouncement(Request.QueryString["id"].ToString());
         SmallScript.goRedirect(Response, Session, "删除成功!", "~/admin/Announcement.aspx");
     }
     catch
     {
         //删除失败提示
         SmallScript.MessageBox(Page, "删除失败!");
     }
 }
 public void AsignAnnouncementOperation(string operation)
 {
     switch(operation.Trim().ToLower())
     {
     default:
         throw new ArgumentException("Unrecognized announcement operation");
         break;
     case "refresh":
         _annOperation	= AnnouncementOperation.Refresh;
         break;
     case "delete":
         _annOperation	= AnnouncementOperation.Delete;
         break;
     case "sold":
         _annOperation	= AnnouncementOperation.MarkAsSold;
         break;
     }
 }
Exemple #4
0
    /// <summary>
    /// Page_Load
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = int.Parse(Request.QueryString["id"].ToString());
            AnnouncementEntity ae = AnnouncementOperation.GetAM(int.Parse(Request.QueryString["id"].ToString()));

            if (ae != null)
            {
                DataBase db   = new DataBase();
                DataSet  sql  = db.ExCommand(string.Format("SELECT tb_announcement.id, tb_announcement.uid, tb_announcement.amtitle, tb_announcement.essay, tb_announcement.uptime, tb_user.userName FROM  tb_announcement INNER JOIN  tb_user ON tb_announcement.uid = tb_user.id  WHERE (tb_announcement.id ={0} ) ", id));
                string   User = sql.Tables[0].Rows[0]["userName"].ToString();
                //在表单中显示数据
                lb_Id.Text      = ae.Id.ToString();
                lb_amtitle.Text = ae.AmTitle;
                lb_User.Text    = User;
                lb_UpTime.Text  = ae.Time.ToString();
                lb_essay.Text   = ae.Essay;
            }
        }
    }
Exemple #5
0
    /// <summary>
    /// 确认修改按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        //修改公告信息
        int    ID      = int.Parse(Request.QueryString["id"].ToString());
        string amtitle = tb_amtitle.Text;
        string essay   = lb_essay.Text;

        try
        {
            AnnouncementOperation.EditAnnouncement(ID, amtitle, essay);
        }
        catch
        {
            SmallScript.MessageBox(Page, "修改失败!");
            return;
        }

        SmallScript.MessageBox(Page, "修改公告成功。");
        SmallScript.goRedirect(Response, Session, "跳转到公告列表 ", "~/admin/Announcement.aspx");
        return;
    }
Exemple #6
0
    /// <summary>
    /// 添加按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void tb_submit_Click(object sender, EventArgs e)
    {
        /*初始化工程,并设置属性*/
        AnnouncementEntity ae = new AnnouncementEntity();

        ae.AmTitle = tb_amtitle.Text;
        ae.Essay   = tb_essay.Text;
        ae.Uid     = UserOperation.GetCurrentUid(Session);
        /*添加工程,并返回是否成功*/
        if (ae.Essay == "" || ae.AmTitle == "")
        {
            SmallScript.MessageBox(Page, "请输入完整公告信息!");
            return;
        }
        if (AnnouncementOperation.AddAnnouncement(ae) == true)
        {
            SmallScript.goRedirect(Response, Session, "公告已成功添加!", "/admin/Announcement.aspx");
        }
        else
        {
            SmallScript.MessageBox(Page, "添加公告失败!");
        };
    }
Exemple #7
0
        string BuildURIByOperation(Uri mainUri, AnnouncementOperation operation, Uri announcementUri)
        {
            string operationUri			= "http://" + mainUri.Host + "/ad/";

            switch(operation)
            {
            case AnnouncementOperation.Refresh:
                operationUri	+= "refresh_ad";
                break;
            case AnnouncementOperation.Delete:
                operationUri	+= "delete_ad";
                break;
            case AnnouncementOperation.MarkAsSold:
                operationUri	+= "mark_as_sol";
                break;
            }

            operationUri			 += announcementUri.AbsolutePath.Replace(".html", "");

            return operationUri;
        }