public void OpenEditURL(OpenEditMode mode) { OpenEditURL(mode, null); }
public void OpenEditURL(OpenEditMode mode, object sender) { string url = this.getURL(mode, sender); string script = string.Empty; if (ShowDialog) { script = "window.showModalDialog('" + url + "','','dialogwidth=" + OpenEditWidth + "px;dialogheight=" + OpenEditHeight + "px,dialogleft=" + OpenEditLeft + "px,dialogtop=" + OpenEditTop + "px'); return false;"; } else { script = "window.open('" + url + "','Edit','height=" + OpenEditHeight + ",width=" + OpenEditWidth + ",top=" + OpenEditTop + ",left=" + OpenEditLeft + ",scrollbars=yes,resizable=yes,toolbar=no,menubar=no,location=no,status=no')"; } RegisterAjaxScript(script); }
public string getURL(OpenEditMode mode, object sender) { string url = this.EditURL.Contains("?") ? this.EditURL + "OpenEditMode=" + mode.ToString() : this.EditURL + "?OpenEditMode=" + mode.ToString(); if (this.Site == null) { WebDataSource ds = (WebDataSource)this.GetObjByID(this.DataSourceID); switch (mode) { case OpenEditMode.Insert: url += "&KeyValues=1=0"; break; case OpenEditMode.Update: case OpenEditMode.View: if (sender != null) { string filter = ""; Control ctrl = (Control)sender; if (ctrl != null && ctrl is GridViewRow) { GridViewRow row = (GridViewRow)ctrl; DataRow drow = null; if (row.DataItem != null) { drow = ((DataRowView)row.DataItem).Row; } else { int index = row.DataItemIndex; //int x = 0, y = 0; //while (x < index) //{ // if (ds.View.Table.Rows[y].RowState != DataRowState.Deleted) // { // x++; // } // y++; //} //drow = ds.View.Table.Rows[y]; //while (drow.RowState == DataRowState.Deleted) //{ // y++; // drow = ds.View.Table.Rows[y]; //} drow = ds.View[index].Row; } string strModuleName = ds.RemoteName.Substring(0, ds.RemoteName.IndexOf('.')); string strTableName = ds.RemoteName.Substring(ds.RemoteName.IndexOf('.') + 1); string tablename = CliUtils.GetTableName(strModuleName, strTableName, CliUtils.fCurrentProject); string sqlcmd = CliUtils.GetSqlCommandText(strModuleName, strTableName, CliUtils.fCurrentProject); string[] quote = CliUtils.GetDataBaseQuote(); for (int i = 0; i < ds.PrimaryKey.Length; i++) { string columnName = ds.PrimaryKey[i].ColumnName; if (drow[columnName].ToString().Length > 0) { Type type = ds.PrimaryKey[i].DataType; if (type == typeof(uint) || type == typeof(UInt16) || type == typeof(UInt32) || type == typeof(UInt64) || type == typeof(int) || type == typeof(Int16) || type == typeof(Int32) || type == typeof(Int64) || type == typeof(Single) || type == typeof(Double) || type == typeof(Decimal)) { filter += HttpUtility.UrlEncode(CliUtils.GetTableNameForColumn(sqlcmd, columnName)) + "=" + HttpUtility.UrlEncode(drow[columnName].ToString()) + " and "; } else if (type == typeof(DateTime)) { filter += HttpUtility.UrlEncode(CliUtils.GetTableNameForColumn(sqlcmd, columnName)) + "=$$$" + HttpUtility.UrlEncode(((DateTime)drow[columnName]).ToShortDateString()) + "$$$ and "; } else { filter += HttpUtility.UrlEncode(CliUtils.GetTableNameForColumn(sqlcmd, columnName)) + "=$$$" + HttpUtility.UrlEncode(drow[columnName].ToString()) + "$$$ and "; } } } if (filter != "") { filter = filter.Substring(0, filter.LastIndexOf(" and ")); url += "&KeyValues=" + filter; } url += "&SelectIndex=" + row.RowIndex; } } string pageIndex = this.PageIndex.ToString(); url += "&PageIndex=" + pageIndex; break; } string strFilePath = this.Page.Request.FilePath; url += "&PagePath=" + strFilePath; string MasterOrDetail = this.GetMasterOrDetail(); url += "&MasterOrDetail=" + MasterOrDetail; if (MasterOrDetail == "detail") { StringBuilder relationField = new StringBuilder(); StringBuilder relationValue = new StringBuilder(); foreach (DictionaryEntry entry in ds.RelationValues) { if (relationField.Length > 0) { relationField.Append(";"); } if (relationValue.Length > 0) { relationValue.Append(";"); } relationField.Append(entry.Key.ToString()); relationValue.Append(entry.Value.ToString()); } if (relationField.Length > 0 && relationValue.Length > 0) { url += "&RelationFields=" + HttpUtility.UrlEncode(relationField.ToString()) + "&RelationValues=" + HttpUtility.UrlEncode(relationValue.ToString()); } } if (this.ViewState["Paramters"] != null) { url += "&Paramters=" + HttpUtility.UrlEncode(this.ViewState["Paramters"].ToString()); } else { string sParam = ""; foreach (GridViewOpenParam param in this.Params) { string pString = this.Page.Request.QueryString[param.ParamName]; if (pString != null && pString != "") { sParam += param.ParamName + "=" + pString + "^"; } } if (sParam != "") { sParam = sParam.Substring(0, sParam.LastIndexOf('^')); } url += "&Paramters=" + HttpUtility.UrlEncode(sParam); } url += "&GridViewID=" + this.ID; string itemparam = this.Page.Request.QueryString["ItemParam"] != null ? HttpUtility.UrlEncode(this.Page.Request.QueryString["ItemParam"]) : string.Empty; url += "&ItemParam=" + itemparam; if (!string.IsNullOrEmpty(ds.WhereStr)) { url += "&DataSourceID=" + ds.ID; url += "&WhereStr=" + HttpUtility.UrlEncode(ds.WhereStr); } } return url.Replace("'", "\\'"); }