protected void uiButtonSearch_Click(object sender, EventArgs e)
 {
     Subscribers objData = new Subscribers();
     objData.SearchSubscribers(uiTextBoxSearch.Text);
     uiGridViewSubscribers.DataSource = objData.DefaultView;
     uiGridViewSubscribers.DataBind();
 }
예제 #2
0
 protected void uiLinkButtonSend_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(uiTextBoxEnMail.Text))
     {
         Subscribers sub = new Subscribers();
         sub.AddNew();
         sub.Email = uiTextBoxEnMail.Text;
         sub.Save();
         uiLabelMessage.Visible = true;
     }
 }
        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            bool done =false;

            if (CurrentSubscriber != null)
            {
                Subscribers objData = CurrentSubscriber;
                objData.Email = uiTextBoxEMail.Text;
                objData.Save();
            }
            else
            {
                Subscribers objData = new Subscribers();
                objData.AddNew();
                objData.Email = uiTextBoxEMail.Text;
                objData.Save();
            }

            uiPanelEdit.Visible = false;
            uiPanelViewSubscribers.Visible = true;
            BindData();
            Clearfields();
            CurrentSubscriber = null;
        }
        protected void uiGridViewSubscribers_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditSubscriber")
            {
                Subscribers objData = new Subscribers();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                uiTextBoxEMail.Text = objData.Email;
                uiPanelViewSubscribers.Visible = false;
                uiPanelEdit.Visible = true;
            }
            else if (e.CommandName == "DeleteSubscriber")
            {
                Subscribers objData = new Subscribers();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                objData.MarkAsDeleted();
                objData.Save();
                uiPanelEdit.Visible = false;
                uiPanelViewSubscribers.Visible = true;
                BindData();
                Clearfields();

            }
        }
 private void BindData()
 {
     Subscribers objData = new Subscribers();
     objData.LoadAll();
     uiGridViewSubscribers.DataSource = objData.DefaultView;
     uiGridViewSubscribers.DataBind();
 }
        protected void uiLinkButtonAskExport_Click(object sender, EventArgs e)
        {
            StringBuilder sbDocBody = new StringBuilder();
            sbDocBody.Append("<html><body>");
            Subscribers objData = new Subscribers();
            objData.LoadAll();
            foreach (DataRowView item in objData.DefaultView)
            {
                sbDocBody.Append(item["Email"].ToString());
                sbDocBody.Append("<br />");

            }
            sbDocBody.Append("</body></html>");
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.Charset = "utf-8";

            HttpContext.Current.Response.ContentType = "application/msword";
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"subscribers.doc\"");
            HttpContext.Current.Response.Write(sbDocBody.ToString());
            HttpContext.Current.Response.End();
        }