/// <summary> /// Writes Top 10 Language Projects, get LanguageID from Session /// </summary> protected void WriteTopLanguageLinks() { //Checks the LanguageID Session Variable to get links int languageID = 1; if (Session["LanguageID"] != null) { languageID = (int)Session["LanguageID"]; } languageIDdiv.Controls.Add(new LiteralControl("Top " + Session["LanguageText"] + " Examples")); languageIDdiv.Controls.Add(new LiteralControl("<br/>")); foreach (DataRow row in SQL_Functions.GetTopLanguageProjects(languageID).Rows) { HtmlGenericControl a = new HtmlGenericControl("a"); string url = Request.Url.ToString(); url = url.Split('?')[0]; a.Attributes.Add("href", url + "?XID=" + row["ID"]); a.InnerText = row["project_name"].ToString(); languageIDdiv.Controls.Add(a); languageIDdiv.Controls.Add(new LiteralControl("<br/>")); } }
protected void WriteFeedNewest() { foreach (DataRow row in SQL_Functions.GetFeedAnnoucements().Rows) { HtmlGenericControl FeedContainer = new HtmlGenericControl("div"); FeedContainer.Attributes.Add("class", "feed-container"); HtmlGenericControl AnnoucTitle = new HtmlGenericControl("div"); AnnoucTitle.Attributes.Add("class", "feed-header"); AnnoucTitle.Controls.Add(new LiteralControl(row["annoucement_title"].ToString())); FeedContainer.Controls.Add(AnnoucTitle); HtmlGenericControl hr = new HtmlGenericControl("div"); hr.Attributes.Add("class", "hr-div"); FeedContainer.Controls.Add(hr); HtmlGenericControl PostedDate = new HtmlGenericControl("div"); PostedDate.Attributes.Add("class", "post-date"); PostedDate.Controls.Add(new LiteralControl(row["post_date"].ToString())); FeedContainer.Controls.Add(PostedDate); HtmlGenericControl AnnoucDescrp = new HtmlGenericControl("div"); AnnoucDescrp.Attributes.Add("class", "feed-description"); AnnoucDescrp.InnerHtml = row["annoucement_description"].ToString(); FeedContainer.Controls.Add(AnnoucDescrp); FeedContentpnl.Controls.Add(FeedContainer); } }
/// <summary> /// Creates the Homepage main content /// </summary> protected void WriteHomePage() { foreach (DataRow row in SQL_Functions.GetNewestExamples().Rows) { //TODO Create Newest Code Examples Div Area } //TODO Think of other information to show on the front page }
protected bool InsertIntoDB() { if (CheckPage()) { int FileID = 0; if (Fileupload.HasFile) { FileID = SQL_Functions.InsertProjectFile(Fileupload.FileName, "/Files/" + Fileupload.FileName, 1); } int ProjID = SQL_Functions.InsertProject(Nametxt.Text, Descrtxt.Text, Convert.ToInt16(Languageddl.SelectedValue), FileID); //TODO Add in Dynamic Examples } return(true); }
/// <summary> /// Creates Link Well for Top 10 Newest Projects /// </summary> protected void WriteTopNewLinks() { topLinks.Controls.Add(new LiteralControl("Top Examples")); topLinks.Controls.Add(new LiteralControl("<br/>")); foreach (DataRow row in SQL_Functions.GetNewestExamples().Rows) { HtmlGenericControl a = new HtmlGenericControl("a"); string url = Request.Url.ToString(); url = url.Split('?')[0]; a.Attributes.Add("href", url + "?XID=" + row["ID"]); a.InnerText = row["project_name"].ToString(); topLinks.Controls.Add(a); topLinks.Controls.Add(new LiteralControl("<br/>")); } }
/// <summary> /// Login Button Event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Submitbtn_Click(object sender, EventArgs e) { if (SQL_Functions.CheckLogin(UserNametxt.Text, Passwordtxt.Text) == true) { UserNametxt.Attributes.Add("class", ""); Passwordtxt.Attributes.Add("class", ""); Errorlb.Visible = false; Global_Functions.SetSessionUp(UserNametxt.Text); CheckAuth(); } else { UserNametxt.Attributes.Add("class", "error"); Passwordtxt.Attributes.Add("class", "error"); Errorlb.Visible = true; } }
protected void WriteVersionNewest() { foreach (DataRow row in SQL_Functions.GetNewestVersions().Rows) { HtmlGenericControl FeedContainer = new HtmlGenericControl("div"); FeedContainer.Attributes.Add("class", "feed-container"); HtmlGenericControl AnnoucTitle = new HtmlGenericControl("div"); AnnoucTitle.Attributes.Add("class", "feed-header"); AnnoucTitle.Controls.Add(new LiteralControl(row["version_title"].ToString())); FeedContainer.Controls.Add(AnnoucTitle); HtmlGenericControl hr = new HtmlGenericControl("div"); hr.Attributes.Add("class", "hr-div"); FeedContainer.Controls.Add(hr); HtmlGenericControl infowrapper = new HtmlGenericControl("div"); infowrapper.Attributes.Add("class", "padding"); HtmlGenericControl PostedDate = new HtmlGenericControl("div"); PostedDate.Attributes.Add("class", "post-date"); PostedDate.Controls.Add(new LiteralControl(row["post_date"].ToString())); infowrapper.Controls.Add(PostedDate); HtmlGenericControl Version = new HtmlGenericControl("div"); Version.Attributes.Add("class", "version"); Version.Controls.Add(new LiteralControl(row["version"].ToString())); infowrapper.Controls.Add(Version); infowrapper.Controls.Add(new LiteralControl("<div class:\"clear\"></div>")); FeedContainer.Controls.Add(infowrapper); HtmlGenericControl AnnoucDescrp = new HtmlGenericControl("div"); AnnoucDescrp.Attributes.Add("class", "feed-description"); AnnoucDescrp.InnerHtml = row["version_description"].ToString(); FeedContainer.Controls.Add(AnnoucDescrp); FeedContentpnl.Controls.Add(FeedContainer); } }
protected void addANewRecord_Click(object sender, EventArgs e) { //set the variables to the Textbox equivalent values fName = firstName.Text; lName = LastName.Text; AddressString = address.Text; CityName = city.Text; zipNumber = int.Parse(zipcode.Text); annualIncome = float.Parse(income.Text); customerEmail = email.Text; SQL_Functions func = new SQL_Functions(); //func.createCustomerTable(); func.insertIntoCustomers(fName, lName, AddressString, CityName, zipNumber, annualIncome, customerEmail); //func.create_check_table(8,"woo","hoo","hoot",9,7.0f,"yo","lo","hoe",92); ////Make a connection to the Database and notify if there was an error. //try //{ // sqlconn.Open(); // if (sqlconn.State == System.Data.ConnectionState.Open) // { // Debug.WriteLine("Success"); // } // else // { // Debug.WriteLine("FAIL"); // } //} //catch(Exception ex) //{ // Debug.WriteLine("There was an Error : \n" + ex); //} //// //string sqlQuery = string.Format("SELECT database_id FROM sys.databases WHERE Name = '{0}'", "Employee_DB"); }
/// <summary> /// Post button that submits to DB /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Postbtn_Click(object sender, EventArgs e) { if (CheckValid()) { string PostDate = Request.Form[txtDate.UniqueID]; PostDate = DateTime.Parse(PostDate).ToString(); if (SQL_Functions.InsertVersion(Titletxt.Text, CKEditor1.Text, versiontxt.Text, PostDate)) { Postbtn.Visible = false; Errorlb.Visible = true; Errorlb.Text = "Annoucement Posted"; EmptyPage(); } else { Postbtn.Visible = true; Errorlb.Visible = true; Errorlb.Text = "Annoucement Post Failed"; } } }
/// <summary> /// Fills in a Code Example if an ID is avaliable /// </summary> /// <param name="CodeExampleID"></param> protected void WriteCodeExample(int CodeExampleID) { DataTable dt = SQL_Functions.GetCodeExample(CodeExampleID); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { HtmlGenericControl Container = new HtmlGenericControl("div"); Container.Attributes.Add("class", "code-container"); //Add A CSS Class //Adds Header to Container HtmlGenericControl Header = new HtmlGenericControl("span"); Header.Attributes.Add("class", "code-header"); Header.InnerText = row["project_name"].ToString(); Container.Controls.Add(Header); //Horizontal Line Container.Controls.Add(new LiteralControl("<hr/>")); HtmlGenericControl p = new HtmlGenericControl("p"); p.InnerText = row["project_description"].ToString(); Container.Controls.Add(p); //Gets A code Snippet Example Block foreach (DataRow ExampleRow in SQL_Functions.GetCodeSamples((int)row["ID"]).Rows) { HtmlGenericControl ExampleHeader = new HtmlGenericControl("span"); ExampleHeader.InnerText = (string)ExampleRow["example_title"]; ExampleHeader.Attributes.Add("class", "example-header"); Container.Controls.Add(new LiteralControl("<br/><br/>")); Container.Controls.Add(ExampleHeader); Container.Controls.Add(new LiteralControl("<br/>")); HtmlGenericControl ExampleDescr = new HtmlGenericControl("p"); ExampleDescr.InnerText = (string)ExampleRow["example_description"]; Container.Controls.Add(ExampleDescr); HtmlGenericControl preCon = new HtmlGenericControl("pre"); preCon.Attributes.Add("class", "pre-scrollable"); HtmlGenericControl codeCont = new HtmlGenericControl("code"); codeCont.Attributes.Add("class", row["language_text"].ToString()); codeCont.InnerText = (string)ExampleRow["example_body"]; preCon.Controls.Add(codeCont); Container.Controls.Add(preCon); Container.Controls.Add(new LiteralControl("<br/><br/>")); } Container.Controls.Add(new LiteralControl("<hr/> ")); //Adds in download links foreach (DataRow FileRow in SQL_Functions.GetCodeFiles((int)row["ID"]).Rows) { HtmlGenericControl FileHeader = new HtmlGenericControl("span"); FileHeader.InnerText = "Download the Source Files Here:"; Container.Controls.Add(FileHeader); Container.Controls.Add(new LiteralControl("<br/><br/>")); HtmlGenericControl a = new HtmlGenericControl("a"); a.Attributes.Add("href", FileRow["web_location"].ToString()); a.InnerText = FileRow["file_name"].ToString(); Container.Controls.Add(a); } contentpnl.Controls.Add(Container); Global_Functions.SetLanguageSession((int)row["language_id"], (string)row["language_text"]); } } else { WriteErrorPage(); } }