예제 #1
0
파일: Program.cs 프로젝트: ankita-anand/DSC
        static void Main(string[] args)
        {
            //declaring an array student1 with 5 elements.
            //it is an array of structures
            //of the structure student
            student[] student1 = new student[5];

            //Assigning values to the first structure element in the array
            student1[0].firstName = "Jane";
            student1[0].lastName = "Doe";
            student1[0].addressLine1 = "This is the first line of the address.";
            student1[0].addressLine2 = "This is the second line of the address.";
            student1[0].Bday = new DateTime (1996, 10, 3);
            student1[0].city = "Bangalore";
            student1[0].state = "Karnataka";
            student1[0].country = "India";

            //Writing to the console window the assigned values of the first structure element
            Console.WriteLine();
            Console.WriteLine("Name : {0} {1} ", student1[0].firstName, student1[0].lastName);
            Console.WriteLine("Birthday : {0}", student1[0].Bday.ToShortDateString());
            Console.WriteLine("Address:");
            Console.WriteLine(student1[0].addressLine1);
            Console.WriteLine(student1[0].addressLine2);
            Console.WriteLine("City : {0}", student1[0].city);
            Console.WriteLine("State : {0}", student1[0].state);
            Console.WriteLine("Country : {0}", student1[0].country);
            Console.WriteLine();
        }
예제 #2
0
 // Insert at the beginning of unSortedArray
 public void Insert(student s)
 {
     size++;     //expand the array by one
     for (int counter = size; counter > 0; counter--)
         array[counter] = array[counter - 1];
     array[0] = s;
 }
예제 #3
0
 // Insert a value at a specific index
 public void Insert(student s, int index)
 {
     size++;     //expand the array by one
     for (int counter = size; counter > index; counter--)
         array[counter] = array[counter - 1];
     array[index] = s;
 }
예제 #4
0
        static void Main(string[] args)
        {
            unSortedArray arr = new unSortedArray(500);

            Console.Write("How many students will you enter? ");
            int numStudents = int.Parse(Console.ReadLine());

            for(int counter = 0; counter < numStudents; counter++)
            {
                student tmpStudent = new student(0, "", "");
                Console.WriteLine("Information for student: {0}", counter + 1);
                Console.Write("TNumber = ");
                tmpStudent.TNumber = int.Parse(Console.ReadLine());
                Console.Write("Name = ");
                tmpStudent.Name = Console.ReadLine();
                Console.Write("Advisor = ");
                tmpStudent.Advisor = Console.ReadLine();
                Console.WriteLine();
                arr.Append(tmpStudent);
            }

            Console.WriteLine("Display all students");
            arr.Display();

            Console.WriteLine("\nFind the student with maximum TNumber");
            student studentTemp = arr.Max();
            Console.WriteLine("TNumber: {0} Name: {1} Advisor: {2}", studentTemp.TNumber, studentTemp.Name, studentTemp.Advisor);

            Console.WriteLine("\nFind the student with minimum TNumber");
            studentTemp = arr.Min();
            Console.WriteLine("TNumber: {0} Name: {1} Advisor: {2}", studentTemp.TNumber, studentTemp.Name, studentTemp.Advisor);

            Console.Write("\nEnter TNumber to search for a student: ");
            int t = int.Parse(Console.ReadLine());
            Console.WriteLine("Student  located at index: " + arr.Search(t));

            Console.Write("\nEnter TNumber to delete a student: ");
            t = int.Parse(Console.ReadLine());
            Console.WriteLine("\nDelete students with TNumber {0}", t);
            arr.Delete(t);
            arr.Display();
            Console.WriteLine("\nRemove an item");
            arr.Remove();
            arr.Display();
            Console.WriteLine("\nRemove an item");
            arr.Remove();
            arr.Display();
            Console.WriteLine("\nRemove an item");
            arr.Remove();
            arr.Display();
            Console.WriteLine("\nRemove an item");
            arr.Remove();
            arr.Display();
            Console.WriteLine("\nRemove an item");
            arr.Remove();
            arr.Display();
            Console.ReadLine();
        }
    protected void addStudentBtn_Click(object sender, EventArgs e)
    {
        student Student = new student();
        if (isTextBoxEmpty(stuIdTB, "学生学号")) Student.stuId = getText(stuIdTB);
        else return;
        if (isTextBoxEmpty(nameTB, "学生姓名")) Student.name = getText(nameTB);
        else return;
        Student.sex = sexDDL.SelectedItem.Value;
        if (isTextBoxEmpty(nationTB, "民族")) Student.nation = getText(nationTB);
        else return;
        if (isTextBoxEmpty(birthdayTB, "出生日期"))
        {
            string birthday = getText(birthdayTB);
            if (birthday.Length != 8)
            {
                MessageBox.Show(this, "出生日期格式不正确!");
                return;
            }
            Student.birthday = birthday;
        }
        else return;
        if (isTextBoxEmpty(certificateTypeTB, "证件类型")) Student.certificateType = getText(certificateTypeTB);
        else return;
        if (isTextBoxEmpty(certificateIdTB, "证件号码")) Student.certificateId = getText(certificateIdTB);
        else return;
        if (isTextBoxEmpty(majorIdTB, "专业代码")) Student.majorId = getText(majorIdTB);
        else return;
        if (isTextBoxEmpty(majorNameTB, "专业名称")) Student.majorName = getText(majorNameTB);
        else return;
        if (isTextBoxEmpty(colleageTB, "所在学院")) Student.colleage = getText(colleageTB);
        else return;
        Student.classType = getText(classTypeTB);
        if (isTextBoxEmpty(degreeTB, "毕业学位")) Student.degree = getText(degreeTB);
        else return;
        Student.type = getText(typeTB);
        Student.placeOfWork = getText(placeOfWorkTB);
        Student.workPhone = getText(workPhoneTB);
        if (isTextBoxEmpty(phoneTB, "移动电话")) Student.phone = getText(phoneTB);
        else return;
        Student.email = getText(emailTB);
        Student.address = getText(addressTB);
        Student.zipCode = getText(zipCodeTB);
        string passWord = Tools.safeUserInput(passWordTB.Text.Trim().ToString());
        if (passWord.Length < 1) Student.passWord = Tools.encrypt(Student.certificateId);
        else Student.passWord = Tools.encrypt(passWord);
        try
        {
            studentBLL StudentBLL = new studentBLL();
            StudentBLL.Add(Student);
        }
        catch
        {
            MessageBox.Show(this, "添加失败!");

        }
        MessageBox.Show(this, "添加成功!");
    }
예제 #6
0
파일: Form1.cs 프로젝트: taibai233/c-
        private void button1_Click(object sender, EventArgs e)
        {
            string strConn = @"Server=.\sqlexpress;database=myschool;integrated security=true";
            SqlConnection conn = new SqlConnection(strConn);
            string name = "四学期";
            try
            {
                conn.Open();
                ////  string sql = "update grade set gradename ='三学期' where gradeid=3";
                //string sql = "insert into grade(gradename)values('"+name+"')";
                //SqlCommand cmd = new SqlCommand(sql,conn);
                //int count = cmd.ExecuteNonQuery();
                //if(count>0)
                //{
                //    MessageBox.Show("操作成功");
                //}
                //string sql = "select count(*) from student";
                //SqlCommand cmd = new SqlCommand(sql, conn);
                //int count = (int)cmd.ExecuteScalar();
                //MessageBox.Show(count.ToString())
                string sql = "select * from student";
                SqlCommand cmd = new SqlCommand(sql, conn);
                SqlDataReader dr = cmd.ExecuteReader();
                list.Clear();
               // this.comboBox1.Items.Clear();
                while(dr.Read())
                {
                    //  MessageBox.Show(dr["studentname"].ToString());
                   // this.comboBox1.Items.Add(dr["studentname"].ToString());
                    student stu = new student();

                    stu.StudnetNO = (int)dr["studentno"];
                    stu.StudnetName = dr["studentname"].ToString();
                    stu.LoginPwd = dr["loginpwd"].ToString();
                    stu.Email = dr["email"].ToString();
                    stu.BornDate = (DateTime)dr["borndate"];
                    list.Add(stu);

                }

                dr.Close();
                this.dataGridView1.DataSource = list;
                this.comboBox1.DataSource = list;
                this.comboBox1.DisplayMember = "studentname";
                this.comboBox1.ValueMember = "studentno";
            ;            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
예제 #7
0
 static void Main(string[] args)
 {
     student[] students = new student[5];
     students[0].firstName = "George";
     students[0].lastName = "Michael";
     students[0].birthDay = "01 Jan 2023";
     Console.WriteLine(students[0].firstName);
     Console.WriteLine(students[0].lastName);
     Console.WriteLine(students[0].birthDay);
     Console.ReadKey();
 }
예제 #8
0
 public static string student_edit(string sname,string sex,string institute,string major,
     string sclass,string tel,string email,string eng, string honour,string intro,string remark)
 {
     student stu = new student();
     stu.Sno = sno;
     stu.Sname = sname;
     stu.Sex = sex;
     stu.Institute = institute;
     stu.Major = major;
     stu.Sclass = sclass;
     stu.Tel = tel;
     stu.Email = email;
     stu.EnglishLevel = eng;
     stu.Honour = honour;
     stu.Intro = intro;
     stu.Remark = remark;
     stu_Manage stuManage = new stu_Manage();
     return string.Format(stuManage.stu_Update(stu));
 }
예제 #9
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        //naša varijabla, inače bi trebao biti identity u bazi ali ...
        stud_id++;
        //kreiramo novog studenta
        student s = new student();
        //postavimo mu vrijednosti polja
        s.stud_id = stud_id;
        s.ime = tb_ime.Text;
        s.prezime = tb_prezime.Text;
        //Uzmi trenutno dabrani kolegij, prebaci ga u int
        s.kol_id = Int32.Parse(DropDownList1.SelectedValue);
        //Dodaj novi red u tablicu, tj novi objekt u bazu
        db.AddObject("student", s);
        //Spremi promjene tj. izvrši SQL prema bazi
        db.SaveChanges();

        refreshGrid();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        studentBLL StudentBLL = new studentBLL();
        student Student = new student();
        DataSet Students = new DataSet();
        int select = Convert.ToInt32(DropDownList1.SelectedValue);
        try
        {
            switch (select)
            {
                case 0: Students = StudentBLL.GetList("[stuId] LIKE '%" + Tools.safeUserInput(TextBox1.Text.Trim()) + "%'");
                    GridView3.DataSource = Students;
                    GridView3.DataBind();
                    Panel1.Visible = false;
                    Panel2.Visible = false;
                    Panel3.Visible = true;
                    break;
                    break;
                case 1: Students = StudentBLL.GetList("[name] LIKE '%" + Tools.safeUserInput(TextBox1.Text.Trim()) + "%'");
                    GridView3.DataSource = Students;
                    GridView3.DataBind();
                    Panel1.Visible = false;
                    Panel2.Visible = false;
                    Panel3.Visible = true;
                    break;
                case 2: Student = StudentBLL.GetModelList("[certificateId] ='" +Tools.safeUserInput( TextBox1.Text.Trim() )+ "'")[0];
                    Response.Redirect("studentView.aspx?id=" + Student.id);
                    break;
                case 3: Student = StudentBLL.GetModelList("[phone] ='" + Tools.safeUserInput(TextBox1.Text.Trim()) + "'")[0];
                    Response.Redirect("studentView.aspx?id=" + Student.id);
                    break;

            }
        }
        catch {
            MessageBox.Show(this, "查询失败!");
        }
    }
예제 #11
0
        //添加
        public ActionResult StudentAdd()
        {
            student objStudent = new student();

            return(View("StudentAdd", objStudent));
        }
예제 #12
0
        static void Main(string[] args)
        {
            // an array to hold 5 student structs
            student[] studentstructs = new student[5];

            //Assign values to the fields in at least one of the student structs in the array
            DateTime std1br = new DateTime(1999, 6, 6);
            student student1 = new student("john", "doe", std1br, "41 Woodeside road", "porstwood", "southampton", "hampshire", "SO17 2BJ", "England");
            studentstructs[0] = student1;

            // Using a series of Console.WriteLine() statements, output the values for the student struct that you assigned in the previous step
            for (int i = 0; i < studentstructs.Length; i++)
            {
                Console.WriteLine("First Name: {0}\n Last Name: {1}", studentstructs[i].firstName, studentstructs[i].lastNmae);
                Console.WriteLine("Birth Date: {0}", studentstructs[i].birthdate);
                Console.WriteLine("Address Line 1 {0}\n Address Line 2: {1}", studentstructs[i].address1, studentstructs[i].address2);
                Console.WriteLine("City: {0}\n State: {1}", studentstructs[i].scity, studentstructs[i].sstate);
                Console.WriteLine("Zipcode: {0}\n Country: {1}", studentstructs[i].zipcode, studentstructs[i].country);
            }

            Console.ReadLine();
        }
예제 #13
0
    private void Entry()
    {
        student student = new student("초코", 3);

        student.PrintInfo();
    }
예제 #14
0
 public void Put(int id, [FromBody] student student)
 {
     student.StudentId = id;
     _CURDContext.Students.Update(student);
     _CURDContext.SaveChanges();
 }
예제 #15
0
        static student[] CreateRoster()
        {
            student[] classList = new student[20];

            for (int i = 0; i < classList.Length; i++)
            {
                classList[i] = new student();
            }

            classList[0].name = "William Twomey";
            classList[0].infoName.Add("nickname");
            classList[0].infoBody.Add("Ash, similar to Ash from Pokemon, however he was actually named after Ash Williams from the Evil Dead trilogy so now Terrell can stop with the Pokemon talk. He probably won't though.");
            classList[0].infoName.Add("favorite meme");
            classList[0].infoBody.Add("Take a closer look at that snout! Just a clip from a nature documentary that is very versatile in uses. Also elephant shrews are just kinda goofy lookin', ya feel me?");

            classList[1].name = "Dr. K";
            classList[1].infoName.Add("hometown");
            classList[1].infoBody.Add("Detroit. Hey, that's where we are!");
            classList[1].infoName.Add("favorite food");
            classList[1].infoBody.Add("Burgers.");

            classList[2].name = "Jacob Snover";
            classList[2].infoName.Add("hometown");
            classList[2].infoBody.Add("Merrillville. That's near Gary. Geary? I think it's in Indiana...");
            classList[2].infoName.Add("favorite food");
            classList[2].infoBody.Add("Pizza.");

            classList[3].name = "Kristen Rieske";
            classList[3].infoName.Add("favorite cod");
            classList[3].infoBody.Add("Black Ops 2. Me personally, I think BO3 was pretty good but I'm just a filthy zombies player so what do I know.");
            classList[3].infoName.Add("college studies");
            classList[3].infoBody.Add("Physics.");

            classList[4].name = "Student 5";
            classList[4].infoName.Add("something cool");
            classList[4].infoBody.Add("cool it worked");
            classList[4].infoName.Add("something amazing");
            classList[4].infoBody.Add("*Lifts car*");

            classList[5].name = "Lucifer S. Aeytan";
            classList[5].infoName.Add("favorite number");
            classList[5].infoBody.Add("66666666666666666... Likes lots of sixes...");
            classList[5].infoName.Add("favorite hobby");
            classList[5].infoBody.Add("Messing with the lives of mortals.");

            classList[6].name = "RNGesus";
            classList[6].infoName.Add("7");
            classList[6].infoBody.Add("...out of 20 is a pretty bad roll, the dragon roasts you alive.");
            classList[6].infoName.Add("roll for dex");
            classList[6].infoBody.Add("You roll a 1. You drop your bow and it somehow fires into your face. You died.");

            classList[7].name = "Arima Kousei";
            classList[7].infoName.Add("favorite food");
            classList[7].infoBody.Add("Egg salad sandwiches. This guy can go on and on about them...");
            classList[7].infoName.Add("colorblindness");
            classList[7].infoBody.Add("He no longer sees the world in monochrome but that wasn't a cheap upgrade.");

            classList[8].name = "Fictional Person 445";
            classList[8].infoName.Add("favorite mode of transportation");
            classList[8].infoBody.Add("Yeetasaurus-Rex. This dude memes on the haters.");
            classList[8].infoName.Add("why im like this");
            classList[8].infoBody.Add("I really don't know.");

            classList[9].name = "Death Metal Kitten";
            classList[9].infoName.Add("favorite champion");
            classList[9].infoBody.Add("Nidalee, she turns in to a cat.");
            classList[9].infoName.Add("favorite game");
            classList[9].infoBody.Add("League of Please-Stop-playing-this-Broken-Game");

            classList[10].name = "Kamina";
            classList[10].infoName.Add("fighting style");
            classList[10].infoBody.Add("All in, never look back, pure anime fighting spirit!");
            classList[10].infoName.Add("lifestyle");
            classList[10].infoBody.Add("Depending on where you are in the show: no.");

            classList[11].name = "Lex";
            classList[11].infoName.Add("forehead size");
            classList[11].infoBody.Add("Bigger than a school bus.");
            classList[11].infoName.Add("favorite movie");
            classList[11].infoBody.Add("ANYTHING without those little yellow minions in it.");

            classList[12].name = "Ali-A";
            classList[12].infoName.Add("intro");
            classList[12].infoBody.Add("*Loud bass-boosted music plays*");
            classList[12].infoName.Add("favorite game");
            classList[12].infoBody.Add("\"Fortnite\"");

            classList[13].name = "Ajit Pai";
            classList[13].infoName.Add("favorite hobby");
            classList[13].infoBody.Add("Returning humanity to the Dark Ages");
            classList[13].infoName.Add("favorite food");
            classList[13].infoBody.Add("Hopes and dreams of a true free market.");

            classList[14].name = "Mark Zuckerberg";
            classList[14].infoName.Add("species");
            classList[14].infoBody.Add("Some sort of reptile, I think. Like an Argonian from Skyrim.");
            classList[14].infoName.Add("data");
            classList[14].infoBody.Add("Error: OverflowException\nWay too much data on EVERYONE\nThe CIA should hire this dude.");

            classList[15].name = "Elon Musk";
            classList[15].infoName.Add("overwatch rank");
            classList[15].infoBody.Add("If this dude finds Overwatch soothing, there's no way he's anywhere above gold.");
            classList[15].infoName.Add("fun machines");
            classList[15].infoBody.Add("Elon's collection includes: Flamethrowers, Rockets, Electric cars (in space), probably his own personal super computer.");

            classList[16].name = "Bill Gates";
            classList[16].infoName.Add("net worth");
            classList[16].infoBody.Add("93.3 Billion USD. \nyikes");
            classList[16].infoName.Add("fun");
            classList[16].infoBody.Add("Probably pretends to be one of the little kids who pretends to be more powerful than he really is on Xbox Live. It's fun because Bill could do anything he wants to anyone in his lobby.");

            classList[17].name = "Bricky";
            classList[17].infoName.Add("favorite operator");
            classList[17].infoBody.Add("Brazilian Spook Factory (Caveira)");
            classList[17].infoName.Add("intelligence");
            classList[17].infoBody.Add("INT: 1");

            classList[18].name = "David Hasselhoff";
            classList[18].infoName.Add("things he wants to love");
            classList[18].infoBody.Add("You: all night long, with his song.");
            classList[18].infoName.Add("survivor status");
            classList[18].infoBody.Add("True");

            classList[19].name = "Final Boss";
            classList[19].infoName.Add("roll");
            classList[19].infoBody.Add("You dodged his attack but you rolled off the edge and suffered an environmental death.");
            classList[19].infoName.Add("attack");
            classList[19].infoBody.Add("You swing your sword but are killed midway through your attack. git gud.");

            //List<student> roster = classList.OfType<student>().ToList();
            //return roster;

            return(classList);
        }
예제 #16
0
 public ActionResult <bool> Put(int id, [FromBody] student student1)
 {
     return(_Istudentmembershipservice.UpdateStudentinformation(id, student1));
 }
예제 #17
0
 public ActionResult Save(student stu)
 {
     tb.students.AddOrUpdate(stu);
     tb.SaveChanges();
     return(RedirectToAction("student", "Home"));
 }
예제 #18
0
파일: Util.cs 프로젝트: zesus19/c4.v2.T
		public static void UploadInfoToXDD(string gardenID, string gardenName, DataTable data)
		{
			string url = "http://xdd.xindoudou.cn/2/partner/sync";
			if (data.Rows.Count > 0)
			{
				string key = "76e8e4411055443c9def688b969c9ac6";
				Hashtable ht = new Hashtable();
				foreach(DataRow dr in data.Rows)
				{
					string classNumber = dr["info_machineAddr"].ToString();
					if (classNumber != null && classNumber != string.Empty)
					{
						Class @class = null;
						if (!ht.ContainsKey(classNumber))
						{
							@class = new Class();
							@class.id = dr["info_machineAddr"].ToString();
							@class.name = dr["info_className"].ToString();
							@class.students = new ArrayList();
							ht[classNumber] = @class;
						}
						else
						{
							@class = ht[classNumber] as Class;
						}
						student stu = new student();
						stu.id = dr["info_stuID"].ToString();
						stu.name = dr["info_stuName"].ToString();
						@class.students.Add(stu);
					}
				}

				ClassList list = new ClassList();
				list.List = new ArrayList();
				foreach(Class @class in ht.Values)
				{
					list.List.Add(@class);
				}
				
				HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
				request.Method = "POST";
				request.ContentType = "application/x-www-form-urlencoded";
				request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

				StringBuilder sb = new StringBuilder();
				sb.Append(key);
				sb.Append("city=");
				sb.Append("&province=");
				sb.Append(string.Format("&school_id={0}", gardenID));
				sb.Append(string.Format("&school_name={0}", gardenName));

				byte[] hash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
				sb = new StringBuilder();
				foreach(byte b in hash)
				{
					sb.Append(b.ToString("x2"));
				}

				string json = AjaxPro.JavaScriptSerializer.Serialize(list);
				json = json.Substring(8, json.Length - 9);
				byte[] val = Encoding.UTF8.GetBytes(string.Format("key={0}&school_id={1}&school_name={2}&province={3}&city={4}&md5={5}&classes={6}",
					key, gardenID, gardenName, string.Empty, string.Empty, sb.ToString(), json));


				using (Stream stream = request.GetRequestStream())  
				{
					stream.Write(val, 0, val.Length);  
				}

				WebResponse response = request.GetResponse();
				using(StreamReader reader = new StreamReader(response.GetResponseStream()))
				{
					string s = reader.ReadToEnd();
				}
			}
		}
예제 #19
0
 private void listView_Item_Selected(object sender, SelectedItemChangedEventArgs e)
 {
     _student = (student)e.SelectedItem;
 }
예제 #20
0
 public ActionResult Add(student stu)
 {
     return(View("Add"));
 }
예제 #21
0
 public override void AddInsertParameters(IContext context, IDbCommand command, student item)
 {
     base.AddInsertParameters(context, command, item);
     context.AddParameter(command, "studentnumber", item.studentnumber);
     context.AddParameter(command, "studentname", item.studentname ?? (object)DBNull.Value);
     /*add customized code between this region*/
     /*add customized code between this region*/
 }
예제 #22
0
 public bool Delete(student student)
 {
     return(studentDAL.Delete(student));
 }
예제 #23
0
 public bool Update(student student)
 {
     return(studentDAL.Update(student));
 }
        public ActionResult details(int id)
        {
            student std = e.Students.FirstOrDefault(s => s.id == id);

            return(PartialView(std));
        }
예제 #25
0
 public Student_item(student st, degree d)
 {
     St  = st;
     Deg = d;
 }
예제 #26
0
 // Append assuming unSortedArray is not full
 public void Append(student s)
 {
     //TODO deal with case when underlying array is full
     array[size] = s;
     size++;
 }
예제 #27
0
 public static string Info(student s)
 {
     return(s.Id + " naveed Ullah");
 }
예제 #28
0
 public long Add(student student)
 {
     return(studentDAL.Insert(student));
 }
예제 #29
0
 public student(student sd)
 {
     rollno = sd.rollno;
     name   = sd.name;
 }
예제 #30
0
        static void Main(string[] args)
        {
            // int[] a = { 1, 2, 3 };
            // System.Console.WriteLine(a[0]);
            // System.Console.WriteLine(a[a.Length-1]);

            // string[] strs = { "aaa", "bbb", "ccc", "ddd", "eee" };
            // for (var i = 0; i < strs.Length; i+=2)
            // {
            //     System.Console.WriteLine(strs[i]);
            // }

            // int[] a = new int[5];
            // System.Console.WriteLine ("请输入5个整数:");
            // for (int i = 0; i < a.Length; i++) {
            //     a[i] = int.Parse (Console.ReadLine ()); // 讲字符串类型转换成整型
            // }
            // int max = a[0]; // 这里假设a[0]是最大的
            // for (int i = 1; i < a.Length; i++) {
            //     if (a[i] > max) {
            //         max = a[i];
            //     }
            // }
            // System.Console.WriteLine("数组中最大值为:" + max);

            // double[,] points = { { 90, 80 }, { 100, 89 }, { 88.5, 86 } };
            // for(int i = 0; i < points.GetLength(0); i++)
            // {
            //     Console.WriteLine("第" + (i + 1) + "个学生成绩:");
            //     for(int j = 0; j < points.GetLength(1); j++)
            //     {
            //         Console.Write(points[i, j] + " ");
            //     }
            //     Console.WriteLine();
            // }

            // int[, ] da = { { 1, 2 }, { 2, 3 } };
            // int[, , ] ta = { { { 1, 2 }, { 1, 2 } },
            //     { { 1, 2 }, { 2, 3 } }
            // };

            // int[][] arrays = new int[3][];
            // arrays[0] = new int[] { 1, 2 };
            // arrays[1] = new int[] { 3, 4, 5 };
            // arrays[2] = new int[] { 6, 7, 8, 9 };
            // for (int i = 0; i < arrays.Length; i++)
            // {
            //      Console.WriteLine("输出数组中第" + (i + 1) + "行的元素:");
            //     for(int j=0;j<arrays[i].Length; j++)
            //     {
            //         Console.Write(arrays[i][j] + " ");
            //     }
            //     Console.WriteLine();
            // }

            // double[] points = { 80, 88, 86, 90, 75.5 };
            // double sum = 0;
            // double avg = 0;
            // foreach (double point in points) {
            //     sum += point;
            // }
            // avg = sum / points.Length;
            // System.Console.WriteLine("总成绩为:" + sum);
            // System.Console.WriteLine("平均成绩为:" + avg);

            // System.Console.WriteLine ("请输入一个字符串:");
            // string str = Console.ReadLine ();
            // string[] condition = { "," };
            // string[] result = str.Split (condition, StringSplitOptions.None);
            // System.Console.WriteLine(result[1]);
            // System.Console.WriteLine("字符串中含有逗号的个数为:" + (result.Length - 1));

            // int[] a = { 5, 1, 7, 2, 3 };
            // for(int i = 0; i < a.Length; i++)
            // {
            //     for(int j = 0; j < a.Length - i - 1; j++)
            //    {
            //         if (a[j] > a[j + 1])
            //        {
            //             int temp = a[j];
            //             a[j] = a[j + 1];
            //            a[j + 1] = temp;
            //         }
            //     }
            // }
            // Console.WriteLine("升序排序后的结果为:");
            // foreach(int b in a)
            // {
            //     Console.Write(b + "");
            // }
            // Console.WriteLine();

            /***
             * 1	Clear()	清空数组中的元素
             * 2    Sort()	冒泡排序,从小到大排序数组中的元素
             * 3	Reverse()	将数组中的元素逆序排列
             * 4	IndexOf()	查找数组中是否含有某个元素,返回该元素第一次出现的位置,如果没有与之匹配的元素,则返回 -1
             * 5	LastIndexOf()	查找数组中是否含有某个元素,返回该元素最后一次出现的位置
             */

            // int[] a = { 5, 3, 2, 4, 1 };
            // Array.Sort(a);
            // Console.WriteLine("排序后的结果为:");
            // foreach(int b in a)
            // {
            //     Console.Write(b + " ");
            // }
            // Console.WriteLine();

            // System.Console.WriteLine(EnumTest.Title.助教 + ": " + (int)EnumTest.Title.助教);
            // System.Console.WriteLine(EnumTest.Title.讲师 + ": " + (int)EnumTest.Title.讲师);
            // System.Console.WriteLine(EnumTest.Title.副教授 + ": " + (int)EnumTest.Title.副教授);
            // System.Console.WriteLine(EnumTest.Title.教授 + ": " + (int)EnumTest.Title.教授);

            // student stu = new student ();
            // stu.Name = "张三";
            // stu.Age = -100;
            // System.Console.WriteLine("学生的信息为:");
            // System.Console.WriteLine(stu.Name + ": " + stu.Age);

            student stu = new student("李四", 25);

            stu.PrintStudent();
        }
예제 #31
0
 //修改
 public ActionResult upDateStudent(student stu)
 {
     entity.Entry <student>(stu).State = System.Data.Entity.EntityState.Modified;
     entity.SaveChanges();
     return(RedirectToAction("Index"));
 }
예제 #32
0
        public override object GetById(string Id)
        {
            student student = (from s in dbEntities.students where s.id.Equals(Id) select s).SingleOrDefault();

            return(student);
        }
예제 #33
0
파일: StudentService.cs 프로젝트: wpmyj/LC
        /// <summary>
        /// 更新学员信息
        /// </summary>
        /// <param name="newClassEditModel">需要更新的学员信息</param>
        public StudentEditModel Update(StudentEditModel newStudentEditModel)
        {
            try
            {
                Repository <student> studentModuleDal = _unitOfWork.GetRepository <student>();
                student studententity = studentModuleDal.GetObjectByKey(newStudentEditModel.Id).Entity;
                if (studententity != null)
                {
                    studententity.address            = newStudentEditModel.Address;
                    studententity.center_id          = newStudentEditModel.CenterId;
                    studententity.dads_name          = newStudentEditModel.Dadsname;
                    studententity.dads_phone         = newStudentEditModel.Dadsphone;
                    studententity.email              = newStudentEditModel.Email;
                    studententity.extra_info         = newStudentEditModel.ExtraInfo;
                    studententity.google_contacts_id = newStudentEditModel.GoogleContactsId;
                    studententity.grade              = newStudentEditModel.Grade;
                    studententity.moms_name          = newStudentEditModel.Momsname;
                    studententity.moms_phone         = newStudentEditModel.Momsphone;
                    studententity.original_class     = newStudentEditModel.OriginalClass;
                    studententity.relationship       = newStudentEditModel.RelationShip;
                    studententity.remaining_balance  = newStudentEditModel.RemainingBalance;
                    studententity.rfid_tag           = newStudentEditModel.RfidTag;
                    studententity.school             = newStudentEditModel.School;
                    studententity.students_birthdate = newStudentEditModel.Birthdate;
                    studententity.students_name      = newStudentEditModel.Name;
                    studententity.students_nickname  = newStudentEditModel.Nickname;
                    studententity.student_id         = newStudentEditModel.Id;
                    studententity.status             = newStudentEditModel.StatusId;

                    if (studententity.consultants.Count > 0)
                    {
                        studententity.consultants.Clear();
                    }

                    if (newStudentEditModel.ConsultantId != 0)
                    {
                        Repository <consultant> consultantModuleDal = _unitOfWork.GetRepository <consultant>();
                        consultant consultantEntity = consultantModuleDal.GetObjectByKey(newStudentEditModel.ConsultantId).Entity;
                        studententity.consultants.Add(consultantEntity);
                    }

                    if (newStudentEditModel.ConsultantRate != 0)
                    {
                        studententity.consultant_check_rate = newStudentEditModel.ConsultantRate;
                    }

                    studententity.classess.Clear();
                    if (newStudentEditModel.ClassesId != null)
                    {
                        Repository <classes> classesDal = _unitOfWork.GetRepository <classes>();
                        foreach (int classid in newStudentEditModel.ClassesId)
                        {
                            classes cls = classesDal.GetObjectByKey(classid).Entity;
                            studententity.classess.Add(cls);
                        }
                    }
                }

                _unitOfWork.AddAction(studententity, DataActions.Update);
                _unitOfWork.Save();

                return(newStudentEditModel);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
예제 #34
0
 public void Post([FromBody] student student)
 {
     _CURDContext.Students.Add(student);
     _CURDContext.SaveChanges();
 }
예제 #35
0
        static void Main(string[] args)
        {
            // 5.Run the same code in Program.cs from Module 5 to create instances of your classes so that you can setup a single course that is part of a program and a degree path. Be sure to include at least one Teacher and an array of Students.
            student student1 = new student();
            student1.Firstname = "Tony";
            student1.Lastname = "Stark";
            student1.Dateofbirth = "1st Jan 1969";
            student1.Grades.Push(90);
            student1.Grades.Push(100);
            student1.Grades.Push(90);
            student1.Grades.Push(75);
            student1.Grades.Push(60);

            student student2 = new student();
            student2.Firstname = "Steve";
            student2.Lastname = "Rodgers";
            student2.Dateofbirth = "1st Feb 1920";
            student2.Grades.Push(90);
            student2.Grades.Push(100);
            student2.Grades.Push(90);
            student2.Grades.Push(75);
            student2.Grades.Push(60);

            student student3 = new student();
            student3.Firstname = "Bruce";
            student3.Lastname = "Banner";
            student3.Dateofbirth = "1st April 1975";
            student3.Grades.Push(90);
            student3.Grades.Push(100);
            student3.Grades.Push(90);
            student3.Grades.Push(75);
            student3.Grades.Push(60);

            //2.Instantiate a Course object called Programming with C#.
            course ProgrammingCourses = new course();
            ProgrammingCourses.CourseTitle = "Programming with C#";
            ProgrammingCourses.CourseLength = 3;
            ProgrammingCourses.CourseCredits = 90;

            //3.Add your three students to this Course object
            ProgrammingCourses.students.Add(student1);
            ProgrammingCourses.students.Add(student2);
            ProgrammingCourses.students.Add(student3);

            //4.Instantiate at least one Teacher object.
            teacher teacher1 = new teacher();
            teacher1.Firstname = "Stan";
            teacher1.Lastname = "Winston";
            teacher1.Dateofbirth = "1st Dec 1919";

            //5.Add that Teacher object to your Course object
            ProgrammingCourses.teachers[0] = teacher1;

            //6.Instantiate a Degree object, such as Bachelor.
            degree degree1 = new degree();
            degree1.DegreeName = "Bachelor";

            //7.Add your Course object to the Degree object.
            degree1.degreecourse = ProgrammingCourses;

            //8.Instantiate a UProgram object called Information Technology.
            uprogram uprogram1 = new uprogram();
            uprogram1.Programtitle = "Information Technology";

            //9.Add the Degree object to the UProgram object.
            uprogram1.Programdegree = degree1;

            //10.Using Console.WriteLine statements, output
            //Console.WriteLine("The {0} program contains the {1} degree", uprogram1.Programtitle, degree1.DegreeName);
            //Console.WriteLine("The {0} degree contains the course {1}", degree1.DegreeName, ProgrammingCourses.CourseTitle);
            //Console.WriteLine("The {0} course contains {1} students(s)", ProgrammingCourses.CourseTitle, ProgrammingCourses.CourseTitle);

            ProgrammingCourses.ListStudents();
        }
예제 #36
0
 //扩展自定义类
 public static void printAge(this student _student)
 {
     MonoBehaviour.print(_student.age);
 }
 partial void Updatestudent(student instance);
예제 #38
0
        public ActionResult Index(string value, int?year, int?term)
        {
            lecturer _lect     = new lecturer();
            bool     isStudent = true;

            var _listStudent = db.students.ToList();

            // convert list of student to list of User
            List <User> _listUser = findUser.GetListUser(_listStudent);

            // find if input value existing in the list of user
            User _user = findUser.FindUserByInputValue(_listUser, value);

            // if user is null then try to find out if the input value is the lecturer
            if (_user == null)
            {
                var _listLecturer = db.lecturers.ToList();

                // convert the list of lectuer to list of user
                _listUser = findUser.GetListUser(_listLecturer);

                // find out if the input value existing in the list of user
                _lect = findUser.FindUserByInputValue(_listUser, value);

                // if can't find lecturer, then redirect to Home controller
                if (_lect == null)
                {
                    return(RedirectToAction("Index", "Home", new { notFound = false }));
                }
                else
                {
                    Session["user"] = _lect;
                    //Session["lecturer"] = _lect;
                    //Session["lecturerId"] = _lect.LecturerID;
                    isStudent = false;
                }
            }
            else
            {
                if (Session["user"] == null)
                {
                    Session["user"] = _user;
                }

                isStudent = true;
            }

            if (isStudent)
            {
                if (Session["lecturerId"] != null)
                {
                    _lect            = db.lecturers.Find((string)Session["lecturerId"]);
                    ViewBag.lecturer = _lect;
                }

                student _student = db.students.Find(_user.LecturerID);

                List <student_studyplan> studyPlans    = _student.student_studyplan.ToList();
                List <SelectListItem>    quals         = new List <SelectListItem>();
                List <SelectListItem>    studyPlanYear = new List <SelectListItem>();
                List <SelectListItem>    terms         = new List <SelectListItem>();

                foreach (var item in studyPlans)
                {
                    quals.Add(new SelectListItem
                    {
                        Text  = item.qualification.QualName,
                        Value = item.QualCode
                    });
                }

                foreach (var item in studyPlans)
                {
                    studyPlanYear.Add(new SelectListItem
                    {
                        Text  = item.TermYearStart.ToString(),
                        Value = item.TermYearStart.ToString()
                    });
                }
                for (int i = 1; i < 5; i++)
                {
                    terms.Add(new SelectListItem
                    {
                        Text  = i.ToString(),
                        Value = i.ToString()
                    });
                }

                ViewBag.quals         = quals;
                ViewBag.studyPlanYear = studyPlanYear;
                ViewBag.terms         = terms;
                ViewBag.year          = year;
                ViewBag.term          = term;
                return(View("Student", _student));
            }
            else
            {
                List <SelectListItem> listDept = new List <SelectListItem>();

                List <crn_detail> listCrn = new List <crn_detail>();
                listCrn = db.lecturers.Find(_lect.LecturerID).crn_detail.ToList(); //_lect.crn_detail.ToList();
                HashSet <string> dept = new HashSet <string>();
                foreach (var item in listCrn)
                {
                    dept.Add(item.department.Department1);
                }
                foreach (var item in dept)
                {
                    listDept.Add(new SelectListItem
                    {
                        Text  = item,
                        Value = item
                    });
                }
                ViewBag.dept = listDept;
                return(View("Lecturer", _lect));
            }
        }
예제 #39
0
        static void Main(string[] args)
        {
            #region Module 5 Code
            //Instantiate a Course object called Programming with C#
            course programmingWithCSharp = new course();
            programmingWithCSharp.CourseName = "Programming in C#";

            //Instantiate three student objects and add them to the course object
            programmingWithCSharp.Students = new student[3];
            for (int i = 0; i < 3; i++)
            {
                programmingWithCSharp.Students[i] = new student();
                student.StudentCount++;
            }

            student student1 = new student();
            try
            {
                student1.TakeTest();
            }
            catch (NotImplementedException notImplemented)
            {
                Console.WriteLine(notImplemented.Message);
            }

            //Instantiate at least one Teacher object
            teacher teacher1 = new teacher();

            //Add that Teacher object to your Course object - only 1 instructor for this module
            programmingWithCSharp.Instructor = new teacher[1] { teacher1 };

            //Instantiate a Degree object
            degree bachelorDegree = new degree();

            //Add your Course object to the Degree object
            bachelorDegree.Course = programmingWithCSharp;

            //Instantiate a UProgram object called Information Technology
            uprogram informationTechnology = new uprogram();

            //Add the Degree object to the UProgram object
            informationTechnology.Degrees = bachelorDegree;
            //These are added for readability and testing in output
            informationTechnology.ProgramName = "Information Technology";
            informationTechnology.Degrees.DegreeName = "ISAT";

            //Console Output
            Console.WriteLine("The name of the Program is {0} and the Degree is {1}.", informationTechnology.ProgramName, informationTechnology.Degrees.DegreeName);
            Console.WriteLine("The name of the Course is {0}.", informationTechnology.Degrees.Course.CourseName);
            Console.WriteLine("The number of students enrolled is {0}", student.StudentCount);

            #endregion

            #region Challenge Code
            //Create an instance of a Person object in code
            person person1 = new person();
            //Create an instance of a Student object in code
            student student2 = new student();
            //Assign the Student object to the Person object
            person1 = student2;
            //Access the properties of the Person instance you created
            person1.FirstName = "Thomas";

            //This doesn't work because person1 is an instance of the person class
            //When we assign an inherited class back to a parent object, we lose the
            //functionality of the inherited class.

            //person1.TakeTest();

            Console.WriteLine(person1.FirstName);
            #endregion
        }
예제 #40
0
파일: Util.cs 프로젝트: zesus19/c4.v2
        public static void UploadInfoToXDD(string gardenID, string gardenName, DataTable data)
        {
            string url = "http://xdd.xindoudou.cn/2/partner/sync";

            if (data.Rows.Count > 0)
            {
                string    key = "76e8e4411055443c9def688b969c9ac6";
                Hashtable ht  = new Hashtable();
                foreach (DataRow dr in data.Rows)
                {
                    string classNumber = dr["info_machineAddr"].ToString();
                    if (classNumber != null && classNumber != string.Empty)
                    {
                        Class @class = null;
                        if (!ht.ContainsKey(classNumber))
                        {
                            @class          = new Class();
                            @class.id       = dr["info_machineAddr"].ToString();
                            @class.name     = dr["info_className"].ToString();
                            @class.students = new ArrayList();
                            ht[classNumber] = @class;
                        }
                        else
                        {
                            @class = ht[classNumber] as Class;
                        }
                        student stu = new student();
                        stu.id   = dr["info_stuID"].ToString();
                        stu.name = dr["info_stuName"].ToString();
                        @class.students.Add(stu);
                    }
                }

                ClassList list = new ClassList();
                list.List = new ArrayList();
                foreach (Class @class in ht.Values)
                {
                    list.List.Add(@class);
                }

                HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
                request.Method      = "POST";
                request.ContentType = "application/x-www-form-urlencoded";
                request.UserAgent   = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";

                StringBuilder sb = new StringBuilder();
                sb.Append(key);
                sb.Append("city=");
                sb.Append("&province=");
                sb.Append(string.Format("&school_id={0}", gardenID));
                sb.Append(string.Format("&school_name={0}", gardenName));

                byte[] hash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(sb.ToString()));
                sb = new StringBuilder();
                foreach (byte b in hash)
                {
                    sb.Append(b.ToString("x2"));
                }

                string json = AjaxPro.JavaScriptSerializer.Serialize(list);
                json = json.Substring(8, json.Length - 9);
                byte[] val = Encoding.UTF8.GetBytes(string.Format("key={0}&school_id={1}&school_name={2}&province={3}&city={4}&md5={5}&classes={6}",
                                                                  key, gardenID, gardenName, string.Empty, string.Empty, sb.ToString(), json));


                using (Stream stream = request.GetRequestStream())
                {
                    stream.Write(val, 0, val.Length);
                }

                WebResponse response = request.GetResponse();
                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                {
                    string s = reader.ReadToEnd();
                }
            }
        }
예제 #41
0
 public void AddTostudents(student student)
 {
     base.AddObject("students", student);
 }
    protected void updateStudentBtn_Click(object sender, EventArgs e)
    {
        student Student = new student();
        if (isTextBoxEmpty(stuIdTB, "学生学号")) Student.stuId = getText(stuIdTB);
        else return;
        if (isTextBoxEmpty(nameTB, "学生姓名")) Student.name = getText(nameTB);
        else return;
        Student.sex = sexDDL.SelectedItem.Value;
        if (isTextBoxEmpty(nationTB, "民族")) Student.nation = getText(nationTB);
        else return;
        if (isTextBoxEmpty(birthdayTB, "出生日期"))
        {
            string birthday = getText(birthdayTB);
            if (birthday.Length != 8)
            {
                MessageBox.Show(this, "出生日期格式不正确!");
                return;
            }
            Student.birthday = birthday;
        }
        else return;
        if (isTextBoxEmpty(certificateTypeTB, "证件类型")) Student.certificateType = getText(certificateTypeTB);
        else return;
        if (isTextBoxEmpty(certificateIdTB, "证件号码")) Student.certificateId = getText(certificateIdTB);
        else return;
        if (isTextBoxEmpty(schoolYearTB, "入学时间")) Student.admissionDate = getText(schoolYearTB);
        else return;
        if (isTextBoxEmpty(majorIdTB, "专业代码")) Student.majorId = getText(majorIdTB);
        else return;
        if (isTextBoxEmpty(majorNameTB, "专业名称")) Student.majorName = getText(majorNameTB);
        else return;
        if (isTextBoxEmpty(colleageTB, "所在学院")) Student.colleage = getText(colleageTB);
        else return;
        Student.classType = getText(classTypeTB);
        Student.degree = getText(degreeTB);
        Student.type = getText(typeTB);
        Student.placeOfWork = getText(placeOfWorkTB);
        Student.workPhone = getText(workPhoneTB);
        if (isTextBoxEmpty(phoneTB, "移动电话")) Student.phone = getText(phoneTB);
        else return;
        Student.email = getText(emailTB);
        Student.address = getText(addressTB);
        Student.zipCode = getText(zipCodeTB);
        string passWord = Tools.safeUserInput(passWordTB.Text.Trim().ToString());
        studentBLL StudentBLL = new studentBLL();
        if (passWord.Length < 1) Student.passWord = StudentBLL.GetModel(id).passWord;
        else Student.passWord = Tools.encrypt(passWord);

        if (StudentBLL.GetModel(id).stuId != Student.stuId)
        {
            examrecordBLL ExamRecordBLL = new examrecordBLL();
            studentloginlogBLL StudentLoginLogBLL = new studentloginlogBLL();
            try
            {
                StudentBLL.Add(Student);
                ExamRecordBLL.repalaceStuId(StudentBLL.GetModel(id).stuId, Student.stuId);
                StudentLoginLogBLL.repalaceStuId(StudentBLL.GetModel(id).stuId, Student.stuId);
                StudentBLL.Delete(id);

            }
            catch
            {
                MessageBox.Show(this, "更新失败!");
            }
        }
        if (Session["StuId"].ToString().Trim().Equals(getText(stuIdTB)))
        {
            Student.id = id;
            try
            {
                StudentBLL.Update(Student);
            }
            catch
            {
                MessageBox.Show(this, "更新失败!");
            }
        }
        MessageBox.ShowAndRedirect(this, "更新成功!", "student.aspx");
    }
예제 #43
0
 public bool UpdateStudentinformation(int id, student student)
 {
     return(_Istudentrespiratory.UpdateStudentInfo(id, student));
 }
예제 #44
0
 static void Main(string[] args)
 {
     student stu = new student(1,"海贼王");
     stu.
 }
예제 #45
0
        public void AddStudent(student stud)
        {
            studdl a = new studdl();

            a.AddStudent(stud);
        }
예제 #46
0
파일: StudentService.cs 프로젝트: wpmyj/LC
        /// <summary>
        /// 根据学员编号删除学员信息
        /// </summary>
        /// <param name="userCode">学员编号</param>
        public bool DeleteById(int id)
        {
            bool res = true;

            try
            {
                Repository <student>             studentModuleDal = _unitOfWork.GetRepository <student>();
                Repository <class_record_detail> crdDal           = _unitOfWork.GetRepository <class_record_detail>();
                student studententity = studentModuleDal.GetObjectByKey(id).Entity;
                if (studententity != null)
                {
                    if (studententity.student_recharge_detail.Count > 0)
                    {
                        throw new FaultException <LCFault>(new LCFault("删除学员失败"), "该学员已经参与过充值、上课等内容,无法删除");
                    }
                    else
                    {
                        if (studententity.consultants != null && studententity.consultants.Count > 0)
                        {
                            //如果该学员设置了会籍顾问,需要先删除会籍顾问
                            studententity.consultants.Clear();
                        }
                        if (studententity.classess != null && studententity.classess.Count > 0)
                        {
                            //如果给这个学员分配过班级,则先需要删除学员班级信息
                            studententity.classess.Clear();
                        }

                        //删除未签到的上课记录
                        IEnumerable <class_record_detail> crds = crdDal.Find(cr => cr.student_id == studententity.student_id).Entities;
                        foreach (class_record_detail crd in crds)
                        {
                            _unitOfWork.AddAction(crd, DataActions.Delete);
                        }

                        _unitOfWork.AddAction(studententity, DataActions.Delete);
                        _unitOfWork.Save();
                    }
                }
                else
                {
                    res = false;
                    throw new FaultException <LCFault>(new LCFault("删除学员失败"), "该学员不存在,无法删除");
                }
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            return(res);
        }
예제 #47
0
 public string stu_Update(student stu)
 {
     SqlConnection myConn = GetConnection();
     myConn.Open();
     SqlCommand myCmd = new SqlCommand("stuUpdate", myConn);
     myCmd.CommandType = CommandType.StoredProcedure;
     myCmd.Parameters.AddWithValue("@sno", stu.Sno);
     myCmd.Parameters.AddWithValue("@sname", stu.Sname);
     myCmd.Parameters.AddWithValue("@sex", stu.Sex);
     myCmd.Parameters.AddWithValue("@institute", stu.Institute);
     myCmd.Parameters.AddWithValue("@major", stu.Major);
     myCmd.Parameters.AddWithValue("@sclass", stu.Sclass);
     myCmd.Parameters.AddWithValue("@tel", stu.Tel);
     myCmd.Parameters.AddWithValue("@email", stu.Email);
     myCmd.Parameters.AddWithValue("@englishLevel", stu.EnglishLevel);
     myCmd.Parameters.AddWithValue("@honour", stu.Honour);
     myCmd.Parameters.AddWithValue("@intro", stu.Intro);
     myCmd.Parameters.AddWithValue("@remark", stu.Remark);
     int i = myCmd.ExecuteNonQuery();
     myConn.Close();
     if (i > 0)
         return string.Format("{0} {1} 修改信息成功", stu.Sno.Trim(), stu.Sname.Trim());
     else
         return string.Format("{0} {1} 修改信息失败", stu.Sno.Trim(), stu.Sname.Trim());
 }
 partial void Insertstudent(student instance);
예제 #49
0
        public ActionResult Edit(student student, HttpPostedFileBase photo)
        {
            if (ModelState.IsValid)
            {
                if (student.EnrollDate < DateTime.Now && student.EnrollDate > Convert.ToDateTime("2000/10/18"))
                {
                    if (photo != null && photo.ContentLength > 0)
                    {
                        var fileName  = Path.GetFileName(photo.FileName);
                        var fileName1 = Path.GetFileNameWithoutExtension(photo.FileName);
                        fileName1 = fileName1.Replace(" ", "_");

                        // extract only the fielname
                        var ext = Path.GetExtension(fileName.ToLower());            //extract only the extension of filename and then convert it into lower case.


                        int name = student.Id;

                        string firstpath1 = "/StuPhoto/";
                        string secondpath = "/StuPhoto/" + name + "/";
                        bool   exists1    = System.IO.Directory.Exists(Server.MapPath(firstpath1));
                        bool   exists2    = System.IO.Directory.Exists(Server.MapPath(secondpath));
                        if (!exists1)
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(firstpath1));
                        }
                        if (!exists2)
                        {
                            System.IO.Directory.CreateDirectory(Server.MapPath(secondpath));
                        }
                        var path = Server.MapPath("/StuPhoto/" + name + "/" + fileName1 + ext);

                        photo.SaveAs(path);
                        student.photopath = "/StuPhoto/" + name + "/" + fileName1 + ext;
                    }
                    else
                    {
                        student.photopath = db.students.Where(m => m.Id == student.Id).FirstOrDefault().photopath;
                    }
                    student std = db.students.Where(m => m.Id == student.Id).FirstOrDefault();
                    std.FirstName  = student.FirstName;
                    std.MiddleName = student.LastName;
                    std.LastName   = student.LastName;
                    std.photopath  = student.photopath;
                    std.RollNo     = student.RollNo;
                    std.Gender     = student.Gender;
                    std.SemisterId = student.SemisterId;
                    std.Status     = true;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                ModelState.AddModelError("", "Date is not valid");
            }
            List <SelectListItem> listItems = new List <SelectListItem>();


            foreach (var item in db.semisters)
            {
                listItems.Add(new SelectListItem
                {
                    Text  = item.SemesterName,
                    Value = item.Id.ToString()
                });
            }

            ViewBag.SemId = listItems;
            return(View(student));
        }
 partial void Deletestudent(student instance);
예제 #51
0
        public ActionResult Create(student student, HttpPostedFileBase photo)
        {
            if (ModelState.IsValid)
            {
                if (student.EnrollDate < DateTime.Now && student.EnrollDate > Convert.ToDateTime("2000/10/18"))
                {
                    var email = db.login.Where(m => m.Email == student.Email).ToList();
                    if (email.Count == 0)
                    {
                        if (photo != null && photo.ContentLength > 0)
                        {
                            var fileName  = Path.GetFileName(photo.FileName);
                            var fileName1 = Path.GetFileNameWithoutExtension(photo.FileName);
                            fileName1 = fileName1.Replace(" ", "_");

                            // extract only the fielname
                            var ext = Path.GetExtension(fileName.ToLower());            //extract only the extension of filename and then convert it into lower case.


                            int name;
                            try
                            {
                                name = db.students.OrderByDescending(m => m.Id).FirstOrDefault().Id;
                            }
                            catch
                            {
                                name = 1;
                            }
                            string firstpath1 = "/StuPhoto/";
                            string secondpath = "/StuPhoto/" + name + "/";
                            bool   exists1    = System.IO.Directory.Exists(Server.MapPath(firstpath1));
                            bool   exists2    = System.IO.Directory.Exists(Server.MapPath(secondpath));
                            if (!exists1)
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath(firstpath1));
                            }
                            if (!exists2)
                            {
                                System.IO.Directory.CreateDirectory(Server.MapPath(secondpath));
                            }
                            var path = Server.MapPath("/StuPhoto/" + name + "/" + fileName1 + ext);

                            photo.SaveAs(path);
                            student.photopath = "/StuPhoto/" + name + "/" + fileName1 + ext;
                        }
                        int data = db.login.Where(t => t.Email == student.Email).Count();
                        if (data > 0)
                        {
                            ModelState.AddModelError("", "Email already exists");
                            return(View());
                        }
                        Random generator = new Random();
                        String password  = generator.Next(0, 999999).ToString("D6");



                        var message = new MailMessage();
                        message.To.Add(new MailAddress(student.Email));
                        message.Subject = "Account has been created";
                        message.Body    = "Use this Password to login:"******"student",
                                    RandomPass = password,
                                    LoginTime  = DateTime.Now
                                });


                                TempData["Message"] = "Student Created Successfully.";
                            }
                            catch (Exception e)
                            {
                                return(new HttpStatusCodeResult(HttpStatusCode.RequestTimeout));
                            }
                        }
                        student.Status = true;
                        db.students.Add(student);
                        db.SaveChanges();
                        int           id    = student.Id;
                        var           text  = System.IO.File.ReadAllText("/Data/NewBehavior.txt");
                        List <string> lines = System.IO.File.ReadAllLines("/Data/NewBehavior.txt").ToList();
                        int           index = text.IndexOf("# User actions");
                        text = text.Insert(index, id + "," + student.FirstName + Environment.NewLine);
                        System.IO.File.WriteAllText("/Data/NewBehavior.txt", text);

                        return(RedirectToAction("Index"));
                    }
                    ModelState.AddModelError("", "email already exists");
                }
                else
                {
                    ModelState.AddModelError("", "Date is not valid");
                }
            }
            List <SelectListItem> listItems = new List <SelectListItem>();


            foreach (var item in db.semisters)
            {
                listItems.Add(new SelectListItem
                {
                    Text  = item.SemesterName,
                    Value = item.Id.ToString()
                });
            }

            ViewBag.SemId = listItems;
            return(View(student));
        }