예제 #1
0
        /// <summary>
        /// Method to Get List of SemesterSetup
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity as an Input.</param>
        /// <returns>Returns List of SemesterSetup</returns>
        public List <SemesterSetupEn> GetListSemesterCur(SemesterSetupEn argEn)
        {
            //create instances
            List <SemesterSetupEn> SemesterList = new List <SemesterSetupEn>();

            //variable declarations
            string SqlStatement = null;

            try
            {
                //Build Sqlstatement - Start
                //SqlStatement = "SELECT Distinct SAST_Code,sast_code2,sast_semester From SAS_SemesterSetup WHERE SAST_Status = true AND sast_iscurrentsem = true";
                SqlStatement  = "SELECT Distinct SAST_Code,sast_code2,sast_semester From SAS_SemesterSetup WHERE SAST_Status = true";
                SqlStatement += " ORDER BY SAST_Code";
                //Build Sqlstatement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    while (_IDataReader.Read())
                    {
                        SemesterSetupEn _SemesterSetupEn = new SemesterSetupEn();
                        string          d1, m1, y1, d2, m2, y2;
                        string          code = GetValue <string>(_IDataReader, "SAST_Code");
                        d1 = code.Substring(0, 4);
                        m1 = code.Substring(4, 4);
                        y1 = code.Substring(8, 1);
                        string semestercode = d1 + "/" + m1 + "-" + y1;
                        string code2        = GetValue <string>(_IDataReader, "SAST_Code2");
                        d2 = code.Substring(0, 4);
                        m2 = code.Substring(4, 4);
                        y2 = code.Substring(8, 1);
                        string semestercode2 = d2 + "/" + m2 + "-" + y2;
                        _SemesterSetupEn.Semester          = GetValue <string>(_IDataReader, "sast_semester");
                        _SemesterSetupEn.SemisterSetupCode = semestercode;
                        _SemesterSetupEn.SemisterCode2     = semestercode2;
                        //_SemesterSetupEn.SemisterSetupCode = GetValue<string>(_IDataReader, "SAST_Code");
                        //_SemesterSetupEn.SemisterCode2 = GetValue<string>(_IDataReader, "sast_code2");
                        SemesterList.Add(_SemesterSetupEn);
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    return(SemesterList);
                }
                //if details available - Stop

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        /// <summary>
        /// Method to Load SemesterSetup Entity
        /// </summary>
        /// <param name="argReader">IDataReader Object is an Input.</param>
        /// <returns>Returns SemesterSetup Entity</returns>
        private SemesterSetupEn LoadObject(IDataReader argReader)
        {
            SemesterSetupEn _SemesterSetupEn = new SemesterSetupEn();
            string          d1, m1, y1, d2, m2, y2;
            string          code = GetValue <string>(argReader, "SAST_Code");

            d1 = code.Substring(0, 4);
            m1 = code.Substring(4, 4);
            y1 = code.Substring(8, 1);
            string semestercode = d1 + "/" + m1 + "-" + y1;
            string code2        = GetValue <string>(argReader, "SAST_Code2");

            d2 = code.Substring(0, 4);
            m2 = code.Substring(4, 4);
            y2 = code.Substring(8, 1);
            string semestercode2 = d2 + "/" + m2 + "-" + y2;

            _SemesterSetupEn.SemisterSetupCode = semestercode;
            _SemesterSetupEn.Semester          = GetValue <string>(argReader, "SAST_Semester");
            _SemesterSetupEn.Description       = GetValue <string>(argReader, "SAST_Description");
            _SemesterSetupEn.Status            = GetValue <bool>(argReader, "SAST_Status");
            _SemesterSetupEn.Code        = GetValue <int>(argReader, "SABR_Code");
            _SemesterSetupEn.UpdatedUser = GetValue <string>(argReader, "SAST_UpdatedUser");
            _SemesterSetupEn.UpdatedDtTm = GetValue <string>(argReader, "SAST_UpdatedDtTm");
            _SemesterSetupEn.CurrSem     = GetValue <bool>(argReader, "sast_iscurrentsem");
            //_SemesterSetupEn.SemisterCode2 = GetValue<string>(argReader, "SAST_Code2");
            _SemesterSetupEn.SemisterCode2 = semestercode2;

            return(_SemesterSetupEn);
        }
예제 #3
0
 /// <summary>
 /// Method to Get List of SemesterSetup
 /// </summary>
 /// <param name="argEn">SemesterSetup Entity as an Input.</param>
 /// <returns>Returns List of SemesterSetup</returns>
 public List <SemesterSetupEn> GetListSemesterCode(SemesterSetupEn argEn)
 {
     try
     {
         SemesterSetupDAL loDs = new SemesterSetupDAL();
         return(loDs.GetListSemesterCode(argEn));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
 /// <summary>
 /// Method to Get List of Semesters
 /// </summary>
 /// <param name="argEn">SemisterSetupCode as Input.</param>
 /// <returns>Returns List of SemesterSetup</returns>
 public SemesterSetupEn GetItemBySession(SemesterSetupEn argEn)
 {
     try
     {
         SemesterSetupDAL loDs = new SemesterSetupDAL();
         return(loDs.GetItemBySession(argEn));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #5
0
 public List <SemesterSetupEn> GetCurrentSessionList(SemesterSetupEn argEn)
 {
     try
     {
         SemesterSetupDAL loDs = new SemesterSetupDAL();
         return(loDs.GetCurrentSessionList(argEn));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
        /// <summary>
        /// Method to Get List of All Semesters
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity as an Input.SemesterSetupCode and Description as Input Properties.</param>
        /// <returns>Returns List of SemesterSetup</returns>
        public List <SemesterSetupEn> GetSemesterSetupListAll(SemesterSetupEn argEn)
        {
            //create instances
            List <SemesterSetupEn> SemseterSetupList = new List <SemesterSetupEn>();

            //variable declarations
            string SqlStatement = null;

            try
            {
                //build Sqlstatement - Start
                argEn.SemisterSetupCode = argEn.SemisterSetupCode.Replace("*", "%");
                argEn.Description       = argEn.Description.Replace("*", "%");
                SqlStatement            = "select distinct * from SAS_SemesterSetup where SAST_Code <> '0'";
                if (argEn.SemisterSetupCode.Length != 0)
                {
                    SqlStatement = SqlStatement + " and SAST_Code like '" + clsGeneric.AddQuotes(argEn.SemisterSetupCode);
                }
                if (argEn.Description.Length != 0)
                {
                    SqlStatement = SqlStatement + " and SAST_Description like '" + clsGeneric.AddQuotes(argEn.Description);
                }
                SqlStatement = SqlStatement + " order by SAST_Code";
                //build Sqlstatement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    while (_IDataReader.Read())
                    {
                        SemesterSetupEn _SemesterSetupEn = LoadObject(_IDataReader);
                        SemseterSetupList.Add(_SemesterSetupEn);
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    return(SemseterSetupList);
                }
                //if details available - Stop

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
        /// <summary>
        /// Method to Load SemesterSetup Entity
        /// </summary>
        /// <param name="argReader">IDataReader Object is an Input.</param>
        /// <returns>Returns SemesterSetup Entity</returns>
        private SemesterSetupEn LoadObject(IDataReader argReader)
        {
            SemesterSetupEn _SemesterSetupEn = new SemesterSetupEn();

            _SemesterSetupEn.SemisterSetupCode = GetValue <string>(argReader, "SAST_Code");
            _SemesterSetupEn.Semester          = GetValue <string>(argReader, "SAST_Semester");
            _SemesterSetupEn.Description       = GetValue <string>(argReader, "SAST_Description");
            _SemesterSetupEn.Status            = GetValue <bool>(argReader, "SAST_Status");
            _SemesterSetupEn.Code          = GetValue <int>(argReader, "SABR_Code");
            _SemesterSetupEn.UpdatedUser   = GetValue <string>(argReader, "SAST_UpdatedUser");
            _SemesterSetupEn.UpdatedDtTm   = GetValue <string>(argReader, "SAST_UpdatedDtTm");
            _SemesterSetupEn.CurrSem       = GetValue <bool>(argReader, "sast_iscurrentsem");
            _SemesterSetupEn.SemisterCode2 = GetValue <string>(argReader, "SAST_Code2");

            return(_SemesterSetupEn);
        }
예제 #8
0
        //modified by Hafiz @ 07/6/2016

        public List <SemesterSetupEn> GetCurrentSessionList(SemesterSetupEn argEn)
        {
            //create instances
            List <SemesterSetupEn> SessionList = new List <SemesterSetupEn>();

            //variable declarations
            string SqlStatement = null;

            try
            {
                //build sql statement - Start
                SqlStatement = "SELECT DISTINCT * FROM SAS_SemesterSetup WHERE SAST_Status = true ORDER by SAST_Code";
                //SqlStatement += "AND sast_iscurrentsem = true;";
                //SqlStatement += clsGeneric.AddQuotes(argEn);
                //build sql statement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    while (_IDataReader.Read())
                    {
                        SemesterSetupEn _SemesterSetupEn = LoadObject(_IDataReader);
                        SessionList.Add(_SemesterSetupEn);
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    return(SessionList);
                }
                //if details available - Stop

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
        /// <summary>
        /// Method to Get List of SemesterSetup
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity as an Input.</param>
        /// <returns>Returns List of SemesterSetup</returns>
        public List <SemesterSetupEn> GetList(SemesterSetupEn argEn)
        {
            //create instances
            List <SemesterSetupEn> SemesterList = new List <SemesterSetupEn>();

            //variable declarations
            string SqlStatement = null;

            try
            {
                //build sql statement - Start
                SqlStatement  = "Select Distinct SAST_Semester From SAS_SemesterSetup ";
                SqlStatement += " order by SAST_Semester";
                //build sql statement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    while (_IDataReader.Read())
                    {
                        SemesterSetupEn _SemesterSetupEn = new SemesterSetupEn();
                        _SemesterSetupEn.Semester = GetValue <string>(_IDataReader, "SAST_Semester");
                        SemesterList.Add(_SemesterSetupEn);
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    return(SemesterList);
                }
                //if details available - Stop

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #10
0
 /// <summary>
 /// Method to Check Validation
 /// </summary>
 /// <param name="argEn">SemesterSetup Entity is as Input.</param>
 /// <returns>Returns a Boolean</returns>
 public bool IsValid(SemesterSetupEn argEn)
 {
     try
     {
         if (argEn.SemisterSetupCode == null || argEn.SemisterSetupCode.ToString().Length <= 0)
         {
             throw new Exception("SemisterSetupCode Is Required!");
         }
         if (argEn.Semester == null || argEn.Semester.ToString().Length <= 0)
         {
             throw new Exception("Semester Is Required!");
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #11
0
        /// <summary>
        /// Method to Delete SemesterSetup
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity is an Input.</param>
        /// <returns>Returns Boolean</returns>
        public bool Delete(SemesterSetupEn argEn)
        {
            bool flag;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    SemesterSetupDAL loDs = new SemesterSetupDAL();
                    flag = loDs.Delete(argEn);
                    ts.Complete();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(flag);
        }
예제 #12
0
        /// <summary>
        /// Method to Get SemesterSetup Entity
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity is an Input.Semester and Description as Input Property.</param>
        /// <returns>Returns SemesterSetup Entity</returns>
        public SemesterSetupEn GetItem(SemesterSetupEn argEn)
        {
            //create instances
            SemesterSetupEn _SemesterSetupEn = new SemesterSetupEn();

            //variable declarations
            string SqlStatement = null;

            try
            {
                //Build Sqlstatement - Start
                SqlStatement  = "Select * FROM SAS_SemesterSetup WHERE SAST_Semester = ";
                SqlStatement += clsGeneric.AddQuotes(argEn.Semester) + " AND SAST_Description = ";
                SqlStatement += clsGeneric.AddQuotes(argEn.Description);
                //Build Sqlstatement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    if (_IDataReader.Read())
                    {
                        _SemesterSetupEn = LoadObject(_IDataReader);
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    return(_SemesterSetupEn);
                }
                //if details available - Stop

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #13
0
        /// <summary>
        /// Method to Delete SemesterSetup
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity is an Input.SASR_Code as Input Property.</param>
        /// <returns>Returns Boolean</returns>
        public bool Delete(SemesterSetupEn argEn)
        {
            //variable declarations
            string SqlStatement = null; int HasRows = 0; int RecordsSaved = 0; bool Result = false;

            try
            {
                //Build Sql Statement - Start
                SqlStatement  = "SELECT SUM(rows) as rows from (select count(*) as rows  from SAS_Student WHERE ";
                SqlStatement += "SASI_Intake = " + clsGeneric.AddQuotes(argEn.SemisterSetupCode) + " UNION ALL ";
                SqlStatement += " SELECT count(*) as rows from SAS_Student WHERE SASI_CurSemYr = ";
                SqlStatement += clsGeneric.AddQuotes(argEn.SemisterSetupCode) + ") AS U ";
                //Build Sql Statement - Stop

                //Get User Login Details - Start
                IDataReader _IDataReader = _DatabaseFactory.ExecuteReader(Helper.GetDataBaseType,
                                                                          DataBaseConnectionString, SqlStatement).CreateDataReader();
                //Get User Login Details - Stop

                //if details available - Start
                if (_IDataReader != null)
                {
                    if (_IDataReader.Read())
                    {
                        HasRows = clsGeneric.NullToInteger(_IDataReader["rows"]);
                        if (HasRows > 0)
                        {
                            throw new Exception("Record Already in Use");
                        }
                    }

                    _IDataReader.Close();
                    _IDataReader.Dispose();

                    //if record not used - Start
                    if (HasRows == 0)
                    {
                        //build sql statement - Start
                        SqlStatement  = "DELETE FROM SAS_SemesterSetup WHERE SAST_Code = ";
                        SqlStatement += clsGeneric.AddQuotes(argEn.SemisterSetupCode);
                        //build sql statement - Stop

                        //Save Details to Database
                        RecordsSaved = _DatabaseFactory.ExecuteSqlStatement(Helper.GetDataBaseType,
                                                                            DataBaseConnectionString, SqlStatement);

                        //if records saved successfully - Start
                        if (RecordsSaved > -1)
                        {
                            Result = true;
                        }
                        else
                        {
                            throw new Exception("Delete Failed! No Row has been deleted...");
                        }
                        //if records saved successfully - Stop
                    }
                    //if record not used - Sto

                    return(Result);
                }
                //if details available - Stop

                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
        /// <summary>
        /// Method to Update SemesterSetup
        /// </summary>
        /// <param name="argEn">SemesterSetup Entity is an Input.</param>
        /// <returns>Returns Boolean</returns>
        public bool Update(SemesterSetupEn argEn)
        {
            //variable declarations - Start
            string Boolvalue = "false"; bool Result = false;
            //string SqlStatement = null; int RecordsSaved = 0;
            //variable declarations - Stop
            int    iOut = 0; int ResetCurrSem = 0;
            string sqlCmd = "Select count(*) as cnt From SAS_SemesterSetup WHERE sast_code2 = @sast_code2 AND SAST_Semester = @sast_semester AND sast_status = @sast_status " +
                            "AND sast_iscurrentsem = @sast_currsem";

            try
            {
                if (!FormHelp.IsBlank(sqlCmd))
                {
                    DbCommand cmdSel = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@sast_code2", DbType.String, argEn.SemisterCode2);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@sast_semester", DbType.String, argEn.Semester);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@sast_status", DbType.Boolean, argEn.Status);
                    _DatabaseFactory.AddInParameter(ref cmdSel, "@sast_currsem", DbType.Boolean, argEn.CurrSem);
                    _DbParameterCollection = cmdSel.Parameters;

                    using (IDataReader dr = _DatabaseFactory.GetIDataReader(Helper.GetDataBaseType, cmdSel,
                                                                            DataBaseConnectionString, sqlCmd, _DbParameterCollection).CreateDataReader())
                    {
                        if (dr.Read())
                        {
                            iOut = clsGeneric.NullToInteger(dr["cnt"]);
                        }
                        if (iOut > 0)
                        {
                            throw new Exception("Record Already Exist");
                        }
                    }
                    if (iOut == 0)
                    {
                        if (argEn.Status)
                        {
                            Boolvalue = "true";
                        }

                        sqlCmd = "UPDATE SAS_SemesterSetup SET SAST_Semester = @sast_semester, SAST_Status = @sast_status, " +
                                 "SAST_Code2 = @sast_code2, sast_iscurrentsem = @sast_currsem, " +
                                 "SAST_UpdatedUser = @sast_updatedby, SAST_UpdatedDtTm = @sast_updateddttm WHERE SAST_Code = @sast_code";

                        if (!FormHelp.IsBlank(sqlCmd))
                        {
                            DbCommand cmd = _DatabaseFactory.GetDbCommand(Helper.GetDataBaseType, sqlCmd, DataBaseConnectionString);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_code", DbType.String, argEn.SemisterSetupCode);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_semester", DbType.String, argEn.Semester);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_status", DbType.Boolean, Boolvalue);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_updatedby", DbType.String, argEn.UpdatedUser);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_updateddttm", DbType.String, argEn.UpdatedDtTm);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_code2", DbType.String, argEn.SemisterCode2);
                            _DatabaseFactory.AddInParameter(ref cmd, "@sast_currsem", DbType.Boolean, argEn.CurrSem);
                            _DbParameterCollection = cmd.Parameters;

                            int liRowAffected = _DatabaseFactory.ExecuteNonQuery(Helper.GetDataBaseType, cmd,
                                                                                 DataBaseConnectionString, sqlCmd, _DbParameterCollection);

                            if (liRowAffected > -1)
                            {
                                Result = true;
                            }

                            else
                            {
                                throw new Exception("Update Failed! No Row has been updated...");
                            }

                            if (argEn.CurrSem == true)
                            {
                                //Reset currentsem = No for other other semester
                                sqlCmd = "UPDATE  SAS_SemesterSetup SET sast_iscurrentsem = false " +
                                         "WHERE SAST_Code != " + clsGeneric.AddQuotes(argEn.SemisterSetupCode);

                                //Update Details to Database
                                ResetCurrSem = _DatabaseFactory.ExecuteSqlStatement(Helper.GetDataBaseType,
                                                                                    DataBaseConnectionString, sqlCmd);

                                if (ResetCurrSem > -1)
                                {
                                    Result = true;
                                }
                                else
                                {
                                    throw new Exception("Reset Current Semester Failed! No Row has been updated...");
                                }
                            }
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }

            return(Result);
        }