private void ProjectPlanForm_Activated(object sender, EventArgs e) { ProjectPlanList listForm = FormSingle.GetForm(typeof(ProjectPlanList)) as ProjectPlanList; this._projectPlanID = listForm.SelectedID; this._isCopy = listForm.IsCopy; if (_projectPlanID == -1) { this.cbxUnit.Text = ""; this.txtActivity.Text = ""; this.txtTask.Text = ""; this.txtBudgetWorkload.Text = ""; this.dtBudgetBeginDate.Text = ""; this.dtBudgetEndDate.Text = ""; this.cbxResource.Text = ""; this.txtBusinessCode.Text = ""; this.txtDiffAnalyze.Text = ""; } else { using (BugTraceEntities context = new BugTraceEntities(EntityContextHelper.GetEntityConnString())) { var projectPlanList = context.Set <PPM_ProjectPlan>().Where(p => p.ID == _projectPlanID); if (projectPlanList != null && projectPlanList.Count() > 0) { var projectPlan = projectPlanList.FirstOrDefault(); this.cbxUnit.Text = projectPlan.Unit; this.txtActivity.Text = projectPlan.Activity; this.txtTask.Text = projectPlan.Task; this.txtBudgetWorkload.Text = projectPlan.BudgetWorkload.ToString(); if (projectPlan.BudgetBeginDate != null) { this.dtBudgetBeginDate.ValueX = projectPlan.BudgetBeginDate; } else { this.dtBudgetBeginDate.ValueX = null; } if (projectPlan.BudgetEndDate != null) { this.dtBudgetEndDate.ValueX = projectPlan.BudgetEndDate; } else { this.dtBudgetEndDate.ValueX = null; } this.cbxResource.Text = projectPlan.ResourceName; this.txtBusinessCode.Text = projectPlan.BusinessCode; this.cbxPlanType.Text = projectPlan.PlanType; this.txtDiffAnalyze.Text = projectPlan.DiffAnalyze; if (projectPlan.HideFlag == 0) { this.rdoDisplay.Checked = true; this.rdoHide.Checked = false; } else { this.rdoDisplay.Checked = false; this.rdoHide.Checked = true; } } } } }