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.
286 lines
12 KiB
286 lines
12 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 FormICSItemOPPriceAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
ICSItemOPPrice EQPSTPUIModel;
|
|
int flag;
|
|
string eqpstpid;
|
|
public FormICSItemOPPriceAdd()
|
|
{
|
|
InitializeComponent();
|
|
init();
|
|
chargeFormState("Add");
|
|
flag = 0;
|
|
eqpstpid = AppConfig.GetGuid();
|
|
}
|
|
public FormICSItemOPPriceAdd(string id)
|
|
{
|
|
InitializeComponent();
|
|
init();
|
|
chargeFormState("Edit");
|
|
SearchTypeInfo(id);
|
|
flag = 1;
|
|
eqpstpid = id;
|
|
}
|
|
private void chargeFormState(string state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case "Add":
|
|
txtMUSERName.Text = AppConfig.UserName;
|
|
txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
|
|
txtMUSERName.Properties.ReadOnly = true;
|
|
txtMTIME.Properties.ReadOnly = true;
|
|
|
|
break;
|
|
case "Edit":
|
|
//txtItemCode.Properties.Buttons[0].Visible = false;
|
|
//txtItemCode.Enabled = false;
|
|
gluItemCode.Properties.Buttons[0].Visible = false;
|
|
gluItemCode.Enabled = false;
|
|
|
|
txtOPCODE.Properties.Buttons[0].Visible = false;
|
|
txtOPCODE.Enabled = false;
|
|
|
|
break;
|
|
}
|
|
}
|
|
private void SearchTypeInfo(string id)
|
|
{
|
|
DataTable dt = ICSItemOPPriceBLL.searchInfoByID(id, AppConfig.AppConnectString);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
eqpstpid = dt.Rows[0]["ID"].ToString();
|
|
//txtItemCode.Text = dt.Rows[0]["ITEMCODE"].ToString();
|
|
gluItemCode.Text = dt.Rows[0]["ITEMCODE"].ToString();
|
|
txtOPCODE.Text = dt.Rows[0]["OPCODE"].ToString();
|
|
txtItemName.Text = dt.Rows[0]["ItemName"].ToString();
|
|
txtOPDESC.Text = dt.Rows[0]["OPDESC"].ToString();
|
|
if (!string.IsNullOrEmpty(dt.Rows[0]["Price"].ToString()))
|
|
{
|
|
txtPrice.Text = dt.Rows[0]["Price"].ToString();
|
|
}
|
|
else
|
|
{
|
|
txtPrice.Text = "0";
|
|
}
|
|
txtMUSERName.Text = AppConfig.UserName;
|
|
txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
|
|
|
|
}
|
|
|
|
}
|
|
private string check()
|
|
{
|
|
string msg = "";
|
|
Decimal decValue = 0m;
|
|
|
|
//if (txtItemCode.Text.Trim() == "")
|
|
// msg += "存货编码不能为空!\n";
|
|
if (gluItemCode.Text.Trim() == "")
|
|
msg += "存货编码不能为空!\n";
|
|
if (txtOPCODE.Text.Trim() == "")
|
|
msg += "工序代码不能为空!\n";
|
|
//if (txtEQPTypeCode.Text.Trim() == "")
|
|
// msg += "设备类型不能为空!\n";
|
|
|
|
if (txtPrice.Text.Trim() == "")
|
|
msg += "价格不能为空!\n";
|
|
else
|
|
{
|
|
if (!Decimal.TryParse(txtPrice.Text.Trim(), out decValue))
|
|
{
|
|
msg += "价格格式不正确!\n";
|
|
}
|
|
}
|
|
//if (txtRTIME.Text.Trim() == "")
|
|
// msg += "准备工时不能为空!\n";
|
|
//else
|
|
//{
|
|
// if (!Decimal.TryParse(txtRTIME.Text.Trim(), out decValue))
|
|
// {
|
|
// msg += "准备工时格式不正确!\n";
|
|
// }
|
|
//}
|
|
//if (flag == 0)
|
|
//{
|
|
// //if (!ICSItemOPPriceBLL.IsIncluding(txtItemCode.Text.Trim(), txtOPCODE.Text.Trim(), txtEQPCODE.Text.Trim(), AppConfig.AppConnectString))
|
|
// if (!ICSItemOPPriceBLL.IsIncluding(gluItemCode.Text.Trim(), txtOPCODE.Text.Trim(), "", AppConfig.AppConnectString))
|
|
// msg += "该产品工序设备类型对应的价格信息已存在!\n";
|
|
//}
|
|
return msg;
|
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string msg = check();
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox(msg);
|
|
return;
|
|
}
|
|
ICSItemOPPrice eqpstp = new ICSItemOPPrice();
|
|
eqpstp.ID = eqpstpid;
|
|
//eqpstp.ITEMCODE = txtItemCode.Text;
|
|
eqpstp.ITEMCODE = gluItemCode.Text;
|
|
eqpstp.OPCODE = txtOPCODE.Text;
|
|
eqpstp.Price =Convert.ToDecimal(txtPrice.Text.Equals("")? "0":txtPrice.Text);
|
|
eqpstp.MUSER = AppConfig.UserId;
|
|
eqpstp.MUSERName = AppConfig.UserName;
|
|
eqpstp.MTIME = DateTime.Now;
|
|
eqpstp.WorkPoint = AppConfig.WorkPointCode;
|
|
eqpstp.EATTRIBUTE1 = "" ;
|
|
|
|
ICSItemOPPriceBLL.Add(eqpstp, AppConfig.AppConnectString);
|
|
if (flag == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("增加成功");
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
else if (flag == 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("修改成功");
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
}
|
|
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
|
|
|
|
private void gluItemCode_EditValueChanged(object sender, EventArgs e)
|
|
{
|
|
var o = gluItemCode.Properties.GetRowByKeyValue(gluItemCode.EditValue);
|
|
if (o is DataRowView)
|
|
{
|
|
DataRowView RowView = o as DataRowView;
|
|
txtItemName.Text = RowView.Row["存货名称"].ToString();
|
|
}
|
|
init3();
|
|
}
|
|
private void init3()
|
|
{
|
|
#region 工序代码
|
|
// string sql2 = @"select distinct
|
|
// a.OPCODE as [工序代码],
|
|
// b.OPDESC as [工序]
|
|
// from ICSITEMROUTE2OP a
|
|
// left join ICSOP b on a.OPCODE=b.OPCODE
|
|
//where a.ITEMCODE='" + gluItemCode.Text + "' and 1=1";
|
|
// DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
|
|
// if (data == null || data.Rows.Count == 0)
|
|
// {
|
|
string sql2 = @"select distinct
|
|
a.OPCODE as [工序代码],
|
|
c.OPDESC as [工序]
|
|
from ICSITEMROUTE2OPLot a
|
|
left join ICSINVENTORY b on a.ITEMCODE=b.INVCODE
|
|
left join ICSOP c on a.OPCODE=c.OPCODE
|
|
where b.INVCODE='" + gluItemCode.Text + "' and 1=1";
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql2).Tables[0];
|
|
//}
|
|
txtOPCODE.Properties.ValueMember = "工序代码";
|
|
txtOPCODE.Properties.DisplayMember = "工序代码";
|
|
|
|
txtOPCODE.Properties.DataSource = data;
|
|
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
|
|
}
|
|
#region 初始化查询条件
|
|
private void init()
|
|
{
|
|
#region 存货编码
|
|
string sql = "SELECT DISTINCT INVCODE AS [存货编码],INVNAME AS [存货名称] FROM ICSINVENTORY ORDER BY INVCODE";
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
gluItemCode.Properties.ValueMember = "存货编码";
|
|
gluItemCode.Properties.DisplayMember = "存货编码";
|
|
gluItemCode.Properties.DataSource = dt;
|
|
gluItemCode.Properties.NullText = "";//空时的值
|
|
gluItemCode.Properties.ImmediatePopup = true;//输入值是否马上弹出窗体
|
|
gluItemCode.Properties.ValidateOnEnterKey = true;//回车确认
|
|
gluItemCode.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.Standard;//要使用户可以输入,这里须设为Standard
|
|
gluItemCode.Properties.AllowNullInput = DevExpress.Utils.DefaultBoolean.True; //可用Ctrl + Delete清空选择內容
|
|
//自适应宽度
|
|
gluItemCode.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
|
|
#endregion
|
|
|
|
#region 工序代码
|
|
string sql2 = "SELECT DISTINCT null AS [工序代码],null as [工序] ";
|
|
|
|
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();
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|