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); }
protected void btnAddSponsors_Click(object sender, EventArgs e) { if (ddlSponsors.SelectedIndex == 0) { this.lblStatus.Text = "Add Sponsor Status"; this.lblStatusMessage.Text = "Select Sponsor To Add"; this.programmaticModalPopup.Show(); return; } List <ATTProgramSponsor> PrgSponsorLST = new List <ATTProgramSponsor>(); foreach (GridViewRow gvRow in grdSponsor.Rows) { ATTProgramSponsor objEPrgSponsor = new ATTProgramSponsor ( 0, 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), "", CheckNull.NullString(gvRow.Cells[5].Text) ); objEPrgSponsor.SponsorOBJ.SponsorName = gvRow.Cells[1].Text; PrgSponsorLST.Add(objEPrgSponsor); } if (grdSponsor.SelectedIndex == -1) { if (PrgSponsorLST.FindIndex(delegate(ATTProgramSponsor obj) { return(int.Parse(this.ddlSponsors.SelectedValue) == obj.SponsorID); }) > 0) { this.lblStatus.Text = "Add Sponsor Status"; this.lblStatusMessage.Text = "Sponsor Already Exists"; this.programmaticModalPopup.Show(); return; } ATTProgramSponsor objPrgSponsor = new ATTProgramSponsor( 0, 0, int.Parse(this.ddlSponsors.SelectedValue), this.txtFromDate.Text, (this.txtBudget.Text == "") ? 0 : double.Parse(this.txtBudget.Text), (int.Parse(this.ddlCurrency.SelectedValue) == 0) ? "" : this.ddlCurrency.SelectedItem.Text, "", "A"); objPrgSponsor.SponsorOBJ.SponsorName = this.ddlSponsors.SelectedItem.Text; PrgSponsorLST.Add(objPrgSponsor); } else { PrgSponsorLST[grdSponsor.SelectedIndex].Budget = double.Parse(this.txtBudget.Text); PrgSponsorLST[grdSponsor.SelectedIndex].Currency = (this.ddlCurrency.SelectedValue == "0")?"":this.ddlCurrency.SelectedItem.Text; PrgSponsorLST[grdSponsor.SelectedIndex].FromDate = this.txtFromDate.Text; PrgSponsorLST[grdSponsor.SelectedIndex].Action = (this.grdSponsor.SelectedRow.Cells[5].Text == "A") ? "A" : "E"; } grdSponsor.DataSource = PrgSponsorLST; grdSponsor.DataBind(); this.grdSponsor.SelectedIndex = -1; this.ddlSponsors.SelectedIndex = -1; this.txtBudget.Text = ""; this.ddlCurrency.SelectedIndex = -1; this.txtFromDate.Text = ""; }