Ejemplo n.º 1
0
        public EditTerm()
        {
            InitializeComponent();

            //查询当前学期
            jdm = new JszxDataManager();
            tm = jdm.GetCurrentTerm();
            SetTermContent();
        }
Ejemplo n.º 2
0
        private void SaveTermForm_Click_1(object sender, RoutedEventArgs e)
        {
            terms_tb _tm = new terms_tb();
            //学期开始日期
            if (this.TermStartDay.SelectedDate == null)
            {
                MessageBox.Show("请选择本学期开始日期!");
            }
            else
            {
                _tm.TermStartDay = (DateTime)this.TermStartDay.SelectedDate;
            }
            //学期周数
            if (this.TermWeeks != null)
            {
                _tm.TermWeeks =Convert.ToSByte(this.TermWeeks.Text.Trim());
            }
            else
            {
                MessageBox.Show("请填写本学期周数!");
            }
            //学年
            if (this.TermYear != null)
            {
                _tm.TermYear = this.TermYear.Text.Trim();
            }
            else
            {
                MessageBox.Show("请填写学年!");
            }

            //学期
            if ((bool)this.TermIndex_False.IsChecked)
            {
                _tm.TermIndex = false;
            }
            if ((bool)this.TermIndex_True.IsChecked)
            {
                _tm.TermIndex = true;
            }
            //是否当前学期
            if ((bool)this.TermIsUse_False.IsChecked)
            {
                _tm.TermIsUse = false;

            }
            if ((bool)this.TermIsUse_True.IsChecked)
            {
                _tm.TermIsUse = true;
            }
            if (isAdd)
            {
                //新增学期
                tm = _tm;
            }
            else
            {
                _tm.TermID = tm.TermID;
                tm = _tm;
            }
            tm.TermID = jdm.SaveTerm(tm);
            this.TermFormGrid.Visibility = Visibility.Hidden;
            SetTermContent();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存学期
        /// </summary>
        /// <param name="tm"></param>
        public int SaveTerm(terms_tb tm)
        {
            //重置当前学期
            if (tm.TermIsUse)
            {
                foreach (terms_tb vtm in jszxEntity.terms_tb.Where(t => t.TermIsUse == true & t.TermID!=tm.TermID))
                {
                    vtm.TermIsUse = false;
                }

            }
            if (tm.TermID == 0)
            {
                //保存新学期
                jszxEntity.terms_tb.Add(tm);
            }
            else
            {
                terms_tb _tm = jszxEntity.terms_tb.Where(t => t.TermID == tm.TermID).FirstOrDefault();
                _tm.TermIndex = tm.TermIndex;
                _tm.TermIsUse = tm.TermIsUse;
                _tm.TermStartDay = tm.TermStartDay;
                _tm.TermWeeks = tm.TermWeeks;
                _tm.TermYear = tm.TermYear;

            }
            jszxEntity.SaveChanges();
            return tm.TermID;
        }