protected void Page_Load(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; cnn = new SqlConnection(connetionString); cnn.Open(); int vw_id = Convert.ToInt32(Session["ids"]); SqlCommand cmd = new SqlCommand("Show_New_Content", cnn); cmd.CommandType = System.Data.CommandType.StoredProcedure; SqlDataAdapter sda = new SqlDataAdapter("Show_New_Content", cnn); sda.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@viewer_id", vw_id)); cmd.Parameters.Add(new SqlParameter("@content_id", DBNull.Value)); sda.SelectCommand.Parameters.Add(new SqlParameter("@viewer_id", vw_id)); sda.SelectCommand.Parameters.Add(new SqlParameter("@content_id", DBNull.Value)); DataTable t1 = new DataTable(); sda.Fill(t1); Table1.DataSource = t1; Table1.DataBind(); cnn.Close(); }
protected void Page_Load(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; cnn = new SqlConnection(connetionString); cnn.Open(); int vw_id = Convert.ToInt32(Session["ids"]); String sql1 = "Select original_content_id,date,text FROM Comment WHERE Viewer_id=" + "'" + vw_id + "'"; SqlDataAdapter sda1 = new SqlDataAdapter(sql1, cnn); DataTable t1 = new DataTable(); sda1.Fill(t1); Table1.DataSource = t1; Table1.DataBind(); String sql2 = "Select C.*,O.rating From Original_Content O INNER JOIN Content C ON O.ID=C.ID"; SqlDataAdapter sda2 = new SqlDataAdapter(sql2, cnn); DataTable t2 = new DataTable(); sda2.Fill(t2); Table2.DataSource = t2; Table2.DataBind(); cnn.Close(); }
private void LoadTableDemo() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Age", typeof(string)); for (int i = 0; i < 3; i++) { int id = i + 1; DataRow row = dt.NewRow(); row["Id"] = id; row["Name"] = "Name " + id; row["Age"] = id * 10; dt.Rows.Add(row); } Table1.DataSource = dt; Table1.DataBind(); Table2.DataSource = dt; Table2.DataBind(); Table3.DataSource = dt; Table3.DataBind(); Table4.DataSource = dt; Table4.DataBind(); Table5.DataSource = dt; Table5.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { DataTable tb = new DataTable(); tb.Load(DB.ExecuteReader(DB.connectionStringSqlServer, CommandType.Text, "Select * from usuario")); Table1.DataBind(); }
protected void LinkButtonAdd_Click(object sender, EventArgs e) { String peopleid = LabelPeopleId.Text; People.add(peopleid, TextBoxName.Text.Trim(), TextBoxUrl.Text.Trim()); GridViewPeople.DataBind(); Table1.DataBind(); TextBoxName.Text = ""; TextBoxUrl.Text = ""; }
public void newq() { string GameID = Session["gameIDSession"].ToString(); XmlDocument myDoc = new XmlDocument(); myDoc.Load(Server.MapPath("/tree/game.xml")); int qcount = (myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count) + 1; ViewState["quastionIDviewstate"] = qcount; cleaneow(); Table1.DataBind(); GridView1edit.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString)) { con.Open(); int Viewer_id = (int)Session["ID"]; SqlCommand cmd = new SqlCommand("Apply_Existing_Request", con); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter sqlda = new SqlDataAdapter("select category_type,subcategory_name, type,uploaded_at from (existing_request ER inner join original_content OC on ER.original_content_id = OC.id) inner join content C on C.id = OC.id Where OC.rating = 4 OR OC.rating = 5", con); DataTable dtb1 = new DataTable(); sqlda.Fill(dtb1); Table1.DataBind(); cmd.Parameters.AddWithValue("@original_content_id", ItemID); cmd.Parameters.AddWithValue("@viewer_id", Viewer_id); con.Close(); } }
protected void Page_Load(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; cnn = new SqlConnection(connetionString); cnn.Open(); String sql = "Select C.*,O.rating From Original_Content O INNER JOIN Content C ON O.ID=C.ID WHERE O.rating=4 OR O.rating=5"; SqlDataAdapter sda = new SqlDataAdapter(sql, cnn); DataTable t1 = new DataTable(); sda.Fill(t1); Table1.DataSource = t1; Table1.DataBind(); cnn.Close(); }
protected void CreateRadioBtn(object sender, EventArgs e) { var variables = MgrVariable.GetVariables(RunningVariableDrp.SelectedValue, ChangingVariableDrp.SelectedValue, string.IsNullOrEmpty(ddlThemes.SelectedValue)?0: int.Parse(ddlThemes.SelectedValue), (int)Utils.GetLanguage()); i = variables.Count; ReportVM result; if (Request.QueryString["RepId"] != null) { result = MgrReports.GetReportsByID(int.Parse(Request.QueryString["RepId"]), (int)Utils.GetLanguage()); } else { result = null; } object sub; PropertyInfo propertyInfo; if (variables.Count > 0) { var subcode = MgrSubCode.GetAllSubCode(variables[0].VariableID, (int)Utils.GetLanguage()); for (int x = 0; x < variables.Count; x++) { SelectLbl.Visible = true; subcode = MgrSubCode.GetAllSubCode(variables[x].GeneralID, (int)Utils.GetLanguage()); RadioButtonList VariablesRadio = new RadioButtonList(); ListItem item1; item1 = new ListItem(variables[x].GeneralName, variables[x].VariableColumnName); ListItem item2; item2 = new ListItem("All", variables[x].VariableColumnName); VariablesRadio.Items.Add(item1); VariablesRadio.Items.Add("unselect"); VariablesRadio.ID = "VariablesRadio" + x; VariablesRadio.RepeatDirection = RepeatDirection.Horizontal; VariablesRadio.SelectedIndexChanged += this.VariablesRadio_SelectedIndexChanged; VariablesRadio.AutoPostBack = true; VariablesRadio.Font.Bold = true; VariablesRadio.ForeColor = Color.DarkBlue; RadioButtonList VariablesValueRadio = new RadioButtonList(); foreach (var item in subcode) { VariablesValueRadio.Items.Add(new ListItem(item.Name, item.SubID)); } // VariablesValueRadio.DataSource = subcode; // VariablesValueRadio.DataTextField = "Name"; // VariablesValueRadio.DataValueField = "SubID"; VariablesValueRadio.ID = "VariablesValueChck" + x; VariablesValueRadio.RepeatDirection = RepeatDirection.Horizontal; VariablesValueRadio.RepeatColumns = 5; VariablesValueRadio.CellPadding = 10; // VariablesValueRadio.DataBind(); VariablesValueRadio.Visible = false; TableCell tcell = new TableCell(); if (result != null) { propertyInfo = result.GetType().GetProperty(variables[x].VariableColumnName); sub = propertyInfo.GetValue(result, null); if (sub != null) { if (sub.ToString().Substring(0, 3) == variables[x].GeneralID) { VariablesRadio.SelectedValue = variables[x].VariableColumnName; VariablesValueRadio.SelectedValue = sub.ToString(); VariablesValueRadio.Visible = true; } } } tcell.Controls.Add(VariablesRadio); tcell.Controls.Add(VariablesValueRadio); TableRow tr = new TableRow(); tr.Cells.Add(tcell); Table1.Rows.Add(tr); Table1.DataBind(); } } }
protected void Button3_Click(object sender, EventArgs e) { string GameID = Session["gameIDSession"].ToString(); string qustionid = ViewState["quastionIDviewstate"].ToString(); XmlDocument myDoc = new XmlDocument(); myDoc.Load(Server.MapPath("/tree/game.xml")); if (Convert.ToInt32(qustionid) > myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count) { XmlElement myNewaquestionNode = myDoc.CreateElement("question"); myNewaquestionNode.SetAttribute("id", qustionid); XmlElement myNewaquestionTextNode = myDoc.CreateElement("questionText"); myNewaquestionNode.AppendChild(myNewaquestionTextNode); XmlElement myNewimgNode = myDoc.CreateElement("img"); myNewaquestionNode.AppendChild(myNewimgNode); XmlElement myNewanswerNode = myDoc.CreateElement("answers"); myNewaquestionNode.AppendChild(myNewanswerNode); XmlNode myqthis = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]/questions"); XmlNode Firstq = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]/questions/question").Item(0); myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]/questions").InsertBefore(myNewaquestionNode, Firstq); } XmlNode titleq = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/questionText"); titleq.InnerXml = Server.UrlEncode(((TextBox)FindControl("mainqtb")).Text); XmlNode titlimg = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/img"); if ((((FileUpload)FindControl("FileUpload1")).PostedFile.ContentType.Contains("image")) || (((ImageButton)FindControl("ImageforUpload1")).ImageUrl.Contains("thisuplod") && (((HiddenField)FindControl("hdnfldVariable1")).Value != "false"))) { if (((FileUpload)FindControl("FileUpload1")).PostedFile.ContentType.Contains("image")) { string fileType = ((FileUpload)FindControl("FileUpload1")).PostedFile.ContentType; if (fileType.Contains("image")) //בדיקה האם הקובץ שהוכנס הוא תמונה { // הנתיב המלא של הקובץ עם שמו האמיתי של הקובץ string fileName = ((FileUpload)FindControl("FileUpload1")).PostedFile.FileName; // הסיומת של הקובץ string endOfFileName = fileName.Substring(fileName.LastIndexOf(".")); //לקיחת הזמן האמיתי למניעת כפילות בתמונות string myTime = DateTime.Now.ToString("dd_MM_yy-HH_mm_ss"); string mynamee = "thisuplod"; // חיבור השם החדש עם הסיומת של הקובץ string imageNewName = mynamee + myTime + 1 + endOfFileName; //שמירה של הקובץ לספרייה בשם החדש שלו // Bitmap המרת הקובץ שיתקבל למשתנה מסוג System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(((FileUpload)FindControl("FileUpload1")).PostedFile.InputStream); //קריאה לפונקציה המקטינה את התמונה //אנו שולחים לה את התמונה שלנו בגירסאת הביטמאפ ואת האורך והרוחב שאנו רוצים לתמונה החדשה System.Drawing.Image objImage = FixedSize(bmpPostedImage, 150, 150); //שמירה של הקובץ לספרייה בשם החדש שלו objImage.Save(Server.MapPath(imagesLibPath) + imageNewName); //הצגה של הקובץ החדש מהספרייה ((ImageButton)FindControl("ImageforUpload1")).ImageUrl = imagesLibPath + imageNewName; //XmlNode pic = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]//answer[" + optionnum + "]"); titlimg.InnerXml = "/uploadedFiles" + "/" + imageNewName; } } if (((ImageButton)FindControl("ImageforUpload1")).ImageUrl.Contains("thisuplod")) { if (((HiddenField)FindControl("hdnfldVariable1")).Value != "false") { titlimg.InnerXml = ((ImageButton)FindControl("ImageforUpload1")).ImageUrl; } } } else { titlimg.InnerXml = ""; } XmlNode myqqthis = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]"); XmlNode node = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers"); node.ParentNode.RemoveChild(node); XmlElement myNewanswersNode = myDoc.CreateElement("answers"); myqqthis.AppendChild(myNewanswersNode); int optionnum = 1; for (int l = 1; l <= 7; l++) { string d = Convert.ToString(l); string dd = Convert.ToString(l + 1); if ((((TextBox)FindControl("ATextBox" + d)).Text != "") || (((FileUpload)FindControl("FileUpload" + dd)).PostedFile.ContentType.Contains("image")) || (((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl.Contains("thisuplod") && (((HiddenField)FindControl("hdnfldVariable" + dd)).Value != "false"))) { XmlElement myNewanswerNode = myDoc.CreateElement("answer"); myNewanswerNode.SetAttribute("feedback", Convert.ToString(((CheckBox)FindControl("ACheckBox" + d)).Checked)); myNewanswerNode.SetAttribute("AnsType", "text"); if (((TextBox)FindControl("ATextBox" + d)).Text != "") { myNewanswerNode.InnerXml = Server.UrlEncode(((TextBox)FindControl("ATextBox" + d)).Text); myNewanswerNode.Attributes["AnsType"].InnerText = "text"; } if (((FileUpload)FindControl("FileUpload" + dd)).PostedFile.ContentType.Contains("image")) { string fileType = ((FileUpload)FindControl("FileUpload" + dd)).PostedFile.ContentType; if (fileType.Contains("image")) //בדיקה האם הקובץ שהוכנס הוא תמונה { // הנתיב המלא של הקובץ עם שמו האמיתי של הקובץ string fileName = ((FileUpload)FindControl("FileUpload" + dd)).PostedFile.FileName; // הסיומת של הקובץ string endOfFileName = fileName.Substring(fileName.LastIndexOf(".")); //לקיחת הזמן האמיתי למניעת כפילות בתמונות string myTime = DateTime.Now.ToString("dd_MM_yy-HH_mm_ss"); string mynamee = "thisuplod"; // חיבור השם החדש עם הסיומת של הקובץ string imageNewName = mynamee + myTime + dd + endOfFileName; // Bitmap המרת הקובץ שיתקבל למשתנה מסוג System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(((FileUpload)FindControl("FileUpload" + dd)).PostedFile.InputStream); //קריאה לפונקציה המקטינה את התמונה //אנו שולחים לה את התמונה שלנו בגירסאת הביטמאפ ואת האורך והרוחב שאנו רוצים לתמונה החדשה System.Drawing.Image objImage = FixedSize(bmpPostedImage, 230, 230); //שמירה של הקובץ לספרייה בשם החדש שלו objImage.Save(Server.MapPath(imagesLibPath) + imageNewName); //הצגה של הקובץ החדש מהספרייה ((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl = imagesLibPath + imageNewName; //XmlNode pic = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]//answer[" + optionnum + "]"); myNewanswerNode.InnerXml = "/uploadedFiles" + "/" + imageNewName; myNewanswerNode.Attributes["AnsType"].InnerText = "picture"; ((TextBox)FindControl("ATextBox" + d)).Enabled = false; } } if (((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl.Contains("thisuplod")) { if (((HiddenField)FindControl("hdnfldVariable" + dd)).Value != "false") { myNewanswerNode.InnerXml = ((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl; myNewanswerNode.Attributes["AnsType"].InnerText = "picture"; ((TextBox)FindControl("ATextBox" + d)).Enabled = false; } } XmlNode myqthis = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers"); myqthis.AppendChild(myNewanswerNode); optionnum++; } } myDoc.Save(Server.MapPath("/tree/game.xml")); cleaneow(); GridView1edit.DataBind(); Table1.DataBind(); refreshrow(); newq(); }
public void refreshrow() { string GameID = Session["gameIDSession"].ToString(); string qustionid = ViewState["quastionIDviewstate"].ToString(); XmlDocument myDoc = new XmlDocument(); myDoc.Load(Server.MapPath("/tree/game.xml")); Qnum.Text = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count.ToString(); if (myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count >= 6) { ifqnum.Text = "<i class='fas fa-check'></i>"; } else { ifqnum.Text = "<i class='fas fa-times'></i>"; } int dl = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers/answer").Count; for (int l = 1; l <= 7; l++) { string d = Convert.ToString(l); string dd = Convert.ToString(l + 1); ((TextBox)FindControl("ATextBox" + d)).Text = ""; ((CheckBox)FindControl("ACheckBox" + d)).Checked = false; ((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl = "~/Images/ImagePlaceholder.png"; ((TextBox)FindControl("ATextBox" + d)).Enabled = true; ((ImageButton)FindControl("ImageforUpload" + dd)).Enabled = true; ((ImageButton)FindControl("ImageforUpload" + dd)).Style.Add("opacity", "1"); } ((TextBox)FindControl("mainqtb")).Text = Server.UrlDecode(myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/questionText").InnerText); if (myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/img").InnerXml != "") { ((ImageButton)FindControl("ImageforUpload1")).ImageUrl = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/img").InnerXml; } else { ((ImageButton)FindControl("ImageforUpload1")).ImageUrl = "/Images/ImagePlaceholder.png"; } for (int l = 1; l <= dl; l++) { string d = Convert.ToString(l); string dd = Convert.ToString(l + 1); if ((myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers/answer[" + d + "]")).Attributes["AnsType"].InnerText == "text") { ((TextBox)FindControl("ATextBox" + d)).Text = Server.UrlDecode(myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers/answer[" + d + "]").InnerXml); ((ImageButton)FindControl("ImageforUpload" + dd)).Enabled = false; ((ImageButton)FindControl("ImageforUpload" + dd)).Style.Add("opacity", "0.3"); ((ImageButton)FindControl("ImageforUpload" + dd)).CssClass = "ImageButtongrid"; } else { ((ImageButton)FindControl("ImageforUpload" + dd)).ImageUrl = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers/answer[" + d + "]").InnerXml; ((TextBox)FindControl("ATextBox" + d)).Enabled = false; } ((CheckBox)FindControl("ACheckBox" + d)).Checked = Convert.ToBoolean(myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[@id=" + qustionid + "]/answers/answer[" + d + "]/@feedback").InnerXml); Table1.DataBind(); } int qcount = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count; for (int q = 1; q <= qcount; q++) { XmlNode thisq = myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]//question[" + q + "]"); thisq.Attributes["id"].InnerText = q.ToString(); } myDoc.SelectSingleNode("/RootTree/game[@GameCode=" + GameID + "]/questions").Attributes["Quantity"].InnerText = myDoc.SelectNodes("/RootTree/game[@GameCode=" + GameID + "]//question").Count.ToString(); myDoc.Save(Server.MapPath("/tree/game.xml")); }
protected void GridViewPeople_RowDeleted(object sender, GridViewDeletedEventArgs e) { Table1.DataBind(); }
public void buttonOClicked(object sender, EventArgs args) { string contentname; string contenttype; contentname = original_content_name.Text; contenttype = original_content_type.Text; if (original_content_name.Text == "") { contentname = ""; } if (original_content_type.Text == "") { contenttype = ""; } string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; //connetionString = @"Data Source=localhost;Initial Catalog=continuems3"; cnn = new SqlConnection(connetionString); cnn.Open(); SqlCommand cmd = new SqlCommand("Original_Content_Search", cnn); SqlDataAdapter c = new SqlDataAdapter("Original_Content_Search", cnn); c.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; // 2. set the command object so it knows to execute a stored procedure cmd.CommandType = System.Data.CommandType.StoredProcedure; // 3. add parameter to command, which will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@typename", contenttype)); cmd.Parameters.Add(new SqlParameter("@categoryname", contentname)); c.SelectCommand.Parameters.Add(new SqlParameter("@typename", contenttype)); c.SelectCommand.Parameters.Add(new SqlParameter("@categoryname", contentname)); DataTable tab = new DataTable(); c.Fill(tab); Table1.DataSource = tab; Table1.DataBind(); SqlDataReader rd; rd = cmd.ExecuteReader(); rd.Close(); // using (var da = new SqlDataAdapter(cmd)) //{ // cmd.CommandType = CommandType.StoredProcedure; // da.Fill(table1); // } //cmd.Parameters.Add("@e_id", System.Data.SqlDbType.Int).Direction = System.Data.ParameterDirection.Output; //int e_id = 0; // execute the command // using (SqlDataReader rdr = cmd.ExecuteReader()) //{ // e_id = Convert.ToInt32(cmd.Parameters["@e_id"].Value); // } //command.dispose(); cnn.Close(); // Session["ID"] = e_id; //Response.Redirect("Default.aspx"); }