/*******************************************************************************
* Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
* 类的信息:
* 1.程序名称:F_PC_0204.cs
* 2.功能描述:生产线基本信息
* 编辑履历:
* 作者 日期 版本 修改内容
* 王鑫 2015/03/27 1.00 新建
*******************************************************************************/
using System;
using System.Windows.Forms;
using Dongke.IBOSS.PRD.Basics.BaseControls;
using Dongke.IBOSS.PRD.Basics.BaseResources;
using Dongke.IBOSS.PRD.Client.CommonModule;
using Dongke.IBOSS.PRD.WCF.DataModels;
using Dongke.IBOSS.PRD.WCF.Proxys;
using Dongke.IBOSS.PRD.WCF.Proxys.PCModuleService;
namespace Dongke.IBOSS.PRD.Client.PCModule
{
///
/// 生产线基本信息
///
public partial class F_PC_0204 : FormBase
{
#region 成员变量
private int _lineID = -1; //生产线ID
private string _lineCode; //生产线编码
private string _lineName; //生产线名称
private string _remarks; //备注
private int _valueflag; //启用、禁用标记
private Constant.FormMode _editStatus; //窗体编辑状态
#endregion 成员变量
#region 构造函数
///
/// 生产线基本信息
///
public F_PC_0204()
{
InitializeComponent();
// 窗体标题
this.Text = FormTitles.F_PC_0201;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CLOSE;
}
///
/// 生产线基本信息
///
public F_PC_0204(Constant.FormMode editStatus, int lineID, string lineCode, string lineName, string remarks, int valueflag)
{
InitializeComponent();
this._editStatus = editStatus;
// 窗体标题
this.Text = FormTitles.F_PC_0201;
this.btnSave.Text = ButtonText.BTN_SAVE;
this.btnCancel.Text = ButtonText.BTN_CANCEL;
this._lineID = lineID;
this.txtLineCode.Text = lineCode;
this.txtLineName.Text = lineName;
this.txtRemarks.Text = remarks;
this.chkValueFlag.Checked = Convert.ToBoolean(valueflag);
}
#endregion 构造函数
#region 属性
///
/// 生产线ID
///
public int LineID
{
set
{
_lineID = value;
}
get
{
return _lineID;
}
}
///
/// 生产线编码
///
public string LineCode
{
set
{
_lineCode = value;
}
get
{
return _lineCode;
}
}
///
/// 生产线名称
///
public string LineName
{
set
{
_lineName = value;
}
get
{
return _lineName;
}
}
///
/// 备注
///
public string Remarks
{
set
{
_remarks = value;
}
get
{
return _remarks;
}
}
///
/// 启用、禁用标记
///
public int ValueFlag
{
set
{
_valueflag = value;
}
get
{
return _valueflag;
}
}
#endregion 属性
#region 事件处理
///
/// 画面加载
///
///
///
private void F_PC_0204_Load(object sender, System.EventArgs e)
{
}
///
/// 保存按钮事件
///
///
///
private void btnSave_Click(object sender, System.EventArgs e)
{
try
{
if (!this.CheckInputValidity())
{
return;
}
this.LineCode = this.txtLineCode.Text.Trim();
this.LineName = this.txtLineName.Text.Trim();
this.Remarks = this.txtRemarks.Text.Trim();
this.ValueFlag = Convert.ToInt32(chkValueFlag.Checked);
this.LineID = this._lineID;
if (this._editStatus == Constant.FormMode.Edit)//编辑只更新生产线信息
{
ProductionLineEntity entity = new ProductionLineEntity();
entity.ProductionLineID = this._lineID;
entity.ProductionLineCode = txtLineCode.Text.Trim();
entity.ProductionLineName = txtLineName.Text.Trim();
entity.Remarks = this.txtRemarks.Text.Trim();
object[] obj = null;
if (chkValueFlag.Checked)
{
obj = new object[] { 1 };
}
else
{
obj = new object[] { 0 };
}
entity.ValueFlags = obj;
int result = PCModuleProxy.Service.UpdateProductionLine(entity);
if (result > Constant.INT_IS_ZERO)
{
MessageBox.Show(string.Format(Messages.MSG_CMN_I001, FormTitles.F_PC_0202, Constant.OPERATE_SAVE),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else if (result == Constant.RETURN_IS_EXIST)//-3
{
MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "生产线编码"),
this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}
this.DialogResult = DialogResult.OK;
}
catch (Exception ex)
{
// 对异常进行共通处理
ExceptionManager.HandleEventException(this.ToString(),
System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
}
}
#endregion 事件处理
#region 私有方法
///
/// 验证输入格式是否正确
///
///
private bool CheckInputValidity()
{
if (string.IsNullOrEmpty(this.txtLineCode.Text.Trim()))
{
this.txtLineCode.IsMustInput = true;
this.txtLineCode.Focus();
return false;
}
if (string.IsNullOrEmpty(this.txtLineName.Text.Trim()))
{
this.txtLineName.IsMustInput = true;
this.txtLineName.Focus();
return false;
}
return true;
}
#endregion
}
}