示例#1
0
        private void AddTeeTime(TeeTimeItem TT)
        {
            string    sSQL;
            int       i2;
            APICommon ApiCommon = new APICommon();

            TT.TTGUID = m.CreateGuid();


            if (m.IsEmpty(TT.Owner))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Owner cannot be blank.");
                return;
            }

            if (m.IsEmpty(TT.Location))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Location cannot be blank.");
                return;
            }

            if (m.IsEmpty(TT.GroupGUID))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Group cannot be blank.");
                return;
            }


            if (TT.TTTime == null)
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Time cannot be blank.");
                return;
            }

            if (TT.TTDate == null)
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Date cannot be blank.");
                return;
            }

            if (m.BeforeToday(m.NoNullDate(TT.TTDate)))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Date cannot be before today.");
                return;
            }

            if (m.FormatDT(TT.TTTime, "HH:mm") == "00:00")
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Time cannot be blank.");
                return;
            }

            if (TTAleadyExists(TT))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "This teetime already exists.");
                return;
            }

            sSQL = "INSERT INTO [dbo].[W_TeeTimes] ";
            sSQL = sSQL + "     ([TeeTimeGUID] ";
            sSQL = sSQL + "    ,[GroupGUID] ";
            sSQL = sSQL + "    ,[TeeTimeOwner] ";
            sSQL = sSQL + "    ,[TeeTimeLocation] ";
            sSQL = sSQL + "    ,[TeeTimeDate] ";
            sSQL = sSQL + "    ,[TeeTimeTime] ";
            sSQL = sSQL + "    ,[OwnerComment] ";
            sSQL = sSQL + "    ,[LockPlayer1] ";
            sSQL = sSQL + "    ,[LockPlayer2] ";
            sSQL = sSQL + "    ,[LockPlayer3] ";
            sSQL = sSQL + "    ,[LockPlayer4] ";
            sSQL = sSQL + "    ,[Player1] ";
            sSQL = sSQL + "    ,[Player2] ";
            sSQL = sSQL + "    ,[Player3] ";
            sSQL = sSQL + "    ,[Player4] ";
            sSQL = sSQL + "    ,[WaitList1] ";
            sSQL = sSQL + "    ,[WaitList2] ";
            sSQL = sSQL + "    ,[WaitList3] ";
            sSQL = sSQL + "    ,[LockMessages] ";
            sSQL = sSQL + "    ,[HideMessages] ";
            sSQL = sSQL + "    ,[IsDeleted] )";
            sSQL = sSQL + "  VALUES (";
            sSQL = sSQL + m.InQuote(TT.TTGUID, 50) + ", ";            //  (<TeeTimeGUID, varchar(50),> ";
            sSQL = sSQL + m.InQuote(TT.GroupGUID, 50) + ", ";         //      ,<GroupGUID, varchar(50),> ";
            sSQL = sSQL + m.InQuote(TT.Owner, 50) + ", ";             //        ,<TeeTimeOwner, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.Location, 100) + ", ";         //        ,<TeeTimeLocation, nvarchar(max),> ";
            sSQL = sSQL + m.InQuoteT(m.NoNullDate(TT.TTDate)) + ", "; //        ,<TeeTimeDate, date,> ";
            sSQL = sSQL + m.InQuoteT(m.NoNullDate(TT.TTTime)) + ", "; //       ,<TeeTimeTime, time(0),> ";
            sSQL = sSQL + m.InQuote(TT.OwnerComment, 500) + ", ";     //       ,<OwnerComment, nvarchar(max),> ";
            sSQL = sSQL + m.InQuoteN(TT.LockPlayer1) + ", ";          //       ,<LockPlayer1, smallint,> ";
            sSQL = sSQL + m.InQuoteN(TT.LockPlayer2) + ", ";          //       ,<LockPlayer2, smallint,> ";
            sSQL = sSQL + m.InQuoteN(TT.LockPlayer3) + ", ";          //       ,<LockPlayer3, smallint,> ";
            sSQL = sSQL + m.InQuoteN(TT.LockPlayer4) + ", ";          //       ,<LockPlayer4, smallint,> ";
            sSQL = sSQL + m.InQuote(TT.Player1, 100) + ", ";          //       ,<Player1, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.Player2, 100) + ", ";          //       ,<Player2, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.Player3, 100) + ", ";          //       ,<Player3, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.Player4, 100) + ", ";          //      ,<Player4, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.WaitList1, 100) + ", ";        //      ,<WaitList1, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.WaitList2, 100) + ", ";        //      ,<WaitList2, nvarchar(max),> ";
            sSQL = sSQL + m.InQuote(TT.WaitList3, 100) + ", ";        //  "    ,<WaitList3, nvarchar(max),>) ";
            sSQL = sSQL + m.InQuoteN(TT.LockMessages) + ", ";         //       ,<LockMessages, smallint,> ";
            sSQL = sSQL + m.InQuoteN(TT.HideMessages) + ", ";         //       ,<HideMessages, smallint,> ";
            sSQL = sSQL + m.InQuoteN(0) + ") ";                       //  "    ,<IsDeleted, int>) ";

            i2 = m.SQLExecuteCommand(sSQL, c.DB.WhosIn);

            ApiCommon.InsertLogItem(m, TT.TTGUID, "Tee Time created.");

            SetResultCode(c.BATCH_RESULT_OK, "TeeTime added.");

            DeleteOldTeeTimes();
            return;
        }
示例#2
0
        private void UpdateInfo2(TeeTimeItem TT)
        {
            string sSQL;
            int    i2;


            if (m.IsEmpty(TT.Owner))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Owner cannot be blank.");
                return;
            }

            if (m.IsEmpty(TT.Location))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Location cannot be blank.");
                return;
            }

            if (m.IsEmpty(TT.GroupGUID))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Group cannot be blank.");
                return;
            }

            if (TT.TTTime == null)
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Time cannot be blank.");
                return;
            }

            if (TT.TTDate == null)
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Date cannot be blank.");
                return;
            }

            if (m.BeforeToday(m.NoNullDate(TT.TTDate)))
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Date cannot be before today.");
                return;
            }

            if (m.FormatDT(TT.TTTime, "HH:mm") == "00:00")
            {
                SetResultCode(c.BATCH_RESULT_FAIL, "Time cannot be blank.");
                return;
            }

            WriteToAuditLog2(TT);

            sSQL  = "UPDATE [dbo].[W_TeeTimes] ";
            sSQL += "  SET [GroupGUID] =" + m.InQuote(TT.GroupGUID);
            sSQL += ", [TeeTimeDate] =" + m.InQuoteT(m.NoNullDate(TT.TTDate));
            sSQL += ", [TeeTimeTime] =" + m.InQuoteT(m.NoNullDate(TT.TTTime));
            sSQL += ", [OwnerComment] =" + m.InQuote(TT.OwnerComment);
            sSQL += ", [LockPlayer1] =" + m.InQuoteN(TT.LockPlayer1);
            sSQL += ", [LockPlayer2] =" + m.InQuoteN(TT.LockPlayer2);
            sSQL += ", [LockPlayer3] =" + m.InQuoteN(TT.LockPlayer3);
            sSQL += ", [LockPlayer4] =" + m.InQuoteN(TT.LockPlayer4);
            sSQL += ", [TeeTimeOwner] =" + m.InQuote(TT.Owner);
            sSQL += ", [TeeTimeLocation] =" + m.InQuote(TT.Location);
            sSQL += ", [LockMessages] =" + m.InQuoteN(TT.LockMessages);
            sSQL += ", [HideMessages] =" + m.InQuoteN(TT.HideMessages);
            sSQL += "  WHERE TeeTimeGUID = " + m.InQuote(TT.TTGUID);
            i2    = m.SQLExecuteCommand(sSQL, c.DB.WhosIn);
            SetResultCode(c.BATCH_RESULT_OK, "");
            return;
        }