Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void NoOfQuestion(object sender, EventArgs e)
- {
- int no = Convert.ToInt32(DropDownList1.Text);
- for (int i = 0; i < no; i++)
- {
- TextBox TxtBoxU = new TextBox();
- TextBox TxtBoxE = new TextBox();
- TextBox TxtBoxR = new TextBox();
- Label lblU = new Label();
- Label lblE = new Label();
- Label lblR = new Label();
- TxtBoxU.ID = "TextBoxU" + i.ToString();
- TxtBoxE.ID = "TextBoxE" + i.ToString();
- TxtBoxR.ID = "TextBoxR" + i.ToString();
- TxtBoxU.Style["Float"] = "Left";
- TxtBoxU.Style["Top"] = "25px";
- TxtBoxU.Style["Left"] = "100px";
- TxtBoxU.Style["Height"] = "80px";
- TxtBoxU.Style["Width"] = "700px";
- TxtBoxU.Style["Margin-left"] = "42px";
- TxtBoxU.TextMode = TextBoxMode.MultiLine;
- TxtBoxE.Style["Float"] = "Left";
- TxtBoxE.Style["Top"] = "25px";
- TxtBoxE.Style["Left"] = "100px";
- TxtBoxE.Style["Height"] = "60px";
- TxtBoxE.Style["Width"] = "100px";
- TxtBoxE.Style["Margin-left"] = "20px";
- TxtBoxE.TextMode = TextBoxMode.MultiLine;
- TxtBoxR.Style["Float"] = "Left";
- TxtBoxR.Style["Top"] = "25px";
- TxtBoxR.Style["Left"] = "100px";
- TxtBoxR.Style["Height"] = "60px";
- TxtBoxR.Style["Width"] = "100px";
- TxtBoxR.Style["Margin-left"] = "45px";
- TxtBoxR.TextMode = TextBoxMode.MultiLine;
- lblU.ID = "LabelU" + i.ToString();
- lblE.ID = "LabelE" + i.ToString();
- lblR.ID = "LabelR" + i.ToString();
- lblU.Style["Float"] = "Left";
- lblU.Style["Top"] = "25px";
- lblU.Style["Left"] = "100px";
- lblE.Style["Float"] = "Left";
- lblE.Style["Top"] = "25px";
- lblE.Style["Left"] = "100px";
- lblR.Style["Float"] = "Left";
- lblR.Style["Top"] = "25px";
- lblR.Style["Left"] = "100px";
- lblU.Text = "Ques " + (i + 1).ToString() + " : ";
- lblE.Text = "Test Cases " + (i + 1).ToString() + " : ";
- lblR.Text = "Output "+ (i + 1).ToString() + " : " ;
- Area1.Controls.Add(lblU);
- Area1.Controls.Add(TxtBoxU);
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(lblE);
- Area1.Controls.Add(TxtBoxE);
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(lblR);
- Area1.Controls.Add(TxtBoxR);
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- Area1.Controls.Add(new LiteralControl("<br>"));
- }
- }
- protected void CreateComp(object sender, EventArgs e)
- {
- HttpCookie cookie = Request.Cookies["mycookie"];
- int no = Convert.ToInt32(DropDownList1.Text);
- if (CheckBox1.Checked==true && cookie != null)
- {
- string name = cookie["name"].ToUpper();
- string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
- using (SqlConnection con = new SqlConnection(CS))
- {
- SqlCommand cmd = new SqlCommand("spCreatCon", con);
- cmd.CommandType = CommandType.StoredProcedure;
- SqlParameter compname = new SqlParameter("@CompId",TextBox1.Text);
- SqlParameter org = new SqlParameter("@UserComp",name);
- cmd.Parameters.Add(compname);
- cmd.Parameters.Add(org);
- con.Open();
- int ReturnCode = (int)cmd.ExecuteScalar();
- if (ReturnCode == -1)
- {
- Label5.Text = "Competition already Created";
- }
- else
- {
- for (int i = 0; i < no; i++)
- {
- string txtR = "TextBoxR"+i.ToString();
- string txtU = "TextBoxU" + i.ToString();
- string txtE = "TextBoxE"+i.ToString();
- TextBox txt1 = (TextBox)Area1.FindControl(txtU);
- TextBox txt2 = (TextBox)Area1.FindControl(txtE);
- TextBox txt3 = (TextBox)Area1.FindControl(txtR);
- SqlCommand cmd1 = new SqlCommand("CreatCom", con);
- cmd1.CommandType = CommandType.StoredProcedure;
- SqlParameter compnam = new SqlParameter("@CompId", TextBox1.Text);
- SqlParameter Ques = new SqlParameter("@Ques", txt1.Text.ToString());
- SqlParameter Tcases = new SqlParameter("@Tcases", txt2.Text);
- SqlParameter Tresults = new SqlParameter("@Tresult", txt3.Text);
- cmd.Parameters.Add(compnam);
- cmd.Parameters.Add(Ques);
- cmd.Parameters.Add(Tcases);
- cmd.Parameters.Add(Tresults);
- con.Open();
- int Return = (int)cmd.ExecuteScalar();
- if (Return == -1)
- {
- Label5.Text = "One Of Question Already Exists";
- SqlCommand cmd2 = new SqlCommand("deltbl", con);
- cmd2.CommandType = CommandType.StoredProcedure;
- SqlParameter compnam2 = new SqlParameter("@CompId", TextBox1.Text);
- cmd.Parameters.Add(compnam2);
- con.Open();
- }
- else
- {
- Label5.Text = "Competition Created Successfully";
- }
- }
- }
- }
- }
- else
- {
- Label5.Text = "please click the check box to proceed";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement