基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,388 @@
|
||||
using Lskj.Business;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Control;
|
||||
using Lskj.Core;
|
||||
using Lskj.Data;
|
||||
using Lskj.Main.Model;
|
||||
using Lskj.Model;
|
||||
using Lskj.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Lskj.Main
|
||||
{
|
||||
public partial class FrmMessages : Form
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础档案审批配置对象
|
||||
/// </summary>
|
||||
public BaseAccraditationModel BaseAuditModelObj;
|
||||
//切换图片的标识
|
||||
private bool iconFlag = false;
|
||||
//是否在朗速里打开
|
||||
private bool isLsERP = false;
|
||||
public string cacheText = string.Empty;
|
||||
public DataRow mSelectRow = null;
|
||||
public bool isFinish;//是否已经完成
|
||||
public DataTable cacheDt;//缓存上一次查询到的审核消息
|
||||
public string sql = string.Format("select '['+typeName+']'+'=>>'+keyvalue+'单子需要你审核' as AuditMessages,* from wms_billflowOperView where CHARINDEX(',{0},',',' + browsers + ',')>0", ERPInfo.Instance.UserName);
|
||||
public FrmMessages()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializationMessages();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置托盘显示的图标
|
||||
/// </summary>
|
||||
/// <param name="index">图像列表中图片的索引</param>
|
||||
private void setIconImg(int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
Image img = this.imgIcon.Images[index];
|
||||
Bitmap b = new Bitmap(img);
|
||||
Icon icon = Icon.FromHandle(b.GetHicon());
|
||||
this.notifyIcon1.Icon = icon;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 10秒刷新数据源更新消息
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void Information_timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable newDt = SqlHelper.ExecuteDataTable(sql);
|
||||
////获取两个数据源的差集
|
||||
IEnumerable<DataRow> QCJ = newDt.AsEnumerable().Except(cacheDt.AsEnumerable(), DataRowComparer.Default);
|
||||
////两个数据源的差集集合
|
||||
int num = QCJ.Count<DataRow>();
|
||||
if (isFinish && num > 0)
|
||||
{
|
||||
|
||||
this.MessageTable.DataSource = cacheDt = newDt;
|
||||
this.Text = cacheText + string.Format("(您有{0}条数据需要审批)", cacheDt.Rows.Count);
|
||||
//还原窗体显示
|
||||
WindowState = FormWindowState.Normal;
|
||||
//任务栏区显示图标
|
||||
this.ShowInTaskbar = true;
|
||||
//托盘区图标隐藏
|
||||
notifyIcon1.Visible = false;
|
||||
this.Opacity = 100D;
|
||||
isFinish = false;
|
||||
timer2.Enabled = true;//如果鼠标在弹出窗上的时候,timer2开始工作
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
if (MessageUtil.Show("检测到网络异常\r\n是否重启信息平台?", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.notifyIcon1.Dispose();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show("删除失败:\r\n" + ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.notifyIcon1.Dispose();
|
||||
this.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 最小化工共方法
|
||||
/// </summary>
|
||||
public void Minimized()
|
||||
{
|
||||
this.WindowState = FormWindowState.Minimized;
|
||||
//图标显示在托盘区
|
||||
notifyIcon1.Visible = true;
|
||||
this.setIconImg(0);
|
||||
this.isFinish = true;
|
||||
//this.ShowInTaskbar = false;
|
||||
}
|
||||
public void InitializationMessages()
|
||||
{
|
||||
cacheDt = SqlHelper.ExecuteDataTable(sql);//缓存上次加载的数据源
|
||||
cacheText = this.Text;
|
||||
this.notifyIcon1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseClick);
|
||||
|
||||
this.gridView.DoubleClick += new EventHandler(OnGridViewDoubleClick);
|
||||
this.MessageTable.DataSource = cacheDt;
|
||||
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width - this.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
||||
this.PointToScreen(p);
|
||||
this.TopMost = true;
|
||||
this.Location = p;
|
||||
for (int i = 0; i <= this.Height; i++)
|
||||
{
|
||||
Application.DoEvents();
|
||||
this.Location = new Point(p.X, p.Y - i);
|
||||
if (i == this.Height)
|
||||
{
|
||||
timer1.Start();
|
||||
timer2.Start();
|
||||
timer3.Start();
|
||||
}
|
||||
}
|
||||
if (Manager.skipMenus || cacheDt.Rows.Count == 0)
|
||||
{
|
||||
this.Opacity = 0;
|
||||
timer2.Enabled=false;
|
||||
}
|
||||
this.Text = cacheText + string.Format("(您有{0}条数据需要审批)", cacheDt.Rows.Count);
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:表格双击打开模块配置</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2018-08-13 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
protected void OnGridViewDoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
mSelectRow = this.gridView.GetFocusedDataRow();
|
||||
if (mSelectRow == null) return;
|
||||
if ((mSelectRow["tagid"] + "").Equals("1"))
|
||||
{
|
||||
OpenAccraditation();
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenBaseAccraditation();
|
||||
}
|
||||
DataTable dt = this.MessageTable.DataSource as DataTable;
|
||||
this.Text = cacheText + string.Format("(您有{0}条数据需要审批)", dt.Rows.Count);
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开单据模块审批
|
||||
/// </summary>
|
||||
public void OpenAccraditation()
|
||||
{
|
||||
try
|
||||
{
|
||||
//单据审批弹出模块
|
||||
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, mSelectRow["typeName"] + "", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, 1, mSelectRow["modid"] + "").Split('~');
|
||||
//模块Id/stepcode/点击数据键值/权限
|
||||
string[] menuArgs = { "0", mSelectRow["modid"] + "", mSelectRow["stepcode"] + "", mSelectRow["keyvalue"] + "", "0", "0" };
|
||||
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
||||
IForm form = FormHelper.LoadDllForm(ResourceDynamic.PubAccraditation, args);
|
||||
Application.DoEvents();
|
||||
this.TopMost = false;
|
||||
timer1.Enabled = false;
|
||||
timer2.Enabled = false;
|
||||
DialogResult result = form.SubForm.ShowDialog();
|
||||
if (result == DialogResult.OK || result == DialogResult.Cancel)
|
||||
{
|
||||
this.MessageTable.DataSource = SqlHelper.ExecuteDataTable(sql);
|
||||
this.TopMost = true;
|
||||
timer1.Start();
|
||||
timer2.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteError("单据审批模块弹出模块出错!", ex);
|
||||
MessageUtil.Show("单据审批模块弹出模块出错!" + ex);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 打开基础模块审批
|
||||
/// </summary>
|
||||
public void OpenBaseAccraditation()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.BaseAuditModelObj = new BaseAccraditationModel(MainImpl.GetSystemdllTab(mSelectRow["modid"] + ""));
|
||||
//单据审批弹出模块
|
||||
string[] defaultArgs = string.Format(ModuleArgs.DefaultArgs, mSelectRow["typeName"] + "", ERPInfo.Instance.UserId, ERPInfo.Instance.UserName, 1, mSelectRow["modid"] + "").Split('~');
|
||||
//模块Id/stepcode/点击数据键值/权限
|
||||
string[] menuArgs = { "0", mSelectRow["modid"] + "", mSelectRow["stepcode"] + "", mSelectRow["keyvalue"] + "", "0", "0" };
|
||||
string[] args = defaultArgs.Concat(menuArgs).ToArray();
|
||||
IForm form = FormHelper.LoadDllForm(ResourceDynamic.BaseAccraditation, args);
|
||||
Application.DoEvents();
|
||||
this.TopMost = false;
|
||||
timer1.Enabled = false;
|
||||
timer2.Enabled = false;
|
||||
DialogResult result = form.SubForm.ShowDialog();
|
||||
if (result == DialogResult.OK || result == DialogResult.Cancel)
|
||||
{
|
||||
this.MessageTable.DataSource = SqlHelper.ExecuteDataTable(sql);
|
||||
this.TopMost = true;
|
||||
timer1.Start();
|
||||
timer2.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogUtil.WriteError("基础审批模块弹出模块出错!", ex);
|
||||
MessageUtil.Show("基础审批模块弹出模块出错!" + ex);
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 10秒不操作隐藏窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
timer2.Enabled = false;//停止timer2计时器,
|
||||
if (this.Opacity > 0 && this.Opacity <= 1)//开始执行弹出窗渐渐透明
|
||||
{
|
||||
this.Opacity = this.Opacity - 0.1;//透明频度
|
||||
}
|
||||
if (System.Windows.Forms.Control.MousePosition.X >= this.Location.X && System.Windows.Forms.Control.MousePosition.Y >= this.Location.Y)//每次都判断鼠标是否是在弹出窗上,使用鼠标在屏幕上的坐标跟弹出窗体的屏幕坐标做比较。
|
||||
{
|
||||
timer2.Enabled = true;//如果鼠标在弹出窗上的时候,timer2开始工作
|
||||
timer1.Enabled = false;//timer1停止工作。
|
||||
}
|
||||
if (this.Opacity == 0)//当透明度==0的时候,关闭弹出窗以释放资源。
|
||||
{
|
||||
Minimized();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 判断鼠标是不是还在弹出框上,如果不是则timer1又可以开始工作了
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void timer2_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
timer1.Enabled = false;//timer1停止工作
|
||||
this.Opacity = 1;//弹出窗透明度设置为1,完全不透明
|
||||
if (System.Windows.Forms.Control.MousePosition.X < this.Location.X && System.Windows.Forms.Control.MousePosition.Y < this.Location.Y)//如下
|
||||
{
|
||||
timer1.Enabled = true;
|
||||
timer2.Enabled = false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否最小化,然后显示托盘
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void F_Main_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
//判断是否选择的是最小化按钮
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
//图标显示在托盘区
|
||||
notifyIcon1.Visible = true;
|
||||
this.setIconImg(0);
|
||||
this.isFinish = true;
|
||||
this.ShowInTaskbar = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加双击托盘图标事件(双击显示窗口)
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (WindowState == FormWindowState.Minimized && e.Button == MouseButtons.Left)
|
||||
{
|
||||
//还原窗体显示
|
||||
WindowState = FormWindowState.Normal;
|
||||
//任务栏区显示图标
|
||||
this.ShowInTaskbar = true;
|
||||
//托盘区图标隐藏
|
||||
notifyIcon1.Visible = false;
|
||||
this.Opacity = 100D;
|
||||
isFinish = false;
|
||||
timer2.Enabled = true;//如果鼠标在弹出窗上的时候,timer2开始工作
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 点击右上角关闭判断
|
||||
/// </summary>
|
||||
/// <param name="msg"></param>
|
||||
protected override void WndProc(ref Message msg)
|
||||
{
|
||||
const int WM_SYSCOMMAND = 0x0112;
|
||||
const int SC_CLOSE = 0xF060;
|
||||
|
||||
if (msg.Msg == WM_SYSCOMMAND && ((int)msg.WParam == SC_CLOSE))
|
||||
{
|
||||
Minimized();
|
||||
}
|
||||
base.WndProc(ref msg);
|
||||
}
|
||||
/// <summary>
|
||||
/// 退出事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.notifyIcon1.Dispose();
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void timer3_Tick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
DataTable dt = this.MessageTable.DataSource as DataTable;
|
||||
if (WindowState == FormWindowState.Minimized)
|
||||
{
|
||||
|
||||
if (dt.Rows.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (iconFlag)
|
||||
{
|
||||
this.setIconImg(0);
|
||||
iconFlag = !iconFlag;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setIconImg(1);
|
||||
iconFlag = !iconFlag;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
this.notifyIcon1.Dispose();
|
||||
this.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user