Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. protected void NoOfQuestion(object sender, EventArgs e)
  2. {
  3. int no = Convert.ToInt32(DropDownList1.Text);
  4.  
  5. for (int i = 0; i < no; i++)
  6. {
  7. TextBox TxtBoxU = new TextBox();
  8. TextBox TxtBoxE = new TextBox();
  9. TextBox TxtBoxR = new TextBox();
  10.  
  11. Label lblU = new Label();
  12. Label lblE = new Label();
  13. Label lblR = new Label();
  14.  
  15. TxtBoxU.ID = "TextBoxU" + i.ToString();
  16. TxtBoxE.ID = "TextBoxE" + i.ToString();
  17. TxtBoxR.ID = "TextBoxR" + i.ToString();
  18.  
  19. TxtBoxU.Style["Float"] = "Left";
  20. TxtBoxU.Style["Top"] = "25px";
  21. TxtBoxU.Style["Left"] = "100px";
  22. TxtBoxU.Style["Height"] = "80px";
  23. TxtBoxU.Style["Width"] = "700px";
  24. TxtBoxU.Style["Margin-left"] = "42px";
  25. TxtBoxU.TextMode = TextBoxMode.MultiLine;
  26.  
  27. TxtBoxE.Style["Float"] = "Left";
  28. TxtBoxE.Style["Top"] = "25px";
  29. TxtBoxE.Style["Left"] = "100px";
  30. TxtBoxE.Style["Height"] = "60px";
  31. TxtBoxE.Style["Width"] = "100px";
  32. TxtBoxE.Style["Margin-left"] = "20px";
  33. TxtBoxE.TextMode = TextBoxMode.MultiLine;
  34.  
  35. TxtBoxR.Style["Float"] = "Left";
  36. TxtBoxR.Style["Top"] = "25px";
  37. TxtBoxR.Style["Left"] = "100px";
  38. TxtBoxR.Style["Height"] = "60px";
  39. TxtBoxR.Style["Width"] = "100px";
  40. TxtBoxR.Style["Margin-left"] = "45px";
  41. TxtBoxR.TextMode = TextBoxMode.MultiLine;
  42.  
  43. lblU.ID = "LabelU" + i.ToString();
  44. lblE.ID = "LabelE" + i.ToString();
  45. lblR.ID = "LabelR" + i.ToString();
  46.  
  47. lblU.Style["Float"] = "Left";
  48. lblU.Style["Top"] = "25px";
  49. lblU.Style["Left"] = "100px";
  50.  
  51. lblE.Style["Float"] = "Left";
  52. lblE.Style["Top"] = "25px";
  53. lblE.Style["Left"] = "100px";
  54.  
  55. lblR.Style["Float"] = "Left";
  56. lblR.Style["Top"] = "25px";
  57. lblR.Style["Left"] = "100px";
  58.  
  59. lblU.Text = "Ques " + (i + 1).ToString() + " : ";
  60. lblE.Text = "Test Cases " + (i + 1).ToString() + " : ";
  61. lblR.Text = "Output "+ (i + 1).ToString() + " : " ;
  62.  
  63. Area1.Controls.Add(lblU);
  64. Area1.Controls.Add(TxtBoxU);
  65. Area1.Controls.Add(new LiteralControl("<br>"));
  66. Area1.Controls.Add(new LiteralControl("<br>"));
  67. Area1.Controls.Add(new LiteralControl("<br>"));
  68. Area1.Controls.Add(new LiteralControl("<br>"));
  69. Area1.Controls.Add(new LiteralControl("<br>"));
  70.  
  71. Area1.Controls.Add(lblE);
  72. Area1.Controls.Add(TxtBoxE);
  73. Area1.Controls.Add(new LiteralControl("<br>"));
  74. Area1.Controls.Add(new LiteralControl("<br>"));
  75. Area1.Controls.Add(new LiteralControl("<br>"));
  76. Area1.Controls.Add(new LiteralControl("<br>"));
  77. Area1.Controls.Add(lblR);
  78. Area1.Controls.Add(TxtBoxR);
  79. Area1.Controls.Add(new LiteralControl("<br>"));
  80. Area1.Controls.Add(new LiteralControl("<br>"));
  81. Area1.Controls.Add(new LiteralControl("<br>"));
  82. Area1.Controls.Add(new LiteralControl("<br>"));
  83. Area1.Controls.Add(new LiteralControl("<br>"));
  84. Area1.Controls.Add(new LiteralControl("<br>"));
  85.  
  86. }
  87. }
  88. protected void CreateComp(object sender, EventArgs e)
  89. {
  90. HttpCookie cookie = Request.Cookies["mycookie"];
  91. int no = Convert.ToInt32(DropDownList1.Text);
  92. if (CheckBox1.Checked==true && cookie != null)
  93. {
  94. string name = cookie["name"].ToUpper();
  95. string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
  96. using (SqlConnection con = new SqlConnection(CS))
  97. {
  98. SqlCommand cmd = new SqlCommand("spCreatCon", con);
  99. cmd.CommandType = CommandType.StoredProcedure;
  100. SqlParameter compname = new SqlParameter("@CompId",TextBox1.Text);
  101. SqlParameter org = new SqlParameter("@UserComp",name);
  102.  
  103. cmd.Parameters.Add(compname);
  104. cmd.Parameters.Add(org);
  105.  
  106. con.Open();
  107. int ReturnCode = (int)cmd.ExecuteScalar();
  108.  
  109. if (ReturnCode == -1)
  110. {
  111. Label5.Text = "Competition already Created";
  112. }
  113. else
  114. {
  115. for (int i = 0; i < no; i++)
  116. {
  117. string txtR = "TextBoxR"+i.ToString();
  118. string txtU = "TextBoxU" + i.ToString();
  119. string txtE = "TextBoxE"+i.ToString();
  120.  
  121. TextBox txt1 = (TextBox)Area1.FindControl(txtU);
  122. TextBox txt2 = (TextBox)Area1.FindControl(txtE);
  123. TextBox txt3 = (TextBox)Area1.FindControl(txtR);
  124.  
  125. SqlCommand cmd1 = new SqlCommand("CreatCom", con);
  126. cmd1.CommandType = CommandType.StoredProcedure;
  127.  
  128. SqlParameter compnam = new SqlParameter("@CompId", TextBox1.Text);
  129. SqlParameter Ques = new SqlParameter("@Ques", txt1.Text.ToString());
  130. SqlParameter Tcases = new SqlParameter("@Tcases", txt2.Text);
  131. SqlParameter Tresults = new SqlParameter("@Tresult", txt3.Text);
  132.  
  133. cmd.Parameters.Add(compnam);
  134. cmd.Parameters.Add(Ques);
  135. cmd.Parameters.Add(Tcases);
  136. cmd.Parameters.Add(Tresults);
  137.  
  138. con.Open();
  139. int Return = (int)cmd.ExecuteScalar();
  140.  
  141. if (Return == -1)
  142. {
  143. Label5.Text = "One Of Question Already Exists";
  144. SqlCommand cmd2 = new SqlCommand("deltbl", con);
  145. cmd2.CommandType = CommandType.StoredProcedure;
  146. SqlParameter compnam2 = new SqlParameter("@CompId", TextBox1.Text);
  147. cmd.Parameters.Add(compnam2);
  148. con.Open();
  149.  
  150. }
  151. else
  152. {
  153. Label5.Text = "Competition Created Successfully";
  154. }
  155. }
  156.  
  157. }
  158. }
  159. }
  160. else
  161. {
  162. Label5.Text = "please click the check box to proceed";
  163. }
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement