华恒Mes鼎捷代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.3 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using ICSSoft.Frame.Data.BLL;
using ICSSoft.Base.Language.Tool;
using ICSSoft.Base.UserControl.MessageControl;
using ICSSoft.Base.Report.Filter;
using ICSSoft.Base.Config.DBHelper;
using ICSSoft.Base.UserControl.FormControl;
using ICSSoft.Base.ReferForm.AppReferForm;
using ICSSoft.Base.Lable.PrintTool;
using ICSSoft.Base.Config.AppConfig;
using ICSSoft.Base.Report.GridReport;
using ICSSoft.Frame.APP.Entity;
using ICSSoft.Frame.APP;
using ICSSoft.Frame.Data.Entity;
namespace ICSSoft.Frame.APP
{
public partial class FormICSAutoCMPOPADD : DevExpress.XtraEditors.XtraForm
{
int flag;
string guid;
public FormICSAutoCMPOPADD()
{
InitializeComponent();
init();
chargeFormState("Add");
flag = 0;
guid = AppConfig.GetGuid();
}
public FormICSAutoCMPOPADD(string id)
{
InitializeComponent();
init();
chargeFormState("Edit");
SearchTypeInfo(id);
flag = 1;
guid = id;
}
private void chargeFormState(string state)
{
switch (state)
{
case "Add":
this.type.Text = "新增";
break;
case "Edit":
this.type.Text = "修改";
SearchTypeInfo(guid);
break;
}
}
private void SearchTypeInfo(string id)
{
ICSAutoCMPOP OP= FormICSAutoCMPOPADDBLL.Search(id, AppConfig.AppConnectString);
if (OP != null)
{
txtOPCODE.EditValue = OP.opcode;
CBStatus.Checked =(bool)OP.Status;
}
}
private string check()
{
string msg = "";
Decimal decValue = 0m;
if (txtOPCODE.Text == null) {
msg += "工序编码不能为空!";
}
return msg;
}
private void btnOK_Click(object sender, EventArgs e)
{
try
{
string msg = check();
if (!string.IsNullOrEmpty(msg))
{
ICSBaseSimpleCode.AppshowMessageBox(msg);
return;
}
ICSAutoCMPOP autoop = new ICSAutoCMPOP();
autoop.opcode = txtOPCODE.Text;
autoop.Mtime = DateTime.Now;
autoop.Muser = AppConfig.UserCode;
autoop.Musername = AppConfig.UserName;
autoop.id = guid; autoop.Status = CBStatus.Checked;
List<ICSAutoCMPOP> LIST = new List<ICSAutoCMPOP>();
LIST.Add(autoop);
FormICSAutoCMPOPADDBLL.AddorEdit(LIST, AppConfig.AppConnectString);
ICSBaseSimpleCode.AppshowMessageBox(type.Text+"成功!");
this.Close();
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
#region 关闭
private void btnCancle_Click(object sender, EventArgs e)
{
this.Close();
//this.DialogResult = DialogResult.Cancel;
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
//this.DialogResult = DialogResult.Cancel;
}
#endregion
#region 初始化查询条件
private void init()
{
#region 工序代码
string sql2 = "SELECT DISTINCT opcode AS [工序代码],opdesc as [工序] from icsop";
DataTable dt2 = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
txtOPCODE.Properties.ValueMember = "工序代码";
txtOPCODE.Properties.DisplayMember = "工序代码";
txtOPCODE.Properties.DataSource = dt2;
txtOPCODE.Properties.NullText = "";//空时的值
txtOPCODE.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
txtOPCODE.Properties.ValidateOnEnterKey = true;//回车确认
txtOPCODE.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
txtOPCODE.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
//自适应宽度
txtOPCODE.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
#endregion
}
#endregion
private void txtOPCODE_EditValueChanged(object sender, EventArgs e)
{
var o = txtOPCODE.Properties.GetRowByKeyValue(txtOPCODE.EditValue);
if (o is DataRowView)
{
DataRowView RowView = o as DataRowView;
txtOPCODE.Text = RowView.Row["工序代码"].ToString();
txtOPDESC.Text = RowView.Row["工序"].ToString();
}
}
}
}