protected void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //try
            //{
                selectedProjectID = Convert.ToInt32(RadGrid1.SelectedValue);
                var query = from b in db.Projects where b.ProjectID == selectedProjectID select b;
                selectedProject = query.Single();

                ProjectNameTextBox.Text = selectedProject.ProjectName;
                StartDateDatePicker.SelectedDate = selectedProject.StartDate;
                EndDateDatePicker.SelectedDate = selectedProject.EndDate;
                CbxIsCompleted.Checked = Convert.ToBoolean( selectedProject.isCompleted);
                if (Page.IsPostBack)
                {
                    //string DeparmentName = selectedProject.Department;
                    //UserIDLabel.Text = DeparmentName;
                    departmentDDL.ClearSelection();
                    departmentDDL.Items.FindByValue(selectedProject.Department).Selected = true;
                }

            //}
            //catch (Exception)
            //{

            //}
        }
예제 #2
0
        protected void BtnAddRecord_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    Project newProject = new Project();
                    newProject.Department = departmentDDL.SelectedValue.ToString();
                    newProject.StartDate = StartDateDatePicker.SelectedDate;
                    newProject.EndDate = EndDateDatePicker.SelectedDate;
                    newProject.UserID = UserIDLabel.Text;
                    newProject.ProjectName = ProjectNameTextBox.Text;
                    newProject.isCompleted = false;

                    TasksEntities db = new TasksEntities();
                    db.Projects.Add(newProject);
                    db.SaveChanges();
                }

            }
            catch (Exception)
            {

            }
        }
        protected void BtnAddRecord_Click(object sender, EventArgs e)
        {
            try
            {
                Page.Validate();
                if (Page.IsValid)
                {
                    var query = from b in db.Projects where b.ProjectID == selectedProjectID select b;

                    selectedProject = query.Single();

                    selectedProject.Department = departmentDDL.SelectedValue.ToString();
                    selectedProject.StartDate = StartDateDatePicker.SelectedDate;
                    selectedProject.EndDate = EndDateDatePicker.SelectedDate;
                    selectedProject.UserID = UserIDLabel.Text;
                    selectedProject.ProjectName = ProjectNameTextBox.Text;
                    selectedProject.isCompleted = CbxIsCompleted.Checked;

                    db.SaveChanges();

                    RadGrid1.DataBind();

                }

            }
            catch (Exception)
            {

            }
        }