コード例 #1
0
ファイル: ExpressionField.cs プロジェクト: san90279/UK_OAS
        /*public override bool Initialize(bool sortingEnabled, Control control)
        {
            if (!DesignMode)
            {
                object obj = null;
                string dm = "";
                if (control is WebGridView)
                {
                    gridView = (WebGridView)control;
                    obj = gridView.GetObjByID(gridView.DataSourceID);
                    if (obj != null && obj is WebDataSource)
                    {
                        WebDataSource wds = (WebDataSource)obj;
                        if (wds.MasterDataSource != null && wds.MasterDataSource != "")
                        {
                            object objMaster = gridView.GetObjByID(wds.MasterDataSource);
                            obj = objMaster;
                        }
                        dm = wds.DataMember;
                    }
                }
                else if (control is WebDetailsView)
                {
                    detView = (WebDetailsView)control;
                    obj = detView.GetObjByID(detView.DataSourceID);
                    if (obj != null && obj is WebDataSource)
                    {
                        WebDataSource wds = (WebDataSource)obj;
                        dm = wds.DataMember;
                    }
                }

                if (obj != null && obj is WebDataSource)
                {
                    WebDataSource wds = (WebDataSource)obj;
                    tab = wds.InnerDataSet.Tables[dm];
                    if (!tab.Columns.Contains(this.Expression))
                    {
                        DataColumn col = new DataColumn(this.Expression, typeof(decimal), this.Expression);
                        tab.Columns.Add(col);
                    }
                }
            }
            return base.Initialize(sortingEnabled, control);
        }*/
        public override bool Initialize(bool sortingEnabled, Control control)
        {
            if (!DesignMode)
            {
                WebDataSource wds = null;
                string dm = "";
                if (control is WebGridView)
                {
                    gridView = (WebGridView)control;
                    object obj = gridView.GetObjByID(gridView.DataSourceID);
                    if (obj != null && obj is WebDataSource)
                    {
                        WebDataSource wdsDetail = (WebDataSource)obj;
                        if (wdsDetail.MasterDataSource != null && wdsDetail.MasterDataSource != "")
                        {
                            object objMaster = gridView.GetObjByID(wdsDetail.MasterDataSource);
                            if (objMaster != null && objMaster is WebDataSource)
                            {
                                wds = (WebDataSource)objMaster;
                            }
                        }
                        else
                        {
                            wds = wdsDetail;
                        }
                        dm = wdsDetail.DataMember;
                    }
                }
                else if (control is WebDetailsView)
                {
                    detView = (WebDetailsView)control;
                    object obj = detView.GetObjByID(detView.DataSourceID);
                    if (obj != null && obj is WebDataSource)
                    {
                        wds = (WebDataSource)obj;
                        dm = wds.DataMember;
                    }
                }

                if (wds != null && wds.InnerDataSet != null)
                {
                    tab = wds.InnerDataSet.Tables[dm];
                    if (!tab.Columns.Contains(this.Expression))
                    {
                        DataColumn col = new DataColumn();
                        col.ColumnName = this.Expression;
                        col.Expression = this.Expression;
                        //DataColumn col = new DataColumn(this.Expression, typeof(decimal), this.Expression);
                        tab.Columns.Add(col);
                    }
                }
            }
            return base.Initialize(sortingEnabled, control);
        }
コード例 #2
0
ファイル: WebClientMove.cs プロジェクト: san90279/UK_OAS
        public void Execute(bool progress)
        {
            if ((SrcDataSorce != null || SrcDataSorce != "") && (DestDataSorce != "" || DestDataSorce != null))
            {
                bool tempSrc = false;
                bool tempDest = false;
                WebGridView wgv = new WebGridView();
                WebDetailsView wdv = new WebDetailsView();
                WebFormView wfv = new WebFormView();

                WebDataSource wsSrc = new WebDataSource();
                DataSet dsSrc = new DataSet();
                WebDataSource wsDest = new WebDataSource();
                DataSet dsDest = new DataSet();
                WebDataSource wsDestM = new WebDataSource();
                foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                {
                    if (c is WebDataSource && (c as WebDataSource).ID == this.SrcDataSorce)
                    {
                        wsSrc = c as WebDataSource;
                        tempSrc = wsSrc.AutoApply;
                        wsSrc.AutoApply = false;
                        dsSrc = wsSrc.InnerDataSet;
                    }
                    if (c is WebDataSource && (c as WebDataSource).ID == this.DestDataSorce)
                    {
                        wsDest = c as WebDataSource;
                        tempDest = wsDest.AutoApply;
                        wsDest.AutoApply = false;
                        dsDest = wsDest.InnerDataSet;
                        foreach (System.Web.UI.Control ctrl in this.Page.Form.Controls)
                            if (ctrl is WebDataSource && (ctrl as WebDataSource).ID == wsDest.MasterDataSource)
                            {
                                wsDestM = ctrl as WebDataSource;
                                //added by lily 2006/12/14 for detail has no innerdataset
                                dsDest = wsDestM.InnerDataSet;
                                //added by lily 2006/12/14 for detail has no innerdataset
                                break;
                            }
                    }
                }
                bool isGet = false;
                DataTable dtSrc = new DataTable();
                for (int i = 0; i < dsSrc.Relations.Count; i++)
                    foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                        if (c is WebDataSource && (c as WebDataSource).ID == this.SrcDataSorce
                            && (c as WebDataSource).DataMember == dsSrc.Relations[i].ChildTable.ToString())
                        {
                            dtSrc = dsSrc.Relations[i].ChildTable;
                            isGet = true;
                        }
                if (isGet == false)
                    if (dsSrc.Tables.Count > 0)
                        dtSrc = dsSrc.Tables[0];
                    else
                        dtSrc = wsSrc.CommandTable;
                DataTable dtDest = new DataTable();
                isGet = false;
                for (int i = 0; i < dsDest.Relations.Count; i++)
                    foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                        if (c is WebDataSource && (c as WebDataSource).ID == this.DestDataSorce
                            && (c as WebDataSource).DataMember == dsDest.Relations[i].ChildTable.ToString())
                        {
                            dtDest = dsDest.Relations[i].ChildTable;
                            isGet = true;
                        }
                if (isGet == false)
                    dtDest = dsDest.Tables[0];
                DataTable dtDestM = new DataTable();
                isGet = false;
                for (int i = 0; i < wsDestM.InnerDataSet.Relations.Count; i++)
                    if (this.DestDataSorce == wsDestM.InnerDataSet.Relations[i].ChildTable.ToString())
                    {
                        dtDestM = wsDestM.InnerDataSet.Relations[i].ChildTable;
                        isGet = true;
                    }
                if (isGet == false)
                    dtDestM = wsDestM.InnerDataSet.Tables[0];

                DataTable dsDestMaster =dsDest.Tables[0];
                string MasterKey = null;
                foreach (System.Web.UI.Control c in this.Page.Form.Controls)
                {
                    if (c is WebFormView)
                        foreach (System.Web.UI.Control ctrl in this.Page.Form.Controls)
                            if (ctrl is WebDataSource && (ctrl as WebDataSource).ID == (c as WebFormView).DataSourceID
                                && (ctrl as WebDataSource).DataMember == dsDestMaster.ToString())
                            {
                                MasterKey = dsDestMaster.Rows[(c as WebFormView).DataItemIndex][dsDestMaster.PrimaryKey[0].ToString()].ToString();
                                break;
                            }
                    if (c is WebDetailsView)
                        foreach (System.Web.UI.Control ctrl in this.Page.Form.Controls)
                            if (ctrl is WebDataSource && (ctrl as WebDataSource).ID == (c as WebDetailsView).DataSourceID
                                && (ctrl as WebDataSource).DataMember == dsDestMaster.ToString())
                            {
                                MasterKey = dsDestMaster.Rows[(c as WebDetailsView).DataItemIndex][dsDestMaster.PrimaryKey[0].ToString()].ToString();
                                break;
                            }
                }

                //modified by lily 2006/12/14 for: List<> can be added when needed, DataRow[] cannot
                //DataRow[] drDestTemp = new DataRow[dtDest.Rows.Count];

                List<DataRow> drDestTemp = new List<DataRow>();

                for (int i = 0; i < dtDest.Rows.Count; i++)
                    if (dtDest.Rows[i][dsDestMaster.PrimaryKey[0].ToString()].ToString() == MasterKey)
                        drDestTemp.Add(dtDest.Rows[i]);
                        //drDestTemp[i] = dtDest.Rows[i];

                ArrayList strSrc = new ArrayList();
                ArrayList strDest = new ArrayList();
                foreach (WebKeyMatchColumn kmc in this.KeyMatchColumns)
                    if (kmc.SrcColumnName == null || kmc.DestColumnName == null || kmc.SrcColumnName == "" || kmc.DestColumnName == "")
                    {
                        language = CliUtils.fClientLang;
                        string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoClientMove", "iskeyMatchColumn", true);
                        this.Page.Response.Write("<script>alert(\"" + message + "\");</script>");
                        return;
                    }
                    else
                    {
                        strSrc.Add(kmc.SrcColumnName);
                        strDest.Add(kmc.DestColumnName);
                    }

                for (int i = 0; i < dtSrc.Rows.Count; i++)
                {
                    int flag = 0;
                    Hashtable ht = new Hashtable();
                    if (this.AlwaysInsert == false && strSrc != null && drDestTemp.Count > 0)
                        for (int j = 0; j < drDestTemp.Count; j++)
                        {
                            for (int x = 0; x < strSrc.Count; x++)
                                if (drDestTemp[j] != null && dtSrc.Rows[i][strSrc[x].ToString()].ToString() == drDestTemp[j][strDest[x].ToString()].ToString())
                                    flag++;
                            if (flag == strSrc.Count)
                            {
                                if (this.AlwaysReplace == true)
                                {
                                    for (int x = 0; x < this.MatchColumns.Count; x++)
                                    {
                                        WebMatchColumn mc = this.MatchColumns[x];
                                        if (mc.Expression != null && mc.Expression != "")
                                        {
                                            DataColumn dcExpression = new DataColumn();
                                            dcExpression.ColumnName = mc.Expression;
                                            dcExpression.Expression = mc.Expression;
                                            if (dtSrc.Columns.Contains(dcExpression.ColumnName) == false)
                                                dtSrc.Columns.Add(dcExpression);
                                            drDestTemp[j][mc.DestColumnName] = dtSrc.Rows[i][mc.Expression].ToString();
                                        }
                                        else
                                            drDestTemp[j][mc.DestColumnName] = dtSrc.Rows[i][mc.SrcColumnName].ToString();
                                    }
                                    OnAfterMove(new EventArgs());
                                }
                                break;
                            }
                            else
                                flag = 0;
                        }
                    if (flag != strSrc.Count || strSrc.Count == 0)
                    {
                        DataRow dr = dtDest.NewRow();
                        ht.Add(dsDest.Tables[0].PrimaryKey[0].ToString(), MasterKey);
                        foreach (WebMatchColumn mc in this.MatchColumns)
                            if (mc.Expression != null && mc.Expression != "")
                            {
                                DataColumn dcExpression = new DataColumn();
                                dcExpression.ColumnName = mc.Expression;
                                dcExpression.Expression = mc.Expression;
                                if (dtSrc.Columns.Contains(dcExpression.ColumnName) == false)
                                    dtSrc.Columns.Add(dcExpression);
                                ht.Add(mc.DestColumnName, dtSrc.Rows[i][mc.Expression]);
                            }
                            else
                            {
                                if ((mc.SrcColumnName == "" || mc.DestColumnName == "" || mc.SrcColumnName == null || mc.DestColumnName == null)
                                   && (mc.Expression == null || mc.Expression == ""))
                                {
                                    language = CliUtils.fClientLang;
                                    string message = SysMsg.GetSystemMessage(language, "Srvtools", "InfoClientMove", "ismatchColumn", true);
                                    this.Page.Response.Write("<script>alert(\"" + message + "\");</script>");
                                    return;
                                }
                                else
                                    ht.Add(mc.DestColumnName, dtSrc.Rows[i][mc.SrcColumnName]);
                            }
                        OnAfterMove(new EventArgs());
                        int isExsite = 0;
                        for (int j = 0; j < dtDestM.Rows.Count; j++)
                        {
                            isExsite = 0;
                            for (int x = 0; x < dtDestM.Columns.Count; x++)
                                if (ht[dtDestM.Columns[x].ToString()] != null && ht[dtDestM.Columns[x].ToString()].ToString() == dtDestM.Rows[j][dtDestM.Columns[x].ToString()].ToString())
                                    isExsite++;
                            if (isExsite == ht.Count) break;
                        }
                        if (isExsite != ht.Count)
                        {
                            wsDest.Insert(ht);
                            OnAfterInsert(new EventArgs());
                        }
                    }
                }
                wsSrc.AutoApply = tempSrc;
                wsDest.AutoApply = tempDest;
                if (progress == true)
                {
                    System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(LongTask));
                    thread.Start();
                    this.Page.Session["State"] = 1;
                    OpenProgressBar(this.Page);
                }
                this.Page.DataBind();
            }
        }
コード例 #3
0
ファイル: WebNavigator.cs プロジェクト: san90279/UK_OAS
        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

            }
        }
コード例 #4
0
ファイル: WebNavigator.cs プロジェクト: san90279/UK_OAS
        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);
                }
            }
        }
コード例 #5
0
ファイル: WebTranslate.cs プロジェクト: san90279/UK_OAS
 private void SetDetails(WebDetailsView detView, string editMode)
 {
     if (MasterOrDetail == "detail" && RelationFields != "" && RelationValues != "")
     {
         string[] fields = RelationFields.Split(';');
         string[] values = RelationValues.Split(';');
         switch (editMode)
         {
             case "Insert":
                 #region Insert
                 foreach (DetailsViewRow row in detView.Rows)
                 {
                     object value = null;
                     if (row.RowType == DataControlRowType.DataRow && row.Cells.Count == 2)
                     {
                         // 用HeaderText获取row的FieldName
                         string FieldName = GetNameByHeaderText(detView, row.Cells[0].Text);
                         int i = fields.Length;
                         for (int j = 0; j < i; j++)
                         {
                             if (fields[j] == FieldName)
                             {
                                 value = values[j];
                             }
                         }
                     }
                     foreach (Control ctrl in row.Cells[1].Controls)
                     {
                         if (value != null)
                         {
                             if (ctrl is TextBox)
                             {
                                 ((TextBox)ctrl).Text = value.ToString();
                                 ((TextBox)ctrl).Enabled = false;
                             }
                             if (ctrl is DropDownList)
                             {
                                 ((DropDownList)ctrl).SelectedValue = value.ToString();
                                 ((DropDownList)ctrl).Enabled = false;
                             }
                             if (ctrl is CheckBox)
                             {
                                 ((CheckBox)ctrl).Checked = Convert.ToBoolean(value);
                                 ((CheckBox)ctrl).Enabled = false;
                             }
                             if (ctrl is WebRefVal)
                             {
                                 ((WebRefVal)ctrl).BindingValue = value.ToString();
                                 ((WebRefVal)ctrl).Enabled = false;
                             }
                         }
                     }
                 }
                 #endregion
                 break;
             case "Update":
                 #region Update
                 foreach (DetailsViewRow row in detView.Rows)
                 {
                     if (row.RowType == DataControlRowType.DataRow && row.Cells.Count == 2)
                     {
                         // 用HeaderText获取row的FieldName
                         string FieldName = GetNameByHeaderText(detView, row.Cells[0].Text);
                         int i = fields.Length;
                         for (int j = 0; j < i; j++)
                         {
                             if (fields[j] == FieldName)
                             {
                                 foreach (Control ctrl in row.Cells[1].Controls)
                                 {
                                     if (ctrl is WebControl)
                                     {
                                         ((WebControl)ctrl).Enabled = false;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 #endregion
                 break;
         }
     }
 }
コード例 #6
0
ファイル: WebTranslate.cs プロジェクト: san90279/UK_OAS
 private string GetNameByHeaderText(WebDetailsView detView, string Header)
 {
     string RetValue = "";
     foreach (DataControlField field in detView.Fields)
     {
         if (field.HeaderText == Header)
         {
             return field.SortExpression;
         }
     }
     return RetValue;
 }