public static Contact LoadAll(DataRow row) { Contact a = Load(row, "ad_"); a.ContactType = ContactTypeDB.Load(row, "at_"); a.ContactType.ContactTypeGroup = IDandDescrDB.Load(row, "atg_contact_type_group_id", "atg_descr"); if (row["act_address_channel_type_id"] != DBNull.Value) { a.AddressChannel = AddressChannelDB.Load(row, "ac_"); a.AddressChannel.AddressChannelType = IDandDescrDB.Load(row, "act_address_channel_type_id", "act_descr"); } if (row["s_suburb_id"] != DBNull.Value) { a.Suburb = SuburbDB.Load(row, "s_"); } if (row["c_country_id"] != DBNull.Value) { a.Country = IDandDescrDB.Load(row, "c_country_id", "c_descr"); } if (row["ad_site_id"] != DBNull.Value) { a.Site.Name = Convert.ToString(row["site_name"]); } return(a); }
protected void btnUpdateType_Click(object sender, EventArgs e) { DataTable addrTypes = ContactTypeDB.GetDataTable(1); ddlContactType.DataSource = addrTypes; ddlContactType.DataBind(); // ddlContactType.SelectedValue = thisRow["ad_contact_type_id"].ToString(); }
protected void btnUpdatePhoneType_Click(object sender, EventArgs e) { DataTable dt_PhoneNumbers = ContactTypeDB.GetDataTable(2); ddlPhoneNumber1.DataSource = dt_PhoneNumbers.Copy(); ddlPhoneNumber2.DataSource = dt_PhoneNumbers.Copy(); ddlPhoneNumber1.DataBind(); ddlPhoneNumber2.DataBind(); ddlPhoneNumber1.SelectedValue = "30"; // mobile ddlPhoneNumber2.SelectedValue = "34"; // office }
protected void GrdContactType_RowUpdating(object sender, GridViewUpdateEventArgs e) { Label lblId = (Label)GrdContactType.Rows[e.RowIndex].FindControl("lblContactTypeId"); TextBox txtDesc = (TextBox)GrdContactType.Rows[e.RowIndex].FindControl("txtDesc"); DropDownList ddlContactTypeGroup = (DropDownList)GrdContactType.Rows[e.RowIndex].FindControl("ddlContactTypeGroup"); DropDownList ddlDisplayOrder = (DropDownList)GrdContactType.Rows[e.RowIndex].FindControl("ddlDisplayOrder"); ContactTypeDB.Update(Convert.ToInt32(lblId.Text), Convert.ToInt32(ddlContactTypeGroup.SelectedValue), txtDesc.Text, Convert.ToInt32(ddlDisplayOrder.SelectedValue)); GrdContactType.EditIndex = -1; FillContactTypeGrid(); }
protected void GrdContactType_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Insert")) { TextBox txtDesc = (TextBox)GrdContactType.FooterRow.FindControl("txtNewDesc"); DropDownList ddlContactTypeGroup = (DropDownList)GrdContactType.FooterRow.FindControl("ddlNewContactTypeGroup"); DropDownList ddlDisplayOrder = (DropDownList)GrdContactType.FooterRow.FindControl("ddlNewDisplayOrder"); ContactTypeDB.Insert(Convert.ToInt32(ddlContactTypeGroup.SelectedValue), txtDesc.Text, Convert.ToInt32(ddlDisplayOrder.SelectedValue)); FillContactTypeGrid(); } }
protected void FillContactTypeGrid() { DataTable dt_contact_type = ContactTypeDB.GetDataTable(-1); Session["contacttype_data"] = dt_contact_type; if (dt_contact_type.Rows.Count > 0) { if (IsPostBack && Session["contacttype_sortexpression"] != null && Session["contacttype_sortexpression"].ToString().Length > 0) { DataView dataView = new DataView(dt_contact_type); dataView.Sort = Session["contacttype_sortexpression"].ToString(); GrdContactType.DataSource = dataView; } else { GrdContactType.DataSource = dt_contact_type; } try { GrdContactType.DataBind(); } catch (Exception ex) { this.lblErrorMessage.Visible = true; this.lblErrorMessage.Text = ex.ToString(); } } else { dt_contact_type.Rows.Add(dt_contact_type.NewRow()); GrdContactType.DataSource = dt_contact_type; GrdContactType.DataBind(); int TotalColumns = GrdContactType.Rows[0].Cells.Count; GrdContactType.Rows[0].Cells.Clear(); GrdContactType.Rows[0].Cells.Add(new TableCell()); GrdContactType.Rows[0].Cells[0].ColumnSpan = TotalColumns; GrdContactType.Rows[0].Cells[0].Text = "No Record Found"; } }
private void FillEmptyAddForm() { string type = "ContactAus"; int contactTypeGroupID = -1; UrlParamContactTypeGroup urlParamContactTypeGroup = GetUrlParamContactTypeGroup(); if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Mailing) { type = "Address"; lblLine1Descr.Text = "Line 1"; contactTypeGroupID = 1; } if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Telecoms) { type = "Phone Number"; lblLine1Descr.Text = "Phone Number"; contactTypeGroupID = 2; } if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Bedroom) { type = "Bedroom"; lblLine1Descr.Text = "Bedroom"; contactTypeGroupID = 3; } if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Internet) { type = "Email/Website"; lblLine1Descr.Text = "Email/Website"; contactTypeGroupID = 4; } lblHeading.Text = "Add " + type; if (contactTypeGroupID != 1) { line2Row.Visible = false; streetRow.Visible = false; suburbRow.Visible = false; countryRow.Visible = false; if (contactTypeGroupID != 4) { billingRow.Visible = false; nonbillingRow.Visible = false; } } DataTable addrTypes = ContactTypeDB.GetDataTable(contactTypeGroupID); ddlContactType.DataSource = addrTypes; ddlContactType.DataBind(); if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Mailing) { // (35, 'Home address'), // (36, 'Business address'), if (GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Referrer || GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Organisation || GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Site) { ddlContactType.SelectedValue = "36"; } else { ddlContactType.SelectedValue = "35"; } } if (urlParamContactTypeGroup == UrlParamContactTypeGroup.Telecoms) { // (34,2,13,'Office Phone'), // (30,2,10,'Mobile'), if (GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Referrer || GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Organisation || GetUrlParamEntityType().Type == EntityType.EntityTypeEnum.Site) { ddlContactType.SelectedValue = "34"; } else { ddlContactType.SelectedValue = "30"; } } idRow.Visible = false; btnSubmit.Text = "Add " + type; btnCancel.Visible = true; }
private void FillEditViewForm(bool isEditMode) { ContactAus contact = ContactAusDB.GetByID(GetFormID()); if (contact == null) { HideTableAndSetErrorMessage("Invalid Contact ID"); return; } DataTable addrTypes = ContactTypeDB.GetDataTable(contact.ContactType.ContactTypeGroup.ID); ddlContactType.DataSource = addrTypes; ddlContactType.DataBind(); string type = "ContactAus"; if (contact.ContactType.ContactTypeGroup.ID == 1) { type = "Address"; lblLine1Descr.Text = "Line 1"; } if (contact.ContactType.ContactTypeGroup.ID == 2) { type = "Phone Number"; lblLine1Descr.Text = "Phone Number"; } if (contact.ContactType.ContactTypeGroup.ID == 3) { type = "Bedroom"; lblLine1Descr.Text = "Bedroom"; } if (contact.ContactType.ContactTypeGroup.ID == 4) { type = "Email/Website"; lblLine1Descr.Text = "Email/Website"; } lblHeading.Text = isEditMode ? "Edit " + type : "View " + type; if (contact.ContactType.ContactTypeGroup.ID != 1) { line2Row.Visible = false; streetRow.Visible = false; suburbRow.Visible = false; countryRow.Visible = false; if (contact.ContactType.ContactTypeGroup.ID != 4) { billingRow.Visible = false; nonbillingRow.Visible = false; } } lblId.Text = contact.ContactID.ToString(); idRow.Visible = Utilities.IsDev(); if (isEditMode) { ddlContactType.SelectedValue = contact.ContactType.ContactTypeID.ToString(); txtFreeText.Text = contact.FreeText; txtAddrLine1.Text = contact.ContactType.ContactTypeGroup.ID == 2 ? Utilities.FormatPhoneNumber(contact.AddrLine1) : contact.AddrLine1; txtAddrLine2.Text = contact.AddrLine2; txtStreet.Text = contact.StreetName; ddlAddressChannelType.SelectedValue = contact.AddressChannelType == null ? "-1" : contact.AddressChannelType.ID.ToString(); suburbID.Value = contact.Suburb == null ? "-1" : contact.Suburb.SuburbID.ToString(); lblSuburbText.Text = contact.Suburb == null ? "--" : contact.Suburb.Name + ", " + contact.Suburb.State + " (" + contact.Suburb.Postcode + ")"; ddlCountry.SelectedValue = contact.Country == null ? "-1" : contact.Country.ID.ToString(); chkIsBilling.Checked = contact.IsBilling; chkIsNonBilling.Checked = contact.IsNonBilling; lblContactType.Visible = false; lblAddrLine1.Visible = false; lblAddrLine2.Visible = false; lblAddressChannelType.Visible = false; lblCountry.Visible = false; lblIsBilling.Visible = false; lblIsNonBilling.Visible = false; } else { lblContactType.Text = contact.ContactType.Descr; lblAddrLine1.Text = contact.ContactType.ContactTypeGroup.ID == 2 ? Utilities.FormatPhoneNumber(contact.AddrLine1) : contact.AddrLine1; lblAddrLine2.Text = contact.AddrLine2; lblStreet.Text = contact.StreetName; lblAddressChannelType.Text = contact.AddressChannelType == null ? string.Empty : contact.AddressChannelType.Descr; suburbID.Value = contact.Suburb == null ? "-1" : contact.Suburb.SuburbID.ToString(); lblSuburbText.Text = contact.Suburb == null ? "--" : contact.Suburb.Name + ", " + contact.Suburb.State + " (" + contact.Suburb.Postcode + ")"; lblSuburbText.Font.Bold = true; lblCountry.Text = contact.Country == null ? string.Empty : contact.Country.Descr; lblIsBilling.Text = contact.IsBilling ? "Yes" : "No"; lblIsNonBilling.Text = contact.IsNonBilling ? "Yes" : "No"; lnkUpdateType.Visible = false; txtValidateAddrLine1Required.Visible = false; ddlContactType.Visible = false; txtFreeText.Visible = false; txtAddrLine1.Visible = false; txtAddrLine2.Visible = false; txtStreet.Visible = false; ddlAddressChannelType.Visible = false; lnkGetSuburb.Visible = false; lnkClearSuburb.Visible = false; ddlCountry.Visible = false; chkIsBilling.Visible = false; chkIsNonBilling.Visible = false; } if (isEditMode) { btnSubmit.Text = "Update Details"; } else // is view mode { btnSubmit.Visible = false; btnCancel.Text = "Close"; } }
private void SetupGUI(string dbID, string orgID) { ddlClinic.Focus(); ddlDOB_Day.Items.Add(new ListItem("--", "-1")); ddlDOB_Month.Items.Add(new ListItem("--", "-1")); ddlDOB_Year.Items.Add(new ListItem("----", "-1")); for (int i = 1; i <= 31; i++) { ddlDOB_Day.Items.Add(new ListItem(i.ToString(), i.ToString())); } for (int i = 1; i <= 12; i++) { ddlDOB_Month.Items.Add(new ListItem(i.ToString(), i.ToString())); } for (int i = 1900; i <= DateTime.Today.Year; i++) { ddlDOB_Year.Items.Add(new ListItem(i.ToString(), i.ToString())); } string curDbName = Session == null || Session["DB"] == null ? null : Session["DB"].ToString(); try { Session["DB"] = "Mediclinic_" + dbID; Session["SystemVariables"] = SystemVariableDB.GetAll(); bool allowPatientsToCreateOwnRecords = ((SystemVariables)Session["SystemVariables"])["AllowPatientsToCreateOwnRecords"].Value == "1"; if (!allowPatientsToCreateOwnRecords) { throw new CustomMessageException("Invalid ID in URL"); } ddlTitle.DataSource = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Title", " title_id <> 0 ", " descr ", "title_id", "descr"); ddlTitle.DataBind(); ddlTitle.SelectedIndex = Utilities.IndexOf(ddlTitle, "mr", "mr."); DataTable phoneNumberTypes = ContactTypeDB.GetDataTable(2); for (int i = phoneNumberTypes.Rows.Count - 1; i >= 0; i--) { if (Convert.ToInt32(phoneNumberTypes.Rows[i]["at_contact_type_id"]) != 30 && Convert.ToInt32(phoneNumberTypes.Rows[i]["at_contact_type_id"]) != 33) { phoneNumberTypes.Rows.RemoveAt(i); } } ddlPhoneNumberType.DataSource = phoneNumberTypes; ddlPhoneNumberType.DataBind(); ddlPhoneNumberType.SelectedValue = "30"; // mobile lblSiteName.Text = ((SystemVariables)Session["SystemVariables"])["Site"].Value; Site[] sites = SiteDB.GetAll(); Site clinicSite = null; Site agedCareSite = null; for (int i = 0; i < sites.Length; i++) { if (sites[i].SiteType.ID == 1) { clinicSite = sites[i]; } if (sites[i].SiteType.ID == 2) { agedCareSite = sites[i]; } } List <Tuple <string, Organisation> > clinics = GetClinicList(); foreach (Tuple <string, Organisation> item in clinics) { ddlClinic.Items.Add(new ListItem(item.Item2.Name, "Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + item.Item2.OrganisationID)); } if (orgID != null && Regex.IsMatch(orgID, @"^\d+$")) { Organisation org = OrganisationDB.GetByID(Convert.ToInt32(orgID)); if (org != null && ddlClinic.Items.FindByValue("Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + org.OrganisationID) != null) { ddlClinic.SelectedValue = "Mediclinic_" + dbID + "__" + clinicSite.SiteID + "__" + org.OrganisationID; } } } finally { Session.Remove("DB"); Session.Remove("SystemVariables"); if (curDbName != null) { Session["DB"] = curDbName; Session["SystemVariables"] = SystemVariableDB.GetAll(); } } bool editable = true; Utilities.SetEditControlBackColour(ddlClinic, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlTitle, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtFirstname, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtSurname, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlGender, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlDOB_Day, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlDOB_Month, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlDOB_Year, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPhoneNumber, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlPhoneNumberType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtEmailAddr, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtLogin, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPwd, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); }
protected void SetupAddressGUI() { string allFeaturesType = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no"; string jsType = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType + "');document.getElementById('btnUpdateAddressType').click();return false;"; string allFeatures = "dialogWidth:1100px;dialogHeight:600px;center:yes;resizable:no; scroll:no"; string js = "javascript:window.showModalDialog('" + "StreetAndSuburbInfo.aspx', '', '" + allFeatures + "');document.getElementById('btnUpdateAddressStreetAndSuburb').click();return false;"; lnkAddressUpdateType.NavigateUrl = " "; lnkAddressUpdateType.Text = "Add/Edit"; lnkAddressUpdateType.Attributes.Add("onclick", jsType); lnkAddressUpdateChannel.NavigateUrl = " "; lnkAddressUpdateChannel.Text = "Add/Edit"; lnkAddressUpdateChannel.Attributes.Add("onclick", js); string allFeaturesType2 = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no"; string jsType2 = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType2 + "');document.getElementById('btnUpdatePhoneType').click();return false;"; string allFeaturesType3 = "dialogWidth:500px;dialogHeight:750px;center:yes;resizable:no; scroll:no"; string jsType3 = "javascript:window.showModalDialog('" + "ContactTypeListV2.aspx', '', '" + allFeaturesType3 + "');document.getElementById('btnUpdateEmailType').click();return false;"; lnkEmailUpdateType.NavigateUrl = " "; lnkEmailUpdateType.Text = "Add/Edit"; lnkEmailUpdateType.Attributes.Add("onclick", jsType3); ddlAddressContactType.DataSource = ContactTypeDB.GetDataTable(1); ddlAddressContactType.DataBind(); ddlAddressContactType.SelectedValue = "36"; // set default as business address DataTable dt_PhoneNumbers = ContactTypeDB.GetDataTable(2); ddlPhoneNumber1.DataSource = dt_PhoneNumbers.Copy(); ddlPhoneNumber2.DataSource = dt_PhoneNumbers.Copy(); ddlPhoneNumber1.DataBind(); ddlPhoneNumber2.DataBind(); ddlPhoneNumber1.SelectedValue = "30"; // mobile ddlPhoneNumber2.SelectedValue = "34"; // office lnkPhone1UpdateType.NavigateUrl = " "; lnkPhone1UpdateType.Text = "Add/Edit"; lnkPhone1UpdateType.Attributes.Add("onclick", jsType2); lnkPhone2UpdateType.NavigateUrl = " "; lnkPhone2UpdateType.Text = "Add/Edit"; lnkPhone2UpdateType.Attributes.Add("onclick", jsType2); DataTable emailWeb = ContactTypeDB.GetDataTable(4); DataView dv = emailWeb.DefaultView; dv.RowFilter = string.Format("at_contact_type_id={0}", 27); DataTable emailOnly = dv.ToTable(); ddlEmailContactType.DataSource = emailOnly; //ddlEmailContactType.DataSource = ContactTypeDB.GetDataTable(4); ddlEmailContactType.DataBind(); if (Utilities.GetAddressType().ToString() == "Contact") { // newOrgAddressRow5.Visible = true; DataTable addrChannels = AddressChannelDB.GetDataTable(); ddlAddressAddressChannel.Items.Add(new ListItem("--", "-1")); foreach (DataRow row in addrChannels.Rows) { ddlAddressAddressChannel.Items.Add(new ListItem(row["ac_descr"] + " " + row["act_descr"], row["ac_address_channel_id"].ToString())); } } else if (Utilities.GetAddressType().ToString() == "ContactAus") { //newOrgAddressRow6.Visible = true; DataTable addrChannelTypes = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "AddressChannelType", "", "descr", "address_channel_type_id", "descr"); ddlAddressAddressChannelType.Items.Add(new ListItem("--", "-1")); foreach (DataRow row in addrChannelTypes.Rows) { ddlAddressAddressChannelType.Items.Add(new ListItem(row["descr"].ToString(), row["address_channel_type_id"].ToString())); } } else { throw new Exception("Unknown AddressType in config: " + Utilities.GetAddressType().ToString().ToString()); } DataTable countries = DBBase.GetGenericDataTable_WithWhereOrderClause(null, "Country", "", "descr", "country_id", "descr"); ddlAddressCountry.Items.Add(new ListItem("--", "-1")); foreach (DataRow row in countries.Rows) { ddlAddressCountry.Items.Add(new ListItem(row["descr"].ToString(), row["country_id"].ToString())); } ddlAddressCountry.SelectedIndex = Utilities.IndexOf(ddlAddressCountry, "australia"); bool editable = true; Utilities.SetEditControlBackColour(ddlAddressContactType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtAddressAddrLine1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtAddressAddrLine2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlAddressAddressChannel, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtStreet, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlAddressAddressChannelType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlAddressCountry, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtAddressFreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlPhoneNumber1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlPhoneNumber2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPhoneNumber1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPhoneNumber2, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPhoneNumber1FreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtPhoneNumber2FreeText, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(ddlEmailContactType, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); Utilities.SetEditControlBackColour(txtEmailAddrLine1, editable, System.Drawing.Color.LightGoldenrodYellow, System.Drawing.Color.Empty); }