|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Action.ChemicalWeighing.DBHelper;
|
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
|
using Mesnac.Controls.Base;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Report.BinReport
|
|
|
{
|
|
|
/// <summary>
|
|
|
///料仓库存警告报表
|
|
|
/// </summary>
|
|
|
class InitFormAction : ChemicalWeighingAction, IAction
|
|
|
{
|
|
|
private DbMCControl _dg = null;
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime); //必须要调用的
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Debug("仓库报警报表-窗体初始化...");
|
|
|
|
|
|
this._dg = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Bin").FirstOrDefault();
|
|
|
if (_dg == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<BinAlarmAction>.Warn("{仓库报警报表} 缺少控件...");
|
|
|
runtime.IsReturn = false;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
IFreeSql fsql = FreeHelper.Instance;
|
|
|
string sql = @"select Bin_Serial,Bin_Name,Material_ID,x.Material_name,LimitWeight,BinWeight,ISNULL(e.OutWeight,0.00) OutWeight,ISNULL(o.EnterWeight,0.00) EnterWeight from Pmt_Bin b left join xl_material x on b.Material_ID=x.ID
|
|
|
left join (
|
|
|
select distinct BinId,BinName,MaterialCode,MaterialName,ISNULL(SUM(Weights),0.00) as OutWeight,TypeName from Hw_BinAlarm where TypeName='出库' group by BinId,BinName,MaterialCode,MaterialName,Weights,TypeName
|
|
|
) e on b.Bin_Serial=e.BinId
|
|
|
left join (
|
|
|
select distinct BinId,BinName,MaterialCode,MaterialName,ISNULL(SUM(Weights),0.00) as EnterWeight,TypeName from Hw_BinAlarm where TypeName='入库' group by BinId,BinName,MaterialCode,MaterialName,Weights,TypeName
|
|
|
) o on b.Bin_Serial=o.BinId";
|
|
|
|
|
|
DataTable dt1 = fsql.Select<object>().WithSql(sql).ToDataTable("*");
|
|
|
|
|
|
_dg.BaseControl.BindDataSource = null;
|
|
|
_dg.BaseControl.BindDataSource = dt1;
|
|
|
|
|
|
#region 根据状态处理背景色
|
|
|
|
|
|
DataGridView clientGrid = this._dg.BaseControl as DataGridView;
|
|
|
SetBackColor(clientGrid);
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
#region 设置(网格控件)计划状态背景色
|
|
|
/// <summary>
|
|
|
/// 设置计划状态背景色
|
|
|
/// </summary>
|
|
|
/// <param name="grid"></param>
|
|
|
public static void SetBackColor(DataGridView grid)
|
|
|
{
|
|
|
lock (String.Empty)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
if (grid == null || grid.Visible == false)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService.Warn("设置料仓报警背景色失败:网格控件为null或不可见");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
grid.ClearSelection(); //清空选中行
|
|
|
grid.ColumnHeadersHeight = 25;
|
|
|
grid.ColumnHeadersDefaultCellStyle.Font = new System.Drawing.Font("宋体", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
|
|
grid.RowHeadersVisible = false;
|
|
|
grid.RowTemplate.Height = 28;
|
|
|
grid.RowsDefaultCellStyle.Font = new System.Drawing.Font("宋体", 12, System.Drawing.FontStyle.Bold);
|
|
|
foreach (DataGridViewRow row in grid.Rows)
|
|
|
{
|
|
|
decimal limitWeight = Convert.ToDecimal(row.Cells["LimitWeight"].Value.ToString());
|
|
|
decimal binWeight = Convert.ToDecimal(row.Cells["BinWeight"].Value.ToString());
|
|
|
if (limitWeight > binWeight)
|
|
|
{
|
|
|
row.DefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(255, 0, 0); //灰色
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("设置料仓报警背景色失败:" + ex.Message);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|