private CompanyContact GetCompanyContact() { CompanyContact contact = new CompanyContact(); if (!string.IsNullOrEmpty(Request.QueryString["contactID"])) { int contactId = int.Parse(Request.QueryString["contactID"]); if (contactId > 0) { contact = new CompanyContactRepository().FindOne(new CompanyContact(contactId)); } } //contact.CompanyID = Int32.Parse(Request.QueryString["companyID"]); contact.LastName = txtLastName.Text.Trim(); contact.FirstName = txtFirstName.Text.Trim(); contact.Position = ddlFunction.Text; contact.Gender = ddlGender.SelectedValue; contact.Language = txtLanguage.Text.Trim(); contact.Remark = txtRemark.Text; contact.Newsletter = chkReceiveNeosNewsletter.Checked; return contact; }
private void BindData() { //load function list ddlFunction.DataSource = new ParamContactFunctionRepository().FindAllWithAscSort(); ddlFunction.DataBind(); //load gender RadComboBoxItem nullItem = new RadComboBoxItem("", ""); RadComboBoxItem fItem = new RadComboBoxItem("F","F"); RadComboBoxItem mItem = new RadComboBoxItem("M", "M"); ddlGender.Items.Add(nullItem); ddlGender.Items.Add(fItem); ddlGender.Items.Add(mItem); if (!string.IsNullOrEmpty(Request.QueryString["contactID"])) //edit contact { int contactId = Int32.Parse(Request.QueryString["contactID"]); CompanyContact contact = new CompanyContact(); if (contactId > 0) { CompanyContactRepository contactRepo = new CompanyContactRepository(); contact = contactRepo.FindOne(new CompanyContact(Int32.Parse(Request.QueryString["contactID"]))); } else { contact = SessionManager.NewCompanyContactList.Find(delegate(CompanyContact t) { return t.ContactID == contactId; }); } txtFirstName.Text = contact.FirstName; txtLastName.Text = contact.LastName; ddlFunction.Text = contact.Position; ddlGender.SelectedValue = contact.Gender; txtLanguage.Text = contact.Language; txtRemark.Text = contact.Remark; chkReceiveNeosNewsletter.Checked = contact.Newsletter; } }
protected void OnMyAjaxManagerAjaxRequest(object sender, AjaxRequestEventArgs e) { if (e.Argument.IndexOf("RebindContactGrid") != -1) { //System.Threading.Thread.Sleep(1000); //divContact.Visible = true; //divContact.Style.Add("display", "block"); CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyContactGrid); CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, pnlAddContact); string[] args = e.Argument.Split('/'); if (args.Length == 3) { try { int companyID = Int32.Parse(args[1]); int rowIndex = Int32.Parse(args[2]); CompanyGrid.MasterTableView.ClearSelectedItems(); CompanyGrid.MasterTableView.Items[rowIndex - 1].Selected = true; } catch (Exception ex) { throw ex; } CompanyContactGrid.Rebind(); } } else if (e.Argument.IndexOf("RebindContactInfoGrid") != -1) { //divContactInfo.Style.Add("display","block"); CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, ContactInfoGrid); CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, pnlAddContactInfo); string[] args = e.Argument.Split('/'); if (args.Length == 3) { try { int contactID = Int32.Parse(args[1]); int rowIndex = Int32.Parse(args[2]); CompanyContactGrid.MasterTableView.ClearSelectedItems(); CompanyContactGrid.MasterTableView.Items[rowIndex - 1].Selected = true; } catch (Exception ex) { throw ex; } ContactInfoGrid.Rebind(); } } else if (e.Argument.IndexOf("AddCompanyContact") != -1) { CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyContactGrid); string[] args = e.Argument.Split('/'); if (args.Length == 2) { try { int companyID = Int32.Parse(args[1]); CompanyContactRepository contactRepo = new CompanyContactRepository(); CompanyContact contact = new CompanyContact(); contact.CompanyID = companyID; contact.LastName = txtLastName.Text.Trim(); contact.FirstName = txtFirstName.Text.Trim(); contact.Position = ddlFunction.Text; contactRepo.Insert(contact); CompanyContactGrid.Rebind(); } catch (Exception ex) { throw ex; } } } else if (e.Argument.IndexOf("AddContactInfo") != -1) { CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, ContactInfoGrid); string[] args = e.Argument.Split('/'); if (args.Length == 2) { try { int contactID = Int32.Parse(args[1]); CompanyContactTelephoneRepository contactInfoRepo = new CompanyContactTelephoneRepository(); CompanyContactTelephone contactInfo = new CompanyContactTelephone(); contactInfo.ContactID = contactID; contactInfo.Type = ddlType.SelectedValue; contactInfo.TelephoneZone = txtPhoneZone.Text.Trim(); contactInfo.Tel = txtInfo.Text.Trim(); contactInfo.Location = txtPlace.Text.Trim(); contactInfoRepo.Insert(contactInfo); ContactInfoGrid.Rebind(); } catch (Exception ex) { throw ex; } } } else if (e.Argument.IndexOf("DeleteSelectedCompany") != -1) { if (CompanyGrid.SelectedItems.Count == 1) { CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyGrid); CompanyRepository companyRepo = new CompanyRepository(); companyRepo.Delete(new Company(GetSelectedCompanyID())); CompanyGrid.Rebind(); } } else if (e.Argument.IndexOf("OpenSeletectedCompany") != -1) { if (CompanyGrid.SelectedItems.Count == 1) { Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&mode=edit&backurl=visible", GetSelectedCompanyID()), true); } } else if (e.Argument.IndexOf("ViewCompanyActions") != -1) { if (CompanyGrid.SelectedItems.Count == 1) { Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&tab=action&mode=edit&backurl=visible", GetSelectedCompanyID()), true); } } else if (e.Argument.IndexOf("ViewCompanyJobs") != -1) { if (CompanyGrid.SelectedItems.Count == 1) { Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&tab=job&mode=edit&backurl=visible", GetSelectedCompanyID()), true); } } else if (e.Argument.IndexOf("ViewCompanyInvoices") != -1) { if (CompanyGrid.SelectedItems.Count == 1) { Response.Redirect(string.Format("~/InvoicesPage.aspx?type=search&customer={0}", GetSelectedCompanyID()), true); } } }