Ejemplo n.º 1
0
        protected void btnAddProspect_OnClick(object sender, EventArgs e)
        {
            var txtCompanyAdd = (TextBox)gvProspects.FooterRow.FindControl("txtCompanyAdd");
            var txtContactNameAdd = (TextBox)gvProspects.FooterRow.FindControl("txtContactNameAdd");
            var txtContactEmailAdd = (TextBox)gvProspects.FooterRow.FindControl("txtContactEmailAdd");
            var txtContactPhoneAdd = (TextBox)gvProspects.FooterRow.FindControl("txtContactPhoneAdd");
            var txtContactCityAdd = (TextBox)gvProspects.FooterRow.FindControl("txtContactCityAdd");
            var ddlState = (DropDownList)gvProspects.FooterRow.FindControl("ddlStateAdd");
            var ddlContactTimeZoneAdd = (DropDownList)gvProspects.FooterRow.FindControl("ddlTimeZoneAdd");
            var txtLastActivityDateAdd = (TextBox)gvProspects.FooterRow.FindControl("txtLastActivityDateAdd");

            var dbContext = new ProspectDataContext();

            var dbProspect = new Prospect
            {
                Company = txtCompanyAdd.Text,
                ContactName = txtContactNameAdd.Text,
                ContactEmail = txtContactEmailAdd.Text,
                ContactPhone = txtContactPhoneAdd.Text,
                ContactCity = txtContactCityAdd.Text,
                ContactState = ddlState.SelectedValue,
                ContactTimeZone = ddlContactTimeZoneAdd.SelectedValue,
                LastActivityDate =Convert.ToDateTime(txtLastActivityDateAdd.Text),
                CreatedByUserId = UserId
            };

            dbContext.Prospects.InsertOnSubmit(dbProspect);
            dbContext.SubmitChanges();
            lblMsg.Text = "Prospect for Company: " + txtCompanyAdd.Text + " added.";

            BindGrid(SearchOn.None);
            PopulateDropdowns();
        }
 partial void UpdateProspect(Prospect instance);
 partial void DeleteProspect(Prospect instance);
 partial void InsertProspect(Prospect instance);