protected override void Page_Load(object sender, EventArgs e) { base.Page_Load(sender, e); //LookupCodeDa da = new LookupCodeDa(); //DataTable codes = da.GetLookupsByFieldName("ProjectApprovalType").Tables[0]; //if (codes.Rows.Count>0) //{ // int parentLkpId = int.Parse(codes.Rows[0]["LookupCodeId"].ToString()); // DataTable childCodes = da.GetChildCodesByLookupIdAndChildLookupName(parentLkpId, "ProjectType"); //} if (!string.IsNullOrEmpty(ProjectId) && !Page.IsPostBack) { PopulateForm(ProjectId); } else if (!Page.IsPostBack) { ProjectManagementDa projDA = new ProjectManagementDa(); ProjectNum.Text = projDA.GetIDForProject(); } }
protected void OnCreateNewProjectClick(object sender, EventArgs e) { // Create New Biz Object Project biz = new Project(); // Verify required fields bool fieldsValid = !string.IsNullOrEmpty(ProjectTitle.Value) && !string.IsNullOrEmpty(ProjectType.Value); // If fields are valid, proceed with update/insert if (fieldsValid) { bool isInsert = true; // Load Project records if working with existing projectid if (!string.IsNullOrEmpty(ProjectId)) { biz.Get(int.Parse(ProjectId)); isInsert = false; } // Populate and Save Biz CICHelper.SetBOValues(this.Controls, biz, 0); if (String.IsNullOrEmpty(biz[Project.ProjectNum].ToString())) { ProjectManagementDa projDA = new ProjectManagementDa(); biz[Project.ProjectNum] = projDA.GetIDForProject(); } biz[Project.AdditionalFormNames] = IncludeFormRadioList.SelectedValue; biz.Save(); // Create child records if needed string projId = biz[Project.ProjectId].ToString(); int priKey = int.Parse(projId); if (isInsert) { //ProjectMgmtUtil.CreateProjectChildRecords(priKey); } // Load/Create LOI Record if needed string loiId = string.Empty; //if (LetterOfIntent.Checked) if (IncludeFormRadioList.SelectedValue == "Letter Of Intent") { //ProjectLetterOfIntent letter = new ProjectLetterOfIntent(); //letter.GetByParent(priKey); //if (letter.RecordCount == 0) //{ // letter[ProjectLetterOfIntent.ProjectId] = projId; // letter[ProjectLetterOfIntent.CreationDate] = DateTime.Now; // ProjectManagementDa projDA = new ProjectManagementDa(); // letter[ProjectLetterOfIntent.LOINumber] = projDA.GetIDForLOI(); // letter.Save(); //} //loiId = letter[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); var criteria = new Dictionary <string, object>() { { ProjectLetterOfIntent.ProjectId, priKey } }; if (!BusinessObject.Exists <ProjectLetterOfIntent>(criteria)) { ProjectLetterOfIntent letter = new ProjectLetterOfIntent(); letter[ProjectLetterOfIntent.ProjectId] = projId; letter[ProjectLetterOfIntent.CreationDate] = DateTime.Now; ProjectManagementDa projDA = new ProjectManagementDa(); letter[ProjectLetterOfIntent.LOINumber] = projDA.GetIDForLOI(); letter.Save(); loiId = letter[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); } else { var letters = BusinessObject.GetByParent <ProjectLetterOfIntent>(priKey); loiId = letters.First()[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); } } // Load/Create ProjectApproval Record if needed string projectApprovalId = string.Empty; //if (FormNeedsApprovalStep(ProjectType.Value)) if (IncludeFormRadioList.SelectedValue == "Project Proposal") { //ProjectLetterOfIntent letter = new ProjectLetterOfIntent(); //letter.GetByParent(priKey); //if (letter.RecordCount == 0) //{ // letter[ProjectLetterOfIntent.ProjectId] = projId; // letter[ProjectLetterOfIntent.CreationDate] = DateTime.Now; // letter.Save(); //} //projectApprovalId = letter[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); var criteria = new Dictionary <string, object>() { { ProjectLetterOfIntent.ProjectId, priKey } }; if (!BusinessObject.Exists <ProjectLetterOfIntent>(criteria)) { ProjectLetterOfIntent letter = new ProjectLetterOfIntent(); letter[ProjectLetterOfIntent.ProjectId] = projId; letter[ProjectLetterOfIntent.CreationDate] = DateTime.Now; letter.Save(); projectApprovalId = letter[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); } else { var letters = BusinessObject.GetByParent <ProjectLetterOfIntent>(priKey); projectApprovalId = letters.First()[ProjectLetterOfIntent.ProjectLetterOfIntentId].ToString(); } } TransferToNextStep(projId, loiId, projectApprovalId); } }