Beispiel #1
0
 protected void btnContact_Click(object sender, EventArgs e)
 {
     Model.Contact contact = new Model.Contact();
     contact.FirstName = txtFirstName.Text;
     contact.LastName = txtLastName.Text;
     contact.Email = txtEmail.Text;
     contact.Comment = txtComments.Text;
     contact.DateCreated = DateTime.Now;
     int i = new ContactRepo().CreateContact(contact);
     txtFirstName.Text = "";
     txtLastName.Text = "";
     txtEmail.Text = "";
     txtComments.Text = "";
     lbMessage.Text = "Sent contact successfully!";
     Response.Redirect("Contact.aspx");
 }
        private void BindItemsList()
        {
            List<Model.Contact> users = new ContactRepo().GetManagementContacts(ToSQL.SQLToDateTimeNull(txtFromDate.Text), ToSQL.SQLToDateTimeNull(txtToDate.Text));
            _PageDataSource.DataSource = users;
            _PageDataSource.AllowPaging = true;
            _PageDataSource.PageSize = 10;
            _PageDataSource.CurrentPageIndex = CurrentPage;
            ViewState["TotalPages"] = _PageDataSource.PageCount;

            //this.lblPageInfo.Text = "Results: " + ProductList.Count.ToString() + "&nbsp;&nbsp;&nbsp;&nbsp;Page " + (CurrentPage + 1) + " of " + _PageDataSource.PageCount + "&nbsp;&nbsp;";

            this.btnPre.Visible = !_PageDataSource.IsFirstPage;
            this.btnNext.Visible = !_PageDataSource.IsLastPage;
            //this.lbtnFirst.Visible = !_PageDataSource.IsFirstPage;
            //this.lbtnLast.Visible = !_PageDataSource.IsLastPage;

            this.gvContacts.DataSource = _PageDataSource;
            this.gvContacts.DataBind();
            //this.gvProducts.UseAccessibleHeader = true;
            //this.gvProducts.HeaderRow.TableSection = TableRowSection.TableHeader;
            this.doPaging();
        }
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            try
            {
                LinkButton lnk = (LinkButton)sender;
                int Id = ToSQL.SQLToInt(lnk.CommandArgument);
                if (Id > 0)
                {
                    int i = new ContactRepo().DeleteContact(Id);
                    BindItemsList();
                }
            }
            catch
            {

            }
        }