Esempio n. 1
0
        private void UpdateRowClickEvent(string[] eventArguments)
        {
            if (Trace.IsTracing)
                Trace.Trace("UpdateRowClick({0}) Start", MasterTable.DataSourceId);

            int i = 0;
            bool status = false;

            while (i < MasterTable.Rows.Count)
            {
                if (eventArguments[1] == MasterTable.Rows[i].PrimaryKeyUpdateValues)
                {
                    status = true;
                    break;
                }
                i++;
            }
            if (Equals(status, true))
            {
                if (UpdateRowClick != null)
                {
                    UpdateRowClickEventArgs ea = new UpdateRowClickEventArgs {EditIndex = eventArguments[1]};
                    UpdateRowClick(this, ea);

                    if (!ea.AcceptChanges) // The programmer can abort further actions.
                        return;
                }

                string res = DisplayView == DisplayView.Detail ? InternalId : MasterTable.Rows[i].PrimaryKeyUpdateValues;

                // Retrieve postback data before we proceeds
                for (int ii = 0; ii < MasterTable.Rows[i].Columns.Count; ii++)
                    MasterTable.Rows[i][ii].GetCellPostBackData();

                MasterTable.InsertUpdate(ref res, MasterTable.Rows[i]);

                if (SystemMessage.Count == 0)
                {
                    ReLoadData = true;
                    if (AfterUpdateInsert != null)
                    {
                        AfterUpdateInsertEventArgs ea = new AfterUpdateInsertEventArgs
                                                            {
                                                                EditIndex = res,
                                                                Row = MasterTable.Rows[i],
                                                                Update = true,
                                                                Insert = false
                                                            };
                        AfterUpdateInsert(this, ea);
                    }
                }
                else // error for record update should not generate on systemMessages.
                    m_IsRecordUpdate = false;
            }
            AddClientNotificationMessage(GetSystemMessage("ClientNotification_Update"));

            if (Trace.IsTracing)
                Trace.Trace("UpdateRowClick({0}) Finished;", MasterTable.DataSourceId);
        }
Esempio n. 2
0
        private void UpdateRowsClickEvent()
        {
            string oldWhere = null;
            if (PageIndex == 0 && GotHttpContext)
            {
                oldWhere = FilterExpression;
                FilterExpression = HttpContext.Current.Server.UrlDecode(HttpContext.Current.Request[ClientID + "_where"]);
            }

            // 16.10.2004, Jorn
            // Happens when the user clicks "Update Rows" inside grid view.
            if (Trace.IsTracing)
                Trace.Trace("UpdateRowsClick({0}) Start;", MasterTable.DataSourceId);

            if (Equals(m_MasterTable.m_GotData, false))
                MasterTable.GetData(false);
            if (UpdateRowsClick != null)
            {
                UpdateRowsClickEventArgs ea = new UpdateRowsClickEventArgs();
                UpdateRowsClick(this, ea);
                if (ea.AcceptChanges == false) // The programmer can abort further actions.
                    return;
            }
            // Kj0r update!
            for (int i = 0; i < MasterTable.Rows.Count; i++)
            {
                string res = DisplayView == DisplayView.Detail ? InternalId : MasterTable.Rows[i].PrimaryKeyUpdateValues;

                if (MasterTable.InsertUpdate(ref res, MasterTable.Rows[i]) == false)
                    continue;

                if (SystemMessage.Count != 0) continue;
                ReLoadData = true;
                if (AfterUpdateInsert == null) continue;
                AfterUpdateInsertEventArgs ea = new AfterUpdateInsertEventArgs
                {
                    EditIndex = res,
                    Row = MasterTable.Rows[i],
                    Update = true,
                    Insert = false
                };

                AfterUpdateInsert(this, ea);
            }
            AddClientNotificationMessage(GetSystemMessage("ClientNotification_Update"));
             // Done cause of the property SystemMessageUpdateRows message should not be rendered if there are systemMessages.
            if (SystemMessage.Count > 0)
                m_IsRecordUpdateRows = false;

            if (Trace.IsTracing)
                Trace.Trace("UpdateRowsClick({0}) Finished;", MasterTable.DataSourceId);
            if (PageIndex == 0)
                FilterExpression = oldWhere;
        }
Esempio n. 3
0
        // Happens when the user clicks a "UPDATE" inside detail view.
        private void RecordUpdateClickEvent(string[] eventArguments)
        {
            DisplayView = DisplayView.Detail;

            if (RecordUpdateClick != null)
            {
                UpdateClickEventArgs ea = new UpdateClickEventArgs();
                if (eventArguments.Length > 2 && eventArguments[2].Equals("true", StringComparison.OrdinalIgnoreCase))
                {
                    ea.Copy = true;
                    ea.EditIndex = null;
                }
                else
                    ea.EditIndex = eventArguments[1];

                RecordUpdateClick(this, ea);
                if (ea.AcceptChanges == false) // The programmer can abort further actions.
                    return;
            }
            // Row should be copied.
            if (eventArguments.Length > 2 && eventArguments[2].Equals("true", StringComparison.OrdinalIgnoreCase))
                InternalId = null;

            else if (eventArguments.Length > 3)
            {
                MasterTable.m_GotPostBackData = false;

                MasterTable.m_GotData = false;
                m_IsOneToOneRelationGrid = true;

                MasterTable.m_Grid.InternalId = eventArguments[1];
                if (eventArguments[3].Equals("new", StringComparison.OrdinalIgnoreCase))
                    m_IsOneToOneRelationNewRecord = true;
            }
            if (m_MasterTable.m_GotData == false)
                MasterTable.GetData(false);

            bool update = (InternalId != null);
            bool insert = (InternalId == null);
            string res = null;
            if (MasterTable.InsertUpdate(ref res) == false)
                return;

            if (SystemMessage.Count != 0) return;
            ReLoadData = true;

            if (MasterTable.m_Grid.StayInDetail == false)
            {
                InternalId = null;
                DisplayView = DisplayView.Grid;
                if (MasterTable.m_Grid.Trace.IsTracing)
                    MasterTable.m_Grid.Trace.Trace(string.Format("{0} grid view after insert", ID));
            }
            if (update)
                m_IsRecordUpdate = true;
            else
                m_IsRecordNew = true;

            if (AfterUpdateInsert != null)
            {
                AfterUpdateInsertEventArgs ea = new AfterUpdateInsertEventArgs
                {
                    EditIndex = res,
                    Row = MasterTable.Rows[0],
                    m_Datarow = MasterTable.Rows[0].m_DataRow,
                    Update = update,
                    Insert = insert
                };

                AfterUpdateInsert(this, ea);
            }
            string message = update
                                 ? GetSystemMessage("ClientNotification_Update")
                                 : GetSystemMessage("ClientNotification_Insert");
            AddClientNotificationMessage(message);

            if (!MasterTable.m_Grid.StayInDetail || !insert) return;
            MasterTable.m_Grid.InternalId = res;
            if( MasterTable.Rows.Count == 1)
                MasterTable.Rows[0].PrimaryKeyValues = res;
            DisplayView = DisplayView.Detail;
            if (MasterTable.m_Grid.Trace.IsTracing)
                MasterTable.m_Grid.Trace.Trace("{0} sets EditIndex at StayInDetail && Insert", ID);
        }