Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

342 lines
8.5 KiB

  1. using System;
  2. using System.Collections;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Web;
  7. using System.Web.SessionState;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.HtmlControls;
  11. using System.Data.SqlClient;
  12. namespace XReports
  13. {
  14. /// <summary>
  15. /// Summary description for countbydate.
  16. /// </summary>
  17. public class countbydate : System.Web.UI.Page
  18. {
  19. protected System.Web.UI.WebControls.Calendar Calendar1;
  20. protected System.Web.UI.WebControls.Table tblUploads;
  21. private void Page_Load(object sender, System.EventArgs e)
  22. {
  23. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  24. SqlCommand cm = new SqlCommand();
  25. SqlDataReader dr;
  26. DateTime dDate = DateTime.Now;
  27. int rowCtr=0;
  28. int cellCtr=0;
  29. int cellCnt = 4;
  30. double dbDays = -7;
  31. if(Page.IsPostBack == false)
  32. {
  33. cn.Open();
  34. cm.CommandType = CommandType.StoredProcedure;
  35. cm.CommandTimeout = 240;
  36. cm.CommandText = "spCountByDate";
  37. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  38. dDate = dDate.AddDays(dbDays);
  39. cm.Parameters[0].Value = dDate.ToShortDateString();
  40. cm.Connection = cn;
  41. dr = cm.ExecuteReader();
  42. // dr.Read();
  43. Calendar1.SelectedDate = dDate;
  44. //for(rowCtr=0; rowCtr <= rowCnt; rowCtr++)
  45. do
  46. {
  47. TableRow tRow = new TableRow();
  48. tblUploads.Rows.Add(tRow);
  49. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  50. {
  51. TableCell tCell = new TableCell();
  52. if(rowCtr == 0)
  53. {
  54. switch(cellCtr)
  55. {
  56. case 1 :
  57. tCell.Text = "Date Uploaded";
  58. break;
  59. case 2 :
  60. tCell.Text = "Total";
  61. break;
  62. case 3 :
  63. tCell.Text = "OS Name";
  64. break;
  65. case 4 :
  66. tCell.Text = "OS Version";
  67. break;
  68. default:
  69. tCell.Text = "";
  70. break;
  71. }
  72. tCell.Style["font-size"] = "small";
  73. }
  74. else
  75. {
  76. switch(cellCtr)
  77. {
  78. case 1 :
  79. if(dr.IsDBNull(0))
  80. {
  81. tCell.Text = "";
  82. }
  83. else
  84. {
  85. tCell.Text = dr.GetDateTime(0).ToShortDateString();
  86. }
  87. break;
  88. case 2 :
  89. tCell.Text = dr.GetInt32(1).ToString();
  90. break;
  91. case 3 :
  92. tCell.Text = dr.GetString(2);
  93. break;
  94. case 4 :
  95. tCell.Text = dr.GetString(3);
  96. break;
  97. default:
  98. tCell.Text = "0";
  99. break;
  100. }
  101. tCell.Style["background-color"] = "white";
  102. tCell.Style["font-size"] = "small-x";
  103. tCell.Style["color"] = "#6487dc";
  104. tCell.Style["font-weight"] = "Bold";
  105. }
  106. tCell.Style["font-family"] = "Tahoma";
  107. tRow.Cells.Add(tCell);
  108. }
  109. rowCtr++;
  110. }while(dr.Read() == true);
  111. }
  112. }
  113. #region Web Form Designer generated code
  114. override protected void OnInit(EventArgs e)
  115. {
  116. //
  117. // CODEGEN: This call is required by the ASP.NET Web Form Designer.
  118. //
  119. InitializeComponent();
  120. base.OnInit(e);
  121. }
  122. /// <summary>
  123. /// Required method for Designer support - do not modify
  124. /// the contents of this method with the code editor.
  125. /// </summary>
  126. private void InitializeComponent()
  127. {
  128. this.Calendar1.VisibleMonthChanged += new System.Web.UI.WebControls.MonthChangedEventHandler(this.Calendar1_VisibleMonthChanged);
  129. this.Calendar1.SelectionChanged += new System.EventHandler(this.Calendar1_SelectionChanged);
  130. this.Load += new System.EventHandler(this.Page_Load);
  131. }
  132. #endregion
  133. private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
  134. {
  135. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  136. SqlCommand cm = new SqlCommand();
  137. SqlDataReader dr;
  138. DateTime dDate = DateTime.Now;
  139. int rowCtr=0;
  140. int cellCtr=0;
  141. int cellCnt = 4;
  142. cn.Open();
  143. cm.CommandType = CommandType.StoredProcedure;
  144. cm.CommandTimeout = 240;
  145. cm.CommandText = "spCountByDate";
  146. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  147. dDate = Calendar1.SelectedDate;
  148. cm.Parameters[0].Value = dDate.ToShortDateString();
  149. cm.Connection = cn;
  150. dr = cm.ExecuteReader();
  151. // dr.Read();
  152. Calendar1.SelectedDate = dDate;
  153. //for(rowCtr=0; rowCtr <= rowCnt; rowCtr++)
  154. do
  155. {
  156. TableRow tRow = new TableRow();
  157. tblUploads.Rows.Add(tRow);
  158. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  159. {
  160. TableCell tCell = new TableCell();
  161. if(rowCtr == 0)
  162. {
  163. switch(cellCtr)
  164. {
  165. case 1 :
  166. tCell.Text = "Date Uploaded";
  167. break;
  168. case 2 :
  169. tCell.Text = "Total";
  170. break;
  171. case 3 :
  172. tCell.Text = "OS Name";
  173. break;
  174. case 4 :
  175. tCell.Text = "OS Version";
  176. break;
  177. default:
  178. tCell.Text = "";
  179. break;
  180. }
  181. tCell.Style["font-size"] = "small";
  182. }
  183. else
  184. {
  185. switch(cellCtr)
  186. {
  187. case 1 :
  188. if(dr.IsDBNull(0))
  189. {
  190. tCell.Text = "";
  191. }
  192. else
  193. {
  194. tCell.Text = dr.GetDateTime(0).ToShortDateString();
  195. }
  196. break;
  197. case 2 :
  198. tCell.Text = dr.GetInt32(1).ToString();
  199. break;
  200. case 3 :
  201. tCell.Text = dr.GetString(2);
  202. break;
  203. case 4 :
  204. tCell.Text = dr.GetString(3);
  205. break;
  206. default:
  207. tCell.Text = "0";
  208. break;
  209. }
  210. tCell.Style["background-color"] = "white";
  211. tCell.Style["font-size"] = "small-x";
  212. tCell.Style["color"] = "#6487dc";
  213. tCell.Style["font-weight"] = "Bold";
  214. }
  215. tCell.Style["font-family"] = "Tahoma";
  216. tRow.Cells.Add(tCell);
  217. }
  218. rowCtr++;
  219. }while(dr.Read() == true);
  220. }
  221. private void Calendar1_VisibleMonthChanged(object sender, System.Web.UI.WebControls.MonthChangedEventArgs e)
  222. {
  223. SqlConnection cn = new SqlConnection("Persist Security Info=False;Pwd=ocarpts@2;User ID=ocarpts;Initial Catalog=SnapShot;Data Source=TimRagain06");
  224. SqlCommand cm = new SqlCommand();
  225. SqlDataReader dr;
  226. DateTime dDate = DateTime.Now;
  227. int rowCtr=0;
  228. int cellCtr=0;
  229. int cellCnt = 4;
  230. cn.Open();
  231. cm.CommandType = CommandType.StoredProcedure;
  232. cm.CommandTimeout = 240;
  233. cm.CommandText = "spCountByDate";
  234. cm.Parameters.Add("@sDate", System.Data.SqlDbType.VarChar, 12);
  235. dDate = Calendar1.SelectedDate;
  236. cm.Parameters[0].Value = dDate.ToShortDateString();
  237. cm.Connection = cn;
  238. dr = cm.ExecuteReader();
  239. // dr.Read();
  240. Calendar1.SelectedDate = dDate;
  241. //for(rowCtr=0; rowCtr <= rowCnt; rowCtr++)
  242. do
  243. {
  244. TableRow tRow = new TableRow();
  245. tblUploads.Rows.Add(tRow);
  246. for (cellCtr = 1; cellCtr <= cellCnt; cellCtr++)
  247. {
  248. TableCell tCell = new TableCell();
  249. if(rowCtr == 0)
  250. {
  251. switch(cellCtr)
  252. {
  253. case 1 :
  254. tCell.Text = "Date Uploaded";
  255. break;
  256. case 2 :
  257. tCell.Text = "Total";
  258. break;
  259. case 3 :
  260. tCell.Text = "OS Name";
  261. break;
  262. case 4 :
  263. tCell.Text = "OS Version";
  264. break;
  265. default:
  266. tCell.Text = "";
  267. break;
  268. }
  269. tCell.Style["font-size"] = "small";
  270. }
  271. else
  272. {
  273. switch(cellCtr)
  274. {
  275. case 1 :
  276. if(dr.IsDBNull(0))
  277. {
  278. tCell.Text = "";
  279. }
  280. else
  281. {
  282. tCell.Text = dr.GetDateTime(0).ToShortDateString();
  283. }
  284. break;
  285. case 2 :
  286. tCell.Text = dr.GetInt32(1).ToString();
  287. break;
  288. case 3 :
  289. tCell.Text = dr.GetString(2);
  290. break;
  291. case 4 :
  292. tCell.Text = dr.GetString(3);
  293. break;
  294. default:
  295. tCell.Text = "0";
  296. break;
  297. }
  298. tCell.Style["background-color"] = "white";
  299. tCell.Style["font-size"] = "small-x";
  300. tCell.Style["color"] = "#6487dc";
  301. tCell.Style["font-weight"] = "Bold";
  302. }
  303. tCell.Style["font-family"] = "Tahoma";
  304. tRow.Cells.Add(tCell);
  305. }
  306. rowCtr++;
  307. }while(dr.Read() == true);
  308. }
  309. }
  310. }