Ejemplo n.º 1
0
 protected void JqgridUser_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     var status = e.RowData["StatusLabel"];
     var mainCompany = e.RowData["PropertyCode"];
     var accessProperties = e.RowData["AccessProperties"];
     var permissionId = e.RowData["PermissionName"];
     var position = e.RowData["Position"];
     var userId = e.RowKey;
     var username = e.RowData["Username"];
     if (!(string.IsNullOrEmpty(status) || string.IsNullOrEmpty(mainCompany) || string.IsNullOrEmpty(permissionId)))
     {
         var user = new HotelDataEntryLib.User()
         {
             UserId = Convert.ToInt32(userId),
             PropertyId = Convert.ToInt32(mainCompany),
             FirstName = e.RowData["FirstName"],
             LastName = e.RowData["LastName"],
             Email = e.RowData["Email"],
             Status = Convert.ToInt32(status),
             AccessProperties = accessProperties,
             PermissionId = Convert.ToInt32(permissionId),
             Username = username,
             Position = position
         };
         UserHelper.UpdateUserProfile(user);
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Jqgrid2_RowEditing(object sender, JQGridRowEditEventArgs e)
        {
            try
            {
                AppSettingsReader asr = new AppSettingsReader();
                string dbconn = (string)asr.GetValue("dbconn", typeof(string));
                using (SqlConnection conn = new SqlConnection(dbconn))
                {
                    conn.Open();
                    SqlCommand sqlcomm = new SqlCommand("update t_RulelogS set alarmlog = '"+ e.RowData["AlarmLog"] +"', alarmdis = '" + e.RowData["AlarmDis"] + "'  where id = " + e.RowKey.ToString() + "", conn);
                    sqlcomm.ExecuteNonQuery();
                    conn.Close();
                }
            }
            catch (Exception)
            {

            }
        }
 protected void JqgridMatch1_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     var teamWin = "<b style='color: red'>ยังไม่มีผลการแข่งขัน</b>";
     var hasResult = 0;
     var homeScore = String.IsNullOrEmpty(e.RowData["TeamHomeScore"])
                         ? 0
                         : Convert.ToInt32(e.RowData["TeamHomeScore"]);
     var awayScore = String.IsNullOrEmpty(e.RowData["TeamAwayScore"])
                         ? 0
                         : Convert.ToInt32(e.RowData["TeamAwayScore"]);
     var date = String.IsNullOrEmpty(e.RowData["FAMatchDate"])
                    ? DateTime.Now
                    : Convert.ToDateTime(e.RowData["FAMatchDate"]);
     if (homeScore > awayScore)
     {
         teamWin = "<b style='color: blue'>" + e.RowData["TeamHomeName"] + "</b>";
         hasResult = 1;
     }
     else if (homeScore < awayScore)
     {
         teamWin = "<b style='color: blue'>" + e.RowData["TeamAwayName"] + "</b>";
         hasResult = 1;
     }
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var faMatch = dc.FAMatches.Single(item => item.FAMatchId == Convert.ToInt32(e.RowKey));
         faMatch.FAMatchDate = date;
         faMatch.TeamHomeName = e.RowData["TeamHomeName"];
         faMatch.TeamHomeScore = homeScore;
         faMatch.TeamAwayScore = awayScore;
         faMatch.TeamAwayName = e.RowData["TeamAwayName"];
         faMatch.TeamWin = teamWin;
         faMatch.HasResult = hasResult;
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 4
0
 protected void JqgridMatch1_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var match = dc.Matches.Single(item => item.MatchId == Convert.ToInt32(e.RowKey));
         match.MatchDate = Convert.ToDateTime(e.RowData["MatchDate"]);
         dc.SubmitChanges();
     }
 }
Ejemplo n.º 5
0
 protected void JqgridHomeTeam_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     using (var dc = ThaitaeDataDataContext.Create())
     {
         var team = dc.TeamMatches.Single(item => item.TeamMatchId == Convert.ToInt32(e.RowKey));
         team.TeamGoalFor = Convert.ToInt32(e.RowData["TeamGoalFor"]);
         team.TeamRedCard = Convert.ToInt32(e.RowData["TeamRedCard"]);
         team.TeamYellowCard = Convert.ToInt32(e.RowData["TeamYellowCard"]);
         if (team.TeamGoalFor == -1 && team.TeamRedCard == -1 && team.TeamYellowCard == -1)
         {
             team.TeamEdited = 0;
             team.TeamStatus = 0;
             team.TeamGoalAgainst = 0;
             team.TeamGoalFor = 0;
             team.TeamRedCard = 0;
             team.TeamYellowCard = 0;
         }
         else
         {
             team.TeamEdited = 1;
             var teamAgainst = dc.TeamMatches.Single(item => item.MatchId == Convert.ToInt32(e.ParentRowKey) && item.TeamHome == 0);
             teamAgainst.TeamGoalAgainst = Convert.ToInt32(e.RowData["TeamGoalFor"]);
             if (teamAgainst.TeamEdited == 1)
             {
                 if (team.TeamGoalFor < teamAgainst.TeamGoalFor)
                 {
                     team.TeamStatus = 3;
                     teamAgainst.TeamStatus = 1;
                 }
                 else if (team.TeamGoalFor > teamAgainst.TeamGoalFor)
                 {
                     team.TeamStatus = 1;
                     teamAgainst.TeamStatus = 3;
                 }
                 else
                 {
                     team.TeamStatus = 2;
                     teamAgainst.TeamStatus = 2;
                 }
                 dc.SubmitChanges();
                 CalculateTeamResult(team, teamAgainst, Convert.ToInt32(Session["seasonid"]));
             }
         }
         dc.SubmitChanges();
         var removePlayerList =
         dc.PlayerMatches.Where(item => item.TeamId == team.TeamId && item.MatchId == team.MatchId && item.SeasonId == team.SeasonId);
         dc.PlayerMatches.DeleteAllOnSubmit(removePlayerList);
         dc.SubmitChanges();
         for (int i = 0; i < team.TeamGoalFor; i++)
         {
             var player = new PlayerMatch { PlayerGoal = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
         for (int i = 0; i < team.TeamRedCard; i++)
         {
             var player = new PlayerMatch { PlayerRedCard = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
         for (int i = 0; i < team.TeamYellowCard; i++)
         {
             var player = new PlayerMatch { PlayerYellowCard = 1, TeamId = team.TeamId, MatchId = team.MatchId, SeasonId = team.SeasonId };
             dc.PlayerMatches.InsertOnSubmit(player);
             dc.SubmitChanges();
         }
     }
 }
Ejemplo n.º 6
0
 protected void JqgridHomePlayer_RowEditing(object sender, JQGridRowEditEventArgs e)
 {
     var playerMatchId = Convert.ToInt32(e.RowKey);
     var playerNumber = Convert.ToInt32(e.RowData["PlayerNumber"]);
     var playerName = e.RowData["PlayerName"];
     var player = CalculatePlayerMatch(playerMatchId, playerNumber, playerName);
     CalculatePlayerResult(player);
 }
        protected void JqgridMatch1_RowEditing(object sender, JQGridRowEditEventArgs e)
        {
            var homeScore = String.IsNullOrEmpty(e.RowData["TeamHomeScore"])
                                ? 0
                                : Convert.ToInt32(e.RowData["TeamHomeScore"]);
            var homePScore = String.IsNullOrEmpty(e.RowData["TeamHomePScore"])
                                ? 0
                                : Convert.ToInt32(e.RowData["TeamHomePScore"]);
            var awayScore = String.IsNullOrEmpty(e.RowData["TeamAwayScore"])
                                ? 0
                                : Convert.ToInt32(e.RowData["TeamAwayScore"]);
            var awayPScore = String.IsNullOrEmpty(e.RowData["TeamAwayPScore"])
                                ? 0
                                : Convert.ToInt32(e.RowData["TeamAwayPScore"]);
            var date = String.IsNullOrEmpty(e.RowData["MatchDate"])
                           ? DateTime.Now
                           : Convert.ToDateTime(e.RowData["MatchDate"]);
            using (var dc = ThaitaeDataDataContext.Create())
            {
                var match = dc.Matches.Single(item => item.MatchId == Convert.ToInt32(e.RowKey));
                var teamHome =
                    dc.TeamMatches.Single(item => item.MatchId == Convert.ToInt32(e.RowKey) && item.TeamHome == 1);
                var teamAway =
                    dc.TeamMatches.Single(item => item.MatchId == Convert.ToInt32(e.RowKey) && item.TeamHome == 0);
                match.MatchDate = date;
                teamHome.TeamGoalFor = homeScore;
                teamHome.TeamGoalPenalty = homePScore;
                teamAway.TeamGoalFor = awayScore;
                teamAway.TeamGoalPenalty = awayPScore;
                if (teamHome.TeamGoalFor == teamAway.TeamGoalFor)
                {
                    //if (teamHome.TeamGoalFor + teamHome.TeamGoalPenalty >
                    //    teamAway.TeamGoalFor + teamAway.TeamGoalPenalty)
                    //{
                    //    teamHome.TeamEdited = 1;
                    //    teamHome.TeamStatus = 1;
                    //    teamAway.TeamEdited = 1;
                    //    teamAway.TeamStatus = 3;
                    //}
                    //else if (teamHome.TeamGoalFor + teamHome.TeamGoalPenalty <
                    //         teamAway.TeamGoalFor + teamAway.TeamGoalPenalty)
                    //{
                    //    teamHome.TeamEdited = 1;
                    //    teamHome.TeamStatus = 3;
                    //    teamAway.TeamEdited = 1;
                    //    teamAway.TeamStatus = 1;
                    //}
                    //else
                    //{
                    teamHome.TeamEdited = 1;
                    teamHome.TeamStatus = 2;
                    teamAway.TeamEdited = 1;
                    teamAway.TeamStatus = 2;

                    //}
                }
                else if (teamHome.TeamGoalFor > teamAway.TeamGoalFor)
                {
                    teamHome.TeamEdited = 1;
                    teamHome.TeamStatus = 1;
                    teamAway.TeamEdited = 1;
                    teamAway.TeamStatus = 3;
                }
                else if (teamHome.TeamGoalFor < teamAway.TeamGoalFor)
                {
                    teamHome.TeamEdited = 1;
                    teamHome.TeamStatus = 3;
                    teamAway.TeamEdited = 1;
                    teamAway.TeamStatus = 1;
                }
                if (teamHome.TeamGoalFor == -1 && teamHome.TeamGoalPenalty == -1 && teamAway.TeamGoalFor == -1 &&
                    teamAway.TeamGoalPenalty == -1)
                {
                    teamHome.TeamGoalFor = 0;
                    teamHome.TeamGoalPenalty = 0;
                    teamAway.TeamGoalFor = 0;
                    teamAway.TeamGoalPenalty = 0;
                    teamHome.TeamEdited = 0;
                    teamHome.TeamStatus = 0;
                    teamAway.TeamEdited = 0;
                    teamAway.TeamStatus = 0;
                }
                dc.SubmitChanges();
                var mirrorMatchId =
                        dc.Matches.Single(
                            item =>
                            item.TeamHomeId == match.TeamAwayId && item.TeamAwayId == match.TeamHomeId && item.SeasonId == match.SeasonId).MatchId;
                var mirrorTeamHome =
                    dc.TeamMatches.Single(item => item.MatchId == mirrorMatchId && item.TeamHome == 1);
                var mirrorTeamAway =
                    dc.TeamMatches.Single(item => item.MatchId == mirrorMatchId && item.TeamHome == 0);
                if (mirrorMatchId < match.MatchId && mirrorTeamHome.TeamEdited == 1 && mirrorTeamAway.TeamEdited == 1 && teamHome.TeamEdited == 1 && teamAway.TeamEdited == 1)
                {
                    var totalScoreHome = teamHome.TeamGoalFor + mirrorTeamAway.TeamGoalFor;
                    var totalScoreAway = teamAway.TeamGoalFor + mirrorTeamHome.TeamGoalFor;
                    if (totalScoreHome > totalScoreAway)
                    {
                        teamHome.TeamStatus = 1;
                        teamAway.TeamStatus = 3;
                    }
                    else if (totalScoreHome < totalScoreAway)
                    {
                        teamHome.TeamStatus = 3;
                        teamAway.TeamStatus = 1;
                    }
                    else
                    {
                        if (teamHome.TeamGoalPenalty > teamAway.TeamGoalPenalty)
                        {
                            teamHome.TeamStatus = 1;
                            teamAway.TeamStatus = 3;
                        }
                        else
                        {
                            teamHome.TeamStatus = 3;
                            teamAway.TeamStatus = 1;
                        }
                    }
                    dc.SubmitChanges();
                }
            }
        }
Ejemplo n.º 8
0
        protected void JqGridDataEntry_RowEditing(object sender, JQGridRowEditEventArgs e)
        {
            var budgetEntryId = e.RowKey;
            var hotelEntryId = e.RowData["HotelEntryId"] == "" ? 0 : Convert.ToInt32(e.RowData["HotelEntryId"]);
            var roomBudget = string.IsNullOrEmpty(e.RowData["RoomBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["RoomBudget"]);
            var fbBudget = string.IsNullOrEmpty(e.RowData["FBBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["FBBudget"]);
            var spa = string.IsNullOrEmpty(e.RowData["SpaBudget"]) ? 0.00 : Convert.ToDouble(e.RowData["SpaBudget"]);
            var others = string.IsNullOrEmpty(e.RowData["Others"]) ? 0.00 : Convert.ToDouble(e.RowData["Others"]);
            var occupancyRoom = 0.0;
            if (string.IsNullOrEmpty(e.RowData["OccupancyRoom"]))
            {
                occupancyRoom = 0;
            }
            else
            {
                var strOccupancy = "";
                strOccupancy = e.RowData["OccupancyRoom"].Contains("%") ? e.RowData["OccupancyRoom"].Remove(e.RowData["OccupancyRoom"].Length - 1, 1) : e.RowData["OccupancyRoom"];
                occupancyRoom = Convert.ToDouble(strOccupancy);
            }

            var revenueEntry = new BudgetEntry()
            {
                BudgetId  = Convert.ToInt32(budgetEntryId),
                HotelBudgetId = hotelEntryId,
                OccupancyRoom = occupancyRoom,
                RoomBudget = roomBudget,
                FBBudget = fbBudget,
                SpaBudget = spa,
                Others = others,
                UpdateUser = Session["UserSession"].ToString(),
                Total = roomBudget + fbBudget + spa + others
            };
            BudgetHelper.UpdateBudgetEntry(revenueEntry);
        }
Ejemplo n.º 9
0
 private void PerformRowEdit()
 {
     NameValueCollection nameValueCollection = new NameValueCollection();
     foreach (string text in HttpContext.Current.Request.Form.Keys)
     {
         if (text != "oper")
         {
             nameValueCollection[text] = HttpContext.Current.Request.Form[text];
         }
     }
     string text2 = string.Empty;
     foreach (JQGridColumn jQGridColumn in this.Columns)
     {
         if (jQGridColumn.PrimaryKey)
         {
             text2 = jQGridColumn.DataField;
             break;
         }
     }
     if (!string.IsNullOrEmpty(text2) && !string.IsNullOrEmpty(nameValueCollection["id"]))
     {
         nameValueCollection[text2] = nameValueCollection["id"];
     }
     JQGridRowEditEventArgs jQGridRowEditEventArgs = new JQGridRowEditEventArgs();
     jQGridRowEditEventArgs.RowData = nameValueCollection;
     jQGridRowEditEventArgs.RowKey = nameValueCollection["id"];
     string text3 = this.QueryString["parentRowID"];
     if (!string.IsNullOrEmpty(text3))
     {
         jQGridRowEditEventArgs.ParentRowKey = text3;
     }
     this.OnRowEditing(jQGridRowEditEventArgs);
     if (!jQGridRowEditEventArgs.Cancel)
     {
         this.HandleUpdate(jQGridRowEditEventArgs);
     }
     this.OnRowEdited(jQGridRowEditEventArgs);
 }
Ejemplo n.º 10
0
 private void HandleUpdate(JQGridRowEditEventArgs e)
 {
     if (base.IsBoundUsingDataSourceID)
     {
         OrderedDictionary orderedDictionary = new OrderedDictionary();
         OrderedDictionary orderedDictionary2 = new OrderedDictionary();
         OrderedDictionary oldValues = new OrderedDictionary();
         DataSourceView data = this.GetData();
         if (data == null)
         {
             throw new HttpException("DataSource is null in edit mode (on update)");
         }
         foreach (JQGridColumn jQGridColumn in this.Columns)
         {
             if (jQGridColumn.PrimaryKey)
             {
                 orderedDictionary.Add(jQGridColumn.DataField, e.RowData[jQGridColumn.DataField]);
             }
             if (jQGridColumn.Editable)
             {
                 orderedDictionary2.Add(jQGridColumn.DataField, e.RowData[jQGridColumn.DataField]);
             }
         }
         data.Update(orderedDictionary, orderedDictionary2, oldValues, new DataSourceViewOperationCallback(this.HandleUpdateCallback));
     }
 }
Ejemplo n.º 11
0
 protected internal virtual void OnRowEditing(JQGridRowEditEventArgs e)
 {
     JQGrid.JQGridRowEditEventHandler jQGridRowEditEventHandler = (JQGrid.JQGridRowEditEventHandler)base.Events[JQGrid.EventRowEditing];
     if (jQGridRowEditEventHandler != null)
     {
         jQGridRowEditEventHandler(this, e);
     }
 }