示例#1
0
    public DateTime getDisplayDate()
    {
        MrTimeZone ETZ = new MrTimeZone();

        sysToday = ETZ.eastTimeNow();
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        MRParams  entry         = db.MRParams.FirstOrDefault(p => p.Key == keyLastDate);

        if (entry != null)
        {
            LastDate   = Convert.ToDateTime((string)entry.Value);
            changeDate = (DateTime)entry.ChangeDate;
        }
        else
        {
            LastDate   = new DateTime(2012, 4, 12, 23, 59, 59, System.Globalization.CultureInfo.InvariantCulture.Calendar);
            changeDate = ETZ.eastTimeNow();
            MRParams newParm = new MRParams();
            newParm.Key        = keyLastDate;
            newParm.Value      = LastDate.ToString();
            newParm.ChangeDate = changeDate;
            db.MRParams.InsertOnSubmit(newParm);
            db.SubmitChanges();
        }
        MRParams edts = db.MRParams.FirstOrDefault(p => p.Key == keyDaysToShow);

        daysToShow = defaultDisplayDays;
        if (edts != null)
        {
            daysToShow = Convert.ToInt32((string)edts.Value);
        }
        else
        {
            changeDate = ETZ.eastTimeNow();
            MRParams newParm = new MRParams();
            newParm.Key        = keyDaysToShow;
            newParm.Value      = daysToShow.ToString();
            newParm.ChangeDate = changeDate;
            db.MRParams.InsertOnSubmit(newParm);
            db.SubmitChanges();
        }
        displayDate = ETZ.eastTimeNow().AddDays(daysToShow);
        if (LastDate < displayDate)
        {
            displayDate = LastDate;
        }
        return(displayDate);
    }
示例#2
0
    protected int DeleteDBEntries()
    {
        // delete from SignUp database entries in SL that are marked to be deleted
        int       n             = 0;
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        foreach (SignupEntry se in this.sl.Entries)
        {
            if (se.SDelete)
            {
                DateTime timestamp = se.STDate;
                string   eid       = se.SeventId;
                int      pid       = se.SPlayerID;
                var      oldentry  = db.PlayersList.Single(pe => pe.TransDate == timestamp && pe.EventID == eid && pe.PlayerID == pid);
                db.PlayersList.DeleteOnSubmit(oldentry);
                n++;
            }
        }
        if (n > 0)
        {
            db.SubmitChanges();
        }
        return(n);
    }
示例#3
0
    protected void loadLastDate()
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        MRParams  entry         = db.MRParams.FirstOrDefault(p => p.Key.Trim() == keyLastDate);

        if (entry != null)
        {
            LastDate   = Convert.ToDateTime((string)entry.Value);
            changeDate = (DateTime)entry.ChangeDate;
        }
        else
        {
            int curyear = etz.eastTimeNow().Year;
            LastDate   = new DateTime(curyear, 3, 1, 23, 59, 59, System.Globalization.CultureInfo.InvariantCulture.Calendar);
            changeDate = etz.eastTimeNow();
            MRParams newParm = new MRParams();
            newParm.Key        = keyLastDate;
            newParm.Value      = LastDate.ToString();
            newParm.ChangeDate = changeDate;
            db.MRParams.InsertOnSubmit(newParm);
            db.SubmitChanges();
        }
        lblDateLastChanged.Text = "Date Last Changed: " + changeDate.ToString();
    }
示例#4
0
    protected void deletePlayerInfo(MrMember memb)
    {
        ActiveSignups = Convert.ToInt32(Session["ActiveSignups"]);
        playerID      = Convert.ToInt32(Session["PlayerID"]);

        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var item = db.Players.FirstOrDefault(p => p.PlayerID == memb.pID);

        if (item != null)
        {
            db.Players.DeleteOnSubmit(item);
            var se =
                from pl in db.PlayersList
                where ((pl.PlayerID == memb.pID) && (pl.Marked == 1))
                select pl;
            db.PlayersList.DeleteAllOnSubmit(se);
            db.SubmitChanges();
            Label2.Text = string.Format("Player {0} {1} Deleted.", item.PlayerID, item.Name);
        }
        else
        {
            lblErrorMsg.Text = string.Format("Player {0} {1} NOT deleted because player does not exist in database!", memb.pID, memb.name);
        }
    }
示例#5
0
    public static int DeleteMember(int playerID)
    {
        int       err           = 1;                                        // set result to not deleted
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        var       pl            = db.Players.Single(p => p.PlayerID == playerID);

        _MembersName = pl.Name;
        if (SignupList.CountPlayersActiveSignupEntries(playerID) == 0)            // delete is active records is zero
        {
            db.Players.DeleteOnSubmit(pl);
            var deleteSignupEntries =
                from SignupEntries in db.PlayersList
                where SignupEntries.PlayerID == playerID
                select SignupEntries;
            if (deleteSignupEntries != null)
            {
                foreach (var SignupEntry in deleteSignupEntries)
                {
                    // delete all signup records for this member
                    db.PlayersList.DeleteOnSubmit(SignupEntry);
                }
                db.SubmitChanges();
                err = 0;                                                        // set result to deleted
            }
        }
        return(err);
    }
示例#6
0
    public static int GetPlayerID(string lName, string fName, int sex)
    {
        keyName = Proper(lName.Trim()) + ", " + Proper(fName.Trim());
        MrTimeZone tz = new MrTimeZone();


        int       pid           = 0;
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        var       query         =
            from p in db.Players
            where p.Name == keyName
            select p;

        Players player = query.FirstOrDefault();             // Lookup Player in Players Datbase

        if (player != null)
        {
            pid = player.PlayerID;
        }
        else
        {
            Players pl = new Players()
            {
                Name     = keyName,
                LName    = Proper(lName.Trim()),
                FName    = Proper(fName.Trim()),
                Hcp      = "NONE",
                MemberID = "",
                Sex      = sex,
                Title    = "",
                HDate    = tz.eastTimeNow(),
                Delete   = 0
            };
            MRParams param = db.MRParams.FirstOrDefault(p => p.Key == keyPlayers);
            if (param != null)
            {
                pid         = Convert.ToInt32(param.Value);
                pid        += 1;
                pl.PlayerID = pid;
                db.Players.InsertOnSubmit(pl);
                param.Value      = pid.ToString();
                param.ChangeDate = tz.eastTimeNow();
            }
            else
            {
                MRParams par = new MRParams();
                par.Key        = keyPlayers;
                par.Value      = "1";
                par.ChangeDate = tz.eastTimeNow();
                db.MRParams.InsertOnSubmit(par);
                pid         = 1;
                pl.PlayerID = pid;
                db.Players.InsertOnSubmit(pl);
            }
        }
        db.SubmitChanges();

        return(pid);
    }
示例#7
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        lblUpdateCount.Text      = " ";
        lblUpdateCount.ForeColor = System.Drawing.Color.Green;
        // load handicaps.txt file from host server in handicap list
        int updateCount    = 0;
        int countOfPlayers = 0;

        // MrResources mr = new MrResources();
        // path = Server.MapPath(mr.Root);
        try
        {
            hcpDate = Convert.ToDateTime(tbHcpDate.Text);

            List <Handicap> hc = Handicap.LoadHandicaps(filename, hcpDate);

            // update sql Players with handicaps from text file
            string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
            MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
            MRParams  entry         = db.MRParams.FirstOrDefault(p => p.Key == "Players");
            if (entry == null)
            {
                PlayersCount = 0;
            }
            else
            {
                PlayersCount = Convert.ToInt32(entry.Value);
                for (int i = 0; i <= PlayersCount; ++i)
                {
                    var m = db.Players.FirstOrDefault(h => h.PlayerID == i);
                    if (m != null)
                    {
                        countOfPlayers++;
                        foreach (var hcp in hc)
                        {
                            if (m.MemberID.Trim() == hcp.ID.Trim())
                            {
                                m.Hcp   = hcp.Index;
                                m.HDate = hcp.Date;
                                db.SubmitChanges();
                                updateCount++;
                            }
                        }
                    }
                }
            }
            ShowMembers();
            lblUpdateCount.Text = string.Format("{0} of {1} Handicaps Updated", updateCount, countOfPlayers);
        }
        catch (FormatException)
        {
            lblUpdateCount.Text      = "Invalid Handicap Date";
            lblUpdateCount.ForeColor = System.Drawing.Color.Red;
        }
    }
示例#8
0
    public static int GetGuestID(string ln, string fn, string hcp, int gender)
    {
        int    id       = 0;
        string keyGuest = Proper(ln.Trim()) + ", " + Proper(fn.Trim());

        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        int       gcount        = db.Guest.Count();
        Guest     ginfo         = db.Guest.FirstOrDefault(g => g.GuestName == keyGuest);

        if (ginfo != null)
        {
            id = ginfo.GuestID;
            if (hcp.Trim() != "")
            {
                if (ginfo.gHcp.Trim() != hcp.Trim())
                {
                    ginfo.gHcp = hcp.Trim();
                    db.SubmitChanges();
                }
            }
        }
        else
        {
            id = gcount + 1;
            Guest gin = new Guest
            {
                GuestID    = id,
                GuestName  = keyGuest,
                gLname     = Proper(ln.Trim()),
                gFname     = Proper(fn.Trim()),
                gSex       = gender,
                gHcp       = hcp,
                Played     = 0,
                DatePlayed = minDate
            };
            db.Guest.InsertOnSubmit(gin);
            db.SubmitChanges();
        }
        return(id);
    }
    protected void SaveParamValue(string Key, string Value)
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var chg = db.MRParams.FirstOrDefault(c => c.Key == Key);

        chg.Value = Value;
        DateTime chgChangeDate = new MrTimeZone().eastTimeNow();

        chg.ChangeDate = chgChangeDate;
        db.SubmitChanges();
    }
示例#10
0
    protected void deleteParam(string k)
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        MRParams rec = db.MRParams.FirstOrDefault(c => c.Key == k);

        if (rec != null)
        {
            db.MRParams.DeleteOnSubmit(rec);
        }
        db.SubmitChanges();
    }
示例#11
0
    protected void AddParameter(string key, string value)
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        MRParams prm = new MRParams();

        prm.Key        = key;
        prm.Value      = value;
        prm.ChangeDate = new MrTimeZone().eastTimeNow();

        db.MRParams.InsertOnSubmit(prm);
        db.SubmitChanges();
    }
    protected void btnDeleteAll_Click(object sender, EventArgs e)
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var entry =
            from p  in db.PlayersList
            where p.PlayerID > 0
            select p;

        foreach (var item in entry)
        {
            db.PlayersList.DeleteOnSubmit(item);
        }
        db.SubmitChanges();
    }
    protected void cleanPlayersList()
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var entry =
            from p in db.PlayersList
            where p.PlayerID > 0
            select p;

        foreach (var item in entry)
        {
            item.GuestID = 0;
        }
        db.SubmitChanges();
    }
示例#14
0
    protected void updateParams()
    {
        DateTime lDate = Convert.ToDateTime(newLastDate);

        LastDate = new DateTime(lDate.Year, lDate.Month, lDate.Day, 23, 59, 59);
//            MrTimeZone tmz = new MrTimeZone();
        DateTime fDate = Convert.ToDateTime(newFirstDate);

        FirstDate = new DateTime(fDate.Year, fDate.Month, fDate.Day, 0, 0, 1);

        changeDate = etz.eastTimeNow();

        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        MRParams  param         = db.MRParams.FirstOrDefault(p => p.Key == keyLastDate);

        if (param != null)
        {
            param.Value      = (string)LastDate.ToString();
            param.ChangeDate = changeDate;
        }
        else
        {
            MRParams newParam = new MRParams();
            newParam.Key        = keyLastDate;
            newParam.Value      = (string)LastDate.ToString();
            newParam.ChangeDate = changeDate;
            db.MRParams.InsertOnSubmit(newParam);
        }
        MRParams xparam = db.MRParams.FirstOrDefault(p => p.Key.Trim() == keyFirstDate);

        if (xparam != null)
        {
            xparam.Value      = (string)FirstDate.ToString();
            xparam.ChangeDate = changeDate;
        }
        else
        {
            MRParams newParam = new MRParams();
            newParam.Key        = keyFirstDate;
            newParam.Value      = (string)FirstDate.ToString();
            newParam.ChangeDate = changeDate;
            db.MRParams.InsertOnSubmit(newParam);
        }
        db.SubmitChanges();
        lblDateChanged.Text = "Last Date Changed Successfully: " + changeDate.ToString();
    }
    public static void Update(string key, string value)
    {
        MrTimeZone etz           = new MrTimeZone();
        string     MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB  db            = new MRMISGADB(MRMISGADBConn);
        SysParams  entry         = db.SysParams.FirstOrDefault(p => p.Key.Trim() == key);

        if (entry != null)
        {
            entry.Value      = value;
            entry.ChangeDate = etz.eastTimeNow();
        }
        else
        {
            SysParams sp = new SysParams
            {
                Key        = key,
                Value      = value,
                ChangeDate = etz.eastTimeNow()
            };
            db.SysParams.InsertOnSubmit(sp);
        }
        db.SubmitChanges();

/*)
 *      MRParams entry = db.MRParams.FirstOrDefault(p => p.Key.Trim() == keyLastDate);
 *      if (entry != null)
 *      {
 *          LastDate = Convert.ToDateTime((string)entry.Value);
 *          changeDate = (DateTime)entry.ChangeDate;
 *      }
 *      else
 *      {
 *          int curyear = etz.eastTimeNow().Year;
 *          LastDate = new DateTime(curyear, 3, 1, 23, 59, 59, System.Globalization.CultureInfo.InvariantCulture.Calendar);
 *          changeDate = etz.eastTimeNow();
 *          MRParams newParm = new MRParams();
 *          newParm.Key = keyLastDate;
 *          newParm.Value = LastDate.ToString();
 *          newParm.ChangeDate = changeDate;
 *          db.MRParams.InsertOnSubmit(newParm);
 *          db.SubmitChanges();
 *      }
 *      lblDateLastChanged.Text = "Date Last Changed: " + changeDate.ToString();
 */
    }
示例#16
0
    private void savePlayerInfo(MrMember memb)
    {
        string    action        = "";
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var item = db.Players.FirstOrDefault(p => p.PlayerID == memb.pID);

        if (item != null)
        {
            item.Name     = memb.name;
            item.LName    = memb.lname;
            item.FName    = memb.fname;
            item.Hcp      = memb.hcp;
            item.HDate    = memb.hdate;
            item.MemberID = memb.memberNumber;
            item.Sex      = memb.gender;
            item.Title    = memb.title;
            item.Delete   = memb.del;
            action        = "updated";
        }
        else
        {
            Players p = new Players()
            {
                PlayerID = memb.pID,
                Name     = memb.name,
                LName    = memb.lname,
                FName    = memb.fname,
                Hcp      = memb.hcp,
                HDate    = memb.hdate,
                MemberID = memb.memberNumber,
                Sex      = memb.gender,
                Title    = memb.title,
                Delete   = memb.del
            };
            db.Players.InsertOnSubmit(p);
            action = "inserted";
        }
        db.SubmitChanges();
        Label2.Text = string.Format("{0} {1} {2} in database.", memb.pID, memb.name, action);
    }
示例#17
0
    protected int PurgeEvents(DateTime StartDate, DateTime EndDate)
    {
        int       result = 0;
        DateTime  vDate;
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);

        var query = from q in db.Events
                    where ((q.Date >= StartDate) && (q.Date <= EndDate))
                    select q;

        foreach (var item in query)
        {
            vDate = item.Date;
            db.Events.DeleteOnSubmit(item);
            result++;
        }
        db.SubmitChanges();
        return(result);
    }
示例#18
0
    public static void PurgeMarkedEntries()
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        var       markedEntries =
            from SignupEntries in db.PlayersList
            where SignupEntries.Marked > 0
            select SignupEntries;

        _entriesPurged = 0;
        if (markedEntries != null)
        {
            foreach (var entry in markedEntries)
            {
                db.PlayersList.DeleteOnSubmit(entry);
                _entriesPurged++;
            }
            db.SubmitChanges();
        }
    }
示例#19
0
    public static void Update(string key, string value)
    {
        MrTimeZone etz           = new MrTimeZone();
        string     MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB  db            = new MRMISGADB(MRMISGADBConn);
        SysParams  entry         = db.SysParams.FirstOrDefault(p => p.Key.Trim() == key);

        if (entry != null)
        {
            entry.Value      = value;
            entry.ChangeDate = etz.eastTimeNow();
        }
        else
        {
            SysParams sp = new SysParams
            {
                Key        = key,
                Value      = value,
                ChangeDate = etz.eastTimeNow()
            };
            db.SysParams.InsertOnSubmit(sp);
        }
        db.SubmitChanges();
    }
示例#20
0
    protected int purgeEntries()
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        int       countOfEntries;

        countOfEntries = 0;

        var sup = from pl in db.PlayersList
                  orderby pl.EventID
                  select pl;

        foreach (PlayersList item in sup)
        {
            int y = Convert.ToInt32(item.EventID.Substring(3, 2)) + 2000;
            if (y < currYear)
            {
                db.PlayersList.DeleteOnSubmit(item);
                countOfEntries++;
            }
        }
        db.SubmitChanges();
        return(countOfEntries);
    }
示例#21
0
    //   protected void btnLogon_Click(object sender, EventArgs e)
//    {

//    }

    private bool ValidateUser(string UserName, string PassWord)
    {
        string userName;
        string passWord;

        userName = UserName;
        passWord = PassWord;
        if (testEnvironment)
        {
            if ((UserName == "") && (PassWord == ""))
            {
                userName = "******";
                passWord = "******";
            }
        }
        string lookupPassword = null;

        string    sdbc = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db   = new MRMISGADB(sdbc);

        // Check for invalid userName.
        // userName must not be null and must be between 1 and 15 characters.
        if ((null == userName) || (0 == userName.Length) || (userName.Length > 15))
        {
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of userName failed.");
            return(false);
        }

        // Check for invalid passWord.
        // passWord must not be null and must be between 1 and 25 characters.
        if ((null == passWord) || (0 == passWord.Length) || (passWord.Length > 25))
        {
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Input validation of passWord failed.");
            return(false);
        }

        try
        {
            var cs = db.Users.FirstOrDefault(c => c.UserID.ToLower() == userName.ToLower());
            if (cs != null)
            {
                lookupPassword = cs.Password;
                usr.UserID     = cs.UserID;
                usr.Name       = cs.Name;
                usr.ClubID     = cs.ClubID;
                usr.Email      = cs.Email;
                usr.Phone      = cs.Phone;
                usr.role       = cs.role;
                usr.LoginCount = cs.LoginCount;
            }
        }
        catch (Exception ex)
        {
            // Add error handling here for debugging.
            // This error message should not be sent back to the caller.
            string stop = "yes";
            System.Diagnostics.Trace.WriteLine("[ValidateUser] Exception " + ex.Message);
        }

        // If no password found, return false.
        if (null == lookupPassword)
        {
            // You could write failed Logon attempts here to event log for additional security.
            return(false);
        }

        // Compare lookupPassword and input passWord, using a case-sensitive comparison.
        if (0 == string.Compare(lookupPassword, passWord, false))
        {
            MrTimeZone tz = new MrTimeZone();

            var cs = db.Users.FirstOrDefault(c => c.UserID == userName);
            cs.LoginCount++;
            cs.LastLogin = tz.eastTimeNow();
            db.SubmitChanges();
            return(true);
        }
        return(false);
    }
示例#22
0
    public static string AddToList(string EventID, int pID, string Action, string Carpool, int Sex, string sr, int guestID)
    {
        ///<Remarks>
        ///
        /// Action settings
        ///    Signup
        ///    Cancel
        ///
        /// Carpool Settings
        ///    No  to Carpool
        ///    Yes to Carpool
        ///
        ////*  Add Player to Players List for the mixer or event specified in'EventID'
        /// *  First task is to find player in the table of 'Players' and if the player cannot be found,
        /// *  to give the player the next PlayerID available then add the player to the 'Players' Table.
        /// *  After completing that then create a players list entry for this player and event.  Then add that entry to the 'PlayersList'
        /// *  Table.
        /// *
        /// * Then return control to caller with a success indicator as the result.
        /// * Result of integer Zero indicates successful completion
        /// *           integer One  indicates an unsuccessful completion
        /// *
        /// * */
        ///

        string result = "";
        //
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        //
        //
        MrTimeZone tz   = new MrTimeZone();
        Events     evnt = db.Events.FirstOrDefault(e => e.EventID == EventID);

        if (evnt != null)
        {
            Players player = db.Players.FirstOrDefault(x => x.PlayerID == pID);
            if (player != null)
            {
                PlayersList entry = db.PlayersList.FirstOrDefault(p => p.EventID == EventID && p.PlayerID == pID && p.Marked == 0);
                if (entry != null)
                {
                    if (Action == txtCancel)
                    {
                        entry.Marked = 1;       // set marked for Delete
                        if (evnt.Date < tz.eastTimeNow().AddHours(24))
                        {
                            result = "Cannot cancel online within 24 hours of Event.<br />Call the Golf Shop.";
                        }
                        else
                        {
                            if (tz.eastTimeNow() > evnt.Deadline)
                            {
                                result = "Cancel recorded.<br />Please notify the Host Golf Shop that you cancelled.";
                            }
                            else
                            {
                                result = "Cancel successful.";
                            }
                        }
                    }
                    else
                    {                           // modify existing entry in players database
                        entry.Carpool     = Carpool;
                        entry.SpecialRule = sr;
                        entry.GuestID     = guestID;
                        result            = "Modification of entry was sucessful.";
                    }
                }
                else
                {                               // no entry for this player and event
                    PlayersList ple = new PlayersList()
                    {                           // create new entry in players list database
                        EventID     = EventID,
                        TransDate   = tz.eastTimeNow(),
                        Marked      = 0,                // set entrymark to zero
                        PlayerID    = pID,
                        Action      = Action,
                        Carpool     = Carpool,
                        SpecialRule = sr,
                        GuestID     = guestID
                    };
                    if (Action != txtCancel)
                    {                                       // cannot do a cancel on new entry
                        db.PlayersList.InsertOnSubmit(ple);
                        result = "Sign-up was successful.";
                    }
                    else
                    {
                        ple.Marked = 1;        // set to not display canceled entries
                        result     = string.Format("Cancel unsuccessful because {0} {1} not Signed Up.", player.FName, player.LName);
                    }
                }
                db.SubmitChanges();
            }
            else
            {
                result = "Player not in database.";
            }
        }
        else
        {
            result = "Event not in database.";
        }
        return(result);
    }
示例#23
0
    public static MrSchedule LoadFromCsv(string fileName)
    {
        string    MRMISGADBConn = ConfigurationManager.ConnectionStrings["MRMISGADBConnect"].ToString();
        MRMISGADB db            = new MRMISGADB(MRMISGADBConn);
        MRParams  item          = db.MRParams.FirstOrDefault(p => p.Key == keyMinDate);

        if ((item == null))
        {
            MinDate = new DateTime(2000, 1, 1, 1, 0, 0);
        }
        else
        {
            MinDate = Convert.ToDateTime(item.Value);
        }

        MrSchedule target = new MrSchedule();

        target.FileName   = fileName;
        target.CreateTime = System.IO.File.GetLastWriteTime(fileName);
        string[] lines = System.IO.File.ReadAllLines(fileName);
        foreach (String line in lines)
        {
            if (line.Trim() == "")
            {
                // Ignore this line
            }
            else if (line.Substring(0, 1) == "/")
            {
                // Ignore comment line
            }
            else
            {
                string[] fields = line.Split(delimiterChars);
                if (fields.Length != 12)
//                if (fields.Length != 11)
                {
                    throw new InvalidOperationException("DERP: Incorrect number of fields in schedule.txt");
                }

                SysEvent e = new SysEvent()
                {
                    Id           = fields[0],
                    EDate        = Convert.ToDateTime(fields[1]),
                    EType        = fields[2],
                    ETitle       = fields[3],
                    ECost        = fields[4],
                    ETime        = fields[5],
                    EDeadline    = Convert.ToDateTime(fields[6]),
                    EHostPhone   = fields[7],
                    ESpecialRule = fields[9],
                    EGuest       = fields[10],
                    EHostID      = fields[0].Substring(11, 3)
                };
                if (string.IsNullOrEmpty(fields[11]))
                {
                    e.EPostDate = MinDate;
                }
                else
                {
                    e.EPostDate = Convert.ToDateTime(fields[11]);
                }

                if (fields[8] == "")
                {
                    e.EPlayerLimit = 6;
                }
                else
                {
                    e.EPlayerLimit = Convert.ToInt32(fields[8]);
                }

                target.Events.Add(e);
                Events ev = db.Events.FirstOrDefault(p => p.EventID == e.Id);
                if (ev == null)
                {
                    Events newEvent = new Events()
                    {
                        EventID     = e.Id,
                        Date        = e.EDate,
                        Type        = e.EType,
                        Title       = e.ETitle,
                        Cost        = e.ECost,
                        Time        = e.ETime,
                        Deadline    = e.EDeadline,
                        HostID      = e.EHostID,
                        SpecialRule = e.ESpecialRule,
                        PlayerLimit = e.EPlayerLimit,
                        Guest       = e.EGuest,
                        HostPhone   = e.EHostPhone,
                        PostDate    = e.EPostDate
                    };
                    db.Events.InsertOnSubmit(newEvent);
                }
                else
                {
                    ev.Date        = e.EDate;
                    ev.Type        = e.EType;
                    ev.Title       = e.ETitle;
                    ev.Cost        = e.ECost;
                    ev.Time        = e.ETime;
                    ev.Deadline    = e.EDeadline;
                    ev.HostID      = e.EHostID;
                    ev.Guest       = e.EGuest;
                    ev.PlayerLimit = e.EPlayerLimit;
                    ev.SpecialRule = e.ESpecialRule;
                    ev.HostPhone   = e.EHostPhone;
                    ev.PostDate    = e.EPostDate;
                }
                db.SubmitChanges();
            }
        }

        return(target);
    }