public ActionResult EditStudent(Student1 student, int id) { objStud = db.Student1.Find(id); ViewBag.student = new SelectList(db.Teachers, "Id", "Teacher", objStud.Teacher); //ViewBag.student = new SelectList(db.Subjects , "Id", "Subject", objStud.Subject); return(View()); }
public IActionResult StudentDetail(int id) { Student1 S = _ORM.Student1.Where(m => m.Id == id).FirstOrDefault <Student1>(); return(View(S)); }
static void Main(string[] args) { Instructor1 John = new Instructor1("John", "English"); Instructor1 Mike = new Instructor1("MIKE", "Math"); Student1 Jane = new Student1("Jane", John); Student1 Joe = new Student1("Joe", John); Student1 Melissa = new Student1("Melissa", Mike); Student1 Matt = new Student1("Matt", Mike); John.SetStudentGrade(Jane, 95); John.SetStudentGrade(Joe, 85); Mike.SetStudentGrade(Melissa, 90); Mike.SetStudentGrade(Matt, 92); Jane.PrintStudentInfo(); Joe.PrintStudentInfo(); Melissa.PrintStudentInfo(); Matt.PrintStudentInfo(); System.Console.WriteLine(); System.Console.ReadKey(); }
public ActionResult Create(Student1 obj) { StudentEntities studobj = new StudentEntities(); studobj.Student1.Add(obj); studobj.SaveChanges(); var department = new List <SelectListItem> { new SelectListItem { Text = "CS", Value = "1" }, new SelectListItem { Text = "ECE", Value = "2" }, new SelectListItem { Text = "EEE", Value = "3" } }; ViewBag.Department = department; //Student user = new Student(); //UpdateModel(user); return(View()); }
public static void AssertAreEqual(Student1 expected, Student1 actual) { Assert.AreEqual(expected.StudentNUM, actual.StudentNUM); Assert.AreEqual(expected.Description, actual.Description); Assert.AreEqual(expected.Name, actual.Name); Assert.AreEqual(expected.StudentName, actual.StudentName); }
public IActionResult DeleteStudent(Student1 S) { _ORM.Student1.Remove(S); _ORM.SaveChanges(); return(RedirectToAction("AllStudents")); }
public ActionResult Delete(int id) { objStud = db.Student1.Find(id); db.Student1.Remove(objStud); db.SaveChanges(); objStud.StudList = db.Student1.ToList(); return(View("Index", objStud.StudList)); }
public ActionResult DeleteConfirmed(string id) { Student1 student1 = db.Student1.Find(id); db.Student1.Remove(student1); db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task AddStudent(Student1 entity) { await WithConnection(async conn => { await conn.ExecuteAsync(_commandText.AddStudent, new { Name = entity.Name, Department = entity.Department }); }); }
public ActionResult Edit([Bind(Include = "CCCD,Address,University,FullName")] Student1 student1) { if (ModelState.IsValid) { db.Entry(student1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student1)); }
public IActionResult EditStudent(Student1 S) { Student1 student = _ORM.Student1.Where(m => m.Id.Equals(S)).FirstOrDefault(); _ORM.Student1.Update(S); _ORM.SaveChanges(); ViewBag.MessageSucess = "Record Updated Succefully"; return(View(S)); }
public void TestRefProperty() { SqlMaker <Relation2> package = new SqlMaker <Relation2>(); SqlMaker <Student1> package1 = new SqlMaker <Student1>(); Student1 student = new Student1(); SqlEntity <Student1> .SetPrimary(student, "abc"); Assert.Equal("abc", (string)RelationSql <Student1, Relation2, Student, Class, Class1> .Getters[0](student)); }
public ActionResult Create(Student1 student) { if (ModelState.IsValid) { context.Student1s.Add(student); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(student)); }
public ActionResult Update(Student1 stud, int id) { objStud = db.Student1.Find(id); objStud.StudentName = stud.StudentName; objStud.Teacher = stud.Teacher; objStud.Subject = stud.Subject; db.Entry(stud); db.SaveChanges(); return(View()); }
public ActionResult Create(Student1 stud) { objStud.StudentName = stud.StudentName; objStud.Teacher = stud.Teacher; objStud.Subject = stud.Subject; db.Student1.Add(objStud); db.SaveChanges(); objStud.StudList = db.Student1.ToList(); return(View("Index", objStud.StudList)); }
public ActionResult Create([Bind(Include = "CCCD,Address,University,FullName")] Student1 student1) { if (ModelState.IsValid) { db.Student1.Add(student1); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(student1)); }
public override string ToString() { string result = Student1.ToString(); if (Student2 != null) { result += ", " + Student2.ToString(); } return(result); }
// GET: Student1/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student1 student1 = db.Student1.Find(id); if (student1 == null) { return(HttpNotFound()); } return(View(student1)); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Student1 c1 = context.Student1s.Find(id); if (c1 == null) { return(HttpNotFound()); } return(View(c1)); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); GameElements.LoadContent(Content, Window); mapEditor = new LevelObjects.LevelEditor(); // Load the textures into the texture handler textures = new The_scroll_of_NOPE.Content.TextureHandler(Content); #region Jonatan, load map // FOR DEBUG PUSPOSES tmpTexture = Content.Load<Texture2D>("images/ANKA/ANKA"); try { // Load the default map levelLayout = mapEditor.LoadMap("defaultMap"); // If it could not load because there probably was no defaultMap if (levelLayout == null) { // Create new map and save it to a file levelLayout = new LevelObjects.LevelLayout(Content); mapEditor.SaveMap(levelLayout, "defaultMap"); } } // Textures probably did not load properly // TODO: Fix the deserialization and serialization of textures catch { levelLayout = new LevelObjects.LevelLayout(Content); } #endregion anka = new BaseClasses.Players.ANKA(1, Content.Load<Texture2D>("images/ANKA/SpriteTest"/*SpriteTest skall vara ANKA*/), new Vector2(50, 50), 5, 10000); testStudent = new Student1(Content.Load<Texture2D>("images/Students/PlayerTemp"), new Vector2(0, 0), 7, Content, new Vector2(5, 5)); // TODO: use this.Content to load your game content here collidables.Add(anka); collidables.Add(levelLayout); collidables.Add(testStudent); // For drawing text font = Content.Load<SpriteFont>("Text/Score"); winFont = Content.Load<SpriteFont>("Text/Win"); // for drawing whatever }
public string DeleteStudentByAjax(Student1 S) { string result; try { _ORM.Student1.Remove(S); _ORM.SaveChanges(); result = "Yes"; } catch { result = "No"; } return(result); }
protected void btnreg_Click(object sender, EventArgs e) { using (var db = new Ceng396_TermEntities()) { int idc = Convert.ToInt32(txtstudentid.Text); var query = (from b in db.Student1 where b.StudentID == idc select b).SingleOrDefault(); if (query == null) { Student1 newUser = new Student1(); newUser.SName = txtname.Text; newUser.SSurname = txtsurname.Text; newUser.StudentID = idc; newUser.IncasePassword = txtincase.Text; newUser.Department = txtdept.Text; newUser.Faculty = txtfac.Text; newUser.YearStarted = txtyear.Text; newUser.Email = txtemail.Text; // newUser.email = txtMail.Text; newUser.Password = txtpass.Text; if (txtcpass.Text == txtpass.Text) { db.Student1.Add(newUser); db.SaveChanges(); lblEror.Text = "Register Successful!"; lblEror.Visible = true; Response.Redirect("Login.aspx"); } else { lblEror.Text = "You entered wrong password!"; lblEror.Visible = true; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true); System.Threading.Thread.Sleep(3000); Response.Redirect("Register.aspx"); } } else { lblEror.Text = "Existing User!"; lblEror.Visible = true; } } }
static void Main(string[] args) { Controller controller = new Controller(); Menu menu = new Menu(); MainStudent student1 = new Student1().get(); MainStudent student2 = new Student2().get(); students.AddRange(new List <MainStudent>() { student2, student1 }); main : menu.Main(); int ordger; try { ordger = int.Parse(Console.ReadLine()); switch (ordger) { case 1: Console.Clear(); controller.ShowList(students); break; case 2: Console.Clear(); controller.Show(students); break; case 3: Console.Clear(); controller.Average(students); break; } Console.ReadKey(); goto main; } catch { Console.WriteLine("\n!!!please enter number!!!"); goto main; } }
static void Main(string[] args) { Student st1 = new Student() { age = 17 }; Student st2 = st1; st2.age = 20; Console.WriteLine("Struct: st1.age = {0}, st2.age = {1}", st1.age, st2.age); Student1 st3 = new Student1() { age = 17 }; Student1 st4 = st3; st4.age = 20; Console.WriteLine("Struct: st3.age = {0}, st4.age = {1}", st3.age, st4.age); Console.ReadKey(true); }
//return teachers; public static List <Student1> GetStu(string ID, string courseID) { List <Student1> stu = new List <Student1>(); using (SqlConnection connection1 = new SqlConnection(@"Data Source=NETRA\SQLEXPRESS;Integrated Security=True;Database = master; uid=NETRA\Dell")) { connection1.Open(); //string StrQuery2 = $"Select StudentID From students Where courseID = 'cis560'"; string StrQuery2 = $"select StudentID, courseID from students where courseID = '{courseID}'"; SqlCommand command1 = new SqlCommand(StrQuery2, connection1); command1.CommandType = CommandType.Text; DataTable university2 = new DataTable(); SqlDataAdapter adapter1 = new SqlDataAdapter(command1); adapter1.Fill(university2); foreach (DataRow dr in university2.Rows) { string id = dr["StudentID"].ToString(); // string fname = dr["FName"].ToString(); // string lname = dr["LName"].ToString(); //string stream = dr["Stream"].ToString(); // string courseid = dr["courseID"].ToString(); string courseidd = dr["courseID"].ToString(); Student1 t = new Student1(); t.StudentID = id; // t.FName = fname; //t.LName = lname; //t.Stream = stream; t.CourseID = courseidd; stu.Add(t); } } return(stu); }
// Update is called once per frame void Update() { //GetCameraRotation.print(); RestClient.Get <Student1>("https://bean-2fd9d.firebaseio.com/student2.json").Then(firstUser => { stu2 = firstUser; }); //get info from firebase RestClient.Get <Student1>("https://bean-2fd9d.firebaseio.com/student3.json").Then(firstUser => { stu3 = firstUser; }); if (stu2.loggedIn) //acitivate student models if they are logged in { student2.SetActive(true); } else { student2.SetActive(false); } if (stu3.loggedIn) { student3.SetActive(true); } else { student3.SetActive(false); } RestClient.Put <Student1>("https://bean-2fd9d.firebaseio.com/student1.json", stu1); //push to firebase }
public IActionResult CreateStudent(Student1 S, IFormFile ProfilePicture, IFormFile Cv) { string wwwRootPath = _ENV.WebRootPath; string FTPPathForPPs = wwwRootPath + "/WebData/PPs/"; string UniqueName = Guid.NewGuid().ToString(); string FileExtension = Path.GetExtension(ProfilePicture.FileName); FileStream FS = new FileStream(FTPPathForPPs + UniqueName + FileExtension, FileMode.Create); ProfilePicture.CopyTo(FS); FS.Close(); S.ProfilePicture = "/WebData/PPs/" + UniqueName + FileExtension; string CVPath = "/WebData/CVs/" + Guid.NewGuid().ToString() + Path.GetExtension(Cv.FileName); FileStream CVS = new FileStream(wwwRootPath + CVPath, FileMode.Create); Cv.CopyTo(CVS); CVS.Close(); S.Cv = CVPath; _ORM.Student1.Add(S); _ORM.SaveChanges(); MailMessage oEmail = new MailMessage(); oEmail.From = new MailAddress("*****@*****.**"); oEmail.To.Add(new MailAddress(S.Email)); oEmail.CC.Add(new MailAddress("*****@*****.**")); oEmail.Subject = "Welcome to ABC"; oEmail.Body = "Dear " + S.Name + ",<br><br>" + "Thanks for registering with us." + "<br><br>" + "<b>Regards</b>,<br>Ansa Team"; oEmail.IsBodyHtml = true; if (!string.IsNullOrEmpty(S.Cv)) { oEmail.Attachments.Add(new Attachment(wwwRootPath + S.Cv)); } SmtpClient oSMTP = new SmtpClient(); oSMTP.Host = "smtp.gmail.com"; oSMTP.Port = 587; //465 //25 oSMTP.EnableSsl = true; oSMTP.Credentials = new System.Net.NetworkCredential("*****@*****.**", "ansaabbas4"); try { oSMTP.Send(oEmail); } catch (Exception ex) { } _ORM.Student1.Add(S); _ORM.SaveChanges(); ViewBag.Message = "Registration is successfully Done"; return(View()); }
public IActionResult EditStudent(int Id) { Student1 S = _ORM.Student1.Where(m => m.Id == Id).FirstOrDefault <Student1>(); return(View(S)); }
public static void Test2()//引用类型:数组型、枚举类型、集合类型、结构类型、特殊类型、类型转换 { #region 数组型 byte[] bytes1 = new byte[2]; bytes1[0] = 10; bytes1[1] = 20; byte[] bytes2 = new byte[] { 30, 40 }; //可省略new byte[] byte[,] bytes3 = new byte[2, 2]; //二维数组 bytes3[0, 0] = 1; bytes3[0, 1] = 100; bytes3[1, 0] = 2; bytes3[1, 1] = 200; byte[,] bytes4 = new byte[, ] { { 1, 100 }, { 2, 200 } }; //可省略new byte[,] byte[][] bytes5 = new byte[2][]; //不规则数组 bytes5[0] = new byte[] { 1, 2, 3 }; bytes5[1] = new byte[] { 4, 5, 6, 7, 8 }; Console.WriteLine("{0}, {1}, {2}, {3}", bytes3, bytes3.GetType(), typeof(byte[, ]), bytes3.Length); #endregion #region 枚举类型 Console.WriteLine("{0}, {1}, {2}", typeof(Day), (int)Day.Monday, Day.Monday.ToString()); Console.WriteLine("{0}, {1}, {2}", typeof(Day), (int)Day.Tuesday, Day.Tuesday.ToString()); Console.WriteLine("{0}, {1}, {2}", typeof(Day), (int)Day.Friday, Day.Friday.ToString()); Console.WriteLine("{0}, {1}, {2}", typeof(Day), (int)Day.Saturday, Day.Saturday.ToString()); Console.WriteLine("{0}, {1}, {2}", typeof(Day), (int)Day.Sunday, Day.Sunday.ToString()); Console.WriteLine("{0}, {1}, {2}, {3}, {4}", Enum.Parse(typeof(Day), "0"), Enum.Parse(typeof(Day), "Monday"), Enum.GetValues(typeof(Day)).GetValue(0), Enum.GetNames(typeof(Day))[0], Enum.GetName(typeof(Day), 0)); //获取枚举的五个方法 int[] days = (int[])Enum.GetValues(typeof(Day)); foreach (int day in days) //枚举遍历1 { Console.Write("{0}, {1} | ", day, Enum.Parse(typeof(Day), day.ToString())); } Console.WriteLine(); string[] days2 = Enum.GetNames(typeof(Day)); foreach (string day in days2)//枚举遍历2 { Console.Write("{0} | ", day); } Console.WriteLine(); Day day1 = Day.Tuesday; switch (day1) { case Day.Monday: Console.WriteLine("星期一"); break; case Day.Tuesday: Console.WriteLine("星期二"); break; case Day.Wednesday: Console.WriteLine("星期三"); break; } #endregion #region 集合类型1:哈希表 //集合类型SortedList与之大同,不同的是它按键排序(从小到大) Hashtable table = new Hashtable(); table.Add("Name", "Sophie"); table.Add("Age", 24); table.Add("Gender", false); table.Add("Word1", new StringBuilder("Hello.")); table.Add("Word2", new StringBuilder("Hi.")); table.Add(5, 100); table.Add(6, 200); table.Remove("Word2"); table.Remove(5); foreach (DictionaryEntry each in table) { Console.Write("{0}: {1} || ", each.Key, each.Value); } Console.WriteLine(); foreach (object each in table.Keys) { Console.Write(each + " | "); } Console.WriteLine(); foreach (object each in table.Values) { Console.Write(each + " | "); } Console.WriteLine(); Console.WriteLine("{0}, {1}, {2}, {3}", table.Contains("Word1"), table.Contains(6), table.Contains("Word2"), table.Contains(5)); //true,true,false,false Console.WriteLine("{0}, {1}, {2}, {3}", table.ContainsKey("Word1"), table.ContainsKey(6), table.ContainsKey("Word2"), table.ContainsKey(5)); //true,true,false,false Console.WriteLine("{0}, {1}, {2}, {3}", table.ContainsValue("Sophie"), table.ContainsValue(200), table.ContainsValue(false), table.ContainsValue(25)); //true,true,true,false Console.WriteLine("Count: {0}.", table.Count); Console.WriteLine("{0} : {1}", table["Age"], table["Age"].GetType()); Console.WriteLine("{0} : {1}", table["Word1"], table["Word1"].GetType()); table.Clear(); Console.WriteLine("Count: {0}.", table.Count); #endregion #region 集合类型2:List泛型 List <string> list1 = new List <string>() { "Apple", "Banana", "Apple2", "Chips" }; //List<string> list1 = new List<string>(); //list1.Add("Apple"); //list1.Add("Banana"); //list1.Add("Apple2"); //list1.Add("Chips"); //list1.Remove("Chips"); list1.RemoveAt(3); list1.Reverse(); string result1 = list1.Find(result => { return(result.StartsWith("A")); }); string result2 = list1.FindLast(result => { return(result.StartsWith("A")); }); bool result3 = list1.Exists(result => { return(result.StartsWith("B")); }); bool result4 = list1.Exists(result => { return(result.StartsWith("C")); }); Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}", list1[0], list1[1], result1, result2, result3, result4); foreach (string each in list1) { Console.Write(each + " | "); } Console.WriteLine(); List <int> list2 = new List <int>() { 3, 2, 1 }; Console.WriteLine(list2.Count); List <bool> list3 = new List <bool>() { true, false, true }; List <Student> list4 = new List <Student>(); Console.WriteLine(); #endregion #region 集合类型3:Queue(先进先出,foreach遍历的顺序与此同) //集合类型Stack与Queue大同,不同的是它后进先出。stack.push()新增/.pop()移除) Queue queue = new Queue(); for (int i = 0; i < 5; i++) { queue.Enqueue(i); } foreach (int each in queue) { Console.Write(each + ", "); } Console.WriteLine(); while (queue.Count != 0) { Console.Write("{0} 被移除。", queue.Dequeue()); } Console.WriteLine(); #endregion #region 集合类型4:ArrayList(先进先出,也可以倒序遍历) ArrayList list5 = new ArrayList(); for (int i = 0; i < 5; i++) { list5.Add(i); } foreach (int each in list5) { Console.Write(each + ", "); } Console.WriteLine("==========="); #endregion #region 结构类型 //Student Student1 = new Student(1, "Jerry", 22); Student Student1; Student1.ID = 1; Student1.Name = "Tom"; Student1.Age = 24; Student1.SayHi(); Console.WriteLine("{0}, {1}, {2}", Student1, Student1.GetType(), typeof(Student)); #endregion #region 特殊类型:Nullable<?> string s1 = null; StringBuilder s2 = null; StringBuilder s3 = new StringBuilder(); /* 因为变量不能用0代替未赋值,因此欲用null表示未赋值,但整数类型变量不能赋值为null, * Framwork 2.0中提供Nullable类型,可以为值类型变量赋值为null。 * HasValue是Nullable一个重要属性,用来判断是否为null值。*/ Nullable <byte> byte1 = null; byte? byte2 = null; Console.WriteLine("{0}, {1}, {2}, {3}, {4}, {5}, {6}", s1 == null, s2 == null, s3 == null, byte1 == null, byte1.HasValue, byte2 == null, byte2.HasValue);//t,t,f,t,f,t,f #endregion #region 类型转换 #region 隐式类型转换 /*由编译器自动进行,不需要做任何工作,一般由取值范围小的类型转化为取值范围大的类型,因此在转换过程中不会丢失数据。例如: * byte——[ushort,short,uint,int,ulong,long,float,double,decimal] * sbyte——[short,int,long,float,double,decimal] * short——[int,long,float,double,decimal] * ushort——[uint,int,ulong,long,float,double,decimal] * int——[long,float,double,decimal] * uint——[ulong,long,float,double,decimal] * long——[float,double,decimal] * ulong——[float,double,decimal] * char——[ushort,uint,int,ulong,long,float,double,decimal] * float——[double]*/ #endregion byte byte3 = 10; short short1 = byte3;//byte型 隐式转换 为short型 #region 显示类型转换 /*又叫强制类型转换,使变量值在要转换的类型取值范围内,只要原类型的取值范围比要转换的类型的取值范围大,就不可以隐式转换。由于显示类型转换是从大取值范围向小取值范围转换,因此可能出现数据丢失的情况。*/ #endregion short1 = 255; byte3 = (byte)short1;//强制转换 #region 装箱拆箱 /*除了值类型之间的转换,值类型和引用类型也可以转换。 * 装箱(Boxing),指从值类型到引用类型的转换,系统会从堆中分配一块内存,将值类型数据复制到这块内存,再使引用类型数据指向这块内存。 * 拆箱(Unboxing),指从引用类型到值类型的显示转换,只能将已装箱的数据拆箱为装箱前的类型。 * 多次进行装箱拆箱对程序性能有影响,需谨慎。*/ #endregion object obj1 = short1; //装箱 short1 = (short)obj1; //拆箱 #endregion }