protected void btnAddCourse_Click(object sender, EventArgs e) { if (this.txtCourseTitle.Text == "") { this.lblStatus.Text = "Add Course Status"; this.lblStatusMessage.Text = "Course Title Can't be Left Blank"; this.programmaticModalPopup.Show(); return; } List <ATTCourse> CourseLST = new List <ATTCourse>(); foreach (GridViewRow gvRow in grdCourses.Rows) { CourseLST.Add(new ATTCourse(0, 0, CheckNull.NullintValue(gvRow.Cells[0].Text), gvRow.Cells[1].Text, CheckNull.NullString(gvRow.Cells[2].Text), CheckNull.NullString(gvRow.Cells[3].Text), CheckNull.NullString(gvRow.Cells[4].Text) )); } if (grdCourses.SelectedIndex == -1) { CourseLST.Add(new ATTCourse(0, 0, 0, this.txtCourseTitle.Text, this.txtCourseDescription.Text, (this.chkCourseActive.Checked == true) ? "Y" : "N", "A" )); } else { CourseLST[grdCourses.SelectedIndex].CourseTitle = this.txtCourseTitle.Text; CourseLST[grdCourses.SelectedIndex].Description = this.txtCourseDescription.Text; CourseLST[grdCourses.SelectedIndex].Active = (this.chkCourseActive.Checked == true) ? "Y" : "N"; CourseLST[grdCourses.SelectedIndex].Action = (this.grdCourses.SelectedRow.Cells[4].Text == "A")?"A": "E"; } grdCourses.SelectedIndex = -1; this.txtCourseTitle.Text = ""; this.txtCourseDescription.Text = ""; this.chkCourseActive.Checked = false; this.grdCourses.DataSource = CourseLST; this.grdCourses.DataBind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { List <ATTProgram> ProgramLST = (List <ATTProgram>)Session["Programs"]; ATTProgram objProgram = new ATTProgram( int.Parse(Session["OrgID"].ToString()), (this.lstProgram.SelectedIndex != -1) ? ProgramLST[lstProgram.SelectedIndex].ProgramID : 0, this.txtProgramName_RQD.Text, int.Parse(this.ddlProgramType.SelectedValue), this.txtPrgDescription.Text, (this.chkActive.Checked == true) ? "Y" : "N", this.txtLaunchDate_REQD.Text, this.txtduration.Text, int.Parse(this.ddlDurationType.SelectedValue), "", this.txtLocation.Text, (this.lstProgram.SelectedIndex != -1) ? "E" : "A" ); ObjectValidation OV = BLLProgram.Validate(objProgram); if (OV.IsValid == false) { this.lblStatusMessage.Text = OV.ErrorMessage; this.programmaticModalPopup.Show(); return; } //PREPARES COORDINATORS TO BE SAVED foreach (GridViewRow gvRow in grdProgramCoordinator.Rows) { if (CheckNull.NullString(gvRow.Cells[6].Text) != "") { ATTProgramCoordinator objPrgCoordinator = new ATTProgramCoordinator ( int.Parse(Session["OrgID"].ToString()), 0, int.Parse(gvRow.Cells[1].Text), gvRow.Cells[3].Text, double.Parse(gvRow.Cells[2].Text), int.Parse(gvRow.Cells[4].Text), gvRow.Cells[5].Text, gvRow.Cells[6].Text ); objProgram.PrgCoordinatorLST.Add(objPrgCoordinator); } } //PREPARES SPONSORS TO BE SAVED foreach (GridViewRow gvRow in grdSponsor.Rows) { if (CheckNull.NullString(gvRow.Cells[5].Text) != "") { ATTProgramSponsor objPrgSponsor = new ATTProgramSponsor ( int.Parse(Session["OrgID"].ToString()), 0, int.Parse(gvRow.Cells[0].Text), CheckNull.NullString(gvRow.Cells[4].Text), CheckNull.NulldblValue(gvRow.Cells[2].Text), CheckNull.NullString(gvRow.Cells[3].Text), "", gvRow.Cells[5].Text ); objPrgSponsor.SponsorOBJ.SponsorName = gvRow.Cells[1].Text; objProgram.PrgSponsorLST.Add(objPrgSponsor); } } //PREPARES SESSIONS TO BE SAVED foreach (GridViewRow gvRow in grdSession.Rows) { if (CheckNull.NullString(gvRow.Cells[4].Text) != "") { objProgram.SessionLST.Add(new ATTSession ( int.Parse(Session["OrgID"].ToString()), 0, CheckNull.NullintValue(gvRow.Cells[0].Text), gvRow.Cells[1].Text, CheckNull.NullString(gvRow.Cells[2].Text), CheckNull.NullString(gvRow.Cells[3].Text), CheckNull.NullString(gvRow.Cells[2].Text), gvRow.Cells[4].Text )); } } //PREPARES COURSES TO BE SAVED foreach (GridViewRow gvRow in grdCourses.Rows) { if (CheckNull.NullString(gvRow.Cells[4].Text) != "") { objProgram.CourseLST.Add(new ATTCourse ( int.Parse(Session["OrgID"].ToString()), 0, CheckNull.NullintValue(gvRow.Cells[0].Text), gvRow.Cells[1].Text, CheckNull.NullString(gvRow.Cells[2].Text), gvRow.Cells[3].Text, gvRow.Cells[4].Text )); } } BLLProgram.AddProgram(objProgram); if (lstProgram.SelectedIndex == -1) { ProgramLST.Add(objProgram); } else { //EDITS THE PROGRAM ProgramLST[lstProgram.SelectedIndex].ProgramName = this.txtProgramName_RQD.Text; ProgramLST[lstProgram.SelectedIndex].ProgramTypeID = int.Parse(this.ddlProgramType.SelectedValue); ProgramLST[lstProgram.SelectedIndex].Active = (this.chkActive.Checked == true) ? "Y" : "N"; ProgramLST[lstProgram.SelectedIndex].Description = this.txtPrgDescription.Text; ProgramLST[lstProgram.SelectedIndex].LaunchDate = this.txtLaunchDate_REQD.Text; ProgramLST[lstProgram.SelectedIndex].Duration = this.txtduration.Text; ProgramLST[lstProgram.SelectedIndex].DurationTypeID = int.Parse(this.ddlDurationType.SelectedValue); ProgramLST[lstProgram.SelectedIndex].Location = this.txtLocation.Text; //EDITS THE PROGRAM COORDINATOR LIST ProgramLST[lstProgram.SelectedIndex].PrgCoordinatorLST.Clear(); foreach (GridViewRow gvRow in this.grdProgramCoordinator.Rows) { if (CheckNull.NullString(gvRow.Cells[6].Text) == "") { ATTProgramCoordinator objPrgCoordinator = new ATTProgramCoordinator ( int.Parse(Session["OrgID"].ToString()), int.Parse(lstProgram.SelectedValue), int.Parse(gvRow.Cells[1].Text), gvRow.Cells[3].Text, double.Parse(gvRow.Cells[2].Text), int.Parse(gvRow.Cells[4].Text), gvRow.Cells[5].Text, "" ); ProgramLST[lstProgram.SelectedIndex].PrgCoordinatorLST.Add(objPrgCoordinator); } } foreach (ATTProgramCoordinator obj in objProgram.PrgCoordinatorLST) { ProgramLST[lstProgram.SelectedIndex].PrgCoordinatorLST.Add(obj); } //EDITS THE SPONSOR LiST ProgramLST[lstProgram.SelectedIndex].PrgSponsorLST.Clear(); foreach (GridViewRow gvRow in this.grdSponsor.Rows) { ATTProgramSponsor obj; if (gvRow.Cells[5].Text != "D") { obj = new ATTProgramSponsor( int.Parse(Session["OrgID"].ToString()), 0, int.Parse(gvRow.Cells[0].Text), CheckNull.NullString(gvRow.Cells[4].Text), CheckNull.NulldblValue(gvRow.Cells[2].Text), CheckNull.NullString(gvRow.Cells[3].Text), "", "" ); obj.SponsorOBJ.SponsorName = gvRow.Cells[1].Text; ProgramLST[lstProgram.SelectedIndex].PrgSponsorLST.Add(obj); } } //EDITS THE SESSION LIST ProgramLST[lstProgram.SelectedIndex].SessionLST.Clear(); foreach (GridViewRow gvRow in this.grdSession.Rows) { if (CheckNull.NullString(gvRow.Cells[4].Text) == "") { ProgramLST[lstProgram.SelectedIndex].SessionLST.Add(new ATTSession ( int.Parse(Session["OrgID"].ToString()), 0, CheckNull.NullintValue(gvRow.Cells[0].Text), gvRow.Cells[1].Text, CheckNull.NullString(gvRow.Cells[2].Text), CheckNull.NullString(gvRow.Cells[3].Text), CheckNull.NullString(gvRow.Cells[2].Text), "" )); } } foreach (ATTSession obj in objProgram.SessionLST) { ProgramLST[lstProgram.SelectedIndex].SessionLST.Add(obj); } //EDITS COURSE LIST ProgramLST[lstProgram.SelectedIndex].CourseLST.Clear(); foreach (GridViewRow gvRow in grdCourses.Rows) { if (CheckNull.NullString(gvRow.Cells[4].Text) == "") { ProgramLST[lstProgram.SelectedIndex].CourseLST.Add(new ATTCourse ( int.Parse(Session["OrgID"].ToString()), 0, CheckNull.NullintValue(gvRow.Cells[0].Text), gvRow.Cells[1].Text, CheckNull.NullString(gvRow.Cells[2].Text), gvRow.Cells[3].Text, "" )); } } foreach (ATTCourse obj in objProgram.CourseLST) { ProgramLST[lstProgram.SelectedIndex].CourseLST.Add(obj); } } //END IF this.lstProgram.DataSource = ProgramLST; this.lstProgram.DataValueField = "ProgramID"; this.lstProgram.DataTextField = "ProgramName"; this.DataBind(); clearAll(1); }