Пример #1
0
        //学号控件的键盘事件,用户查询学生信息
        private void txtstu_no_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Return)                                       //判断用户按下的是不是回车键
            {
                StudentsServiceSoapClient ss = new StudentsServiceSoapClient(); //实例化Web服务的对象
                Student student = new Student();                                //对应表的实体(Model)对象
                //只需要给学号的信息赋值
                student.stu_no = txtstu_no.Text.Trim();                         //把控件中的值,赋给实体对象的属因为
                student        = ss.SelectStudent(student);
                if (student == null)
                {
                    MessageBox.Show("学号信息不存在!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                txtstu_age.Text   = student.stu_age.ToString();
                txtstu_card.Text  = student.stu_card;
                txtstu_class.Text = student.stu_class;
                txtstu_major.Text = student.stu_major;
                txtstu_name.Text  = student.stu_name;
                txtstu_nat.Text   = student.stu_nat;
                txtstu_no.Text    = student.stu_no;
                txtstu_pwd.Text   = student.stu_pwd;
                txtstu_sex.Text   = student.stu_sex;
            }
        }
Пример #2
0
        private void FrmStuSearch_Load(object sender, EventArgs e)
        {
            StudentsServiceSoapClient ss = new  StudentsServiceSoapClient();
            DataTable dt = ss.SearchStudent();

            DGViewStu.DataSource = dt.DefaultView;
        }
Пример #3
0
        //删除
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("确定要删除" + txtstu_no.Text.Trim() + "学员的信息吗?", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                StudentsServiceSoapClient ss = new StudentsServiceSoapClient(); //实例化Web服务的对象
                Student student = new Student();                                //对应表的实体(Model)对象

                student.stu_no = txtstu_no.Text.Trim();

                string message = ss.DeleteStudent(student);
                MessageBox.Show(message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Пример #4
0
        //修改
        private void btnAlter_Click(object sender, EventArgs e)
        {
            StudentsServiceSoapClient ss = new StudentsServiceSoapClient(); //实例化Web服务的对象
            Student student = new Student();                                //对应表的实体(Model)对象

            student.stu_no    = txtstu_no.Text.Trim();
            student.stu_name  = txtstu_name.Text.Trim();//把控件中的值,赋给实体对象的属性
            student.stu_major = txtstu_major.Text.Trim();
            student.stu_class = txtstu_class.Text.Trim();
            student.stu_sex   = txtstu_sex.Text.Trim();
            student.stu_age   = int.Parse(txtstu_age.Text.Trim());
            student.stu_nat   = txtstu_nat.Text.Trim();
            student.stu_card  = txtstu_card.Text.Trim();
            student.stu_pwd   = Program.md5(txtstu_pwd.Text.Trim());

            string message = ss.UpdateStudent(student);

            MessageBox.Show(message, "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }