public static void Main(string[] args) { Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Namespaces In C#."); first_space.namespace_c1 fc = new first_space.namespace_c1(); second_space.namespace_c1 sc = new second_space.namespace_c1(); fc.func(); sc.func(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Use Namespaces In Our Code With Using Directives..."); //namespace içerisindeki classın objectini doğrudan class adıyla oluşturabiliyoruz. //namespace adını kullanmıyoruz çünki yukarıdaki using directive ile namespace kodumuza ekledik. //böylece namespace adını kullanmadan direk class adıyla instance ımızı oluşturuyoruz. abc fobj = new abc(); efg sobj = new efg(); fobj.func(); sobj.func(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Nested Namespaces..."); xyz prnt = new xyz(); wwww chld = new wwww(); prnt.func(); chld.func(); Console.ReadKey(); }
protected void Button3_Click(object sender, EventArgs e) { if (status.Value == "") { } else { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from wallpost", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); DataRow dr = ds.Tables[0].NewRow(); dr[1] = Session["uname"].ToString(); dr[2] = status.Value; dr[3] = System.DateTime.Now.ToString(); dr[5] = 0; ds.Tables[0].Rows.Add(dr); ad.Update(ds); cn.Close(); } status.Value = ""; wall.Controls.Clear(); abc A = new abc(); A.noti(Session["uname"].ToString(), 0); fillpost(); }
protected void send_comment(object sender, EventArgs e) { TextBox t = (TextBox)sender; string wid = t.ID; string text = t.Text; SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from comment order by doc desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); DataRow dr = ds.Tables[0].NewRow(); dr[1] = wid; dr[2] = Session["uname"].ToString(); dr[3] = text; dr[4] = System.DateTime.Now.ToString(); ds.Tables[0].Rows.Add(dr); ad.Update(ds); cn.Close(); t.Text = ""; abc A = new abc(); A.noti(Session["uname"].ToString(), 2); wall.Controls.Clear(); fillpost(); }
protected void b_click(object sender, EventArgs e) { Button b = (Button)sender; string send = Session["uname"].ToString(); string rec = b.CommandName; string dos = System.DateTime.Now.ToString(); SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from follow", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); DataRow dr = ds.Tables[0].NewRow(); dr[1] = send; dr[2] = rec; dr[3] = dos; ds.Tables[0].Rows.Add(dr); ad.Update(ds); cn.Close(); abc A = new abc(); A.noti(Session["uname"].ToString(), 3); }
public abc Clone(abc instanceToClone) { abc result = new abc(); result.i = instanceToClone.i; result.a = instanceToClone.a; }
public static void infDemoTest() { Console.WriteLine("Hello Interfaces"); infDemo inf = new infDemo(); inf.pqr(); Console.WriteLine("new class infDemo"); abc infa = (abc)inf; //interface infa.xyz(); Console.WriteLine("interface abc"); Sample s = new Sample(); s.xyz(); Console.WriteLine("new class Sample"); abc infb = (abc)s; infb.xyz(); Console.WriteLine("interface abc"); abc infc = new infDemo(); //new keywork interface infc.xyz(); abc[] infArray = { new infDemo(), new Sample() }; for (int i = 0; i < infArray.Length; i++) { infArray[i].xyz(); } }
static void Main(string[] args) { abc fc = new abc(); efg sc = new efg(); fc.func(); sc.func(); Console.ReadKey(); }
static void Main(string[] args) { abc fc = new abc(); abc2 sc = new abc2(); fc.func(); sc.func(); }
static void Main(string[] args) { abc fc = new abc(); efg sc = new efg(); fc.func(); sc.func(); }
static void Main(string[] args) { //var check = new string[] { "100", "200" }; //args = new string[] { "100" }; //P.ThrowAndLog() // .When(args, "args").IsNull() // .Or(args.Length, "args.Length").IsLessThan(1) // .Or().IsLessOrEqualThan(1) // .Or().IsGreaterThan(2) // .Or().IsGreaterOrEqualThan(1) // .Or(args[0], "args[0]").InArray(new string[] { "100", "200" }) // .Or().IsEqual("100") // .Or().NotInArray(new string[] { "100", "200" }); string val1; var test = new Test(); using (var reader = XmlReaderEx.CreateFromFile("~Src.Sample.exe.config")) { reader .AddParse("/configuration/appSettings/add", () => val1 = reader.GetAttribute("value")) .AddParse("/configuration/test", () => { test.pp = reader.GetAttribute("pp"); test.cc = reader.ReadAttrToBoolean("cc"); }) .AddParse("/configuration/test/abc", () => { var abc = new abc(); abc.Value = reader.ReadAttrToInt32("value"); reader.Attach(abc); test.abcs.Add(abc); }) .AddParse("/configuration/test/abc/a", () => { var abc = (abc) reader.GetAttach(); var a = new a(); a.a0 = reader.ReadAttrToInt32("a0"); abc.A = a; }) .AddParse("/configuration/test/abc/b", () => { var abc = (abc) reader.GetAttach(); var b = new b(); b.b0 = reader.ReadAttrToInt32("b0"); abc.B = b; }) .AddParse("/configuration/test/abc/c", () => { var abc = (abc) reader.GetAttach(); var c = new c(); c.c0 = reader.ReadAttrToInt32("c0"); abc.C = c; }) .Go(); } }
static void Main() { var strs = Enumerable.Range(0, 1000).Select(i => i.ToString()); var myAbc = new abc <string>( xs => xs.OrderByDescending(x => x.Length).ThenByDescending(x => x.Substring(1)) ); myAbc.someMethod(strs); //5, 6, 7, 8, 9, 10, 11, 12, 13, 14 myAbc.someMethod(strs, true); //14, 13, 12, 11, 10, 5, 6, 7, 8, 9 }
static void Main(string[] args) { Console.WriteLine("Hello World!"); abc ob = new abc(); def obj = new def(); obj.function(); ob.function(); Console.ReadKey(); }
public static void MainMethod(string[] args) { abc obj = new abc(); obj.func(); xyz obj2 = new xyz(); obj2.func(); Console.ReadKey(); }
void fillfriend() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from friend where (receiver='" + Session["uname"].ToString() + "'or sender='" + Session["uname"].ToString() + "') and status='1' order by dor desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); a = new ArrayList(); r = new returnname(); foreach (DataRow dr in ds.Tables[0].Rows) { if (dr[1].ToString() == Session["uname"].ToString()) { a.Add(dr[2].ToString()); } else { a.Add(dr[1].ToString()); } } foreach (object o in a) { LinkButton l = new LinkButton(); l.Text = o.ToString(); abc A = new abc(); int t = A.chkpicstat(o.ToString()); if (t == 0) { if (A.chkgender(o.ToString())) { friend.Controls.Add(new LiteralControl("<li><a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(o.ToString()) + "'><img src='temp/b.jpg' alt='Profile Pics' width='55' height='60'></a>")); } else { friend.Controls.Add(new LiteralControl("<li><a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(o.ToString()) + "'><img src='temp/g.jpg' alt='Profile Pics' width='55' height='60'></a>")); } } else { friend.Controls.Add(new LiteralControl("<li><a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(o.ToString()) + "'><img src='Account/" + o.ToString() + "/p.jpg' alt='Profile Pics' width='55' height='60'></a>")); } friend.Controls.Add(new LiteralControl("</li>")); } cn.Close(); }
protected void Button2_Click(object sender, EventArgs e) { try { if ((Path.GetExtension(FileUpload1.PostedFile.FileName).Substring(1) == "jpg") || (Path.GetExtension(FileUpload1.PostedFile.FileName).Substring(1) == "JPG")) { abc A = new abc(); int t = A.chkpicstat(Session["uname"].ToString()); if (t == 0) { if (A.chkgender(Session["uname"].ToString())) { fi = new FileInfo(Server.MapPath("temp") + "\\b.jpg"); fi.CopyTo(Server.MapPath("Profileimg" + "\\" + Session["uname"].ToString()) + "\\p" + i + ".jpg"); } else { fi = new FileInfo(Server.MapPath("temp") + "\\g.jpg"); fi.CopyTo(Server.MapPath("Profileimg" + "\\" + Session["uname"].ToString()) + "\\p" + i + ".jpg"); } } else { fi = new FileInfo(Server.MapPath("Account" + "\\" + Session["uname"].ToString()) + "\\p.jpg"); string nn = Server.MapPath("Profileimg" + "\\" + Session["uname"].ToString()); DirectoryInfo d = new DirectoryInfo(nn); FileInfo[] f = d.GetFiles(); j = f.Count(); k = i + j; fi.CopyTo(Server.MapPath("Profileimg" + "\\" + Session["uname"].ToString()) + "\\p" + k + ".jpg"); } FileUpload1.SaveAs(Server.MapPath("Account" + "\\" + Session["uname"].ToString() + "\\p.jpg")); SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); cn.Open(); string str = "update reg set PStatus=1 where Email='" + Session["uname"].ToString() + "'"; SqlCommand cmd = new SqlCommand(str, cn); cmd.ExecuteNonQuery(); cn.Close(); } else { alert1.Visible = true; Label3.Text = "OOPs! Only jpg Format images can be uploaded"; } } catch { alert1.Visible = true; Label3.Text = "OOPs! Choose the image you want to upload"; } }
public static void Main() { System.Console.WriteLine("Hello Interfaces"); InterfaceDemo8 refDemo = new InterfaceDemo8(); abc refabc = refDemo; refabc.xyz(); def refdef = refDemo; refdef.pqr(); // refdef.xyz(); /* try uncommenting line */ }
public override bool Equals(object obj) { abc other = obj as abc; if (object.ReferenceEquals(null, other)) { return(false); } else { return(string.Equals(firstName, other.firstName) && string.Equals(lastName, other.lastName)); } }
// custom equality comparer public override bool Equals(object other) { if (other is abc) { abc comparer = other as abc; if (comparer != null) { return(string.Equals(comparer.firstName, this.firstName) && string.Equals(comparer.lastName, this.lastName)); } } return(base.Equals(other)); }
protected void like_post(object sender, EventArgs e) { LinkButton l = (LinkButton)sender; string wid = l.CommandName; string pliked = string.Empty; int clike = 0; int i = 1; SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); cn.Open(); string str = "select * from wallpost where wid='" + wid + "'"; SqlCommand cmd = new SqlCommand(str, cn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr[4].ToString() == "") { pliked = Session["uname"].ToString(); } else { pliked = dr[4].ToString() + '/' + Session["uname"].ToString(); } clike = Convert.ToInt32(dr[5].ToString()) + i; } dr.Close(); cmd.ExecuteNonQuery(); cn.Close(); SqlConnection cn1 = new SqlConnection(); cn1.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); cn1.Open(); string str1 = "update wallpost set peopleliked=@Peopleliked,likecount=@Likecount where wid='" + wid + "'"; SqlCommand cmd1 = new SqlCommand(str1, cn1); SqlParameter p1 = new SqlParameter("Peopleliked", pliked); SqlParameter p2 = new SqlParameter("Likecount", clike); cmd1.Parameters.Add(p1); cmd1.Parameters.Add(p2); cmd1.ExecuteNonQuery(); cn1.Close(); abc A = new abc(); A.noti(Session["uname"].ToString(), 1); }
void fillpendingreq() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from friend where receiver='" + Session["uname"].ToString() + "' and status='0' order by fid desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); r = new returnname(); foreach (DataRow dr in ds.Tables[0].Rows) { Label l = new Label(); string s = r.name(dr[1].ToString()); l.Text = s; request.Controls.Add(new LiteralControl("<div class='panel panel-default relative text-center'>")); A = new abc(); int t = A.chkpicstat(dr[1].ToString()); if (t == 0) { if (A.chkgender(dr[1].ToString())) { request.Controls.Add(new LiteralControl("<img src='temp/b.jpg' class='media-object' height='50' width='60' style='margin-top:10px'>")); } else { request.Controls.Add(new LiteralControl("<img src='temp/g.jpg' class='media-object' height='50' width='60' style='margin-top:10px'>")); } } else { request.Controls.Add(new LiteralControl("<img src='Account/" + dr[1].ToString() + "/p.jpg' class='media-object' height='50' width='60' style='margin-top:10px'>")); } request.Controls.Add(l); request.Controls.Add(new LiteralControl(" <div class='panel-body panel-boxed text-center'><div class='rating'>")); string str1 = "<a href='accept.aspx?reqid=" + dr[0].ToString() + "' class='btn btn-primary'>Accept</a>"; request.Controls.Add(new LiteralControl(" ")); string str2 = "<a href='reject.aspx?reqid=" + dr[0].ToString() + "' class='btn btn-danger'>Reject</a>"; request.Controls.Add(new LiteralControl(str1)); request.Controls.Add(new LiteralControl(" ")); request.Controls.Add(new LiteralControl(str2)); request.Controls.Add(new LiteralControl("</div><hr/></div></div>")); request.Controls.Add(new LiteralControl("<br/>")); } cn.Close(); }
public void notmsg() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from notification order by nid desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); int c = 0; foreach (DataRow dr in ds.Tables[0].Rows) { c++; if (a.Contains(dr[1].ToString())) { abc A = new abc(); int t1 = A.chkpicstat(dr[1].ToString()); if (t1 == 0) { if (A.chkgender(dr[1].ToString())) { noti.Controls.Add(new LiteralControl("<div class='media'><div class='media-left'><a href='#'><img src='temp/b.jpg' class='media-object' width='60' height='60'></a></div>")); } else { noti.Controls.Add(new LiteralControl("<div class='media'><div class='media-left'><a href='#'><img src='temp/g.jpg' class='media-object' width='60' height='60'></a></div>")); } } else { noti.Controls.Add(new LiteralControl("<div class='media'><div class='media-left'><a href='#'><img src='Account/" + dr[1].ToString() + "/p.jpg' class='media-object' width='60' height='60'></a></div>")); } returnname r = new returnname(); noti.Controls.Add(new LiteralControl("<div class='media-body message'><div class='panel panel-default'><div class='panel-heading panel-heading-white'><a href='#'>" + r.name(dr[1].ToString()) + "</a></div><div class='panel-body'><p>" + dr[2].ToString() + "</p></div></div></div></div>")); } } cmd.Dispose(); cn.Close(); if (c == 0) { noti.Controls.Add(new LiteralControl("<div class='panel panel-default'><div class='panel-body'><p style='text-align:center'>There are no notifications. </p></div></div>")); } }
[HttpPost]//annotation public ActionResult Index(abc b) { db.abcs.Add(b); int s = db.SaveChanges(); ModelState.Clear(); if (s > 0) { ViewBag.msg = "inserted successfully"; } else { ViewBag.msg = "inserted unsuccessfully"; } return(RedirectToAction("Select", "Home")); }
protected void login_Click(object sender, EventArgs e) { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); cn.Open(); string str = "select * from reg where Email='" + email.Value + "' and Pass='******'"; SqlCommand cmd = new SqlCommand(str, cn); SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { if (dr[10].ToString() == "0") { if (dr[9].ToString() == "0") { Session["uname"] = email.Value; Response.Redirect("index.aspx"); } else { otp = rand(); abc A = new abc(); A.otpsave(otp, email.Value); returnname r = new returnname(); em.send_maill(r.name(email.Value), email.Value, 3, otp); Response.Redirect("ChkOTP.aspx"); } } else { alert.Visible = true; Label4.Text = "Your Account has been deactivated"; } } else { alert1.Visible = true; Label3.Text = "OOPs! Check your E-mail & Password"; } cn.Close(); }
protected void follow() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from follow where followrec='" + Session["uname"].ToString() + "' ", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); int c = 0; foreach (DataRow dr in ds.Tables[0].Rows) { c++; abc A = new abc(); int t = A.chkpicstat(dr[1].ToString()); if (t == 0) { if (A.chkgender(dr[1].ToString())) { dispfollow.Controls.Add(new LiteralControl("<a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(dr[1].ToString()) + "'><img src='temp/b.jpg' class='img-circle' width='50' height='50'></a>")); } else { dispfollow.Controls.Add(new LiteralControl("<a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(dr[1].ToString()) + "'><img src='temp/g.jpg' class='img-circle' width='50' height='50'></a>")); } } else { dispfollow.Controls.Add(new LiteralControl("<a href='#' data-toggle='tooltip' data-placement='bottom' title='" + r.name(dr[1].ToString()) + "'><img src='Account/" + dr[1].ToString() + "/p.jpg' class='img-circle' width='50' height='50'></a>")); } } if (c == 0) { dispfollow.Controls.Add(new LiteralControl("No Followers...")); } }
static void Main(string[] args) { #region Uses Shape, Rectangle, RectangleConstruct class Console.WriteLine("DEMONSTRATION ON INHERITANCE"); int w1 = 5; int h1 = 7; //Using a constructor and inheritance RectangleConstruct Recta = new RectangleConstruct(w1, h1); Console.WriteLine("Total Area(w/ Constructor): " + Recta.GetArea()); Rectangle Rect = new Rectangle(); /*Console.WriteLine("Input Width: "); * w1 = Int32.Parse(Console.ReadLine()); * Console.WriteLine("Input Height: "); * h1 = Int32.Parse(Console.ReadLine());*/ Rect.SetWidth(w1); Rect.SetHeight(h1); Console.WriteLine("Total area: {0}", Rect.getArea()); #endregion #region Uses Line class Console.WriteLine("\nDEMONSTRATION ON USING CONSTRUCTORS/DESTRUCTORS"); Line line = new Line(); // set line length line.setLength(6.0); Console.WriteLine("Length of line : {0}", line.getLength()); #endregion #region Uses StaticVar class Console.WriteLine("\nDEMONSTRATION ON USING STATIC MEMBERS"); StaticVar s1 = new StaticVar(); StaticVar s2 = new StaticVar(); s1.count(); s1.count(); s1.count(); s2.count(); s2.count(); s2.count(); Console.WriteLine("Variable num for s1: {0}", s1.getNum()); Console.WriteLine("Variable num for s2: {0}", s2.getNum()); #endregion #region Uses Polymorph Class Console.WriteLine("\nDEMONSTRATION ON POLYMORPHISM"); //Polymorph p = new Polymorph(); Polymorph p = new Polymorph(); // Call print to print integer p.Print(5); // Call print to print float p.Print(500.263); // Call print to print string p.Print("Hello C#"); #endregion #region Demonstration on Abstract Classes Console.WriteLine("\nDEMONSTRATION ON ABSTRACT CLASSES"); Rectangle1 r = new Rectangle1(10, 7); double a = r.Area(); Console.WriteLine("Area: {0}", a); #endregion #region Demonstration on Dynamic Polymorphism (Using Virtual Functions) Console.WriteLine("\nDEMONSTRATION ON DYNAMIC FUNCTION (Using Virtual Functions)"); Rectangle2 rect2 = new Rectangle2(10, 7); Triangle t = new Triangle(10, 5); Caller c = new Caller(); c.CallArea(rect2); c.CallArea(t); /**************/ #endregion #region Day14: Scope Console.WriteLine("\nACTIVITY ON RETRIEVING MAXIMUM DIFFERENCE BETWEEN VALUES"); //DIFFERENCE CLASS //Computes maximum difference in a range of values //e.g. 1 2 3 4 5 //Read user input on number of characters //Convert.ToInt32(Console.ReadLine()); Console.Write("Input values (e.g. 1 2 3):"); int[] b = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToArray(); Difference d = new Difference(b); d.computeDifference(); Console.WriteLine("Maximum Difference: " + d.maximumDifference); #endregion #region Referenced OperatorOverloadApp namespace Console.WriteLine("\nDEMONSTRATION ON OPERATOR OVERLOADING"); Box Box1 = new Box(); // Declare Box1 of type Box Box Box2 = new Box(); // Declare Box2 of type Box Box Box3 = new Box(); // Declare Box3 of type Box Box Box4 = new Box(); double volume = 0.0; // Store the volume of a box here // box 1 specification Box1.setLength(6.0); Box1.setBreadth(7.0); Box1.setHeight(5.0); // box 2 specification Box2.setLength(12.0); Box2.setBreadth(13.0); Box2.setHeight(10.0); //displaying the Boxes using the overloaded ToString(): Console.WriteLine("Box 1: {0}", Box1.ToString()); Console.WriteLine("Box 2: {0}", Box2.ToString()); // volume of box 1 volume = Box1.getVolume(); Console.WriteLine("Volume of Box1 : {0}", volume); // volume of box 2 volume = Box2.getVolume(); Console.WriteLine("Volume of Box2 : {0}", volume); // Add two object as follows: Box3 = Box1 + Box2; Console.WriteLine("Box 3: {0}", Box3.ToString()); // volume of box 3 volume = Box3.getVolume(); Console.WriteLine("Volume of Box3 : {0}", volume); //comparing the boxes if (Box1 > Box2) { Console.WriteLine("Box1 is greater than Box2"); } else { Console.WriteLine("Box1 is not greater than Box2"); } if (Box1 < Box2) { Console.WriteLine("Box1 is less than Box2"); } else { Console.WriteLine("Box1 is not less than Box2"); } if (Box1 >= Box2) { Console.WriteLine("Box1 is greater or equal to Box2"); } else { Console.WriteLine("Box1 is not greater or equal to Box2"); } if (Box1 <= Box2) { Console.WriteLine("Box1 is less or equal to Box2"); } else { Console.WriteLine("Box1 is not less or equal to Box2"); } if (Box1 != Box2) { Console.WriteLine("Box1 is not equal to Box2"); } else { Console.WriteLine("Box1 is not greater or equal to Box2"); } Box4 = Box3; if (Box3 == Box4) { Console.WriteLine("Box3 is equal to Box4"); } else { Console.WriteLine("Box3 is not equal to Box4"); } #endregion #region Demonstration on Interfaces Console.WriteLine("\nDEMONSTRATION ON INTERFACES"); Transaction t1 = new Transaction("001", "8/10/2012", 78900.00); Transaction t2 = new Transaction("002", "9/10/2012", 451900.00); t1.showTransaction(); t2.showTransaction(); #endregion #region Demonstration on Namespaces Console.WriteLine("\nDEMONSTRATION ON NAMESPACES"); abc fc = new abc(); efg sc = new efg(); fc.func(); sc.func(); abcd fc1 = new abcd(); third_space.fourth_space.efgh sc1 = new third_space.fourth_space.efgh(); fc1.func(); sc1.func(); #endregion #region Demonstration on Exceptions Console.WriteLine("\nDEMONSTRATION ON EXCEPTIONS"); Console.WriteLine("FIRST EXCEPTION"); DivNumbers eDiv = new DivNumbers(); eDiv.division(25, 0); Console.WriteLine("\nSECOND EXCEPTION"); Temperature temp = new Temperature(); try { temp.showTemp(); } catch (TempIsZeroException e) { Console.WriteLine("TempIsZeroException: {0}", e.Message); } #endregion #region THIS SHOWS A PREPROCESSOR DIRECTIVE Console.WriteLine("\nTHIRD EXCEPTION"); string strVal = Console.ReadLine(); try { int x = int.Parse(strVal); Console.WriteLine(x); } catch (FormatException) { Console.WriteLine("Bad String"); } #endregion Console.ReadKey(); }
void fillfriend() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from friend where (receiver='" + Session["uname"].ToString() + "'or sender='" + Session["uname"].ToString() + "') and status='1' order by dor desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); int c = 0; a = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { if (dr[1].ToString() == Session["uname"].ToString()) { a.Add(dr[2].ToString()); } else { a.Add(dr[1].ToString()); } } foreach (object o in a) { c++; returnname r = new returnname(); LinkButton l = new LinkButton(); l.Text = o.ToString(); l.Click += new EventHandler(l_click); Button b = new Button(); Button b1 = new Button(); b.Text = "Follow"; b1.Text = "Unfriend"; b.Attributes["class"] = "btn btn-default btn-sm"; b1.Attributes["class"] = "btn btn-success btn-sm"; b.CommandName = l.Text; b1.CommandName = l.Text; b.Click += new EventHandler(b_click); b1.Click += new EventHandler(b1_click); panel.Controls.Add(new LiteralControl("<div class='col-md-6 col-lg-4 item'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='pull-left'>")); abc A = new abc(); int t = A.chkpicstat(o.ToString()); if (t == 0) { if (A.chkgender(o.ToString())) { panel.Controls.Add(new LiteralControl("<img src='temp/b.jpg' alt='People' class='media-object img-circle' width='40' height='40'>")); } else { panel.Controls.Add(new LiteralControl("<img src='temp/g.jpg' alt='People' class='media-object img-circle' width='40' height='40'>")); } } else { panel.Controls.Add(new LiteralControl("<img src='Account/" + o.ToString() + "/p.jpg' alt='People' class='media-object img-circle' width='40' height='40'>")); } panel.Controls.Add(new LiteralControl("</div><div class='media-body'><h4 class='media-heading margin-v-5'>")); panel.Controls.Add(new LiteralControl("" + r.name(o.ToString()) + "<br/>")); panel.Controls.Add(l); panel.Controls.Add(new LiteralControl("</h4></div></div></div><div class='panel-footer'><div class='row'><div class='col-xs-6 col-sm-6 col-md-6'>")); if (!v.isinfollow(Session["uname"].ToString(), b.CommandName)) { panel.Controls.Add(b); } panel.Controls.Add(new LiteralControl("</div><div class='col-xs-6 col-sm-6 col-md-6'>")); panel.Controls.Add(b1); panel.Controls.Add(new LiteralControl("</div></div></div></div></div>")); } cn.Close(); if (c == 0) { panel.Controls.Add(new LiteralControl("<div class='panel panel-default'><div class='panel-body'><p style='text-align:center'>There is no Friends of your's search for Friends. </p></div></div>")); } }
void fillfriend() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from friend where (receiver='" + Session["uname"].ToString() + "'or sender='" + Session["uname"].ToString() + "') and status='1' order by dor desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); int c = 0; a = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { c++; if (dr[1].ToString() == Session["uname"].ToString()) { a.Add(dr[2].ToString()); } else { a.Add(dr[1].ToString()); } } foreach (object o in a) { returnname r = new returnname(); LinkButton l = new LinkButton(); l.Text = o.ToString(); l.ForeColor = System.Drawing.Color.White; l.Font.Name = "Comic Sans MS"; l.CommandName = r.name(o.ToString()); l.Click += new EventHandler(l_click); A = new abc(); int t = A.chkpicstat(o.ToString()); if (t == 0) { if (A.chkgender(o.ToString())) { frnds.Controls.Add(new LiteralControl("<li class='list-group-item active'><div class='media'><div class='media-left'><img src='temp/b.jpg' alt='' class='media-object' width='65' height='60'></div> <div class='media-body'><span class='user'>" + l.CommandName + "")); } else { frnds.Controls.Add(new LiteralControl("<li class='list-group-item active'><div class='media'><div class='media-left'><img src='temp/g.jpg' alt='' class='media-object' width='65' height='60'></div> <div class='media-body'><span class='user'>" + l.CommandName + "")); } } else { frnds.Controls.Add(new LiteralControl(" <li class='list-group-item active'><div class='media'><div class='media-left'><img src='Account/" + o.ToString() + "/p.jpg' alt='' class='media-object' width='65' height='60'></div> <div class='media-body'><span class='user'>" + l.CommandName + "")); } frnds.Controls.Add(l); frnds.Controls.Add(new LiteralControl("</span></div></div></li><hr/>")); } cn.Close(); if (c == 0) { frnds.Controls.Add(new LiteralControl("<p>Sorry there are no friends whom you can chat.</p>")); } }
void fillmessage() { r = new returnname(); SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from message where (receiver='" + Session["uname"].ToString() + "'or sender='" + Session["uname"].ToString() + "') order by msgid desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); b = new ArrayList(); b.Add(Session["uname"].ToString()); foreach (DataRow dr in ds.Tables[0].Rows) { if (b.Contains(dr[1].ToString())) { string sender = r.name(dr[1].ToString()); msg.Controls.Add(new LiteralControl("<div class='media'><div class='media-body message'><div class='panel panel-default'><div class='panel-heading panel-heading-white'><div class='pull-right'><small class='text-muted'>" + dr[4].ToString() + "</small></div><a href='#'>" + sender + "</a></div><div class='panel-body'>" + dr[3].ToString() + "</div></div></div><div class='media-right'>")); abc A = new abc(); int t = A.chkpicstat(dr[1].ToString()); if (t == 0) { if (A.chkgender(dr[1].ToString())) { msg.Controls.Add(new LiteralControl("<img src='temp/b.jpg' alt='' class='media-object' width='60'></div></div><br/>")); } else { msg.Controls.Add(new LiteralControl("<img src='temp/g.jpg' alt='' class='media-object' width='60'></div></div><br/>")); } } else { msg.Controls.Add(new LiteralControl("<img src='Account/" + dr[1].ToString() + "/p.jpg' alt='' class='media-object' width='60'></div></div><br/>")); } } if (b.Contains(dr[2].ToString())) { string receiver = r.name(dr[1].ToString()); int t = A.chkpicstat(dr[1].ToString()); if (t == 0) { if (A.chkgender(dr[1].ToString())) { msg.Controls.Add(new LiteralControl("<div class='media'><div class='media-left'><img src='temp/b.jpg' alt='' class='media-object' width='60'></div> <div class='media-body message'><div class='panel panel-default'><div class='panel-heading panel-heading-white'><div class='pull-right'><small class='text-muted'>" + dr[4].ToString() + "</small></div><a href='#'>" + receiver + "</a></div><div class='panel-body'>" + dr[3].ToString() + "</div></div></div></div><br/>")); } else { msg.Controls.Add(new LiteralControl("<div class='media'><div class='media-left'><img src='temp/g.jpg' alt='' class='media-object' width='60'></div> <div class='media-body message'><div class='panel panel-default'><div class='panel-heading panel-heading-white'><div class='pull-right'><small class='text-muted'>" + dr[4].ToString() + "</small></div><a href='#'>" + receiver + "</a></div><div class='panel-body'>" + dr[3].ToString() + "</div></div></div></div><br/>")); } } else { msg.Controls.Add(new LiteralControl(" <div class='media'><div class='media-left'><img src='Account/" + dr[1].ToString() + "/p.jpg' alt='' class='media-object' width='60'></div> <div class='media-body message'><div class='panel panel-default'><div class='panel-heading panel-heading-white'><div class='pull-right'><small class='text-muted'>" + dr[4].ToString() + "</small></div><a href='#'>" + receiver + "</a></div><div class='panel-body'>" + dr[3].ToString() + "</div></div></div></div><br/>")); } } } cn.Close(); }
void fillpost() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from wallpost order by wid desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); r = new returnname(); validfriend v1 = new validfriend(); a.Add(Session["uname"].ToString()); foreach (DataRow dr in ds.Tables[0].Rows) { if (a.Contains(dr[1].ToString())) { if (v1.stat(dr[1].ToString())) { LinkButton l1 = new LinkButton(); l1.Text = "Like"; TextBox text = new TextBox(); text.Attributes["class"] = "form-control"; l1.CommandName = dr[0].ToString(); l1.Click += new EventHandler(like_post); text.ID = dr[0].ToString(); string s = r.name(dr[1].ToString()); text.AutoPostBack = true; text.TextChanged += new EventHandler(send_comment); A = new abc(); int t1 = A.chkpicstat(dr[1].ToString()); if (t1 == 0) { if (A.chkgender(dr[1].ToString())) { wall.Controls.Add(new LiteralControl("<div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='temp/b.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on " + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>")); } else { wall.Controls.Add(new LiteralControl("<div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='temp/g.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on " + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>")); } } else { wall.Controls.Add(new LiteralControl(" <div class='timeline-block'><div class='panel panel-default'><div class='panel-heading'><div class='media'><div class='media-left'> <a><img src='Account/" + dr[1].ToString() + "/p.jpg' class='media-object' width='60' height='60'></a></div><div class='media-body'><a class='pull-right text-muted'><i class='icon-reply-all-fill fa fa-2x '></i></a><a href='#'>" + s + "</a><span>on " + dr[3].ToString() + "</span></div></div></div><div class='panel-body'><p>" + dr[2].ToString().Replace(System.Environment.NewLine, "<br>") + "</p></div><div class='view-all-comments'><a href='#'><i class='fa fa-thumbs-o-up'></i>")); } string[] b = dr[4].ToString().Split('/'); if (!A.islike(Session["uname"].ToString(), l1.CommandName)) { wall.Controls.Add(l1); } if (dr[5].ToString() == "0") { wall.Controls.Add(new LiteralControl("</a><span></span></div><ul class='comments'>")); } else { wall.Controls.Add(new LiteralControl("</a><span> ")); for (int i = 0; i < b.Length; i++) { wall.Controls.Add(new LiteralControl(" " + b[i] + "")); } wall.Controls.Add(new LiteralControl(" " + dr[5].ToString() + "Likes</a></span></div><ul class='comments'>")); } cmd.Dispose(); cn.Close(); SqlConnection cn1 = new SqlConnection(); cn1.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd1 = new SqlCommand("select * from comment order by cid asc", cn1); DataSet ds1 = new DataSet(); SqlDataAdapter ad1 = new SqlDataAdapter(cmd1); SqlCommandBuilder cmdb1 = new SqlCommandBuilder(ad1); ad1.Fill(ds1); foreach (DataRow dr1 in ds1.Tables[0].Rows) { string[] st = dr1[4].ToString().Split(' '); if (dr1[1].ToString().Contains(text.ID)) { wall.Controls.Add(new LiteralControl("<li class='media'><div class='media-left'><a href='#'>")); int t = A.chkpicstat(dr1[2].ToString()); if (t == 0) { if (A.chkgender(dr1[2].ToString())) { wall.Controls.Add(new LiteralControl("<img src='temp/b.jpg' class='media-object' width='60' height='60'>")); } else { wall.Controls.Add(new LiteralControl("<img src='temp/g.jpg' class='media-object' width='60' height='60'>")); } } else { wall.Controls.Add(new LiteralControl("<img src='Account/" + dr1[2].ToString() + "/p.jpg' class='media-object' width='60' height='60'>")); } wall.Controls.Add(new LiteralControl("</a></div><div class='media-body'><a href='#' class='comment-author pull-left'>" + r.name(dr1[2].ToString()) + "</a><span>" + dr1[3].ToString() + "</span><div class='comment-date'>" + st[0] + "</div></div></li>")); } } wall.Controls.Add(new LiteralControl(" <li class='comment-form'><div class='input-group'><span class='input-group-btn'><a href='#' class='btn btn-default'><i class='fa fa-comments'></i></a></span>")); wall.Controls.Add(text); wall.Controls.Add(new LiteralControl("</div></li></ul></div></div>")); cmd1.Dispose(); cn1.Close(); } } } }
void fillpen() { SqlConnection cn = new SqlConnection(); cn.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["cn"].ToString(); SqlCommand cmd = new SqlCommand("select * from friend where (receiver='" + Session["uname"].ToString() + "'or sender='" + Session["uname"].ToString() + "') and status='1' order by dor desc", cn); DataSet ds = new DataSet(); SqlDataAdapter ad = new SqlDataAdapter(cmd); SqlCommandBuilder cmdb = new SqlCommandBuilder(ad); ad.Fill(ds); int c = 0; a = new ArrayList(); foreach (DataRow dr in ds.Tables[0].Rows) { c++; if (dr[1].ToString() == Session["uname"].ToString()) { a.Add(dr[2].ToString()); } else { a.Add(dr[1].ToString()); } } foreach (object o in a) { LinkButton b12 = new LinkButton(); b12.Text = r.name(o.ToString()); b12.Style.Add("font-size", "15px"); b12.Attributes.Add("href", "javascript:register_popup('" + r.id1(o.ToString()) + "' , '" + r.name(o.ToString()) + "');"); flist.Controls.Add(new LiteralControl("<table><tr><td><img src='img/d.png' id='" + r.id1(o.ToString()) + "-i' /></td>")); flist.Controls.Add(new LiteralControl("<td style='width:8px'></td>")); A = new abc(); int t = A.chkpicstat(o.ToString()); if (t == 0) { if (A.chkgender(o.ToString())) { flist.Controls.Add(new LiteralControl("<td><img src='temp/b.jpg' alt='image' class='img-circle' width='60' height='60'></td>")); } else { flist.Controls.Add(new LiteralControl("<td><img src='temp/g.jpg' alt='image' class='img-circle' width='60' height='60'></td>")); } } else { flist.Controls.Add(new LiteralControl("<td><img src='Account/" + o.ToString() + "/p.jpg' alt='image' class='img-circle' width='60' height='60'></td>")); } flist.Controls.Add(new LiteralControl("<td style='width:15px'></td>")); flist.Controls.Add(new LiteralControl("<td>")); flist.Controls.Add(b12); flist.Controls.Add(new LiteralControl("</td></tr></table>")); //flist.Controls.Add(new LiteralControl("</li>")); } cn.Close(); if (c == 0) { flist.Controls.Add(new LiteralControl("<p>No Friends yet...!</p>")); } }