Пример #1
0
 public void BindData()
 {
     if (Request.QueryString["id"] != "" && Request.QueryString["id"] != null)
     {
         int        msgId = Convert.ToInt32(Request.QueryString["id"]);
         List <Msg> list  = MsgBll.GetMsgbyId(msgId);
         if (list.Count > 0)
         {
             lblName.Text   = list[0].Author;
             lblPhone.Text  = list[0].Phone;
             lblEmail.Text  = list[0].Email;
             lblAdr.Text    = list[0].Adress;
             lblTime.Text   = list[0].CreateTime;
             lblDetail.Text = list[0].Details;
             if (list[0].IsRead == 0)
             {
                 try
                 {
                     MsgBll.UpdateRead(msgId, 1);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Alert("未知错误:" + ex.Message, Page);
                     /*throw;*/
                 }
             }
         }
         else
         {
             Response.Redirect("Message.aspx");
         }
     }
 }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Msg    msg   = new Msg();
            string name  = context.Request.Params["name"];
            string phone = context.Request.Params["phone"];
            string email = context.Request.Params["email"];
            string adr   = context.Request.Params["adr"];
            string con   = context.Request.Params["con"];

            msg.Author     = name;
            msg.Phone      = phone;
            msg.Email      = email;
            msg.Adress     = adr;
            msg.Details    = con;
            msg.CreateTime = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            msg.IsRead     = 0;
            try
            {
                MsgBll.AddMsg(msg);
                context.Response.Write("1");
            }
            catch (Exception)
            {
                context.Response.Write("0");
                throw;
            }
            context.Response.Flush();
        }
Пример #3
0
        public void BindData()
        {
            string author = txtName.Text.Trim();
            string phone  = txtPhone.Text.Trim();
            string email  = txtEmail.Text.Trim();
            string adr    = txtAdress.Text.Trim();
            int    read   = Convert.ToInt32(dropStatus.SelectedValue);
            string time1  = txtTimer1.Value;
            string time2  = txtTimer2.Value;

            try
            {
                DataTable dt = MsgBll.getMsg(author, phone, email, adr, time1, time2, read);
                if (dt.Rows.Count > 0)
                {
                    AspNetPager1.RecordCount = dt.Rows.Count;
                    PagedDataSource pds = new PagedDataSource();
                    pds.DataSource       = dt.DefaultView;
                    pds.PageSize         = AspNetPager1.PageSize;
                    pds.AllowPaging      = true;
                    pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                    dgMsg.DataSource     = pds;
                    dgMsg.DataBind();
                }
                else
                {
                    dgMsg.DataSource = dt;
                    dgMsg.DataBind();
                }
            }
            catch (Exception)
            {
                DataTable dt = MsgBll.getAllMsg();
                if (dt.Rows.Count > 0)
                {
                    AspNetPager1.RecordCount = dt.Rows.Count;
                    PagedDataSource pds = new PagedDataSource();
                    pds.DataSource       = dt.DefaultView;
                    pds.PageSize         = AspNetPager1.PageSize;
                    pds.AllowPaging      = true;
                    pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                    dgMsg.DataSource     = pds;
                    dgMsg.DataBind();
                }
                else
                {
                    dgMsg.DataSource = dt;
                    dgMsg.DataBind();
                }
                /*throw;*/
            }
        }
Пример #4
0
 protected void dgMsg_ItemCommand(object source, DataGridCommandEventArgs e)
 {
     if (e.CommandName == "del")
     {
         int msgId = Convert.ToInt32(e.CommandArgument);
         try
         {
             MsgBll.DeleteMsg(msgId);
             MessageBox.Alert("删除成功!", Page);
             BindData();
         }
         catch (Exception)
         {
             MessageBox.Alert("删除失败!", Page);
             /*throw;*/
         }
     }
 }
Пример #5
0
        protected void btnShowAllMsg_Click(object sender, EventArgs e)
        {
            DataTable dt = MsgBll.getAllMsg();

            if (dt.Rows.Count > 0)
            {
                AspNetPager1.RecordCount = dt.Rows.Count;
                PagedDataSource pds = new PagedDataSource();
                pds.DataSource       = dt.DefaultView;
                pds.PageSize         = AspNetPager1.PageSize;
                pds.AllowPaging      = true;
                pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
                dgMsg.DataSource     = pds;
                dgMsg.DataBind();
            }
            else
            {
                dgMsg.DataSource = null;
                dgMsg.DataBind();
            }
        }
Пример #6
0
        protected void btnDelSelect_Click(object sender, EventArgs e)
        {
            int selectNum = 0;

            for (int i = 0; i < dgMsg.Items.Count; i++)
            {
                CheckBox chk = dgMsg.Items[i].FindControl("chkSelect") as CheckBox;
                if (chk.Checked)
                {
                    selectNum++;
                }
            }
            if (selectNum == 0)
            {
                MessageBox.Alert("请选择要删除的项!", Page);
            }
            else
            {
                for (int i = 0; i < dgMsg.Items.Count; i++)
                {
                    CheckBox chk = dgMsg.Items[i].FindControl("chkSelect") as CheckBox;
                    if (chk.Checked)
                    {
                        int sId = Convert.ToInt32(dgMsg.DataKeys[i]);
                        try
                        {
                            MsgBll.DeleteMsg(sId);
                        }
                        catch (Exception)
                        {
                            MessageBox.Alert("删除失败!", Page);
                            break;
                        }
                    }
                }
            }
            BindData();
        }