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.

142 lines
6.1 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Action.Base;
using Mesnac.Controls.Base;
using System.Windows.Forms;
namespace Mesnac.Action.Intake.Qingquan.MaterialManager
{
public class UpdateMaterial : IntakeAction, IAction
{
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime);
List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Modify);//获取所有待初始化控件
//Label objID = base.GetControlById("lblObjID") as Label;
DbMCControl objID = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pmt_material].[objid]").FirstOrDefault();
if (objID == null)
{
ICSharpCode.Core.LoggingService.Warn("缺少物料ObjID控件!");
MessageBox.Show("缺少物料ObjID控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true;
return;
}
if (objID.BaseControl.MCValue.ToString().Trim() == "")
{
MessageBox.Show("请选择要修改的物料!", "提示", MessageBoxButtons.OK);
runtime.IsReturn = true;
return;
}
//TextBox Mater_ID = base.GetControlById("txtMater_ID") as TextBox;
TextBox Mater_Code = base.GetControlById("MCTextBox1") as TextBox;
TextBox Mater_Name = base.GetControlById("MCTextBox2") as TextBox;
TextBox Mater_Bycode = base.GetControlById("MCTextBox3") as TextBox;
//if (Mater_ID == null)
//{
// ICSharpCode.Core.LoggingService.Warn("缺少物料ID输入控件!");
// MessageBox.Show("输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
// runtime.IsReturn = true;
// return;
//}
//if (Mater_ID.Text == "")
//{
// MessageBox.Show("请输入物料ID", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
// Mater_ID.Focus();
// runtime.IsReturn = true;
// return;
//}
if (Mater_Code == null)
{
ICSharpCode.Core.LoggingService.Warn("缺少物料编码输入控件!");
MessageBox.Show("缺少物料编码输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true;
return;
}
if (Mater_Code.Text == "")
{
MessageBox.Show("请输入物料编码!", "提示", MessageBoxButtons.OK);
Mater_Code.Focus();
runtime.IsReturn = true;
return;
}
if (Mater_Name == null)
{
ICSharpCode.Core.LoggingService.Warn("缺少物料名称输入控件!");
MessageBox.Show("缺少物料名称输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true;
return;
}
if (Mater_Name.Text == "")
{
MessageBox.Show("请输入物料名称!", "提示", MessageBoxButtons.OK);
Mater_Name.Focus();
runtime.IsReturn = true;
return;
}
if (Mater_Bycode == null)
{
ICSharpCode.Core.LoggingService.Warn("缺少物料别名输入控件!");
MessageBox.Show("缺少物料别名输入控件!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true;
return;
}
if (Mater_Bycode.Text == "")
{
MessageBox.Show("请输入物料别名!", "提示", MessageBoxButtons.OK);
Mater_Bycode.Focus();
runtime.IsReturn = true;
return;
}
string materCode = String.Empty;
string materName = String.Empty;
string materByCode = string.Empty;
if (Mater_Code.Text.Trim() != "")
{
materCode = Mater_Code.Text.Trim();
}
if (Mater_Name.Text.Trim() != "")
{
materName = Mater_Name.Text.Trim().ToString();
}
if (Mater_Bycode.Text.Trim() != "")
{
materByCode = Mater_Bycode.Text.Trim();
}
int flag=Material.IsUpdateMaterByObjId(objID.BaseControl.MCValue.ToString(),materCode,materByCode,materName);
if(flag==1)
{
//【物料编码】已存在,请输入一个不存在的物料编码!
MessageBox.Show(Language(290), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true; //终止执行
return;
}
else if (flag == 2)
{
//【物料名称】已存在,请输入一个不存在的物料名称!
MessageBox.Show(Language(291), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true; //终止执行
return;
}
else if (flag == 3)
{
//【物料别名】已存在,请输入一个不存在的物料别名!
MessageBox.Show("【物料别名】已存在,请输入一个不存在的物料别名!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true; //终止执行
return;
}
else if (flag == 4)
{
//【物料别名】已存在,请输入一个不存在的物料名称!
MessageBox.Show("数据异常!", Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
runtime.IsReturn = true; //终止执行
return;
}
}
}
}