2015年12月10日 星期四

Reset CSS – 重置歸零 – 網頁排版在各瀏覽器一致化

Reset CSS – 重置歸零 – 網頁排版在各瀏覽器一致化
只要在寫 CSS 前掛上這一段「Reset CSS」的語法,就可以解決各大瀏覽器初始化的差異


  1. <style>
  2. /* v1.0 | 20080212 */
  3.  
  4. html, body, div, span, applet, object, iframe,
  5. h1, h2, h3, h4, h5, h6, p, blockquote, pre,
  6. a, abbr, acronym, address, big, cite, code,
  7. del, dfn, em, font, img, ins, kbd, q, s, samp,
  8. small, strike, strong, sub, sup, tt, var,
  9. b, u, i, center,
  10. dl, dt, dd, ol, ul, li,
  11. fieldset, form, label, legend,
  12. table, caption, tbody, tfoot, thead, tr, th, td {
  13. margin: 0;
  14. padding: 0;
  15. border: 0;
  16. outline: 0;
  17. font-size: 100%;
  18. vertical-align: baseline;
  19. background: transparent;
  20. }
  21. body {
  22. line-height: 1;
  23. }
  24. ol, ul {
  25. list-style: none;
  26. }
  27. blockquote, q {
  28. quotes: none;
  29. }
  30. blockquote:before, blockquote:after,
  31. q:before, q:after {
  32. content: '';
  33. content: none;
  34. }
  35.  
  36. /* remember to define focus styles! */
  37. :focus {
  38. outline: 0;
  39. }
  40.  
  41. /* remember to highlight inserts somehow! */
  42. ins {
  43. text-decoration: none;
  44. }
  45. del {
  46. text-decoration: line-through;
  47. }
  48.  
  49. /* tables still need 'cellspacing="0"' in the markup */
  50. table {
  51. border-collapse: collapse;
  52. border-spacing: 0;
  53. }
  54. </style>


DownLoad: http://meyerweb.com/eric/tools/css/reset/reset.css

Source: http://meyerweb.com/eric/tools/css/reset/

Reference: http://www.flycan.com/article/css/reset-css-562.html

ASP.NET 選擇性引數函式範例

ASP.NET 選擇性引數函式範例


cs
  1. ///
  2. /// 選擇性引數函式範例
  3. ///
  4. public partial class tsExampleMethod : System.Web.UI.Page
  5. {
  6. protected void Page_Load(object sender, EventArgs e)
  7. {
  8. ExampleClass anExample = new ExampleClass();
  9. string a = anExample.ExampleMethod(1, "One", 1);
  10. string b = anExample.ExampleMethod(2, "Two");
  11. string c = anExample.ExampleMethod(3);
  12.  
  13. Response.Write(a);
  14. Response.Write(b);
  15. Response.Write(c);
  16. }
  17. }


  1. class ExampleClass
  2. {
  3. private string _name;
  4.  
  5. // Because the parameter for the constructor, name, has a default
  6. // value assigned to it, it is optional.
  7. public ExampleClass(string name = "Default name")
  8. {
  9. _name = name;
  10. }
  11.  
  12. // The first parameter, required, has no default value assigned
  13. // to it. Therefore, it is not optional. Both optionalstr and
  14. // optionalint have default values assigned to them. They are optional.
  15. public string ExampleMethod(int required, string optionalstr = "default string",
  16. int optionalint = 10)
  17. {
  18. return string.Format("{0}: {1}, {2}, and {3}.", _name, required, optionalstr,
  19. optionalint);
  20.  
  21. }
  22. }

2015年12月9日 星期三

Searching in SQL Multiple Keyword

SQL 多條件查詢

使用逗號間隔多關鍵字查詢及對多個欄位進行搜查,組合條件為"或"。
※逗號前後不可留空白,否則會查出全部的資料



SQL
  1. DECLARE @strKeyword VARCHAR(512);
  2. SET @strKeyword = 'john,howard,lee';
  3.  
  4. SELECT * FROM v_HRM_Evaluation
  5. JOIN dbo.FN_SPLIT_TBL(@strKeyword,',') tblB
  6. ON name + batchnumber + jobtitles +
  7. CONVERT(varchar(30),joblevel) + workingfunc +
  8. ogno + ogname + ouno + ouname + ename + status +
  9. CONVERT(varchar(30),cdt,120) LIKE '%'+tblB.Value+'%'
  10. WHERE 1=1


FN_SPLIT_TBL
  1. --註:字串切割,用在單一欄位多條件同時查詢,如:(Select * from Table Where name like '%張%' or name like '%陳%' or name like '%王%')
  2. --引用範例(一):
  3. --select tblA.* from t_HRM_Evaluation tblA join dbo.FN_SPLIT_TBL('張,陳,王',',') tblB on tblA.name like '%'+tblB.Value+'%'
  4. --引用範例(二):
  5. --SELECT dbo.[FN_SPLIT](Name.Value, 2, '=') as Name,
  6. --dbo.[FN_SPLIT](Age.Value, 2, '=') as Age,
  7. --dbo.[FN_SPLIT](Job.Value, 2, '=') as Job,
  8. --dbo.[FN_SPLIT](Location.Value, 2, '=') as Location,
  9. --dbo.[FN_SPLIT](Add_Date.Value, 2, '=') as Add_Date
  10. --FROM HR data
  11. -- CROSS APPLY FN_SPLIT_TBL(data.Details, '|') Name
  12. -- CROSS APPLY FN_SPLIT_TBL(data.Details, '|') Age
  13. -- CROSS APPLY FN_SPLIT_TBL(data.Details, '|') Job
  14. -- CROSS APPLY FN_SPLIT_TBL(data.Details, '|') Location
  15. -- CROSS APPLY FN_SPLIT_TBL(data.Details, '|') Add_Date
  16. --WHERE Name.Pos = 1 AND Age.Pos = 2 AND Job.Pos = 3 AND Location.Pos = 4 AND Add_Date.Pos = 5
  17.  
  18. CREATE FUNCTION [dbo].[FN_SPLIT_TBL](@InExp varchar(8000), @Sep varchar(10)) --SELECT * FROM DBO.[FN_SPLIT_TBL]('TEST1,TEST2', ',')
  19. RETURNS @Res TABLE(
  20. Pos int,
  21. Value varchar(max))
  22. AS
  23. BEGIN
  24. WITH Pieces(pn, start, stop) AS (
  25. SELECT 1, 1, CHARINDEX(@Sep, @InExp)
  26. UNION ALL
  27. SELECT pn + 1, stop + 1, CHARINDEX(@sep, @InExp, stop + 1)
  28. FROM Pieces
  29. WHERE stop > 0
  30. )
  31.  
  32. INSERT INTO @Res
  33. SELECT pn, SUBSTRING(@InExp, start, CASE WHEN stop > 0 THEN stop-start ELSE 512 END) AS s
  34. FROM Pieces OPTION (MAXRECURSION 0);
  35.  
  36. RETURN;
  37. END


FN_SPLIT
  1. --註:無
  2. --引用範例(一):
  3. --SELECT
  4. --dbo.[FN_SPLIT](data.Name, 2, '=') as Name,
  5. --dbo.[FN_SPLIT](data.Age, 2, '=') as Age,
  6. --dbo.[FN_SPLIT](data.Job, 2, '=') as Job,
  7. --dbo.[FN_SPLIT](data.Location, 2, '=') as Location,
  8. --dbo.[FN_SPLIT](data.Add_Date, 2, '=') as Add_Date
  9. --FROM (
  10. -- SELECT
  11. -- dbo.[FN_SPLIT](Details, 1, '|') as Name,
  12. -- dbo.[FN_SPLIT](Details, 2, '|') as Age,
  13. -- dbo.[FN_SPLIT](Details, 3, '|') as Job,
  14. -- dbo.[FN_SPLIT](Details, 4, '|') as Location,
  15. -- dbo.[FN_SPLIT](Details, 5, '|') as Add_Date
  16. -- FROM HR) data
  17.  
  18.  
  19.  
  20. CREATE FUNCTION [dbo].[FN_SPLIT] ( --SELECT DBO.FN_SPLIT('TEST1 , TEST2', 2, ',')
  21. @s varchar(512),
  22. @i int,
  23. @sep char(1) = ',')
  24. RETURNS varchar(512)
  25. AS
  26. BEGIN
  27. DECLARE @Ret VARCHAR(512);
  28.  
  29. WITH Pieces(pn, start, stop) AS (
  30. SELECT 1, 1, CHARINDEX(@sep, @s)
  31. UNION ALL
  32. SELECT pn + 1, stop + 1, CHARINDEX(@sep, @s, stop + 1)
  33. FROM Pieces
  34. WHERE stop > 0
  35. )
  36. SELECT @Ret =
  37. RTRIM(SUBSTRING(@s, start, CASE WHEN stop > 0 THEN stop-start ELSE 512 END))
  38. FROM Pieces
  39. WHERE pn = @i
  40.  
  41. RETURN @Ret;
  42. END

Searching in ASP.Net GridView Multiple Parameters

Searching in ASP.Net GridView Multiple Parameters

cs
  1. private void BindData()
  2. {
  3.     string conString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
  4.     string query = "select * from customers where (name like '%' + @name + '%' or @name = '') and (age = @age or @age= 0) and (mobile = @mobile or @mobile= '') and (city = @city or @city= '')";
  5.     SqlCommand cmd = new SqlCommand(query);
  6.     cmd.Parameters.AddWithValue("@name", txtName.Text.Trim());
  7.     cmd.Parameters.AddWithValue("@age", txtAge.Text.Trim() == "" ? 0 txtAge.Text.Trim());
  8.     cmd.Parameters.AddWithValue("@mobile", txtMobile.Text.Trim());
  9.     cmd.Parameters.AddWithValue("@city", ddlCity.SelectedIndex > 0 ? ddlCity.SelectedValue : "");
  10.     using (SqlConnection con = new SqlConnection(conString))
  11.     {
  12.         using (SqlDataAdapter sda = new SqlDataAdapter())
  13.         {
  14.             cmd.Connection = con; sda.SelectCommand = cmd;
  15.             using (DataSet ds = new DataSet())
  16.             {
  17.                 sda.Fill(ds);
  18.                 GridView1.DataSource = ds;
  19.                 GridView1.DataBind();
  20.             }
  21.         }
  22.     }
  23. }
  24.  


ref url:

CRM2011 How to get Options Set Value in DataBase?

CRM2011 How to get Options Set Value in DataBase?



StringMap table
  1. SELECT AttributeValue, Value
  2. FROM StringMap
  3. WHERE ObjectTypeCode = 1 -- entity type code 1 = account
  4. AND AttributeName = 'statecode' --fieldname


Entity Type Code
  1. SELECT EntityId, Name, ObjectTypeCode
  2. FROM [MetadataSchema].[Entity]
  3. ORDER BY Name

2015年12月8日 星期二

CRM2011 Get Entity/Attribute's Display Name from CRM database

CRM2011 Get Entity/Attribute's Display Name from CRM database
從資料庫取得CRM2011 Attribute Display Name







  1. SELECT EntityView.Name AS EntityName, LocalizedLabelView_1.Label AS EntityDisplayName,
  2. AttributeView.Name AS AttributeName, LocalizedLabelView_2.Label AS AttributeDisplayName
  3. FROM LocalizedLabelView AS LocalizedLabelView_2 INNER JOIN
  4. AttributeView ON LocalizedLabelView_2.ObjectId = AttributeView.AttributeId RIGHT OUTER JOIN
  5. EntityView INNER JOIN
  6. LocalizedLabelView AS LocalizedLabelView_1 ON EntityView.EntityId = LocalizedLabelView_1.ObjectId ON
  7. AttributeView.EntityId = EntityView.EntityId
  8. WHERE LocalizedLabelView_1.ObjectColumnName = 'LocalizedName'
  9. AND LocalizedLabelView_2.ObjectColumnName = 'DisplayName'
  10. AND LocalizedLabelView_1.LanguageId = '1033'
  11. AND LocalizedLabelView_2.LanguageId = '1033'
  12. AND EntityView.Name IN ('Account','Contact')
  13. ORDER BY EntityName, AttributeName


reference from: http://jianwang.blogspot.tw/2009/03/get-entityattributes-display-name-from.html