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(); } }
private DataSet GetDD(WebFormView formView) { DataSet dsDD = new DataSet(); DTE2 myDTE2 = FDTE2; //(DTE2)Marshal.GetActiveObject("VisualStudio.DTE.8.0"); string strModuleName = "", strTableName = "", sCurProject = "", tabName = "", dbAlias = ""; object obj = formView.GetObjByID(formView.DataSourceID); if (obj == null) return null; if (myDTE2 != null) { Solution2 sol = (Solution2)myDTE2.Solution; sCurProject = Path.ChangeExtension(Path.GetFileName(sol.FileName), ""); if ((sCurProject.Length >= 1) && (sCurProject[sCurProject.Length - 1] == '.')) sCurProject = sCurProject.Substring(0, sCurProject.Length - 1); } if (obj is WebDataSource) { WebDataSource wds = (WebDataSource)obj; if (wds.SelectAlias != null && wds.SelectAlias != "" && wds.SelectCommand != null && wds.SelectCommand != "") { MatchCollection mc = Regex.Matches(wds.SelectCommand.ToLower(), @"(\s+)\bfrom\b(\s+)(\S+)"); string s = mc[0].Value; strModuleName = "GLModule"; strTableName = "cmdDDUse"; tabName = s.Substring(s.LastIndexOf(' ') + 1); dbAlias = wds.SelectAlias; } else { strModuleName = FClientData.ProviderName; strModuleName = strModuleName.Substring(0, strModuleName.IndexOf('.')); strTableName = wds.DataMember; if (strTableName == null || strTableName.Length == 0) { System.Windows.Forms.MessageBox.Show(formView.DataSourceID + "'s DataMember property is null.", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return null; } tabName = CliUtils.GetTableName(strModuleName, strTableName, sCurProject); } } String OWNER = String.Empty, SS = tabName; if (SS.Contains(".")) { OWNER = WzdUtils.GetToken(ref SS, new char[] { '.' }); tabName = SS; } string strSql = "Select * from COLDEF where TABLE_NAME='" + tabName + "' OR TABLE_NAME='" + OWNER + "." + tabName + "'"; if (dbAlias != "") { dsDD = CliUtils.ExecuteSql(strModuleName, strTableName, strSql, dbAlias, true, sCurProject); } else { dsDD = CliUtils.ExecuteSql(strModuleName, strTableName, strSql, true, sCurProject); } return dsDD; }
private void CreateInnerNavigator(WebFormView formView, IDesignerHost host) { string[] ctrlTexts = { "<<", "<", ">", ">>", "add", "update", "delete", "ok", "cancel", "apply", "abort", "query", "print" }; //language = CliSysMegLag.GetClientLanguage(); language = CliUtils.fClientLang; String message = SysMsg.GetSystemMessage(language, "Srvtools", "WebNavigator", "ControlText", true); ctrlTexts = message.Split(';'); StringBuilder sbHeader = new StringBuilder(); sbHeader.Append("<cc1:WebNavigator ID=\"WebNavigator1\" runat=\"server\">"); // BindingObject=\"" + formView.ID + "\" sbHeader.Append("<NavControls>"); sbHeader.Append("<cc1:ControlItem ControlName=\"First\" ControlText=\"" + ctrlTexts[0] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/first.gif\" MouseOverImageUrl=\"../image/uipics/first2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Previous\" ControlText=\"" + ctrlTexts[1] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/previous.gif\" MouseOverImageUrl=\"../image/uipics/previous2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Next\" ControlText=\"" + ctrlTexts[2] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/next.gif\" MouseOverImageUrl=\"../image/uipics/next2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Last\" ControlText=\"" + ctrlTexts[3] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/last.gif\" MouseOverImageUrl=\"../image/uipics/last2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Add\" ControlText=\"" + ctrlTexts[4] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/add.gif\" MouseOverImageUrl=\"../image/uipics/add2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Update\" ControlText=\"" + ctrlTexts[5] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/edit.gif\" MouseOverImageUrl=\"../image/uipics/edit2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Delete\" ControlText=\"" + ctrlTexts[6] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/delete.gif\" MouseOverImageUrl=\"../image/uipics/delete2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"OK\" ControlText=\"" + ctrlTexts[7] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/ok.gif\" MouseOverImageUrl=\"../image/uipics/ok2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Cancel\" ControlText=\"" + ctrlTexts[8] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/cancel.gif\" MouseOverImageUrl=\"../image/uipics/cancel2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Apply\" ControlText=\"" + ctrlTexts[9] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/apply.gif\" MouseOverImageUrl=\"../image/uipics/apply2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Abort\" ControlText=\"" + ctrlTexts[10] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/abort.gif\" MouseOverImageUrl=\"../image/uipics/abort2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Query\" ControlText=\"" + ctrlTexts[11] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/query.gif\" MouseOverImageUrl=\"../image/uipics/query2.gif\" Size=\"25\" />"); sbHeader.Append("<cc1:ControlItem ControlName=\"Print\" ControlText=\"" + ctrlTexts[12] + "\" ControlType=\"Image\" ControlVisible=\"True\" ImageUrl=\"../image/uipics/print.gif\" MouseOverImageUrl=\"../image/uipics/print2.gif\" Size=\"25\" />"); sbHeader.Append("</NavControls>"); sbHeader.Append("</cc1:WebNavigator>"); formView.HeaderTemplate = ControlParser.ParseTemplate(host, sbHeader.ToString()); }
public WebFormViewActionList(IComponent component, IControlDesignerTag designerTag) : base(component) { this.formView = component as WebFormView; this.tag = designerTag; }
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 } }
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); } } }
private void SetDetails(WebFormView frmView, string editMode) { if (MasterOrDetail == "detail" && RelationFields != "" && RelationValues != "") { string[] fields = RelationFields.Split(';'); string[] values = RelationValues.Split(';'); switch (editMode) { case "Insert": break; case "Update": #region Update #endregion break; } } }