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.

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