You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

143 lines
5.2 KiB
C#

1 year ago
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Entity;
using Mesnac.Action.ChemicalWeighing.Product.PptPlan;
using Mesnac.Codd.Session;
using Mesnac.Controls.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.Alarm.PmtAlarm
{
class ModifyAction : ChemicalWeighingAction, IAction
{
private string caption = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_Caption")); //提示
private DbMCControl _clientGridControl = null;
private RuntimeParameter _runtime;
public static event EventHandler OnModifyRefresh;
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
this._runtime = runtime;
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_SynchroData_Update_msg1")); //您确认要修改当前信息吗?
if (MessageBox.Show(msg1, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
{
return;
}
base.RunIni(runtime); //必须调用
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Alarm").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<ModifyAction>.Error("{预警管理—添加预警}缺少预警管理控件...");
return;
}
this._clientGridControl = clientGridControl;
DataGridView alarmGridView = this._clientGridControl.BaseControl as DataGridView;
if (alarmGridView.SelectedRows.Count != 1)
{
string msg1_1 = StringParser.Parse("请选择一行要修改的数据"); //请选择一条要修改计划数的计划!
MessageBox.Show(msg1_1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
var selectID = alarmGridView.SelectedRows[0].Cells["ID"].Value.ToString();
var entity= AlarmHelper.GetAlarmInfoEntity(selectID);
FrmInsert frmInsert = new FrmInsert(ActionType.Modify, entity);
frmInsert.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
if (frmInsert.DialogResult == DialogResult.OK)
{
PmtAlarmInfo info = new PmtAlarmInfo();
info.ID =int.Parse(selectID);
info.AlarmPLC = frmInsert.AlarmPLC;
info.AlarmBlock = frmInsert.AlarmBlock;
info.AlarmAlias = frmInsert.Alarm_Alias;
info.Alarm_Cn_Info = frmInsert.Alarm_Cn_Info;
AlarmHelper.UpdateAlarmData(info);
string msg3 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_Default_SynchroData_Update_msg3")); //信息修改成功!
ShowMsg(msg3);
#region 记录操作日志
base.DBLog(msg3);
#endregion
}
if (OnModifyRefresh != null)
{
OnModifyRefresh(runtime, System.EventArgs.Empty);
}
}
}
public class LastActionRow : DatabaseAction
{
public LastActionRow(RuntimeParameter runtime, DbMCSource dbsource)
{
base.RunIni(runtime);
List<DbMCControl> lstDbMCControl = GetAllDbMCControls();
foreach (DbMCControl dbgrid in lstDbMCControl)
{
if (dbgrid.DbMCSource == null ||
dbgrid.DbMCSource.DbMCKey != dbsource.DbMCKey ||
(dbgrid.BaseControl as DataGridView) == null)
{
continue;
}
DataGridView grid = dbgrid.BaseControl as DataGridView;
if (grid.SelectedRows.Count > 0)
{
this.Index = grid.SelectedRows[0].Index;
}
else
{
this.Index = grid.SelectedRows[0].Index;
}
}
}
public LastActionRow(RuntimeParameter runtime)
{
base.RunIni(runtime);
}
public int Index
{
get
{
int iResult = 0;
IBaseControl control = this.GetMCControlByKey("SelectRowIndexControl").FirstOrDefault();
if (control != null)
{
int.TryParse(control.MCValue.ToString(), out iResult);
}
return iResult;
}
private set
{
IBaseControl control = this.GetMCControlByKey("SelectRowIndexControl").FirstOrDefault();
if (control != null)
{
control.MCValue = value.ToString();
}
}
}
}
}