예제 #1
0
 public ClassModify(StuClass s, UpData upData, string flag)
 {
     clas        = s;
     this.flag   = flag;
     this.upData = upData;
     InitializeComponent();
 }
예제 #2
0
        /// <summary>
        /// 据班级ID查询班级
        /// </summary>
        /// <param name="stuClass">班级信息</param>
        /// <returns>查询成功返回布尔值true,反之false</returns>
        public bool SelectByPK(StuClass stuClass)
        {
            try
            {
                using (StuInfo_Entities context = new StuInfo_Entities())
                {
                    var query = context.TClass.Single(c => c.ClassId == stuClass.ClassId && c.DelFlag != 1);

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// 删除班级记录
        /// </summary>
        /// <param name="stuClass">班级信息</param>
        /// <returns>插入成功返回布尔值true,反之false</returns>
        public bool DeleteByPK(StuClass stuClass)
        {
            try
            {
                using (StuInfo_Entities context = new StuInfo_Entities())
                {
                    var query = context.TClass.Single(c => c.ClassId == stuClass.ClassId);

                    query.DelFlag = 1;
                    context.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                throw;
            }
        }
예제 #4
0
        /// <summary>
        /// 得到指定ID班级信息
        /// </summary>
        /// <param name="stuClass">班级信息</param>
        /// <returns></returns>
        public List <StuClass> GetClassByPK(StuClass stuClass)
        {
            try
            {
                using (StuInfo_Entities context = new StuInfo_Entities())
                {
                    var stuc = from c in context.TClass.Where(c => c.ClassId == stuClass.ClassId && c.DelFlag != 1)
                               select new StuClass
                    {
                        ClassId    = c.ClassId,
                        ClassName  = c.ClassName,
                        UpdateTime = (DateTime)c.UpdateTime,
                        Remark     = c.Remark
                    };

                    return(stuc.ToList());
                }
            }
            catch
            {
                return(null);
            }
        }
예제 #5
0
        /// <summary>
        /// 修改班级信息
        /// </summary>
        /// <param name="stuClass">班级信息</param>
        /// <returns>修改成功返回布尔值true,反之false</returns>
        public bool UpData(StuClass stuClass)
        {
            try
            {
                using (StuInfo_Entities context = new StuInfo_Entities())
                {
                    var query = context.TClass.Single(c => c.ClassId == stuClass.ClassId);

                    query.ClassId    = stuClass.ClassId;
                    query.ClassName  = stuClass.ClassName;
                    query.UpdateTime = stuClass.UpdateTime;
                    query.Remark     = stuClass.Remark;

                    context.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                throw;
            }
        }
예제 #6
0
        /// <summary>
        /// 插入班级记录
        /// </summary>
        /// <param name="stuClass">班级信息</param>
        /// <returns>插入成功返回布尔值true,反之false</returns>
        public bool Insert(StuClass stuClass)
        {
            try
            {
                using (StuInfo_Entities context = new StuInfo_Entities())
                {
                    TClass stuc = new TClass
                    {
                        ClassName  = stuClass.ClassName,
                        UpdateTime = (DateTime)stuClass.UpdateTime,
                        Remark     = stuClass.Remark
                    };

                    context.TClass.Add(stuc);
                    context.SaveChanges();

                    return(true);
                }
            }
            catch
            {
                return(false);
            }
        }
예제 #7
0
        /// <summary>
        /// Id查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            int id;

            #region 学生查询
            if (radioButton1.Checked)
            {
                Student s = new Student();

                if (Int32.TryParse(textBox1.Text.Trim(), out id))
                {
                    s.StuId = id;

                    if (stuBll.SelectStuInfoByPK(s))
                    {
                        dataGridView1.DataSource = stuBll.GetStuInfoByPK(s);
                        MessageBox.Show("查询成功");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("无此条记录");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("请输入整形数据!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            #endregion

            #region 班级查询
            if (radioButton2.Checked)
            {
                StuClass c = new StuClass();

                if (Int32.TryParse(textBox1.Text.Trim(), out id))
                {
                    c.ClassId = id;
                    if (classBll.SelectClassByPK(c))
                    {
                        dataGridView2.DataSource = classBll.GetClassByPK(c);
                        MessageBox.Show("查询成功");
                        return;
                    }
                    else
                    {
                        MessageBox.Show("无此条记录");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("请输入整形数据!", "", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
            }
            #endregion
            MessageBox.Show("请选择查询对象");
        }