Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.63 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Web;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using RSosa_C40_A03.App_Code;
  9. using System.Diagnostics;
  10. using System.Data;
  11. using AjaxControlToolkit;
  12.  
  13.  
  14. public partial class MakeReservation : System.Web.UI.Page
  15. {
  16. protected void Page_Load(object sender, EventArgs e)
  17. {
  18. Customer customer;
  19.  
  20. decimal custNum;
  21. if (Session["Customer"] != null)
  22. {
  23. customer = (Customer)(Session["Customer"]);
  24. custNum = customer.CustomerNumber;
  25.  
  26. PetDAL cd = new PetDAL();
  27. DataTable dt = new DataTable();
  28.  
  29. dt = cd.GetPetByCustNum(Convert.ToDecimal(custNum));
  30.  
  31.  
  32.  
  33. AccordionPane[] apArray = new AccordionPane[dt.Rows.Count];
  34.  
  35. Table[] petTables = new Table[dt.Rows.Count];
  36. CheckBox[] chkBoarding = new CheckBox[dt.Rows.Count];
  37. TextBox[] txtWalk = new TextBox[dt.Rows.Count];
  38. TextBox[] txtGrooming = new TextBox[dt.Rows.Count];
  39. TextBox[] txtPlaytime = new TextBox[dt.Rows.Count];
  40. TextBox[] txtMedName = new TextBox[dt.Rows.Count];
  41. TextBox[] txtMedDosage = new TextBox[dt.Rows.Count];
  42. TextBox[] txtFoodFreq = new TextBox[dt.Rows.Count];
  43. TextBox[] txtFoodQuan = new TextBox[dt.Rows.Count];
  44. DropDownList[] ddlBrand = new DropDownList[dt.Rows.Count];
  45.  
  46. Label[] lblBoarding = new Label[dt.Rows.Count];
  47. Label[] lblWalk = new Label[dt.Rows.Count];
  48. Label[] lblGrooming = new Label[dt.Rows.Count];
  49. Label[] lblPlaytime = new Label[dt.Rows.Count];
  50. Label[] lblMed = new Label[dt.Rows.Count];
  51. Label[] lblMedName = new Label[dt.Rows.Count];
  52. Label[] lblMedDosage = new Label[dt.Rows.Count];
  53. Label[] lblFood = new Label[dt.Rows.Count];
  54. Label[] lblFoodFreq = new Label[dt.Rows.Count];
  55. Label[] lblFoodQuan = new Label[dt.Rows.Count];
  56. Label[] lblFoodBrand = new Label[dt.Rows.Count];
  57.  
  58. Label[] lblTitle = new Label[dt.Rows.Count];
  59.  
  60. for (int i = 0; i < dt.Rows.Count; ++i)
  61. {
  62. apArray[i] = new AccordionPane();
  63. apArray[i].ID = "appArray" + i;
  64. petTables[i] = new Table();
  65. chkBoarding[i] = new CheckBox();
  66. txtWalk[i] = new TextBox();
  67. txtGrooming[i] = new TextBox();
  68. txtPlaytime[i] = new TextBox();
  69. txtMedName[i] = new TextBox();
  70. txtMedDosage[i] = new TextBox();
  71. txtFoodFreq[i] = new TextBox();
  72. txtFoodQuan[i] = new TextBox();
  73. ddlBrand[i] = new DropDownList();
  74. lblTitle[i] = new Label();
  75. lblBoarding[i] = new Label();
  76. lblBoarding[i].Text = "Boarding";
  77. lblWalk[i] = new Label();
  78. lblWalk[i].Text = "Walking Frequency";
  79. lblGrooming[i] = new Label();
  80. lblGrooming[i].Text = "Grooming Frequency";
  81. lblPlaytime[i] = new Label();
  82. lblPlaytime[i].Text = "Playtime Frequency";
  83. lblMed[i] = new Label();
  84. lblMed[i].Text = "Medication";
  85. lblMedName[i] = new Label();
  86. lblMedName[i].Text = "Name";
  87. lblMedDosage[i] = new Label();
  88. lblMedDosage[i].Text = "Dosage";
  89. lblFood[i] = new Label();
  90. lblFood[i].Text = "Food";
  91. lblFoodFreq[i] = new Label();
  92. lblFoodFreq[i].Text = "Frequency";
  93. lblFoodQuan[i] = new Label();
  94. lblFoodQuan[i].Text = "Quantity";
  95. lblFoodBrand[i] = new Label();
  96. lblFoodBrand[i].Text = "Brand";
  97. }
  98.  
  99. for (int i = 0; i < dt.Rows.Count; ++i)
  100. {
  101. DropDownList1.Items.Add(dt.Rows[i]["pet_name"].ToString());
  102. DropDownList1.Items[i].Value = dt.Rows[i]["pet_number"].ToString();
  103.  
  104. lblTitle[i].Text = dt.Rows[i]["pet_name"].ToString();
  105.  
  106. apArray[i].HeaderContainer.Controls.Add(lblTitle[i]);
  107.  
  108. petTables[i].CssClass = "petReservationTable";
  109.  
  110. TableRow[] rows = new TableRow[8];
  111.  
  112. for (int n = 0; n < 8; ++n)
  113. {
  114. rows[n] = new TableRow();
  115. }
  116.  
  117. TableCell[] cells = new TableCell[20];
  118.  
  119. for (int n = 0; n < 20; ++n)
  120. {
  121. cells[n] = new TableCell();
  122. }
  123.  
  124. cells[0].Controls.Add(lblBoarding[i]);
  125. cells[1].Controls.Add(chkBoarding[i]);
  126. cells[2].Controls.Add(lblWalk[i]);
  127. cells[3].Controls.Add(txtWalk[i]);
  128. cells[4].Controls.Add(lblGrooming[i]);
  129. cells[5].Controls.Add(txtGrooming[i]);
  130. cells[6].Controls.Add(lblPlaytime[i]);
  131. cells[7].Controls.Add(txtPlaytime[i]);
  132. cells[8].Controls.Add(lblMed[i]);
  133. cells[9].Controls.Add(lblMedName[i]);
  134. cells[10].Controls.Add(txtMedName[i]);
  135. cells[11].Controls.Add(lblMedDosage[i]);
  136. cells[12].Controls.Add(txtMedDosage[i]);
  137. cells[13].Controls.Add(lblFood[i]);
  138. cells[14].Controls.Add(lblFoodFreq[i]);
  139. cells[15].Controls.Add(txtFoodFreq[i]);
  140. cells[16].Controls.Add(lblFoodQuan[i]);
  141. cells[17].Controls.Add(txtFoodQuan[i]);
  142. cells[18].Controls.Add(lblFoodBrand[i]);
  143. cells[19].Controls.Add(ddlBrand[i]);
  144.  
  145. rows[0].Cells.Add(cells[0]);
  146. rows[0].Cells.Add(cells[1]);
  147. rows[1].Cells.Add(cells[2]);
  148. rows[1].Cells.Add(cells[3]);
  149. rows[2].Cells.Add(cells[4]);
  150. rows[2].Cells.Add(cells[5]);
  151. rows[3].Cells.Add(cells[6]);
  152. rows[3].Cells.Add(cells[7]);
  153. rows[4].Cells.Add(cells[8]);
  154. rows[5].Cells.Add(cells[9]);
  155. rows[5].Cells.Add(cells[10]);
  156. rows[5].Cells.Add(cells[11]);
  157. rows[5].Cells.Add(cells[12]);
  158. rows[6].Cells.Add(cells[13]);
  159. rows[7].Cells.Add(cells[14]);
  160. rows[7].Cells.Add(cells[15]);
  161. rows[7].Cells.Add(cells[16]);
  162. rows[7].Cells.Add(cells[17]);
  163. rows[7].Cells.Add(cells[18]);
  164. rows[7].Cells.Add(cells[19]);
  165.  
  166. petTables[i].Rows.AddAt(0, rows[0]);
  167. petTables[i].Rows.AddAt(1, rows[1]);
  168. petTables[i].Rows.AddAt(2, rows[2]);
  169. petTables[i].Rows.AddAt(3, rows[3]);
  170. petTables[i].Rows.AddAt(4, rows[4]);
  171. petTables[i].Rows.AddAt(5, rows[5]);
  172. petTables[i].Rows.AddAt(6, rows[6]);
  173. petTables[i].Rows.AddAt(7, rows[7]);
  174.  
  175. apArray[i].ContentContainer.Controls.Add(petTables[i]);
  176.  
  177. Accordion1.Panes.Add(apArray[i]);
  178.  
  179. }
  180.  
  181.  
  182.  
  183.  
  184. }
  185. }
  186.  
  187. protected void btnAccount_Click(object sender, EventArgs e)
  188. {
  189. Response.Redirect("OverviewEmployee.aspx");
  190. }
  191. protected void cvStartDate_ServerValidate(object source, ServerValidateEventArgs args)
  192. {
  193. DateTime startdate;
  194.  
  195. startdate = DateTime.ParseExact(txtStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
  196.  
  197.  
  198. if (startdate >= DateTime.Now)
  199. args.IsValid = true;
  200.  
  201.  
  202. else
  203. args.IsValid = false;
  204. }
  205.  
  206. protected void cvEndDate_ServerValidate(object source, ServerValidateEventArgs args)
  207. {
  208. DateTime startdate;
  209. startdate = DateTime.ParseExact(txtStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
  210.  
  211.  
  212. DateTime enddate;
  213. enddate = DateTime.ParseExact(txtEndDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
  214.  
  215. if (enddate >= startdate)
  216. args.IsValid = true;
  217.  
  218.  
  219. else
  220. args.IsValid = false;
  221. }
  222. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement