示例#1
0
        private void WebNavigatorCommand(CommandEventArgs e)
        {
            object obj = GetObjByID(this.BindingObject);
            object vobj = GetObjByID(this.ViewBindingObject);
            bool ViewExist = false;
            WebGridView viewGridView = new WebGridView();
            WebGridView gridView = new WebGridView();
            WebDetailsView detailView = new WebDetailsView();
            WebFormView formView = new WebFormView();
            WebDataSource ds = new WebDataSource();
            language = CliSysMegLag.GetClientLanguage();
            if (this.ShowDataStyle == NavigatorStyle.GridStyle && obj is WebGridView)
            {
                gridView = (WebGridView)obj;
                if (gridView.AutoPostBackMultiCheckBoxes)
                {
                    gridView.PostBackMultiCheckBoxes();
                }
                if (gridView.AutoPostBackWebGridTextBoxes)
                {
                    gridView.PostBackMultiTextBoxes();
                }
                ds = (WebDataSource)GetObjByID(gridView.DataSourceID);
                WebValidate validate = (WebValidate)gridView.ExtendedFindChildControl(gridView.DataSourceID, FindControlType.DataSourceID, typeof(WebValidate));
                WebNavigator bindingNav = gridView.GetBindingNavigator();
                #region GridView Default Operation
                switch (e.CommandName)
                {
                    case "cmdFirst":
                        if (this.GridViewMoveMode == MoveMode.PageMode)
                        {
                            if (gridView.AllowPaging)
                                gridView.PageIndex = 0;
                        }
                        else if (this.GridViewMoveMode == MoveMode.RowMode)
                        {
                            if (gridView.AllowPaging)
                                gridView.PageIndex = 0;
                            gridView.SelectedIndex = 0;
                        }
                        break;
                    case "cmdPrevious":
                        if (this.GridViewMoveMode == MoveMode.PageMode)
                        {
                            if (gridView.AllowPaging && gridView.PageIndex > 0)
                                gridView.PageIndex -= 1;
                        }
                        else if (this.GridViewMoveMode == MoveMode.RowMode)
                        {
                            if (gridView.SelectedIndex == 0)
                            {
                                if (gridView.AllowPaging && gridView.PageIndex > 0)
                                {
                                    gridView.PageIndex -= 1;
                                    gridView.SelectedIndex = gridView.PageSize - 1;
                                }
                            }
                            else
                            {
                                gridView.SelectedIndex -= 1;
                            }
                        }
                        break;
                    case "cmdNext":
                        if (this.GridViewMoveMode == MoveMode.PageMode)
                        {
                            if (gridView.AllowPaging && gridView.PageIndex != gridView.PageCount - 1)
                            {
                                gridView.PageIndex += 1;
                            }
                            if (gridView.PageIndex == gridView.PageCount - 1)
                            {
                                int j = gridView.PageIndex;
                                Object c = (this.Page.Master == null) ? this.Page.FindControl(gridView.DataSourceID) : this.Parent.FindControl(gridView.DataSourceID);
                                if (c != null)
                                {
                                    WebDataSource webDs = ((WebDataSource)c);
                                    if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                    {
                                        DataTable table = new DataTable();
                                        if (webDs.CommandTable != null)
                                        {
                                            table = webDs.CommandTable;
                                        }
                                        else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                        {
                                            table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                        }
                                        int i = table.Rows.Count;
                                        while (i <= gridView.PageSize * (j + 1) && (!webDs.Eof))
                                        {
                                            webDs.GetNextPacket();
                                            i += webDs.PacketRecords;
                                        }
                                    }
                                }
                            }
                        }
                        else if (this.GridViewMoveMode == MoveMode.RowMode)
                        {
                            if (gridView.AllowPaging)
                            {
                                if (gridView.PageIndex == gridView.PageCount - 1)
                                {
                                    if (gridView.SelectedIndex != gridView.Rows.Count - 1)
                                        gridView.SelectedIndex += 1;
                                }
                                else
                                {
                                    //不是最后一行
                                    if (gridView.SelectedIndex != gridView.PageSize - 1)
                                    {
                                        gridView.SelectedIndex += 1;
                                    }
                                    //最后一行
                                    else
                                    {
                                        gridView.PageIndex += 1;
                                        gridView.SelectedIndex = 0;
                                        if (gridView.PageIndex == gridView.PageCount - 1)
                                        {
                                            int j = gridView.PageIndex;
                                            Object c = (this.Page.Master == null) ? this.Page.FindControl(gridView.DataSourceID) : this.Parent.FindControl(gridView.DataSourceID);
                                            if (c != null)
                                            {
                                                WebDataSource webDs = ((WebDataSource)c);
                                                if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                                {
                                                    DataTable table = new DataTable();
                                                    if (webDs.CommandTable != null)
                                                    {
                                                        table = webDs.CommandTable;
                                                    }
                                                    else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                                    {
                                                        table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                                    }
                                                    int i = table.Rows.Count;
                                                    while (i <= gridView.PageSize * (j + 1) && (!webDs.Eof))
                                                    {
                                                        webDs.GetNextPacket();
                                                        i += webDs.PacketRecords;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "cmdLast":
                        if (gridView.AllowPaging)
                        {
                            gridView.PageIndex = gridView.PageCount - 1;
                            int j = gridView.PageIndex;
                            Object c = (this.Page.Master == null) ? this.Page.FindControl(gridView.DataSourceID) : this.Parent.FindControl(gridView.DataSourceID);
                            if (c != null)
                            {
                                WebDataSource webDs = ((WebDataSource)c);
                                if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                {
                                    DataTable table = new DataTable();
                                    if (webDs.CommandTable != null)
                                    {
                                        table = webDs.CommandTable;
                                    }
                                    else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                    {
                                        table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                    }
                                    int i = table.Rows.Count;
                                    bool b = false;
                                    while (i <= gridView.PageSize * (j + 1) && (!webDs.Eof))
                                    {
                                        webDs.GetNextPacket();
                                        i += webDs.PacketRecords;
                                        b = true;
                                    }

                                    if (this.GridViewMoveMode == MoveMode.RowMode)
                                    {
                                        if (!b && gridView.PageSize > 1)
                                        {
                                            gridView.SelectedIndex = (i % gridView.PageSize - 1 + gridView.PageSize) % gridView.PageSize;
                                        }
                                        else
                                        {
                                            gridView.SelectedIndex = gridView.PageSize - 1;
                                        }
                                    }
                                }
                            }
                        }
                        break;
                    case "cmdAdd":
                        if (ds.AllowAdd)
                        {
                            if (!CheckInsertedNotApply(gridView, 1))
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "InsertedNotApply", true);

                                ScriptHelper.ShowMessage(this, "InsertedNotApply", message);
                                formView.NeedExecuteAdd = false;
                                return;
                            }

                            formView.NeedExecuteAdd = true;
                            if (gridView.EditURL != null && gridView.EditURL != "")
                            {
                                gridView.OpenEditURL(WebGridView.OpenEditMode.Insert);
                                return;
                            }
                            else if (!string.IsNullOrEmpty(gridView.EditURLPanel))
                            {
                                object obj_pan = this.GetObjByID(gridView.EditURLPanel);
                                if (obj_pan != null && obj_pan is IModalPanel)
                                {
                                    IModalPanel panel = obj_pan as IModalPanel;
                                    panel.Open(WebGridView.OpenEditMode.Insert, new GridViewCommandEventArgs(null, new CommandEventArgs("Insert", gridView.ID)));
                                }
                                return;
                            }
                            else
                            {
                                gridView.GridInserting = true;
                                if (!gridView.TotalActive)
                                    gridView.ShowFooter = true;
                                else
                                    gridView.DataBind();
                                gridView.OnAdding(new EventArgs());
                            }
                            if (bindingNav != null && bindingNav != this)
                            {
                                bindingNav.SetState(NavigatorState.Inserting);
                                bindingNav.SetNavState("Inserting");
                            }
                            this.SetState(NavigatorState.Inserting);
                            this.SetNavState("Inserting");
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToAdd", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdOK":
                        gridView.OnInserting(new EventArgs());
                        if (!gridView.SkipInsert)
                        {
                            doOkForGridInsert(gridView, ds);
                        }
                        gridView.SkipInsert = false;
                        if (!gridView.ValidateFailed)
                            FlowOK();
                        break;
                    case "cmdCancel":
                        if (validate != null)
                            validate.Text = string.Empty;
                        gridView.GridInserting = false;
                        if (gridView.EditIndex != -1)
                            gridView.EditIndex = -1;
                        if (!gridView.TotalActive)
                            gridView.ShowFooter = false;
                        else
                            gridView.DataBind();

                        if (bindingNav != null && bindingNav != this)
                        {
                            if (gridView.DataHasChanged)
                            {
                                bindingNav.SetState(NavigatorState.Changed);
                                bindingNav.SetNavState("Changing");
                            }
                            else
                            {
                                bindingNav.SetState(NavigatorState.Browsing);
                                bindingNav.SetNavState("Browsed");
                            }
                        }
                        if (gridView.DataHasChanged)
                        {
                            this.SetState(NavigatorState.Changed);
                            this.SetNavState("Changing");
                        }
                        else
                        {
                            this.SetState(NavigatorState.Browsing);
                            this.SetNavState("Browsed");
                        }
                        FlowCancel();
                        gridView.OnCanceled(EventArgs.Empty);
                        break;
                    case "cmdApply":
                        foreach (GridViewRow row in gridView.Rows)
                        {
                            if (row.RowType == DataControlRowType.DataRow)
                            {
                                if ((row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
                                {
                                    gridView.UpdateRow(row.RowIndex, false);

                                    if ((row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
                                        return;
                                }
                            }
                        }
                        if (gridView.GridInserting)
                            doOkForGridInsert(gridView, ds);
                        bool bSucess = ds.ApplyUpdates();
                        if (bSucess && !gridView.ValidateFailed)
                        {
                            if (ds.AutoRecordLock)
                            {
                                ds.RemoveLock();
                            }
                            if (bindingNav != null && bindingNav != this)
                            {
                                bindingNav.SetState(NavigatorState.ApplySucess);
                                bindingNav.SetNavState("Browsed");
                            }
                            this.SetState(NavigatorState.ApplySucess);
                            this.SetNavState("Browsed");
                            FlowApply();
                        }
                        else
                        {
                            this.SetState(NavigatorState.ApplyFail);
                            if (gridView.EditIndex != -1)
                            {
                                this.SetNavState("Editing");
                                if (bindingNav != null && bindingNav != this)
                                    bindingNav.SetNavState("Editing");
                            }
                            else
                            {
                                this.SetNavState("Inserting");
                                if (bindingNav != null && bindingNav != this)
                                    bindingNav.SetNavState("Inserting");
                            }
                        }
                        break;
                    case "cmdAbort":
                        if (validate != null)
                            validate.Text = string.Empty;
                        if (gridView.EditIndex != -1)
                            gridView.EditIndex = -1;
                        if (gridView.ShowFooter && !gridView.TotalActive)
                        {
                            gridView.ShowFooter = false;
                        }
                        ds.InnerDataSet.RejectChanges();
                        if (ds.AutoRecordLock)
                        {
                            ds.RemoveLock();
                        }
                        this.SetState(NavigatorState.Aborted);
                        this.SetNavState("Browsed");
                        gridView.DataBind();
                        FlowAbort();
                        gridView.OnCanceled(EventArgs.Empty);
                        break;
                    case "cmdQuery":
                        DoQuery(ds);
                        break;
                    case "cmdPrint":
                        if (ds.AllowPrint)
                        { }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdExport":
                        Export();
                        break;
                    default:
                        GridViewFlowCommand(e);
                        break;
                }
                #endregion
            }
            else if (this.ShowDataStyle == NavigatorStyle.DetailStyle && obj is WebDetailsView)
            {
                detailView = (WebDetailsView)obj;
                if (vobj is WebGridView)
                {
                    viewGridView = (WebGridView)vobj;
                    ViewExist = true;
                }
                ds = (WebDataSource)GetObjByID(detailView.DataSourceID);
                WebValidate validate = (WebValidate)detailView.ExtendedFindChildControl(detailView.DataSourceID, FindControlType.DataSourceID, typeof(WebValidate));
                WebNavigator bindingNav = detailView.GetBindingNavigator();
                #region DetailsView Default Operation
                switch (e.CommandName)
                {
                    case "cmdFirst":
                        if (ViewExist)
                        {
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging)
                                    viewGridView.PageIndex = 0;
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.AllowPaging)
                                    viewGridView.PageIndex = 0;
                                viewGridView.SelectedIndex = 0;
                            }
                        }
                        else
                        {
                            if (detailView.AllowPaging)
                                detailView.PageIndex = 0;
                        }
                        break;
                    case "cmdPrevious":
                        if (ViewExist)
                        {
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging && viewGridView.PageIndex > 0)
                                    viewGridView.PageIndex -= 1;
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.SelectedIndex == 0)
                                {
                                    if (viewGridView.AllowPaging && viewGridView.PageIndex > 0)
                                    {
                                        viewGridView.PageIndex -= 1;
                                        viewGridView.SelectedIndex = viewGridView.PageSize - 1;
                                    }
                                }
                                else
                                {
                                    viewGridView.SelectedIndex -= 1;
                                }
                            }
                        }
                        else
                        {
                            if (detailView.AllowPaging && detailView.PageIndex > 0)
                                detailView.PageIndex -= 1;
                        }
                        break;
                    case "cmdNext":
                        if (ViewExist)
                        {
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging && viewGridView.PageIndex != viewGridView.PageCount - 1)
                                {
                                    viewGridView.PageIndex += 1;
                                }
                                if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                {
                                    Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID)
                                        : this.Parent.FindControl(viewGridView.DataSourceID);
                                    if (c != null)
                                    {
                                        ((WebDataSource)c).GetNextPacket();
                                    }
                                }
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.AllowPaging)
                                {
                                    if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                    {
                                        if (viewGridView.SelectedIndex != viewGridView.Rows.Count - 1)
                                            viewGridView.SelectedIndex += 1;
                                    }
                                    else
                                    {
                                        //不是最后一行
                                        if (viewGridView.SelectedIndex != viewGridView.PageSize - 1)
                                        {
                                            viewGridView.SelectedIndex += 1;
                                        }
                                        //最后一行
                                        else
                                        {
                                            viewGridView.PageIndex += 1;
                                            viewGridView.SelectedIndex = 0;
                                            if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                            {
                                                int j = viewGridView.PageIndex;
                                                Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID) : this.Parent.FindControl(viewGridView.DataSourceID);
                                                if (c != null)
                                                {
                                                    WebDataSource webDs = ((WebDataSource)c);
                                                    if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                                    {
                                                        DataTable table = new DataTable();
                                                        if (webDs.CommandTable != null)
                                                        {
                                                            table = webDs.CommandTable;
                                                        }
                                                        else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                                        {
                                                            table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                                        }
                                                        int i = table.Rows.Count;
                                                        while (i <= viewGridView.PageSize * (j + 1) && (!webDs.Eof))
                                                        {
                                                            webDs.GetNextPacket();
                                                            i += webDs.PacketRecords;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (detailView.AllowPaging && detailView.PageIndex != detailView.PageCount - 1)
                            {
                                detailView.PageIndex += 1;
                                if (detailView.PageIndex == detailView.PageCount - 1)
                                {
                                    Object c = (this.Page.Master == null) ? this.Page.FindControl(detailView.DataSourceID)
                                        : this.Parent.FindControl(detailView.DataSourceID);
                                    if (c != null)
                                    {
                                        ((WebDataSource)c).GetNextPacket();
                                    }
                                }
                            }
                        }
                        break;
                    case "cmdLast":
                        if (ViewExist)
                        {
                            //if (viewGridView.AllowPaging)
                            //{
                            //    viewGridView.PageIndex = viewGridView.PageCount - 1;
                            //    Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID)
                            //     : this.Parent.FindControl(viewGridView.DataSourceID);
                            //    if (c != null)
                            //    {
                            //        ((WebDataSource)c).GetNextPacket();
                            //    }
                            //}
                            if (viewGridView.AllowPaging)
                            {
                                viewGridView.PageIndex = viewGridView.PageCount - 1;
                                int j = viewGridView.PageIndex;
                                Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID) : this.Parent.FindControl(viewGridView.DataSourceID);
                                if (c != null)
                                {
                                    WebDataSource webDs = ((WebDataSource)c);
                                    if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                    {
                                        DataTable table = new DataTable();
                                        if (webDs.CommandTable != null)
                                        {
                                            table = webDs.CommandTable;
                                        }
                                        else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                        {
                                            table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                        }
                                        int i = table.Rows.Count;
                                        bool b = false;
                                        while (i <= viewGridView.PageSize * (j + 1) && (!webDs.Eof))
                                        {
                                            webDs.GetNextPacket();
                                            i += webDs.PacketRecords;
                                            b = true;
                                        }

                                        if (this.GridViewMoveMode == MoveMode.RowMode)
                                        {
                                            if (!b && viewGridView.PageSize > 1)
                                            {
                                                viewGridView.SelectedIndex = (i % viewGridView.PageSize - 1 + viewGridView.PageSize) % viewGridView.PageSize;
                                            }
                                            else
                                            {
                                                viewGridView.SelectedIndex = viewGridView.PageSize - 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (detailView.AllowPaging)
                            {
                                detailView.PageIndex = detailView.PageCount - 1;
                                Object c = (this.Page.Master == null) ? this.Page.FindControl(detailView.DataSourceID)
                                     : this.Parent.FindControl(detailView.DataSourceID);
                                if (c != null)
                                {
                                    ((WebDataSource)c).GetNextPacket();
                                }
                            }
                        }
                        break;
                    case "cmdAdd":
                        if (ds.AllowAdd)
                        {
                            if (!CheckInsertedNotApply(detailView, 2))
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "InsertedNotApply", true);

                                ScriptHelper.ShowMessage(this, "InsertedNotApply", message);
                                formView.NeedExecuteAdd = false;
                                return;
                            }
                            formView.NeedExecuteAdd = true;
                            if (validate != null)
                                detailView.SetValidateFlag(validate);
                            detailView.ChangeMode(DetailsViewMode.Insert);
                            if (bindingNav != null && bindingNav != this)
                            {
                                bindingNav.SetState(NavigatorState.Inserting);
                                bindingNav.SetNavState("Inserting");
                            }
                            this.SetState(NavigatorState.Inserting);
                            this.SetNavState("Inserting");
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToAdd", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdUpdate":
                        if (ds.AllowUpdate)
                        {
                            if (!CheckInsertedNotApply(detailView, 2))
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "InsertedNotApply", true);

                                ScriptHelper.ShowMessage(this, "InsertedNotApply", message);
                                return;
                            }
                            formView.NeedExecuteAdd = true;
                            if (!ds.IsEmpty)
                            {
                                if (validate != null)
                                    detailView.SetValidateFlag(validate);
                                detailView.ChangeMode(DetailsViewMode.Edit);
                                if (bindingNav != null && bindingNav != this)
                                {
                                    bindingNav.SetState(NavigatorState.Editing);
                                    bindingNav.SetNavState("Editing");
                                }
                                this.SetState(NavigatorState.Editing);
                                this.SetNavState("Editing");
                            }
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToUpdate", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdDelete":
                        if (ds.InnerDataSet.Tables[ds.DataMember].Rows.Count != 0)
                            detailView.DeleteItem();
                        break;
                    case "cmdOK":
                        if (detailView.CurrentMode == DetailsViewMode.Insert)
                            detailView.InsertItem(false);
                        else if (detailView.CurrentMode == DetailsViewMode.Edit)
                            detailView.UpdateItem(false);
                        if (!detailView.ValidateFailed)
                            FlowOK();
                        break;
                    case "cmdCancel":
                        if (detailView.CurrentMode == DetailsViewMode.Insert
                            || detailView.CurrentMode == DetailsViewMode.Edit)
                        {
                            detailView.ChangeMode(DetailsViewMode.ReadOnly);
                            if (validate != null)
                                validate.Text = string.Empty;
                        }
                        if (validate != null)
                            detailView.RemoveValidateFlag(validate);
                        if (detailView.DataHasChanged)
                        {
                            this.SetState(NavigatorState.Changed);
                            this.SetNavState("Changing");
                        }
                        else
                        {
                            this.SetState(NavigatorState.Browsing);
                            this.SetNavState("Browsed");
                        }
                        this.SetNavState("Browsed");
                        FlowCancel();
                        detailView.OnCanceled(EventArgs.Empty);

                        break;
                    case "cmdApply":
                        if (detailView.CurrentMode == DetailsViewMode.Insert)
                            detailView.InsertItem(false);
                        else if (detailView.CurrentMode == DetailsViewMode.Edit)
                            detailView.UpdateItem(false);
                        if (detailView.CurrentMode == DetailsViewMode.ReadOnly)
                        {
                            bool bSucess = ds.ApplyUpdates();
                            if (bSucess && !detailView.ValidateFailed)
                            {
                                if (ds.AutoRecordLock)
                                {
                                    ds.RemoveLock();
                                }
                                if (bindingNav != null && bindingNav != this)
                                {
                                    bindingNav.SetState(NavigatorState.ApplySucess);
                                    bindingNav.SetNavState("Browsed");
                                }
                                this.SetState(NavigatorState.ApplySucess);
                                this.SetNavState("Browsed");
                                FlowApply();
                            }
                            else
                            {
                                this.SetState(NavigatorState.ApplyFail);
                                if (detailView.CurrentMode == DetailsViewMode.Edit)
                                {
                                    if (bindingNav != null && bindingNav != this)
                                    {
                                        bindingNav.SetNavState("Editing");
                                    }
                                    this.SetNavState("Editing");
                                }
                                else if (detailView.CurrentMode == DetailsViewMode.Insert)
                                {
                                    if (bindingNav != null && bindingNav != this)
                                    {
                                        bindingNav.SetNavState("Inserting");
                                    }
                                    this.SetNavState("Inserting");
                                }
                            }
                        }
                        break;
                    case "cmdAbort":
                        if (detailView.CurrentMode == DetailsViewMode.Insert
                            || detailView.CurrentMode == DetailsViewMode.Edit)
                        {
                            detailView.ChangeMode(DetailsViewMode.ReadOnly);
                            if (validate != null)
                                validate.Text = string.Empty;
                        }
                        ds.InnerDataSet.RejectChanges();
                        if (ds.AutoRecordLock)
                        {
                            ds.RemoveLock();
                        }
                        if (validate != null)
                            detailView.RemoveValidateFlag(validate);
                        if (bindingNav != null && bindingNav != this)
                        {
                            bindingNav.SetState(NavigatorState.Aborted);
                            bindingNav.SetNavState("Browsed");
                        }
                        this.SetState(NavigatorState.Aborted);
                        this.SetNavState("Browsed");
                        detailView.DataBind();
                        FlowAbort();
                        detailView.OnCanceled(EventArgs.Empty);
                        break;
                    case "cmdQuery":
                        if (ViewExist)
                        {
                            ds = this.GetObjByID(viewGridView.DataSourceID) as WebDataSource;
                        }
                        DoQuery(ds);
                        break;
                    case "cmdPrint":
                        if (ViewExist)
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        else
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        break;
                    case "cmdExport":
                        Export();
                        break;
                    default:
                        DetailsViewFlowCommand(e);
                        break;
                }
                #endregion
            }
            else if (this.ShowDataStyle == NavigatorStyle.FormViewStyle && obj is WebFormView)
            {
                formView = (WebFormView)obj;
                ds = (WebDataSource)GetObjByID(formView.DataSourceID);
                WebValidate validate = (WebValidate)formView.ExtendedFindChildControl(formView.DataSourceID, FindControlType.DataSourceID, typeof(WebValidate));
                if (vobj is WebGridView)
                {
                    viewGridView = (WebGridView)vobj;
                    ViewExist = true;
                }
                #region WebFormView Default Operation
                switch (e.CommandName)
                {
                    case "cmdFirst":
                        if (ViewExist)
                        {
                            //if (viewGridView.AllowPaging)
                            //    viewGridView.PageIndex = 0;
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging)
                                    viewGridView.PageIndex = 0;
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.AllowPaging)
                                    viewGridView.PageIndex = 0;
                                viewGridView.SelectedIndex = 0;
                            }
                        }
                        else
                        {
                            if (formView.AllowPaging)
                                formView.PageIndex = 0;
                        }
                        break;
                    case "cmdPrevious":
                        if (ViewExist)
                        {
                            //if (viewGridView.AllowPaging && viewGridView.PageIndex > 0)
                            //    viewGridView.PageIndex -= 1;
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging && viewGridView.PageIndex > 0)
                                    viewGridView.PageIndex -= 1;
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.SelectedIndex == 0)
                                {
                                    if (viewGridView.AllowPaging && viewGridView.PageIndex > 0)
                                    {
                                        viewGridView.PageIndex -= 1;
                                        viewGridView.SelectedIndex = viewGridView.PageSize - 1;
                                    }
                                }
                                else
                                {
                                    viewGridView.SelectedIndex -= 1;
                                }
                            }
                        }
                        else
                        {
                            if (formView.AllowPaging && formView.PageIndex > 0)
                                formView.PageIndex -= 1;
                        }
                        break;
                    case "cmdNext":
                        if (ViewExist)
                        {
                            if (this.GridViewMoveMode == MoveMode.PageMode)
                            {
                                if (viewGridView.AllowPaging && viewGridView.PageIndex != viewGridView.PageCount - 1)
                                {
                                    viewGridView.PageIndex += 1;
                                }
                                if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                {
                                    Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID)
                                        : this.Parent.FindControl(viewGridView.DataSourceID);
                                    if (c != null)
                                    {
                                        ((WebDataSource)c).GetNextPacket();
                                    }
                                }
                            }
                            else if (this.GridViewMoveMode == MoveMode.RowMode)
                            {
                                if (viewGridView.AllowPaging)
                                {
                                    if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                    {
                                        if (viewGridView.SelectedIndex != viewGridView.Rows.Count - 1)
                                            viewGridView.SelectedIndex += 1;
                                    }
                                    else
                                    {
                                        //不是最后一行
                                        if (viewGridView.SelectedIndex != viewGridView.PageSize - 1)
                                        {
                                            viewGridView.SelectedIndex += 1;
                                        }
                                        //最后一行
                                        else
                                        {
                                            viewGridView.PageIndex += 1;
                                            viewGridView.SelectedIndex = 0;
                                            if (viewGridView.PageIndex == viewGridView.PageCount - 1)
                                            {
                                                int j = viewGridView.PageIndex;
                                                Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID) : this.Parent.FindControl(viewGridView.DataSourceID);
                                                if (c != null)
                                                {
                                                    WebDataSource webDs = ((WebDataSource)c);
                                                    if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                                    {
                                                        DataTable table = new DataTable();
                                                        if (webDs.CommandTable != null)
                                                        {
                                                            table = webDs.CommandTable;
                                                        }
                                                        else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                                        {
                                                            table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                                        }
                                                        int i = table.Rows.Count;
                                                        while (i <= viewGridView.PageSize * (j + 1) && (!webDs.Eof))
                                                        {
                                                            webDs.GetNextPacket();
                                                            i += webDs.PacketRecords;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (formView.AllowPaging && formView.PageIndex != formView.PageCount - 1)
                            {
                                formView.PageIndex += 1;
                                if (formView.PageIndex == formView.PageCount - 1)
                                {
                                    Object c = (this.Page.Master == null) ? this.Page.FindControl(formView.DataSourceID)
                                        : this.Parent.FindControl(formView.DataSourceID);
                                    if (c != null)
                                    {
                                        ((WebDataSource)c).GetNextPacket();
                                    }
                                }
                            }
                        }
                        break;
                    case "cmdLast":
                        if (ViewExist)
                        {
                            //if (viewGridView.AllowPaging)
                            //{
                            //    viewGridView.PageIndex = viewGridView.PageCount - 1;
                            //    Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID)
                            //        : this.Parent.FindControl(viewGridView.DataSourceID);
                            //    if (c != null)
                            //    {
                            //        ((WebDataSource)c).GetNextPacket();
                            //    }
                            //}
                            if (viewGridView.AllowPaging)
                            {
                                viewGridView.PageIndex = viewGridView.PageCount - 1;
                                int j = viewGridView.PageIndex;
                                Object c = (this.Page.Master == null) ? this.Page.FindControl(viewGridView.DataSourceID) : this.Parent.FindControl(viewGridView.DataSourceID);
                                if (c != null)
                                {
                                    WebDataSource webDs = ((WebDataSource)c);
                                    if (webDs.MasterDataSource == null || webDs.MasterDataSource.Length == 0)
                                    {
                                        DataTable table = new DataTable();
                                        if (webDs.CommandTable != null)
                                        {
                                            table = webDs.CommandTable;
                                        }
                                        else if (webDs.InnerDataSet != null && webDs.InnerDataSet.Tables.Count != 0)
                                        {
                                            table = webDs.InnerDataSet.Tables[webDs.DataMember];
                                        }
                                        int i = table.Rows.Count;
                                        bool b = false;
                                        while (i <= viewGridView.PageSize * (j + 1) && (!webDs.Eof))
                                        {
                                            webDs.GetNextPacket();
                                            i += webDs.PacketRecords;
                                            b = true;
                                        }

                                        if (this.GridViewMoveMode == MoveMode.RowMode)
                                        {
                                            if (!b && viewGridView.PageSize > 1)
                                            {
                                                viewGridView.SelectedIndex = (i % viewGridView.PageSize - 1 + viewGridView.PageSize) % viewGridView.PageSize;
                                            }
                                            else
                                            {
                                                viewGridView.SelectedIndex = viewGridView.PageSize - 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (formView.AllowPaging)
                            {
                                formView.PageIndex = formView.PageCount - 1;
                                Object c = (this.Page.Master == null) ? this.Page.FindControl(formView.DataSourceID)
                                    : this.Parent.FindControl(formView.DataSourceID);
                                if (c != null)
                                {
                                    ((WebDataSource)c).GetNextPacket();
                                }
                            }
                        }
                        break;
                    case "cmdAdd":
                        if (ds.AllowAdd)
                        {
                            if (!CheckInsertedNotApply(formView, 3))
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "InsertedNotApply", true);

                                ScriptHelper.ShowMessage(this, "InsertedNotApply", message);
                                formView.NeedExecuteAdd = false;
                                return;
                            }
                            formView.NeedExecuteAdd = true;
                            formView.ChangeMode(FormViewMode.Insert);
                            formView.OnAdding(EventArgs.Empty);
                            this.SetState(NavigatorState.Inserting);
                            this.SetNavState("Inserting");
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToAdd", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdUpdate":
                        if (ds.AllowUpdate)
                        {
                            if (!CheckInsertedNotApply(formView, 3))
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "InsertedNotApply", true);

                                ScriptHelper.ShowMessage(this, "InsertedNotApply", message);
                                return;
                            }
                            formView.NeedExecuteAdd = true;
                            if (!ds.IsEmpty)
                            {
                                formView.ChangeMode(FormViewMode.Edit);
                                this.SetState(NavigatorState.Editing);
                                this.SetNavState("Editing");
                            }
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToUpdate", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdDelete":
                        if (ds.AllowDelete)
                            formView.DeleteItem();
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToDelete", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdOK":
                        if (formView.CurrentMode == FormViewMode.Insert)
                            formView.InsertItem(false);
                        else if (formView.CurrentMode == FormViewMode.Edit)
                            formView.UpdateItem(false);
                        if (!formView.ValidateFailed)
                            FlowOK();
                        break;
                    case "cmdCancel":
                        if (formView.CurrentMode == FormViewMode.Insert
                            || formView.CurrentMode == FormViewMode.Edit)
                        {
                            formView.ChangeMode(formView.DefaultMode);
                            if (validate != null)
                                validate.Text = string.Empty;
                            if (formView.DataHasChanged)
                            {
                                this.SetState(NavigatorState.Changed);
                                this.SetNavState("Changing");
                            }
                            else
                            {
                                this.SetState(NavigatorState.Browsing);
                                this.SetNavState("Browsed");
                            }
                            FlowCancel();
                            formView.OnCanceled(EventArgs.Empty);
                        }
                        break;
                    case "cmdApply":
                        if (formView.CurrentMode == FormViewMode.Insert)
                            formView.InsertItem(false);
                        else if (formView.CurrentMode == FormViewMode.Edit)
                            formView.UpdateItem(false);
                        if (formView.CurrentMode == FormViewMode.ReadOnly) //防止formview updating event 调用 e.cancel == true; navigator state会变
                        {
                            bool bSucess = ds.ApplyUpdates();
                            if (bSucess && !formView.ValidateFailed)
                            {
                                if (ds.AutoRecordLock)
                                {
                                    ds.RemoveLock();
                                }
                                this.SetState(NavigatorState.ApplySucess);
                                this.SetNavState("Browsed");
                                FlowApply();
                            }
                            else
                            {
                                this.SetState(NavigatorState.ApplyFail);
                                if (formView.CurrentMode == FormViewMode.Edit)
                                    this.SetNavState("Editing");
                                else if (formView.CurrentMode == FormViewMode.Insert)
                                    this.SetNavState("Inserting");
                            }
                        }
                        break;
                    case "cmdAbort":
                        ds.InnerDataSet.RejectChanges();
                        formView.DataBind();
                        if (formView.CurrentMode == FormViewMode.Insert || formView.CurrentMode == FormViewMode.Edit)
                        {
                            formView.ChangeMode(formView.DefaultMode);
                            if (validate != null)
                                validate.Text = string.Empty;
                        }
                        if (ds.AutoRecordLock)
                        {
                            ds.RemoveLock();
                        }
                        this.SetState(NavigatorState.Aborted);
                        this.SetNavState("Browsed");
                        FlowAbort();
                        formView.OnCanceled(EventArgs.Empty);
                        break;
                    case "cmdQuery":
                        if (ViewExist)
                        {
                            ds = this.GetObjByID(viewGridView.DataSourceID) as WebDataSource;
                        }
                        DoQuery(ds);
                        break;
                    case "cmdPrint":
                        if (ViewExist)
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        else
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        break;
                    case "cmdExport":
                        Export();
                        break;
                    default:
                        FormViewFlowCommand(e);
                        break;
                }
                #endregion
            }
            else if (this.ShowDataStyle == NavigatorStyle.ASPxGridView && obj.GetType().Name == "ASPxGridView")
            {
                var aspxGridView = obj.GetType();

                object objPageIndex = obj.GetType().GetProperty("PageIndex").GetValue(obj, null);
                int pageIndex = int.Parse(objPageIndex.ToString());
                object objPageCount = obj.GetType().GetProperty("PageCount").GetValue(obj, null);
                int pageCount = int.Parse(objPageCount.ToString());

                String strDataSourceID = obj.GetType().GetProperty("DataSourceID").GetValue(obj, null).ToString();
                ds = (WebDataSource)GetObjByID(strDataSourceID);
                //WebValidate validate = (WebValidate)gridView.ExtendedFindChildControl(gridView.DataSourceID, FindControlType.DataSourceID, typeof(WebValidate));
                #region ASPxGridView Default Operation
                switch (e.CommandName)
                {
                    case "cmdFirst":
                        obj.GetType().GetProperty("PageIndex").SetValue(obj, 0, null);
                        break;
                    case "cmdPrevious":
                        if (objPageIndex != null)
                        {
                            obj.GetType().GetProperty("PageIndex").SetValue(obj, pageIndex - 1, null);
                        }
                        break;
                    case "cmdNext":
                        if (objPageIndex != null)
                        {
                            if (pageIndex == pageCount - 1)
                            {
                                ((WebDataSource)ds).GetNextPacket();
                            }
                            obj.GetType().GetProperty("PageIndex").SetValue(obj, pageIndex + 1, null);
                        }
                        break;
                    case "cmdLast":
                        bool b = false;
                        while (!ds.Eof)
                        {
                            ds.GetNextPacket();
                            b = true;
                        }
                        DataBind();
                        obj.GetType().GetProperty("PageIndex").SetValue(obj, pageCount - 1, null);
                        break;
                    case "cmdAdd":
                        if (ds.AllowAdd)
                        {
                            //AddNewRow
                            obj.GetType().GetMethod("AddNewRow").Invoke(obj, null);
                            this.SetState(NavigatorState.Inserting);
                            this.SetNavState("Inserting");
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToAdd", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdUpdate":
                        if (ds.AllowUpdate)
                        {
                            if (!ds.IsEmpty)
                            {
                                this.SetState(NavigatorState.Editing);
                                this.SetNavState("Editing");
                            }
                        }
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToUpdate", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdDelete":
                        if (ds.AllowDelete)
                            ;
                        else
                        {
                            language = CliUtils.fClientLang;
                            String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToDelete", true);
                            CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                        }
                        break;
                    case "cmdOK":
                    case "cmdApply":
                        obj.GetType().GetMethod("UpdateEdit").Invoke(obj, null);
                        this.SetState(NavigatorState.Changed);
                        this.SetNavState("Changing");
                        break;
                    case "cmdCancel":
                    case "cmdAbort":
                        obj.GetType().GetMethod("CancelEdit").Invoke(obj, null);

                        //if (formView.DataHasChanged)
                        //{
                        //    this.SetState(NavigatorState.Changed);
                        //    this.SetNavState("Changing");
                        //}
                        //else
                        {
                            this.SetState(NavigatorState.Browsing);
                            this.SetNavState("Browsed");
                        }
                        break;
                    //case "cmdApply":
                    //    if (formView.CurrentMode == FormViewMode.Insert)
                    //        formView.InsertItem(false);
                    //    else if (formView.CurrentMode == FormViewMode.Edit)
                    //        formView.UpdateItem(false);
                    //    if (formView.CurrentMode == FormViewMode.ReadOnly) //防止formview updating event 调用 e.cancel == true; navigator state会变
                    //    {
                    //        bool bSucess = ds.ApplyUpdates();
                    //        if (bSucess && !formView.ValidateFailed)
                    //        {
                    //            if (ds.AutoRecordLock)
                    //            {
                    //                ds.RemoveLock();
                    //            }
                    //            this.SetState(NavigatorState.ApplySucess);
                    //            this.SetNavState("Browsed");
                    //            FlowApply();
                    //        }
                    //        else
                    //        {
                    //            this.SetState(NavigatorState.ApplyFail);
                    //            if (formView.CurrentMode == FormViewMode.Edit)
                    //                this.SetNavState("Editing");
                    //            else if (formView.CurrentMode == FormViewMode.Insert)
                    //                this.SetNavState("Inserting");
                    //        }
                    //    }
                    //    break;
                    //case "cmdAbort":
                    //    ds.InnerDataSet.RejectChanges();
                    //    formView.DataBind();
                    //    if (formView.CurrentMode == FormViewMode.Insert || formView.CurrentMode == FormViewMode.Edit)
                    //    {
                    //        formView.ChangeMode(formView.DefaultMode);

                    //    }
                    //    if (ds.AutoRecordLock)
                    //    {
                    //        ds.RemoveLock();
                    //    }
                    //    this.SetState(NavigatorState.Aborted);
                    //    this.SetNavState("Browsed");
                    //    FlowAbort();
                    //    formView.OnCanceled(EventArgs.Empty);
                    //    break;
                    case "cmdQuery":
                        if (ViewExist)
                        {
                            ds = this.GetObjByID(viewGridView.DataSourceID) as WebDataSource;
                        }
                        DoQuery(ds);
                        break;
                    case "cmdPrint":
                        if (ViewExist)
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        else
                        {
                            if (ds.AllowPrint)
                            { }
                            else
                            {
                                language = CliUtils.fClientLang;
                                String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebDataSource", "rightToPrint", true);
                                CliUtils.RegisterStartupScript(this, "alert('" + message + "')");
                            }
                        }
                        break;
                    case "cmdExport":
                        Export();
                        break;
                    default:
                        FormViewFlowCommand(e);
                        break;
                }
                #endregion

            }
        }
示例#2
0
        public void PerformApply()
        {
            object obj = GetObjByID(this.BindingObject);
            WebGridView gridView = new WebGridView();
            WebDetailsView detailView = new WebDetailsView();
            WebFormView formView = new WebFormView();
            WebDataSource ds = new WebDataSource();
            if (this.ShowDataStyle == NavigatorStyle.GridStyle && obj is WebGridView)
            {
                gridView = (WebGridView)obj;
                ds = (WebDataSource)GetObjByID(gridView.DataSourceID);
                foreach (GridViewRow row in gridView.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        if ((row.RowState & DataControlRowState.Edit) == DataControlRowState.Edit)
                        {
                            gridView.UpdateRow(row.RowIndex, false);
                        }
                    }
                    if (gridView.ShowFooter)
                    {
                        doOkForGridInsert(gridView, ds);
                    }
                }
                ds.ApplyUpdates();
            }
            else if (this.ShowDataStyle == NavigatorStyle.DetailStyle && obj is WebDetailsView)
            {
                detailView = (WebDetailsView)obj;
                if (detailView.CurrentMode == DetailsViewMode.Insert)
                    detailView.InsertItem(false);
                else if (detailView.CurrentMode == DetailsViewMode.Edit)
                    detailView.UpdateItem(false);
                detailView.ChangeMode(DetailsViewMode.ReadOnly);
                ds.ApplyUpdates();
            }
            else if (this.ShowDataStyle == NavigatorStyle.FormViewStyle && obj is WebFormView)
            {
                formView = (WebFormView)obj;
                if (formView.CurrentMode == FormViewMode.Insert)
                    formView.InsertItem(false);
                else if (formView.CurrentMode == FormViewMode.Edit)
                    formView.UpdateItem(false);

                ds.ApplyUpdates();
                if (formView.CurrentMode == FormViewMode.Insert
                    || formView.CurrentMode == FormViewMode.Edit)
                {
                    formView.ChangeMode(formView.DefaultMode);
                }
            }
        }