예제 #1
0
        public void LoadData()
        {
            base.LoadData();

            ApasConfigurationManager cfg=new ApasConfigurationManager();
            AdoNetManager db = new AdoNetManager("APAS_Regular");

            db.ClearParameters();
            db.objCmd.Parameters.Clear();

            db.objCmd.Parameters.Add(
                "@id", SqlDbType.Int).Value = Id;

            DataTable tbl = db.queryTable(
                " SELECT * FROM APAS_Regular " +
                " WHERE intIdRegular = @id ");

            if (tbl.Rows.Count > 0)
            {
                ColorCode = (string)tbl.Rows[0]["strColorCodeRegular"];
            }
            else
            {
                //if base regular exists and extended APAS_Regular does not
                //exist, assume null for ColorCode

                ColorCode = cfg.getConfigValue("DefaultClassColor");

                //throw new ApasDatabaseException
                //    ("Requested Regular record is not found.");
            }
        }
예제 #2
0
        public void initConfigCollection()
        {
            AdoNetManager db = new AdoNetManager("APAS_Configuration");

            string strSQL =
                " SELECT * " +
                " FROM APAS_Configuration ";

            DataTable result = db.queryTable(strSQL);

            configCollection = new Dictionary<string, string>();

            if (!(result == null) && result.Rows.Count > 0)
            {
                foreach (DataRow row in result.Rows)
                {
                    configCollection.Add(
                        Convert.ToString(row["strConfigKey"]),
                        Convert.ToString(row["strConfigValue"])
                    );
                }
            }
        }
예제 #3
0
        //no more time to consider design problems
        //directly query from database using AdoNetManager
        //reconsider later
        public virtual void SyncNextMonthCredits(DateTime curMonth)
        {
            AdoNetManager db = new AdoNetManager("DaysInMonth");

            db.objCmd.Parameters.Clear();
            db.objCmd.Parameters.Add(
                "@inputDate", SqlDbType.DateTime
                ).Value = curMonth;

            string strSQL = " SELECT * FROM DaysInMonth " +
                " WHERE DATEPART(MONTH, YearMonth) = DATEPART(MONTH, @inputDate) " +
                " AND DATEPART(YEAR, YearMonth)= DATEPART(YEAR, @inputDate) ";

            DataTable tbl = db.queryTable(strSQL);
            if (tbl.Rows.Count == 0)
                throw new Apas.ApasException("Cannot find number of lessons for " +
                    curMonth.ToString("MMMM yyyy"));

            BCRegular regular = GetAssociatedClass();
            DataRow row = tbl.Rows[0];
            switch (regular.Day.ToLower())
            {
                case "monday":
                    NextMonthCredit = (int)row["NumOfMonday"];
                    break;
                case "tuesday":
                    NextMonthCredit = (int)row["NumOfTuesday"];
                    break;
                case "wednesday":
                    NextMonthCredit = (int)row["NumOfWednesday"];
                    break;
                case "thursday":
                    NextMonthCredit = (int)row["NumOfThursday"];
                    break;
                case "friday":
                    NextMonthCredit = (int)row["NumOfFriday"];
                    break;
                case "saturday":
                    NextMonthCredit = (int)row["NumOfSaturday"];
                    break;
                case "sunday":
                    NextMonthCredit = (int)row["NumOfSunday"];
                    break;
                default:
                    NextMonthCredit = 0;
                    throw new ApasException("Invalid Day Name");
                    break;
            }
        }
예제 #4
0
    /// <summary>
    /// Obtain exclusive hold of all PAs within the given PAList. 
    /// If no PA is currently held by any other user, operation is successful and
    /// an empty list is returned. 
    /// If there are users currently holding some PAs, operation is not successful and
    /// the list of users who are holding PAs is returned.
    /// </summary>
    /// <returns></returns>
    public List<BCAspenUser> HoldPAListExclusive(long idPAList)
    {
        //Hold all PAs within this PAlist
        string whereClause =
            " WHERE intIdPAList = @idPAList ";
        List<SqlParameter> pCol = new List<SqlParameter>();
        SqlParameter param = new SqlParameter("@idPAList", SqlDbType.BigInt);
        param.Value = idPAList;
        pCol.Add(param);

        Hold(whereClause, pCol);

        //check if any PA remains held by others
        AdoNetManager db = new AdoNetManager("table");

        db.objCmd.Parameters.Clear();
        db.objCmd.Parameters.Add
            ("@idPAList", SqlDbType.BigInt).Value = idPAList;
        db.objCmd.Parameters.Add
            ("@paLockKey", SqlDbType.VarChar).Value = LockKey;

        DataTable tbl = db.queryTable(
            " SELECT DISTINCT intIdLockHolderPA FROM APAS_PaymentAdvice " +
            " WHERE strLockKeyPA IS NOT NULL " +
            " AND strLockKeyPA != '' " +
            " AND strLockKeyPA != @paLockKey  " +
            " AND intIdPAList = @idPAList "
            );

        List<BCAspenUser> result = new List<BCAspenUser>();

        if (tbl != null && tbl.Rows.Count > 0)
        {
            //has PAs held by others
            //hold unsuccessful

            //Release PAs
            pCol = new List<SqlParameter>();
            whereClause =
            " WHERE intIdPAList = @idPAList ";
            param = new SqlParameter("@idPAList", SqlDbType.BigInt);
            param.Value = idPAList;
            pCol.Add(param);
            Release(whereClause, pCol);

            foreach (DataRow row in tbl.Rows)
            {
                BCAspenUser objStaff = new BCAspenUser();
                objStaff.Id = Convert.ToInt32(row["intIdLockHolderPA"]);
                objStaff.loadData();

                result.Add(objStaff);
            }

            return result;
        }
        else
        {
            //has no PA held by others
            //hold successful

            return result;
        }
    }