public static ObjectValidation Validate(ATTProgram objProgram)
        {
            ObjectValidation OV = new ObjectValidation();

            if (objProgram.OrgID <= 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Organization ID cannot be blank.";
                return(OV);
            }

            if (objProgram.ProgramName == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Program Name Cannot be Blank.";
                return(OV);
            }

            if (objProgram.ProgramTypeID == 0)
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Please Select Program Type";
                return(OV);
            }

            if (objProgram.LaunchDate == "")
            {
                OV.IsValid      = false;
                OV.ErrorMessage = "Launch Date Can't Be Left Blank";
                return(OV);
            }
            return(OV);
        }
 public static bool AddProgram(ATTProgram objProgram)
 {
     try
     {
         DLLProgram.AddProgram(objProgram);
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public static List <ATTProgram> GetProgramList(int orgID, int programID, string ContainDefPorgramValue, string ContainDefPrgCoordinatorValue, string ContainDefPrgSponsorValue, string ContainDefSessionValue, string ContainDefSessionCourseValue, string ContainDefCourseValue)
        {
            List <ATTProgram> PorgramLST = new List <ATTProgram>();

            foreach (DataRow row in DLLProgram.GetProgramTable(orgID, programID).Rows)
            {
                ATTProgram objProgram = new ATTProgram
                                        (
                    int.Parse(row["ORG_ID"].ToString()),
                    int.Parse(row["PROGRAM_ID"].ToString()),
                    row["PROGRAM_NAME"].ToString(),
                    int.Parse(row["PRG_TYPE_ID"].ToString()),
                    row["DESCRIPTION"].ToString(),
                    row["ACTIVE"].ToString(),
                    row["LAUNCH_DATE"].ToString(),
                    row["DURATION"].ToString(),
                    (row["DURATION_TYPE_ID"] == System.DBNull.Value)?0: int.Parse(row["DURATION_TYPE_ID"].ToString()),
                    row["TO_DATE"].ToString(),
                    row["LOCATION"].ToString(),
                    "A"
                                        );
                objProgram.PrgCoordinatorLST = BLLProgramCoordinator.GetProgramCoordinatorList(int.Parse(row["ORG_ID"].ToString()), int.Parse(row["PROGRAM_ID"].ToString()), 0, ContainDefPrgCoordinatorValue);

                objProgram.PrgSponsorLST = BLLProgramSponsor.GetProgramSponsorList(int.Parse(row["ORG_ID"].ToString()), int.Parse(row["PROGRAM_ID"].ToString()), 0, ContainDefPrgSponsorValue);

                objProgram.SessionLST = BLLSessions.GetSessionList(int.Parse(row["ORG_ID"].ToString()), int.Parse(row["PROGRAM_ID"].ToString()), 0, ContainDefSessionValue, ContainDefSessionCourseValue);

                objProgram.CourseLST = BLLCourse.GetCourseList(int.Parse(row["ORG_ID"].ToString()), int.Parse(row["PROGRAM_ID"].ToString()), 0, ContainDefCourseValue);


                PorgramLST.Add(objProgram);
            }
            if (ContainDefPorgramValue == "Y")
            {
                PorgramLST.Insert(0, new ATTProgram(0, 0, "--- Select Program ---", 0, "", "", "", "", 0, "", "", ""));
            }
            return(PorgramLST);
        }
        public static bool AddProgram(ATTProgram objProgram)
        {
            string            InsertUpdateSP = "";
            OracleTransaction Tran;

            if (objProgram.Action == "A")
            {
                InsertUpdateSP = "SP_ADD_PROGRAM";
            }
            else if (objProgram.Action == "E")
            {
                InsertUpdateSP = "SP_EDIT_PROGRAM";
            }

            int?durationTypeID;

            if (objProgram.DurationTypeID == 0)
            {
                durationTypeID = null;
            }
            else
            {
                durationTypeID = objProgram.DurationTypeID;
            }

            OracleParameter[] paramArray = new OracleParameter[11];
            paramArray[0]  = Utilities.GetOraParam(":p_ORG_ID", objProgram.OrgID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[1]  = Utilities.GetOraParam(":p_PROGRAM_ID", objProgram.ProgramID, OracleDbType.Int64, ParameterDirection.InputOutput);
            paramArray[2]  = Utilities.GetOraParam(":p_PROGRAM_NAME", objProgram.ProgramName, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[3]  = Utilities.GetOraParam(":p_PROGRAM_TYPE_ID", objProgram.ProgramTypeID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[4]  = Utilities.GetOraParam(":p_DESCRIPTION", objProgram.Description, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[5]  = Utilities.GetOraParam(":p_ACTIVE", objProgram.Active, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[6]  = Utilities.GetOraParam(":p_LAUNCH_DATE", objProgram.LaunchDate, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[7]  = Utilities.GetOraParam(":p_DURATION", objProgram.Duration, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[8]  = Utilities.GetOraParam(":p_DURATION_TYPE_ID", durationTypeID, OracleDbType.Int64, ParameterDirection.Input);
            paramArray[9]  = Utilities.GetOraParam(":p_TO_DATE", objProgram.ToDate, OracleDbType.Varchar2, ParameterDirection.Input);
            paramArray[10] = Utilities.GetOraParam(":p_LOCATION", objProgram.Location, OracleDbType.Varchar2, ParameterDirection.Input);

            GetConnection GetConn = new GetConnection();

            OracleConnection DBConn = GetConn.GetDbConn(Module.DLPDS);

            Tran = DBConn.BeginTransaction();

            try
            {
                SqlHelper.ExecuteNonQuery(Tran, CommandType.StoredProcedure, InsertUpdateSP, paramArray);
                objProgram.ProgramID = int.Parse(paramArray[1].Value.ToString());

                if (objProgram.PrgCoordinatorLST != null)
                {
                    DLLProgramCoordinator.AddProgramCoordinator(objProgram.PrgCoordinatorLST, objProgram.ProgramID, Tran);
                }

                if (objProgram.PrgSponsorLST != null)
                {
                    DLLProgramSponsor.AddProgramSponsor(objProgram.PrgSponsorLST, objProgram.ProgramID, Tran);
                }

                if (objProgram.SessionLST != null)
                {
                    DLLSession.AddSession(objProgram.SessionLST, objProgram.ProgramID, Tran);
                }

                if (objProgram.CourseLST != null)
                {
                    DLLCourse.AddCourse(objProgram.CourseLST, objProgram.ProgramID, Tran);
                }

                Tran.Commit();

                return(true);
            }
            catch (Exception ex)
            {
                Tran.Rollback();
                throw ex;
            }
            finally
            {
                GetConn.CloseDbConn();
            }
        }
    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);
    }