easy way:
with this method, you must include the leading '#' sign
System.Drawing.Color myOrangeColor = System.Drawing.ColorTranslator.FromHtml("#CE560C");
harder way:
protected System.Drawing.Color HexStringToColor(string hex)
{
hex = hex.Replace("#", "");
if (hex.Length != 6)
{
throw new System.Exception(hex + " is not a valid 6-place hexadecimal color code");
}
string r = hex.Substring(0, 2);
string g = hex.Substring(2, 2);
string b = hex.Substring(4, 2);
return System.Drawing.Color.FromArgb(HexStringToBase10Int(r), HexStringToBase10Int(g), HexStringToBase10Int(b));
}
protected int HexStringToBase10Int(string hex)
{
int base10value = 0;
try{ base10value = System.Convert.ToInt32(hex, 16); }
catch{ base10value = 0; }
return base10value;
}
C:\vrm\Products\VMS\3.1\SourceCode\VRM.Business.VMS\BusinessIndustryDesignations.custom.cs
using System.Data;
using System.Data.SqlClient; //for SqlParameter
using VRM.Data; //for DataLayer
using VRM.Configuration; //for Settings
public static DataSet GetData(int businessID)
{
IDbCommand command = DataLayer.CommandCreateForProcedure("BusinessIndustryDesignations_Select");
command.Parameters.Add(new SqlParameter("@intBusinessID", businessID));
return DataLayer.GetDataSet(command, Settings.ConnectionStringVMS);
}
This works without a function!
DECLARE @AllEmails VARCHAR(MAX) = 'jbreo@soldinoregon.com,info@soldinoregon.com, barbralston@comcast.net,reo@soldinoregon.com,loraparnell1@yahoo.com, nivrita@exitadvancedrealtyca.com,Mark@elitearizona.com,Jeff@atlantareopartners.com, Charlotte@YesNoPlaceLikeHome.com,cgim@expertrei.com,lashelle@windermere.com, eric.egeland@remax.net,tonyacuffee@msn.com,james@ReoRealtorSpokane.com, REOsales@JulieBaldino.com';
SELECT ContactID, BusinessID, ContactTypeID, FirstName, LastName, EmailAddress FROM Contacts WHERE ',' + @AllEmails + ',' LIKE '%,' + CAST(EmailAddress as VARCHAR(MAX))+',%'
C:\vrm\Products\Corporate\2.2\SourceCode\VRM.Website.Corporate\Admin\AdminTopics.aspx
<asp:DropDownList ID="ddlTopicTypes" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ddlTopicTypes_SelectedIndexChanged" />
protected void ddlTopicTypes_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlTopicTypes.SelectedIndex != -1)
{
int selIndex = ddlTopicTypes.SelectedIndex;
if (ddlTopicTypes.Items[selIndex] != null)
{
ListItem li = ddlTopicTypes.Items[selIndex];
//for retrieve, for add new
TopicType = (li.Value).ToEnum(); //(Convert.ToInt32(li.Value));
LoadData();
}
}
}
private void LoadData()
{
gvTopics.DataSource = TopicsCollection.RetrieveByTopicType(TopicType, true);
//topicType.ToString()
lblPageHeader.Text = "Manage " + Topics.GetNameField(TopicType.FromEnum()) + " Section";
gvTopics.DataBind();
}//LoadData()
partial class TopicsCollection
{
public static TopicsCollection RetrieveByTopicType(TopicType typeID, bool showInactiveRecords)
{
string sWhere = "WHERE TopicTypeID = " + typeID.FromEnum();
if (!showInactiveRecords)
{
sWhere += " AND IsActive = 1";
}
return Retrieve(sWhere, true, "SortIndex ASC");
}
}
Using cache manager to set standard dropdownlists
THIS:
VMSDataCacheManager.SetTypeTableDropDownList(ref ddlVendorType, VMSDataCacheTable.ValidBusinessSubTypes, string.Concat("BusinessTypeID = ", BusinessType.Vendor.FromEnum()), "-1", "-1", "-Select-");
REPLACES THIS:
DataView results = VMSDataCacheManager.GetTypeTableData(
VMSDataCacheTable.ValidBusinessSubTypes,
string.Concat("BusinessTypeID = " , BusinessType.Vendor.FromEnum()));
if (results.Count > 0)
{
ddlVendorType.DataSource = results;
ddlVendorType.DataTextField = "Name";
ddlVendorType.DataValueField = "ID";
ddlVendorType.DataBind();
}
<VRMCustomConfig>
<JobConfig>
<add key="ExecuteAsUserID" value="1" />
<add key="VendorAdministratorRoleName" value="Administrator" />
<add key="EquatorMailServer" value="mail" />
<add key="EquatorMailPort" value="993" />
<add key="EquatorMailUserName" value="equatorsupport" />
<add key="EquatorMailPassword" value="EQmail4vrm!" />
<add key="EquatorMailTimeout" value="90000" />
<add key="EquatorMailToAddress" value="jbechtold@vrmco.com" />
</JobConfig>
</VRMCustomConfig>
public static string EquatorMailServer { get; private set; }
public static int EquatorMailPort { get; private set; }
EquatorMailServer = ReadString(config, "EquatorMailServer");
EquatorMailPort = ReadInteger(config, "EquatorMailPort");
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> <div class="date"> <telerik:RadDatePicker ID="txtRequestedCompletionDate" runat="server" /> </div>
if (ds == null || ds.Tables.Count == 0)
{
VRM.Common.Logging.Event.Write("Asset Assignment - File Cannot Be Generated - No EquatorAssets for this upload.");
return;
}
private void LoadVendorTypes()
{
DataView results = VMSDataCacheManager.GetTypeTableData(
VMSDataCacheTable.ValidBusinessSubTypes,
string.Concat("BusinessTypeID = " , BusinessType.Vendor.FromEnum()));
if (results.Count > 0)
{
ddlVendorType.DataSource = results;
ddlVendorType.DataTextField = "Name";
ddlVendorType.DataValueField = "ID";
ddlVendorType.DataBind();
}
}//end ()
Update: there is a 1-line version of the above:
/// <summary>
/// VendorTypes in this case are ValidBusinessSubTypes where ValidBusinessTypeID = 3
/// </summary>
private void LoadVendorTypes()
{
VMSDataCacheManager.SetTypeTableDropDownList(ref ddlVendorTypes, VMSDataCacheTable.ValidBusinessSubTypes,
string.Concat("BusinessTypeID = ", BusinessType.Vendor.FromEnum()), "-1", "-1", "-Select-");
}
To get the name out of cache:
using System.Security.Principal;
WindowsIdentity wi = WindowsIdentity.GetCurrent();
private string _windowsIndentityName = wi.Name;
lblUserEntered.Text = _windowsIndentityName;
using System.Web;
_windowsIndentityName = ((WindowsPrincipal)HttpContext.Current.User).Identity.Name;
ClearControls(this);
private void ClearControls(Control parent)
{
foreach (Control control in parent.Controls)
{
if (control is TextBox)
{
((TextBox)control).Text = string.Empty;
}
else if (control is DropDownList)
{
((DropDownList)control).SelectedIndex = 0;
}
else if (control is RadNumericTextBox)
{
((RadNumericTextBox)control).Value = null;
}
else if (control is RadMaskedTextBox)
{
((RadMaskedTextBox)control).Text = string.Empty;
}
if (control.HasControls())
{
ClearControls(control);
}
}
UserSession.ContactSearch = null;
gvContacts.DataSource = null;
gvContacts.DataBind();
}