示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            bool rs = false;

            using (GeneralRepository <DAL.Sql.Modles.Course> repository = new GeneralRepository <DAL.Sql.Modles.Course>())
            {
                DAL.Sql.Modles.Course data = null;
                if (CourseID != -1)
                {
                    data = repository.Find(x => x.CourseID == CourseID).FirstOrDefault();
                    rs   = repository.Update(GetData(data));
                    lblSatusInfo.Text = rs ? "Updating is successful!" : "Updating had been failed!";
                }
                else
                {
                    data = new DAL.Sql.Modles.Course();
                    rs   = repository.Add(GetData(data)) > 0;
                    lblSatusInfo.Text = rs ? "Inserting is successful!" : "Inserting had been failed!";
                }
            }
            if (rs)
            {
                PopulateControls();
            }
        }
示例#2
0
 private void SetData(DAL.Sql.Modles.Course source)
 {
     txtID.Text                  = source.CourseID.ToString();
     txtName.Text                = source.Name;
     txtStartDate.Text           = source.StartDate.ToString();
     txtFee.Text                 = source.Fee.ToString();
     txtDuration.Text            = source.Duration.ToString();
     chkIsActive.Checked         = source.IsActive == null? false : Convert.ToBoolean(source.IsActive);
     txtIntroduction.Text        = source.Introduction;
     ddlMembers.SelectedValue    = source.TearcherID.ToString();
     ddlCategories.SelectedValue = source.CategoryID.ToString();
 }
示例#3
0
 private DAL.Sql.Modles.Course GetData(DAL.Sql.Modles.Course source)
 {
     source.Name         = txtName.Text;
     source.CategoryID   = Convert.ToInt32(ddlCategories.SelectedValue);
     source.TearcherID   = Convert.ToInt32(ddlMembers.SelectedValue);
     source.StartDate    = Convert.ToDateTime(txtStartDate.Text);
     source.Duration     = Convert.ToInt32(txtDuration.Text);
     source.Fee          = Convert.ToDecimal(txtFee.Text);
     source.IsActive     = chkIsActive.Checked;
     source.Introduction = txtIntroduction.Text;
     return(source);
 }
示例#4
0
        public string ShowData(object input, string columnName)
        {
            DAL.Sql.Modles.Course data = input as DAL.Sql.Modles.Course;
            switch (columnName)
            {
            case "CourseID":
                return(String.Format("<input type='checkbox' name='cid' id='cid' value='{0}' />", data.CourseID));

            case "IsActive":
                return(data.IsActive != null ? ((bool)data.IsActive ? Link.ToAdminImage("checkbox.png") : Link.ToAdminImage("none.png")) : Link.ToAdminImage("none.png"));

            default:
                return("");
            }
        }