示例#1
0
        protected void btnSaveYear_Click(object sender, EventArgs e)
        {
            bool isvalid = true;

            if (string.IsNullOrEmpty(txtName.Text))
            {
                isvalid             = false;
                valiTxtName.Visible = true;
            }
            if (cmbProgram.SelectedValue == "" || cmbProgram.SelectedValue == "0")
            {
                isvalid             = false;
                valiProgram.Visible = true;
            }
            if (string.IsNullOrEmpty(txtPosition.Text))
            {
                isvalid = false;
                valitxtPosition.Visible = true;
            }
            if (isvalid)
            {
                var year = new Academic.DbEntities.Structure.Year()
                {
                    Name = txtName.Text
                    ,
                    Position      = Convert.ToInt32(txtPosition.Text)
                    , ProgramId   = Convert.ToInt32(cmbProgram.SelectedValue)
                    , Description = txtDescription.Text
                    ,
                };

                using (var helper = new DbHelper.Structure())
                {
                    var saved = helper.AddOrUpdateYear(year);
                    if (saved != null)
                    {
                        if (OnSaveClicked != null)
                        {
                            OnSaveClicked(this, DbHelper.StaticValues.SuccessSaveMessageEventArgs);
                        }
                        ClearCreateTextBoxes();
                    }
                    else
                    {
                        if (OnSaveClicked != null)
                        {
                            OnSaveClicked(this, DbHelper.StaticValues.ErrorSaveMessageEventArgs);
                        }
                    }
                }
            }
            //if (OnSaveClicked != null)
            //{
            //    OnSaveClicked(this,EventArgs.Empty);
            //}
        }
示例#2
0
        bool SaveYear()
        {
            using (var helper = new DbHelper.Structure())
            {
                var year = new Academic.DbEntities.Structure.Year()
                {
                    Name = txtName.Text
                    ,
                    Description = txtDescription.Text
                    ,
                    Id = this.StructureId
                    ,
                    ProgramId = ParentId
                    ,
                    Position = Convert.ToInt32(string.IsNullOrEmpty(txtPosition.Text) ? "0" : txtPosition.Text)
                };

                var sems = new List <Academic.DbEntities.Structure.SubYear>();
                sems.Add(new Academic.DbEntities.Structure.SubYear()
                {
                    Id       = Sem1Id,
                    Name     = txtSem1Name.Text,
                    Position = 1,
                    Void     = false,
                    YearId   = StructureId,
                });
                sems.Add(new Academic.DbEntities.Structure.SubYear()
                {
                    Id       = Sem2Id,
                    Name     = txtSem2Name.Text,
                    Position = 2,
                    Void     = false,
                    YearId   = StructureId,
                });


                if (StructureId == 0)
                {
                    var date = DateTime.Now;
                    year.CreatedDate    = date;
                    sems[0].CreatedDate = date;
                    sems[1].CreatedDate = date;
                }

                var saved = helper.AddOrUpdateYear(year, sems);
                return(saved != null);
            }
        }
示例#3
0
        public void SetStructureData(Academic.DbEntities.Structure.Year year
                                     , Academic.DbEntities.Structure.SubYear subYear
                                     , List <Academic.DbEntities.Subjects.Subject> subjectsList

                                     , bool earlier = false)
        {
            if (year != null)
            {
                lblStructureName.Text = year.Name + ((subYear == null) ? "" : (" / " + subYear.Name));
            }
            dListCourses.DataSource = subjectsList;
            dListCourses.DataBind();
            if (earlier)
            {
                Image1.Visible           = true;
                lblStructureName.Enabled = true;
                dListCourses.Visible     = false;
            }
        }