using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraGrid;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using System.Data;
using CommonLib.utils;
using CommonLib;
using System.Collections;
using System.Data.SqlClient;
using DevExpress.XtraEditors;
using System.ComponentModel;
using DevExpress.XtraGrid.Columns;
using System.Diagnostics;
using Lskj.MyControl;
using DevExpress.XtraTreeList;
using DevExpress.XtraCharts;
using Lskj.MyControl.Panel_Chart;
using System.Threading;
using DevExpress.XtraGrid.Views.Layout;
using System.IO;
using System.Web;
namespace Lskj.Common
{
///
/// Class GridMenu.
///
public class GridMenu
{
public string FormText { get; set; }
public string OperatorId { get; set; }
public string OperatorName { get; set; }
public string Privilege { get; set; }
public string DLLCoid { get; set; }
public string Sql { get; set; }
public string DirId { get; set; }
public string ObjectId { get; set; }
public string filedKey { get; set; }
public GridControl gc { get; set; }
public TreeList tl { get; set; }
public Panel_Chart chart { get; set; }
public Control btnCtr { get; set; }
public refreshData internal_func { get; set; }
public delegate void refreshData(object sender, string DJH);
public event EventHandler OnGridMenuClickRefreshData; // 点击右键菜单后,刷新表格数据
public String ShowMenuType { get; set; }
public DataTable DtMenuList = new DataTable();
public GridControlEx grid;
///
/// 主表面板
///
public Panel MainPanel { get; set; }
private List tsmMenuList = new List();
public GridMenu(string FormText, string OperatorId, string OperatorName, string Privilege, string DLLCoid, string Sql, GridControl gc)
{
this.FormText = FormText;
this.OperatorId = OperatorId;
this.OperatorName = OperatorName;
this.Privilege = Privilege;
this.DLLCoid = DLLCoid;
this.Sql = Sql;
this.gc = gc;
}
public GridMenu(string FormText, string OperatorId, string OperatorName, string Privilege, string DLLCoid, string Sql, TreeList tl)
{
this.FormText = FormText;
this.OperatorId = OperatorId;
this.OperatorName = OperatorName;
this.Privilege = Privilege;
this.DLLCoid = DLLCoid;
this.Sql = Sql;
this.tl = tl;
}
public GridMenu(string FormText, string OperatorId, string OperatorName, string Privilege, string DLLCoid, string Sql, Panel_Chart chart)
{
this.FormText = FormText;
this.OperatorId = OperatorId;
this.OperatorName = OperatorName;
this.Privilege = Privilege;
this.DLLCoid = DLLCoid;
this.Sql = Sql;
this.chart = chart;
}
public GridMenu(string FormText, string OperatorId, string OperatorName, string Privilege, string DLLCoid, string Sql, GridControl gc, refreshData func)
{
this.FormText = FormText;
this.OperatorId = OperatorId;
this.OperatorName = OperatorName;
this.Privilege = Privilege;
this.DLLCoid = DLLCoid;
this.Sql = Sql;
this.gc = gc;
this.internal_func = func;
}
public void BindGridMenu(string tab)
{
ContextMenuStrip msItem = new ContextMenuStrip();
msItem.Opening += new CancelEventHandler(cmsGrid_Opening);
if (ShowMenuType == "bill")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible1=0 order by orderid asc").Tables[0];
}
else if (ShowMenuType == "sh")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible2=0 order by orderid asc").Tables[0];
}
else
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 order by orderid asc").Tables[0];
}
foreach (DataRow dr in DtMenuList.Rows)
{
ToolStripMenuItem tsm = new ToolStripMenuItem(dr["menuname"].ToString());
tsm.Click += new EventHandler(tsm_Click);
tsm.Tag = dr;
tsm.Text = dr["menuname"].ToString();
if (!string.IsNullOrEmpty(tsm.Text))
tsm.Text = tsm.Text.Replace("\r", "").Replace("\n", "");
msItem.Items.Add(tsm);
tsmMenuList.Add(tsm);
}
//if (dt.Rows.Count > 0)
{
gc.ContextMenuStrip = msItem;
}
}
public void BindGridMenuChart(string tab)
{
ContextMenuStrip msItem = new ContextMenuStrip();
msItem.Opening += new CancelEventHandler(cmsGrid_Opening);
if (ShowMenuType == "bill")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible1=0 order by orderid asc").Tables[0];
}
else if (ShowMenuType == "sh")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible2=0 order by orderid asc").Tables[0];
}
else
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 order by orderid asc").Tables[0];
}
foreach (DataRow dr in DtMenuList.Rows)
{
ToolStripMenuItem tsm = new ToolStripMenuItem(dr["menuname"].ToString());
tsm.Click += new EventHandler(tsm_ClickChart);
tsm.Tag = dr;
tsm.Text = dr["menuname"].ToString();
if (!string.IsNullOrEmpty(tsm.Text))
tsm.Text = tsm.Text.Replace("\r", "").Replace("\n", "");
msItem.Items.Add(tsm);
tsmMenuList.Add(tsm);
}
//if (dt.Rows.Count > 0)
{
chart.chartControl.ContextMenuStrip = msItem;
}
}
public void BindGridMenuTreeList(string tab)
{
ContextMenuStrip msItem = new ContextMenuStrip();
msItem.Opening += new CancelEventHandler(cmsGrid_Opening);
if (ShowMenuType == "bill")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible1=0 order by orderid asc").Tables[0];
}
else if (ShowMenuType == "sh")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible2=0 order by orderid asc").Tables[0];
}
else
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where isnull(visible,0)=0 and tab='" + tab + "' and isnull(menutype,0)=0 order by orderid asc").Tables[0];
}
foreach (DataRow dr in DtMenuList.Rows)
{
ToolStripMenuItem tsm = new ToolStripMenuItem(dr["menuname"].ToString());
tsm.Click += new EventHandler(tsm_Click);
tsm.Tag = dr;
tsm.Text = dr["menuname"].ToString();
if (!string.IsNullOrEmpty(tsm.Text))
tsm.Text = tsm.Text.Replace("\r", "").Replace("\n", "");
msItem.Items.Add(tsm);
tsmMenuList.Add(tsm);
}
//if (dt.Rows.Count > 0)
{
tl.ContextMenuStrip = msItem;
}
}
public void BindGridMenuWQ(string tab, ContextMenuStrip menu)
{
ContextMenuStrip msItem = new ContextMenuStrip();
msItem.Opening += new CancelEventHandler(cmsGrid_Opening);
if (ShowMenuType == "bill")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where visible=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible1=0 order by orderid asc").Tables[0];
}
else if (ShowMenuType == "sh")
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where visible=0 and tab='" + tab + "' and isnull(menutype,0)=0 and visible2=0 order by orderid asc").Tables[0];
}
else
{
DtMenuList = SqlHelper.ExecuteDataSet("select * from P_systempopupmenu where visible=0 and tab='" + tab + "' and isnull(menutype,0)=0 order by orderid asc").Tables[0];
}
if (menu != null && menu.Items.Count > 0)
{
for (int i = menu.Items.Count - 1; i >= 0; i--)
{
ToolStripMenuItem item = menu.Items[i] as ToolStripMenuItem;
msItem.Items.Add(item);
tsmMenuList.Add(item);
}
}
foreach (DataRow dr in DtMenuList.Rows)
{
ToolStripMenuItem tsm = new ToolStripMenuItem(dr["menuname"].ToString());
tsm.Click += new EventHandler(tsm_Click);
tsm.Tag = dr;
tsm.Text = dr["menuname"].ToString();
if (!string.IsNullOrEmpty(tsm.Text))
tsm.Text = tsm.Text.Replace("\r", "").Replace("\n", "");
msItem.Items.Add(tsm);
tsmMenuList.Add(tsm);
}
if (DtMenuList.Rows.Count > 0)
{
gc.ContextMenuStrip = msItem;
}
}
public void BindGridMenuWQ(string tab)
{
BindGridMenuWQ(tab, null);
}
///
///动态加载菜单
///
///
///
private void cmsGrid_Opening(object sender, CancelEventArgs e)
{
try
{
ContextMenuStrip cms = (ContextMenuStrip)sender;
if (cms.SourceControl is GridControl)
{
cms.Items.Clear();
cms.Items.AddRange(tsmMenuList.ToArray());
List listQQ = new List();
List listWWW = new List();
if (gc.MainView is GridView)
{
GridView GridViewpub = gc.MainView as GridView;
if (GridViewpub.GetSelectedRows().Length < 1)
GridViewpub.SelectRow(GridViewpub.FocusedRowHandle);
int[] rowCount = GridViewpub.GetSelectedRows();
if (rowCount.Length > 0)
{
DataRow row = GridViewpub.GetDataRow(rowCount[0]);
GridColumnCollection columns = GridViewpub.Columns;
for (int i = 0; i < columns.Count; i++)
{
GridColumn gcItem = columns[i];
if (!row.Table.Columns.Contains(gcItem.Name))
continue;
if (gcItem.Tag == null)
{
if ((row[gcItem.Name].ToString().IndexOf("www", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("http://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("ftp://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("file://", StringComparison.OrdinalIgnoreCase) != -1))
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.www);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_www_Click);
listWWW.Add(item);
}
}
continue;
}
MyTagModel ctm = gcItem.Tag as MyTagModel;
string tag = string.Empty;
if (ctm == null)
{
tag = gcItem.Tag + "";
}
else
{
tag = ctm.Tag + "";
}
if (tag == "qq")
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.qq);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_qq_Click);
listQQ.Add(item);
}
}
if ((tag == "www") || (row[gcItem.Name].ToString().IndexOf("www", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("http://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("ftp://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("file://", StringComparison.OrdinalIgnoreCase) != -1))
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.www);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_www_Click);
listWWW.Add(item);
}
}
}
cms.Items.AddRange(listQQ.ToArray());
cms.Items.AddRange(listWWW.ToArray());
}
GridControl gridControl = cms.SourceControl as GridControl;
GridView gv = (gridControl.MainView as GridView);
ToolStripItemCollection gsc = gridControl.ContextMenuStrip.Items;
if (gridControl != null)
{
int[] rows = gv.GetSelectedRows();
foreach (int index in rows)
{
DataRow row = gv.GetDataRow(index);
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
if (pmenu == null)
continue;
string menuCond = pmenu["menuCond"] + "";
string menuPrivilege = pmenu["privilegeOper"] + ",";
if (menuPrivilege.Length > 1 && !menuPrivilege.Contains(OperatorName + ","))
{
item.Enabled = false;
}
else
{
if (string.IsNullOrEmpty(menuCond))
continue;
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhere(row, MainPanel, menuCond);
item.Enabled = Convert.ToBoolean(Evaluator.Eval(menuCond));
}
}
}
}
}
if (gc.MainView is LayoutView)
{
LayoutView layoutView = gc.MainView as LayoutView;
if (layoutView.GetSelectedRows().Length < 1)
layoutView.SelectRow(layoutView.FocusedRowHandle);
int[] rowCount = layoutView.GetSelectedRows();
if (rowCount.Length > 0)
{
DataRow row = layoutView.GetDataRow(rowCount[0]);
LayoutViewColumnCollection columns = layoutView.Columns;
for (int i = 0; i < columns.Count; i++)
{
LayoutViewColumn gcItem = columns[i];
if (!row.Table.Columns.Contains(gcItem.Name))
continue;
if (gcItem.Tag == null)
{
if ((row[gcItem.Name].ToString().IndexOf("www", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("http://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("ftp://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("file://", StringComparison.OrdinalIgnoreCase) != -1))
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.www);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_www_Click);
listWWW.Add(item);
}
}
continue;
}
MyTagModel ctm = gcItem.Tag as MyTagModel;
string tag = string.Empty;
if (ctm == null)
{
tag = gcItem.Tag + "";
}
else
{
tag = ctm.Tag + "";
}
if (tag == "qq")
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.qq);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_qq_Click);
listQQ.Add(item);
}
}
if ((tag == "www") || (row[gcItem.Name].ToString().IndexOf("www", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("http://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("ftp://", StringComparison.OrdinalIgnoreCase) != -1)
|| (row[gcItem.Name].ToString().IndexOf("file://", StringComparison.OrdinalIgnoreCase) != -1))
{
if (!string.IsNullOrEmpty(row[gcItem.Name] + ""))
{
ToolStripMenuItem item = new ToolStripMenuItem("(" + gcItem.Caption + ")" + row[gcItem.Name] + "", global::Lskj.Common.Properties.Resources.www);
item.Tag = row[gcItem.Name];
item.Click += new EventHandler(item_www_Click);
listWWW.Add(item);
}
}
}
cms.Items.AddRange(listQQ.ToArray());
cms.Items.AddRange(listWWW.ToArray());
}
GridControl gridControl = cms.SourceControl as GridControl;
LayoutView lv = (gridControl.MainView as LayoutView);
ToolStripItemCollection gsc = gridControl.ContextMenuStrip.Items;
if (gridControl != null)
{
int[] rows = lv.GetSelectedRows();
foreach (int index in rows)
{
DataRow row = lv.GetDataRow(index);
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
if (pmenu == null)
continue;
string menuCond = pmenu["menuCond"] + "";
string menuPrivilege = pmenu["privilegeOper"] + ",";
if (menuPrivilege.Length > 1 && !menuPrivilege.Contains(OperatorName + ","))
{
item.Enabled = false;
}
else
{
if (string.IsNullOrEmpty(menuCond))
continue;
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhere(row, MainPanel, menuCond);
item.Enabled = Convert.ToBoolean(Evaluator.Eval(menuCond));
}
}
}
}
}
}
else if (cms.SourceControl is TreeList)
{
TreeList treeList = cms.SourceControl as TreeList;
ToolStripItemCollection gsc = treeList.ContextMenuStrip.Items;
DataRowView rowView = treeList.GetDataRecordByNode(treeList.FocusedNode) as DataRowView;
if (rowView != null)
{
DataRow row = rowView.Row;
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
if (pmenu == null)
continue;
string menuCond = pmenu["menuCond"] + "";
string menuPrivilege = pmenu["privilegeOper"] + ",";
if (menuPrivilege.Length > 1 && !menuPrivilege.Contains(OperatorName + ","))
{
item.Enabled = false;
}
else
{
if (string.IsNullOrEmpty(menuCond))
continue;
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhere(row, MainPanel, menuCond);
item.Enabled = Convert.ToBoolean(Evaluator.Eval(menuCond));
}
}
}
cms.Items.Clear();
cms.Items.AddRange(tsmMenuList.ToArray());
if (tsmMenuList.ToArray().Count() > 0)
{
cms.Items.Add(new ToolStripSeparator());
}
ToolStripMenuItem expandall = new ToolStripMenuItem("全部展开");
expandall.Click += new EventHandler(item_expandall_Click);
cms.Items.Add(expandall);
ToolStripMenuItem merge = new ToolStripMenuItem("全部合并");
merge.Click += new EventHandler(item_merge_Click);
cms.Items.Add(merge);
}
else if (cms.SourceControl is ChartControl)
{
ToolStripItemCollection gsc = chart.chartControl.ContextMenuStrip.Items;
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
if (pmenu == null)
continue;
string menuCond = pmenu["menuCond"] + "";
string menuPrivilege = pmenu["privilegeOper"] + ",";
if (menuPrivilege.Length > 1 && !menuPrivilege.Contains(OperatorName + ","))
{
item.Enabled = false;
}
else
{
if (!string.IsNullOrEmpty(menuCond))
{
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
item.Enabled = Convert.ToBoolean(Evaluator.Eval(menuCond));
}
}
//if (chart.seriesPoint == null)
// item.Enabled = false;
}
}
}
catch (Exception)
{
}
}
#region 打开QQ
protected void item_qq_Click(object sender, EventArgs e)
{
ToolStripMenuItem t = (ToolStripMenuItem)sender;
string text = t.Tag + "";
if (string.IsNullOrEmpty(text))
{
MessageBox.Show("请输入您的QQ号码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
Process p = new Process();
ProcessStartInfo ps = new ProcessStartInfo();
string Url = string.Format(@"tencent://message/?Menu=yes&uin={0}", text);
ps.FileName = @"iexplore.exe";
ps.Arguments = Url;
ps.UseShellExecute = true;
ps.RedirectStandardInput = false;
//ps.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo = ps;
p.Start();
}
#endregion
#region 打开WWW
protected void item_www_Click(object sender, EventArgs e)
{
ToolStripMenuItem t = (ToolStripMenuItem)sender;
string url = t.Tag + "";
if (string.IsNullOrEmpty(url))
{
MessageBox.Show("请输入您要打开网址", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
System.Diagnostics.Process.Start("iexplore.exe", url);
}
#endregion
#region 展开合并节点
///
/// 展开所有节点
///
///
///
protected void item_expandall_Click(object sender, EventArgs e)
{
tl.ExpandAll();
}
///
/// 合并所有节点
///
///
///
protected void item_merge_Click(object sender, EventArgs e)
{
tl.CollapseAll();
}
#endregion
///
/// 打开右键菜单
///
///
///
protected void ms_Opening(object sender, CancelEventArgs e)
{
ContextMenuStrip cms = sender as ContextMenuStrip;
if (cms == null)
return;
GridControl gc = cms.SourceControl as GridControl;
if (gc == null)
return;
if (gc.MainView is GridView)
{
GridView gv = (gc.MainView as GridView);
ToolStripItemCollection gsc = gc.ContextMenuStrip.Items;
if (gc != null)
{
int[] rows = gv.GetSelectedRows();
foreach (int index in rows)
{
DataRow row = gv.GetDataRow(index);
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
string menuCond = pmenu["menuCond"] + "";
string menuName = pmenu["menuname"] + "";
if (string.IsNullOrEmpty(menuCond))
continue;
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhere(row, menuCond);
if (MainPanel != null)
{
menuCond = PubClass.ReqSqlWhere(MainPanel, menuCond);
}
try
{
item.Enabled = string.IsNullOrWhiteSpace(menuCond) || Convert.ToBoolean(Evaluator.Eval(menuCond));
}
catch (Exception)
{
XtraMessageBox.Show(string.Format("{0} 配置条件错误,请检查.", menuName));
}
}
}
}
}
else if (gc.MainView is LayoutView)
{
LayoutView gv = (gc.MainView as LayoutView);
ToolStripItemCollection gsc = gc.ContextMenuStrip.Items;
if (gc != null)
{
int[] rows = gv.GetSelectedRows();
foreach (int index in rows)
{
DataRow row = gv.GetDataRow(index);
foreach (ToolStripItem item in gsc)
{
DataRow pmenu = item.Tag as DataRow;
string menuCond = pmenu["menuCond"] + "";
string menuName = pmenu["menuname"] + "";
if (string.IsNullOrEmpty(menuCond))
continue;
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhere(row, menuCond);
if (MainPanel != null)
{
menuCond = PubClass.ReqSqlWhere(MainPanel, menuCond);
}
try
{
item.Enabled = string.IsNullOrWhiteSpace(menuCond) || Convert.ToBoolean(Evaluator.Eval(menuCond));
}
catch (Exception)
{
XtraMessageBox.Show(string.Format("{0} 配置条件错误,请检查.", menuName));
}
}
}
}
}
}
///
/// 点击事件
///
///
///
protected void tsm_Click(object sender, EventArgs e)
{
bool isContinue = true; // 是否继续执行
bool multiRow = false; //多行执行标记
bool msgHinted = true; //多行执行时如果定义有提示只提示一次
ToolStripMenuItem t = sender as ToolStripMenuItem;
DataRow dr_p = t.Tag as DataRow;
DataRow[] d_Rows = GetSelectRow();
if (d_Rows == null || d_Rows.Length == 0)
{
XtraMessageBox.Show("请选择一行进行操作.");
return;
}
if (DtMenuList.Columns.Contains("ifMoreClick") && dr_p["ifMoreClick"] + "" == "1")
{
d_Rows = GetMultipleSelectRow();
multiRow = true;
}
else
{
if (d_Rows.Length > 1)
{
XtraMessageBox.Show("该功能只允许选择一行记录进行,请取消多行选择");
return;
}
}
for (int x = 0; x < d_Rows.Count(); x++)
{
if (!isContinue) return;
DataRow rowData = d_Rows[x];
if (rowData == null)
return;
GridView gv = null;
LayoutView lv = null;
int oldRowHandle = 0;
if (gc != null)
{
if (gc.MainView is GridView)
{
gv = gc.MainView as GridView;
oldRowHandle = gv.FocusedRowHandle;
}
if (gc.MainView is LayoutView)
{
lv = gc.MainView as LayoutView;
oldRowHandle = lv.FocusedRowHandle;
}
}
string beforeMsg = dr_p["beforeMsg"].ToString().Trim();
if ((beforeMsg != "") && (msgHinted == true))
{
msgHinted = false;
beforeMsg = PubClass.ReqSql(rowData, beforeMsg);
DialogResult dlgResult = XtraMessageBox.Show(beforeMsg, "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dlgResult != DialogResult.Yes)
return;
}
string action = dr_p["action"].ToString();
int actionType = Convert.ToInt32(dr_p["actiontype"]);
int ifRefresh = Convert.ToInt32(dr_p["ifRefresh"]);
string dllName = dr_p["dllname"].ToString();
string maxWindow = dr_p["maxWindow"] + "";
List valueList = new List();
valueList.Add(dr_p["dllpar1"].ToString() + "");
valueList.Add(dr_p["dllpar2"].ToString() + "");
valueList.Add(dr_p["dllpar3"].ToString() + "");
valueList.Add(dr_p["dllpar4"].ToString() + "");
valueList.Add(dr_p["dllpar5"].ToString() + "");
valueList.Add(dr_p["dllpar6"].ToString() + "");
valueList.Add(dr_p["dllpar7"].ToString() + "");
valueList.Add(dr_p["dllpar8"].ToString() + "");
valueList.Add(dr_p["dllpar9"].ToString() + "");
valueList.Add(dr_p["dllpar10"].ToString() + "");
string DJH = string.Empty;
dllName = dllName.Replace("{loginid}", ERPInfo.Instance.EmployeeId.ToString());
dllName = dllName.Replace("{loginname}", ERPInfo.Instance.EmployeeName.ToString());
//打开exe
if ((dllName.Trim() != "") && (dllName.ToLower().IndexOf(".exe", 1) != -1) && ((dllName.ToLower() != "iexplore.exe")) && ((dllName.ToLower() != "lstest.exe")))
{
string tmpDllName = dllName;
List sqlpar = PubClass.GetParamValue(tmpDllName);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
tmpDllName = tmpDllName.Replace(s, rowData[filed] + "");
}
//MessageBox.Show(tmpDllName);
PubUtil.WinExec(tmpDllName, 1);
}
else if ((dllName.Trim() != "") && (dllName.ToLower().IndexOf("http:", StringComparison.OrdinalIgnoreCase) != -1) ||
(dllName.ToLower().IndexOf("www.", StringComparison.OrdinalIgnoreCase) != -1) ||
(dllName.ToLower().IndexOf("ftp:", StringComparison.OrdinalIgnoreCase) != -1))
{
Process.Start(dllName);
}
else
//打开dll
if (actionType == 2)
{
#region 打开DLL
List paremList = new List();
foreach (string item in valueList)
{
string action_type = string.Empty;
if (item.Length > 0)
{
action_type = item.Substring(0, 1);
}
// 解析sql
if (action_type == "@")
{
// 右键菜单假如是调用单据,则参数8和参数9为打开单据新增sql语句
if (dllName.ToLower() == "lskj.pubbill.dll" && (item == dr_p["dllpar8"] + "" || item == dr_p["dllpar9"] + ""))
{
isContinue = false;
string sql = item.Replace("@", "");
sql = PubClass.ReqSqlParam(sql, OperatorId, OperatorName);
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string fieldValues = string.Empty;
string filed = s.Replace("{", "").Replace("}", "");
foreach (DataRow rowItem in d_Rows)
{
//fieldValues += "'" + rowItem[filed] + "',";
fieldValues += "" + rowItem[filed] + ",";
}
sql = sql.Replace(s, (item == dr_p["dllpar8"] + "") ? rowData[filed] + "" : fieldValues.TrimEnd(','));
}
paremList.Add(sql);
}
else
{
string sql = item.Replace("@", "");
sql = PubClass.ReqSqlParam(sql, OperatorId, OperatorName);
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
}
else if (action_type == "{")
{
string p = item.Replace("{", "").Replace("}", "");
if (item == "{COLUMN_NAME}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.FieldName);
}
}
else if (item == "{COLUMN_TITLE}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.GetTextCaption());
}
}
else
{
paremList.Add(rowData[p] + "");
}
}
else if (item.Contains("{") && item.Contains("}"))
{
string str = item;
str = PubClass.ReqSqlParam(str, OperatorId, OperatorName);
List listStr = PubClass.GetParamValue(str);
foreach (String s in listStr)
{
string fileName = s.Replace("{", "").Replace("}", "");
string v = rowData[fileName] + "";
str = str.Replace(s, v);
}
paremList.Add(str);
}
else if (item.Contains("[FormTitle_"))
{
String str = item.Replace("[", "{").Replace("]", "}");
List listStr = PubClass.GetParamValue(str);
foreach (String s in listStr)
{
string fileName = s.Replace("FormTitle_", "").Replace("{", "").Replace("}", "");
string v = rowData[fileName] + "";
str = str.Replace(s, v);
}
paremList.Add(str);
}
else if (action_type == "#")
{
string sql = item.Replace("#", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
paremList.Add(sql);
}
else
{
paremList.Add(item);
}
}
if (dllName.ToLower() == "iexplore.exe")
{
//MessageBox.Show(paremList[0] + Uri.EscapeUriString(paremList[1]));
string url = paremList[0] + Uri.EscapeUriString(paremList[1]);
url = url.Replace("#", "%23");
System.Diagnostics.Process.Start("iexplore.exe", url);
break;
}
if (dllName.ToLower() == "lstest.exe")
{
// 为了兼容之前版本,参数10配置为调用附件类型,为空则为打开附件,
// 1.上传附件(参数1分类SpeciesNo,参数2分类SpeciesName,参数3.目录ID),
// 2.下载附件(参数1附件目录ID,参数2附件ID列表格式:(123,234,124,563,22)为5个附件括号不传递.)
// 3.删除附件(参数1附件ID列表格式:(123,234,124,563,22)为5个附件括号不传递.)
string param1 = paremList[0];
string param2 = paremList[1];
string param3 = paremList[2];
string fileType = paremList[9];
switch (fileType)
{
case "1":
{
if (string.IsNullOrEmpty(param1))
{
XtraMessageBox.Show("参数1不正确.未传递分类编号");
return;
}
if (string.IsNullOrEmpty(param2))
{
XtraMessageBox.Show("参数2不正确.未传递分类名称");
return;
}
if (string.IsNullOrEmpty(param3))
{
XtraMessageBox.Show("参数3不正确.未传递目录ID");
return;
}
fmUpdateDownloadType type = (fmUpdateDownloadType)0;
TParamsData pd = new TParamsData(type, this.gc.Handle);
pd.setLocation(100, 100);
pd.setSize(800, 500);
pd.setParent(Convert.ToInt32(param3));
//文件编码
pd.SetfileNumber("001");
//类别编码
pd.SetspecieNo(param2);
pd.CallUpdateUIEx();
break;
}
case "2":
{
if (string.IsNullOrEmpty(param1))
{
XtraMessageBox.Show("参数1不正确.未传递目录ID");
return;
}
if (string.IsNullOrEmpty(param2))
{
XtraMessageBox.Show("参数2不正确.未传递附件ID");
return;
}
fmUpdateDownloadType type = (fmUpdateDownloadType)2;
TParamsData pd = new TParamsData(type, this.gc.Handle);
pd.setLocation(100, 100);
pd.setSize(800, 500);
pd.setParent(Convert.ToInt32(param1));
string[] strFileIds = param2.Split(',');
foreach (string sId in strFileIds)
{
pd.addFileId(int.Parse(sId));
}
pd.CallUpdateUI();
break;
}
case "3":
{
if (string.IsNullOrEmpty(param1))
{
XtraMessageBox.Show("参数1不正确.未传递目录ID");
return;
}
if (string.IsNullOrEmpty(param2))
{
XtraMessageBox.Show("参数2不正确.未传递附件ID");
return;
}
DialogResult drt = MessageBox.Show("附件删除后不可恢复,是否真要删除选中的附件?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (drt != DialogResult.Yes)
return;
string ids = param2.Trim(',');
fmUpdateDownloadType type = (fmUpdateDownloadType)2;
TParamsData pd = new TParamsData(type, this.gc.Handle);
pd.setLocation(100, 100);
pd.setSize(800, 500);
pd.setParent(Convert.ToInt32(param1));
string[] strFileIds = ids.Split(',');
foreach (string sId in strFileIds)
{
if (this.AttachOperation(3, ERPInfo.Instance.EmployeeId, ERPInfo.Instance.EmployeeName, "", Convert.ToInt32(sId), "", 0))
{
pd.addFileId(int.Parse(sId));
}
}
pd.CallDeleteFile();
break;
}
default:
{
StringBuilder dfile = new StringBuilder();
StringBuilder rfile = new StringBuilder();
int hwnd = 0;
dfile.Append(paremList[0] + paremList[1]);
rfile = PubUtil.DownloadAttach(dfile, hwnd);
rfile.Clear();
string fileName = System.IO.Path.GetFileName(dfile.ToString());
string file = Application.StartupPath + @"\tempfiles\" + fileName;
rfile.Append(file);
string newFile = file;
if (fileName.EndsWith(".pdf"))
newFile = VerifyDownLoadFinish(file, fileName);
string newFile2 = Application.StartupPath + @"\tempfiles\" + paremList[1];
//if (System.IO.File.Exists(rfile.ToString()))
//{
// if(fileName.Contains(".pdf")){
//}
if (File.Exists(newFile))
System.Diagnostics.Process.Start(newFile, "");
if (File.Exists(newFile2))
System.Diagnostics.Process.Start(newFile2, "");
//}
break;
}
}
}
else if (dllName == "Lskj.PhotoView.dll")
{
string[] str = {
FormText,
OperatorId,
OperatorName,
"0",
DLLCoid,
paremList[0],
paremList[1],
paremList[2],
paremList[3],
paremList[4],
paremList[5],
paremList[6],
paremList[7],
paremList[8],
paremList[9]
};
IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str);
if (maxWindow == "1")
form.SubForm.WindowState = FormWindowState.Maximized;
form.SubForm.ShowDialog();
}
else
{
string[] str = {
FormText,
OperatorId,
OperatorName,
Privilege,
DLLCoid,
paremList[0],
paremList[1],
paremList[2],
paremList[3],
paremList[4],
paremList[5],
paremList[6],
paremList[7],
paremList[8],
paremList[9]
};
IForm form = PubUtil.LoadDllForm(dllName, str);
form.SubForm.WindowState = maxWindow == "1" ? FormWindowState.Maximized : FormWindowState.Normal;
form.SubForm.StartPosition = FormStartPosition.CenterParent;
form.SubForm.ShowDialog();
}
#endregion
}//执行存储过程
else if (actionType == 1)
{
#region 执行存储过程
try
{
List paremList = new List();
ArrayList sqlParamList = new ArrayList();
foreach (string item in valueList)
{
//解析sql
if (item.IndexOf('@') != -1)
{
string sql = item.Replace("@", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (item.IndexOf('{') != -1)
{
string p = item;
List sqlpar = PubClass.GetParamValue(item);
foreach (string s in sqlpar)
{
string filedName = s.Replace("{", "").Replace("}", "");
if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase))
{
p = p.Replace(s, OperatorName);
}
else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase))
{
p = p.Replace(s, OperatorId);
}
else if (s == "{COLUMN_NAME}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.FieldName);
}
}
else if (s == "{COLUMN_TITLE}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.GetTextCaption());
}
}
else
{
p = p.Replace(s, rowData[filedName] + "");
}
}
paremList.Add(p);
}
else
{
paremList.Add(item);
}
}
List paramName = PubClass.GetParamValue(action);
string[] paramStr = paramName[0].Replace("{", "").Replace("}", "").Split(',');
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
//for (int i = 0; i < paremList.Count; i++)
//{
// string item = paremList[i];
// if (!string.IsNullOrEmpty(item))
// {
// if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
// {
// pMsg.Direction = ParameterDirection.Output;
// pMsg.Value = "";
// sqlParamList.Add(pMsg);
// }
// else
// {
// string paramStr1 = paramStr[i];
// SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
// DbTypeConverter.ConvertToSql(FieldType.VarChar));
// param.Value = item;
// sqlParamList.Add(param);
// }
// }
//}
for (int i = 0; i < paramStr.Length; i++)
{
string item = paremList[i];
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
{
pMsg.Direction = ParameterDirection.InputOutput;
pMsg.Value = "";
sqlParamList.Add(pMsg);
}
else
{
string paramStr1 = paramStr[i];
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.Value = item;
sqlParamList.Add(param);
}
}
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
sqlParamList.Add(returnValue);
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, action.Replace(paramName[0], "").Trim(), (SqlParameter[])sqlParamList.ToArray(typeof(SqlParameter)));
if (Convert.ToInt32(returnValue.Value) == -1)
{
XtraMessageBox.Show("操作失败\n" + pMsg.Value, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
if (Convert.ToInt32(returnValue.Value) == 9999)
{
XtraMessageBox.Show(pMsg.Value + "", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (Convert.ToInt32(returnValue.Value) == 99)
{
//对话框输入
ComfirmDialog.ComfirmDialog cfd = new ComfirmDialog.ComfirmDialog(pMsg.Value + "");
DialogResult result = cfd.ShowDialog();
if (result == DialogResult.Cancel)
return;
string hintMsg = cfd.ComfirmMsg;
sqlParamList.Clear();
for (int i = 0; i < paramStr.Length; i++)
{
string item = paremList[i];
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
{
pMsg.Direction = ParameterDirection.InputOutput;
pMsg.Value = hintMsg;
sqlParamList.Add(pMsg);
}
else
{
string paramStr1 = paramStr[i];
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.Value = item;
sqlParamList.Add(param);
}
}
SqlParameter returnValue1 = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue1.Direction = ParameterDirection.ReturnValue;
sqlParamList.Add(returnValue1);
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, action.Replace(paramName[0], "").Trim(), (SqlParameter[])sqlParamList.ToArray(typeof(SqlParameter)));
if (Convert.ToInt32(returnValue1.Value) == -1)
{
XtraMessageBox.Show("操作失败\n" + pMsg.Value, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
if (!multiRow)
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
if (!multiRow)
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
try
{
if (action.Contains("p_baseApply"))
{
// 调用消息推送
PushHelper push = new PushHelper(paramStr[1], "0", paramStr[0], "", "", 0);
new Thread(new ThreadStart(push.push_base_oper_message));
}
else if (action.Contains("p_billApply"))
{
// 调用消息推送
PushHelper push = new PushHelper(paramStr[1], "0", paramStr[0], "", "", 0);
new Thread(new ThreadStart(push.push_bill_oper_message));
}
}
catch (Exception)
{
}
}
DJH = (pMsg.Value + "").Trim();
}
}
catch (Exception ex)
{
XtraMessageBox.Show("操作失败\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Sql = gc.Tag + "";
if (gc.Parent != null && gc.Parent.Parent != null)
{
btnCtr = gc.Parent.Parent;
}
if (btnCtr != null)
{
Control[] ctr = btnCtr.Controls.Find("btnCondSearch", true);
if (ctr != null && ctr.Length > 0)
{
if (ctr[0] is SimpleButton)
{
SimpleButton btn = ctr[0] as SimpleButton;
btn.PerformClick();
}
}
else
{
if (!string.IsNullOrEmpty(Sql))
{
gc.DataSource = SqlHelper.ExecuteDataSet(Sql).Tables[0];
}
}
}
#endregion
}//调用delphi
else if (actionType == 3)
{
List paremList = new List();
foreach (string item in valueList)
{
string action_type = string.Empty;
if (item.Length > 0)
{
action_type = item.Substring(0, 1);
}
if (action_type == "@")
{
//解析sql
string sql = item.Replace("@", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (action_type == "{")
{
string p = item.Replace("{", "").Replace("}", "");
if (item == "{COLUMN_NAME}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.FieldName);
}
}
else if (item == "{COLUMN_TITLE}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.GetTextCaption());
}
}
else
{
paremList.Add(rowData[p] + "");
}
}
else if (action_type == "#")
{
string sql = item.Replace("#", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
paremList.Add(sql);
}
else
{
string sql = item;
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
paremList.Add(sql);
}
}
PubUtil.LoadDelphiDll(dllName, paremList[0], paremList[1], paremList[2], paremList[3], Convert.ToInt32(paremList[4]), paremList[5]);
}
else if (actionType == 6)
{
List paremList = new List();
foreach (string item in valueList)
{
string action_type = string.Empty;
if (item.Length > 0)
{
action_type = item.Substring(0, 1);
}
if (action_type == "@")
{
//解析sql
string sql = item.Replace("@", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (action_type == "{")
{
string p = item.Replace("{", "").Replace("}", "");
if (item == "{COLUMN_NAME}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.FieldName);
}
}
else if (item == "{COLUMN_TITLE}")
{
if (gc != null && gc.MainView is GridView)
{
paremList.Add((gc.MainView as GridView).FocusedColumn.GetTextCaption());
}
}
else
{
paremList.Add(rowData[p] + "");
}
}
else if (action_type == "#")
{
string sql = item.Replace("#", "");
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
paremList.Add(sql);
}
else
{
string sql = item;
List sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string filed = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, rowData[filed] + "");
}
paremList.Add(sql);
}
}
string url = paremList[0];
if (!string.IsNullOrEmpty(url))
{
string urlStart = SqlHelper.ExecuteDataTable("select OAUrl from P_systemTab").Rows[0]["OAUrl"] + "";
//获取下载url
if (!url.StartsWith("http"))
{
string OAUrl = !string.IsNullOrEmpty(urlStart) && urlStart.EndsWith("/") ? urlStart : urlStart + "/";
url = OAUrl + url;
}
//获取下载的文件名
url = HttpUtility.UrlDecode(url);
url = url.Replace("%2f", "/");
url = url.Replace("#", "%23");
string[] newurl = url.Split('?');
string szFilename = newurl[0].Substring(newurl[0].LastIndexOf('/') + 1);//简单处理文件名,实际中还需要单独处理,这里有BUG
//string SzFileName = HttpUtility.UrlDecode(szFilename);
string[] szName = szFilename.Split('/');
string fileTitle = szName[szName.Length - 1];
//设置文件存放路径
string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
if (!Directory.Exists(DownloadFileDirectory))
{
Directory.CreateDirectory(DownloadFileDirectory);
}
DownloadFileDirectory = string.Format("{0}\\{1}", DownloadFileDirectory, fileTitle);
FrmDownload frm = new FrmDownload(url, fileTitle, DownloadFileDirectory, true);
frm.isprompt = false;
if (frm.ShowDialog() == DialogResult.OK)
{
}
}
}
else
{
//执行SQL
#region 执行SQL语句
try
{
List pList = PubClass.GetParamValue(action);
string newSql = action;
for (int i = 0; i < pList.Count; i++)
{
string filedName = pList[i];
if (filedName == "{COLUMN_NAME}")
{
if (gc != null && gc.MainView is GridView)
{
newSql = newSql.Replace(filedName, (gc.MainView as GridView).FocusedColumn.FieldName);
}
}
if (filedName == "{COLUMN_TITLE}")
{
if (gc != null && gc.MainView is GridView)
{
newSql = newSql.Replace(filedName, (gc.MainView as GridView).FocusedColumn.GetTextCaption());
}
}
newSql = newSql.Replace("'" + pList[i] + "'", "@" + pList[i].Replace("{#", "").Replace("{", "").Replace("}", ""));
newSql = newSql.Replace(pList[i], "@" + pList[i].Replace("{", "").Replace("}", ""));
}
//string newSql = action.Replace("{", "@").Replace("}", "").Replace("'", "");
if (tl != null)
{
ArrayList parameters = new ArrayList();
for (int i = 0; i < pList.Count; i++)
{
string filedName = pList[i].Replace("{", "").Replace("}", "");
if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorName;
parameters.Add(param);
}
else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorId;
parameters.Add(param);
}
else if (filedName.IndexOf("#") >= 0)
{
string fName = filedName.Replace("#", "");
string value = "";
SqlParameter param = new SqlParameter(string.Format("{0}", fName.Replace("#", "")),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
Control[] c = MainPanel.Controls.Find("txt_" + fName, true);
if (c.Length > 0)
{
value = PubControl.GetControlText(c[0]);
}
param.Value = value;
parameters.Add(param);
}
else
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = rowData[filedName];
parameters.Add(param);
}
}
int result = SqlHelper.ExecuteNonQuery(CommandType.Text, newSql, (SqlParameter[])parameters.ToArray(typeof(SqlParameter)));
//XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (result > 0)
{
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
XtraMessageBox.Show("操作失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
if (gc != null)
{
//int[] rows = gv.GetSelectedRows();
//for (int j = 0; j < rows.Length; j++)
//{
//int index = rows[j];
ArrayList parameters = new ArrayList();
//DataRow row = gv.GetDataRow(index);
for (int i = 0; i < pList.Count; i++)
{
if (pList[i] == "{COLUMN_NAME}" || pList[i] == "{COLUMN_TITLE}") continue;
string filedName = pList[i].Replace("{", "").Replace("}", "");
if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorName;
parameters.Add(param);
}
else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorId;
parameters.Add(param);
}
else if (filedName.IndexOf("#") >= 0)
{
string fName = filedName.Replace("#", "");
string value = "";
SqlParameter param = new SqlParameter(string.Format("{0}", fName.Replace("#", "")),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
Control[] c = MainPanel.Controls.Find("txt_" + fName, true);
if (c.Length > 0)
{
value = PubControl.GetControlText(c[0]);
}
param.Value = value;
parameters.Add(param);
}
else
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = rowData[filedName];
parameters.Add(param);
}
}
int result = SqlHelper.ExecuteNonQuery(CommandType.Text, newSql, (SqlParameter[])parameters.ToArray(typeof(SqlParameter)));
//XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (result > 0)
{
if (msgHinted)
{
msgHinted = false;
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
XtraMessageBox.Show("操作失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
XtraMessageBox.Show("操作失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
if (gc != null)
{
Form f = GetForm(gc);
if (f != null)
{
Control[] ctr = f.Controls.Find("btnCondSearch", true);
if (ctr.Length > 0)
{
foreach (var item in ctr)
{
if (item is SimpleButton)
{
SimpleButton b = item as SimpleButton;
// 去掉全部刷新 改为按需求刷新数据
//b.PerformClick();
}
}
}
else
{
Sql = gc.Tag + "";
if (!string.IsNullOrEmpty(Sql))
{
if (!string.IsNullOrEmpty(Sql))
{
gc.DataSource = SqlHelper.ExecuteDataSet(Sql).Tables[0];
}
}
}
}
}
#endregion
}
if (gv != null)
{
// 多选刷新,执行到最后一条的时候才刷新
if ((multiRow && x == d_Rows.Length - 1) || !multiRow)
{
// 老版本刷新数据
if (internal_func != null)
internal_func(gv, DJH);
// 新增加刷新数据,避免改动以前功能增加
if (ifRefresh == 1 && OnGridMenuClickRefreshData != null)
OnGridMenuClickRefreshData(gv, null);
}
gv.FocusedRowHandle = oldRowHandle;
gv.SelectRow(oldRowHandle);
}
if (lv != null)
{
// 多选刷新,执行到最后一条的时候才刷新
if ((multiRow && x == d_Rows.Length - 1) || !multiRow)
{
// 老版本刷新数据
if (internal_func != null)
internal_func(lv, DJH);
// 新增加刷新数据,避免改动以前功能增加
if (ifRefresh == 1 && OnGridMenuClickRefreshData != null)
OnGridMenuClickRefreshData(lv, null);
}
}
if (grid != null) grid.refreshSearchLookUp();
}
}
///
/// 说明:验证附件是否下载完成
/// 创建人:姜棚
/// 创建日期:2018-06-06
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The file.
/// Name of the file.
/// System.String.
private string VerifyDownLoadFinish(string file, string fileName)
{
int i = 0;
while (i < 20)
{
try
{
if (File.Exists(file) && !PubClass.SearchProc("LSTest"))
{
string newFile = file;
if (fileName.Contains(".pdf"))
{
newFile = Lskj.Common.PubClass.CreateNewPdf(fileName, file);
}
return newFile;
}
Thread.Sleep(500);
}
catch (Exception ex)
{
throw;
}
i++;
}
return "";
}
protected void tsm_ClickChart(object sender, EventArgs e)
{
if (chart == null)
return;
if (chart.seriesPoint == null)
return;
string keyString = chart.seriesPoint.Argument + "";
string keyValue = chart.seriesPoint.Values[0] + "";
ToolStripMenuItem t = sender as ToolStripMenuItem;
DataRow dr_p = t.Tag as DataRow;
string action = dr_p["action"].ToString();
int actionType = Convert.ToInt32(dr_p["actiontype"]);
int ifRefresh = Convert.ToInt32(dr_p["ifRefresh"]);
string dllName = dr_p["dllname"].ToString();
string maxWindow = dr_p["maxWindow"] + "";
List valueList = new List();
valueList.Add(dr_p["dllpar1"].ToString() + "");
valueList.Add(dr_p["dllpar2"].ToString() + "");
valueList.Add(dr_p["dllpar3"].ToString() + "");
valueList.Add(dr_p["dllpar4"].ToString() + "");
valueList.Add(dr_p["dllpar5"].ToString() + "");
valueList.Add(dr_p["dllpar6"].ToString() + "");
valueList.Add(dr_p["dllpar7"].ToString() + "");
valueList.Add(dr_p["dllpar8"].ToString() + "");
valueList.Add(dr_p["dllpar9"].ToString() + "");
valueList.Add(dr_p["dllpar10"].ToString() + "");
string DJH = string.Empty;
//打开dll
if (actionType == 2)
{
#region 打开DLL
List paremList = new List();
foreach (string item in valueList)
{
string action_type = string.Empty;
if (item.Length > 0)
{
action_type = item.Substring(0, 1);
}
//解析sql
if (action_type == "@")
{
string sql = item.Replace("@", "");
sql = PubClass.ReqSqlParam(sql, OperatorId, OperatorName);
sql = sql.Replace("{key}", keyString);
sql = sql.Replace("{value}", keyValue);
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (action_type == "{")
{
string p = item.Replace("{key}", keyString).Replace("{value}", keyValue);
paremList.Add(p);
}
else if (item.Contains("{") && item.Contains("}"))
{
string str = item.Replace("{key}", keyString).Replace("{value}", keyValue);
paremList.Add(str);
}
else if (item.Contains("[FormTitle_"))
{
String str = item.Replace("[", "{").Replace("]", "}");
paremList.Add(str);
}
else if (action_type == "#")
{
string sql = item.Replace("#", "");
sql = sql.Replace("{key}", keyString).Replace("{value}", keyValue);
paremList.Add(sql);
}
else
{
paremList.Add(item);
}
}
if (dllName.ToLower() == "iexplore.exe")
{
//MessageBox.Show(paremList[0] + Uri.EscapeUriString(paremList[1]));
string url = paremList[0] + Uri.EscapeUriString(paremList[1]);
url = url.Replace("#", "%23");
System.Diagnostics.Process.Start("iexplore.exe", url);
}
else if (dllName == "Lskj.PhotoView.dll")
{
string[] str = {
FormText,
OperatorId,
OperatorName,
Privilege,
DLLCoid,
paremList[0],
paremList[1],
paremList[2],
paremList[3],
paremList[4],
paremList[5],
paremList[6],
paremList[7],
paremList[8],
paremList[9]
};
IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str);
if (maxWindow == "1")
form.SubForm.WindowState = FormWindowState.Maximized;
form.SubForm.ShowDialog();
}
else
{
string[] str = {
FormText,
OperatorId,
OperatorName,
Privilege,
DLLCoid,
paremList[0],
paremList[1],
paremList[2],
paremList[3],
paremList[4],
paremList[5],
paremList[6],
paremList[7],
paremList[8],
paremList[9]
};
IForm form = PubUtil.LoadDllForm(dllName, str);
form.SubForm.WindowState = maxWindow == "1" ? FormWindowState.Maximized : FormWindowState.Normal;
form.SubForm.StartPosition = FormStartPosition.CenterParent;
form.SubForm.ShowDialog();
}
#endregion
}//执行存储过程
else if (actionType == 1)
{
#region 执行存储过程
try
{
List paremList = new List();
ArrayList sqlParamList = new ArrayList();
foreach (string item in valueList)
{
//解析sql
if (item.IndexOf('@') != -1)
{
string sql = item.Replace("@", "");
sql = sql.Replace("{key}", keyString).Replace("{value}", keyValue);
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (item.IndexOf('{') != -1)
{
string p = item.Replace("{key}", keyString).Replace("{value}", keyValue); ;
List sqlpar = PubClass.GetParamValue(item);
foreach (string s in sqlpar)
{
string filedName = s.Replace("{", "").Replace("}", "");
if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase))
{
p = p.Replace(s, OperatorName);
}
else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase))
{
p = p.Replace(s, OperatorId);
}
else
{
}
}
paremList.Add(p);
}
else
{
paremList.Add(item);
}
}
List paramName = PubClass.GetParamValue(action);
string[] paramStr = paramName[0].Replace("{", "").Replace("}", "").Split(',');
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
//for (int i = 0; i < paremList.Count; i++)
//{
// string item = paremList[i];
// if (!string.IsNullOrEmpty(item))
// {
// if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
// {
// pMsg.Direction = ParameterDirection.Output;
// pMsg.Value = "";
// sqlParamList.Add(pMsg);
// }
// else
// {
// string paramStr1 = paramStr[i];
// SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
// DbTypeConverter.ConvertToSql(FieldType.VarChar));
// param.Value = item;
// sqlParamList.Add(param);
// }
// }
//}
for (int i = 0; i < paramStr.Length; i++)
{
string item = paremList[i];
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
{
pMsg.Direction = ParameterDirection.InputOutput;
pMsg.Value = "";
sqlParamList.Add(pMsg);
}
else
{
string paramStr1 = paramStr[i];
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.Value = item;
sqlParamList.Add(param);
}
}
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
sqlParamList.Add(returnValue);
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, action.Replace(paramName[0], "").Trim(), (SqlParameter[])sqlParamList.ToArray(typeof(SqlParameter)));
if (Convert.ToInt32(returnValue.Value) == -1)
{
XtraMessageBox.Show("操作失败\n" + pMsg.Value, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
if (Convert.ToInt32(returnValue.Value) == 9999)
{
XtraMessageBox.Show(pMsg.Value + "", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (Convert.ToInt32(returnValue.Value) == 99)
{
//对话框输入
ComfirmDialog.ComfirmDialog cfd = new ComfirmDialog.ComfirmDialog(pMsg.Value + "");
DialogResult result = cfd.ShowDialog();
if (result == DialogResult.Cancel)
return;
string hintMsg = cfd.ComfirmMsg;
sqlParamList.Clear();
for (int i = 0; i < paramStr.Length; i++)
{
string item = paremList[i];
if (paramStr[i].Equals("@msg", StringComparison.OrdinalIgnoreCase))
{
pMsg.Direction = ParameterDirection.InputOutput;
pMsg.Value = hintMsg;
sqlParamList.Add(pMsg);
}
else
{
string paramStr1 = paramStr[i];
SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.Value = item;
sqlParamList.Add(param);
}
}
SqlParameter returnValue1 = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue1.Direction = ParameterDirection.ReturnValue;
sqlParamList.Add(returnValue1);
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, action.Replace(paramName[0], "").Trim(), (SqlParameter[])sqlParamList.ToArray(typeof(SqlParameter)));
if (Convert.ToInt32(returnValue1.Value) == -1)
{
XtraMessageBox.Show("操作失败\n" + pMsg.Value, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
DJH = pMsg.Value.ToString().Trim();
}
}
catch (Exception ex)
{
XtraMessageBox.Show("操作失败\n" + ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
Sql = gc.Tag + "";
if (gc.Parent != null && gc.Parent.Parent != null)
{
btnCtr = gc.Parent.Parent;
}
if (btnCtr != null)
{
Control[] ctr = btnCtr.Controls.Find("btnCondSearch", true);
if (ctr != null && ctr.Length > 0)
{
if (ctr[0] is SimpleButton)
{
SimpleButton btn = ctr[0] as SimpleButton;
btn.PerformClick();
}
}
else
{
if (!string.IsNullOrEmpty(Sql))
{
gc.DataSource = SqlHelper.ExecuteDataSet(Sql).Tables[0];
}
}
}
#endregion
}//调用delphi
else if (actionType == 3)
{
List paremList = new List();
foreach (string item in valueList)
{
string action_type = string.Empty;
if (item.Length > 0)
{
action_type = item.Substring(0, 1);
}
if (action_type == "@")
{
//解析sql
string sql = item.Replace("@", "").Replace("{key}", keyString).Replace("{value}", keyValue);
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (action_type == "{")
{
string p = item.Replace("{key}", keyString).Replace("{value}", keyValue); ;
paremList.Add(p + "");
}
else if (action_type == "#")
{
string sql = item.Replace("#", "").Replace("@", "").Replace("{key}", keyString).Replace("{value}", keyValue);
paremList.Add(sql);
}
else
{
string sql = item.Replace("{key}", keyString).Replace("{value}", keyValue);
paremList.Add(sql);
}
}
PubUtil.LoadDelphiDll(dllName, paremList[0], paremList[1], paremList[2], paremList[3], Convert.ToInt32(paremList[4]), paremList[5]);
}
else
{
//执行SQL
#region 执行SQL语句
try
{
List pList = PubClass.GetParamValue(action);
string newSql = action;
for (int i = 0; i < pList.Count; i++)
{
newSql = newSql.Replace("'" + pList[i] + "'", "@" + pList[i].Replace("{#", "").Replace("{", "").Replace("}", ""));
newSql = newSql.Replace(pList[i], "@" + pList[i].Replace("{", "").Replace("}", ""));
}
if (chart != null)
{
ArrayList parameters = new ArrayList();
for (int i = 0; i < pList.Count; i++)
{
string filedName = pList[i].Replace("{", "").Replace("}", "");
if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorName;
parameters.Add(param);
}
else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase))
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = OperatorId;
parameters.Add(param);
}
else if (filedName.IndexOf("#") >= 0)
{
string fName = filedName.Replace("#", "");
string value = "";
SqlParameter param = new SqlParameter(string.Format("{0}", fName.Replace("#", "")),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
Control[] c = MainPanel.Controls.Find("txt_" + fName, true);
if (c.Length > 0)
{
value = PubControl.GetControlText(c[0]);
}
param.Value = value;
parameters.Add(param);
}
else
{
SqlParameter param = new SqlParameter(string.Format("{0}", filedName),
DbTypeConverter.ConvertToSql(FieldType.VarChar));
param.IsNullable = true;
param.Value = filedName.ToLower() == "key" ? keyString : keyValue;
parameters.Add(param);
}
}
int result = SqlHelper.ExecuteNonQuery(CommandType.Text, newSql, (SqlParameter[])parameters.ToArray(typeof(SqlParameter)));
XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
catch (Exception ex)
{
XtraMessageBox.Show("操作失败!\n" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
#endregion
}
}
private Form GetForm(Control ctr)
{
if (ctr is Form)
{
return ctr as Form;
}
else
{
return GetForm(ctr.Parent);
}
}
///
/// 获取选中行数据(包括gridView和TreeView)
///
///
private DataRow[] GetSelectRow()
{
DataRow[] rows = null;
if (gc != null)
{
if (gc.MainView is GridView)
{
GridView gridView = (gc.MainView as GridView);
if ((gridView.GetSelectedRows() == null) || (gridView.GetSelectedRows().Length < 1))
return null;
int[] iRows = gridView.GetSelectedRows();
rows = new DataRow[iRows.Length];
for (int i = 0; i < iRows.Length; i++)
{
rows[i] = gridView.GetDataRow(iRows[i]);
}
return rows;
}
else if (gc.MainView is LayoutView)
{
LayoutView layoutView = (gc.MainView as LayoutView);
if ((layoutView.GetSelectedRows() == null) || (layoutView.GetSelectedRows().Length < 1))
return null;
int[] iRows = layoutView.GetSelectedRows();
rows = new DataRow[iRows.Length];
for (int i = 0; i < iRows.Length; i++)
{
rows[i] = layoutView.GetDataRow(iRows[i]);
}
return rows;
}
}
else if (tl != null)
{
DataRowView rowView = tl.GetDataRecordByNode(tl.FocusedNode) as DataRowView;
return rowView != null ? new DataRow[] { rowView.Row } : null;
}
return rows;
}
///
/// 获取多选中行数据(包括gridView和TreeView)
///
///
private DataRow[] GetMultipleSelectRow()
{
DataRow[] rows = null;
if (gc != null)
{
if (gc.MainView is GridView)
{
GridView gridView = (gc.MainView as GridView);
if ((gridView.GetSelectedRows() == null) || (gridView.GetSelectedRows().Length < 1))
return null;
DataTable selectTable = (DataTable)gc.DataSource;
if (selectTable.Columns.Contains("selectflag"))
{
DataRow[] iRows = selectTable.Select("selectflag=" + true);
rows = new DataRow[iRows.Length];
for (int i = 0; i < iRows.Length; i++)
{
rows[i] = iRows[i];
}
return rows;
}
else
{
int[] selectrows = gridView.GetSelectedRows();
DataRow[] dataRows = new DataRow[selectrows.Length];
for (int i = 0; i < selectrows.Length; i++)
{
dataRows[i] = gridView.GetDataRow(selectrows[i]);
}
return dataRows;
}
}
else if (gc.MainView is LayoutView)
{
LayoutView layoutView = (gc.MainView as LayoutView);
if ((layoutView.GetSelectedRows() == null) || (layoutView.GetSelectedRows().Length < 1))
return null;
int[] iRows = layoutView.GetSelectedRows();
rows = new DataRow[iRows.Length];
for (int i = 0; i < iRows.Length; i++)
{
rows[i] = layoutView.GetDataRow(iRows[i]);
}
return rows;
}
}
else if (tl != null)
{
DataRowView rowView = tl.GetDataRecordByNode(tl.FocusedNode) as DataRowView;
return rowView != null ? new DataRow[] { rowView.Row } : null;
}
return rows;
}
///
/// 说明:附件操作之前调用
/// 创建人:龚宇超
/// 创建日期:2017-09-28
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// 1=上传,2=下载,3=删除,4=锁定,5=解除锁定 必填
/// The user identifier.
/// Name of the user.
/// The file specis no.
/// The filename.
/// The filesize.
/// true if XXXX, false otherwise.
private bool AttachOperation(int operType, int userId, string userName, string fileSpecisNo, int fileid, string filename, int filesize)
{
try
{
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
pMsg.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
SqlParameter[] param =
{
new SqlParameter("@opertype",SqlDbType.Int),
new SqlParameter("@operatorid",SqlDbType.Int),
new SqlParameter("@operatorname",SqlDbType.VarChar,50),
new SqlParameter("@fileSpecisNo",SqlDbType.VarChar,50),
new SqlParameter("@fileid",SqlDbType.Int),
new SqlParameter("@filename",SqlDbType.VarChar,200),
new SqlParameter("@filesize",SqlDbType.Int),
pMsg,
returnValue
};
param[0].Value = operType;
param[1].Value = userId;
param[2].Value = userName;
param[3].Value = fileSpecisNo;
param[4].Value = fileid;
param[5].Value = filename;
param[6].Value = filesize;
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_SystemAttachOperation", "attach", param);
string msg = pMsg.Value.ToString();
int rVaule = Convert.ToInt32(returnValue.Value + "");
if (rVaule != 1)
{
MessageBox.Show(msg);
}
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return true;
}
}
}