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.
149 lines
5.2 KiB
149 lines
5.2 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 ICSSoft.Frame.User.BLL;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
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.Frame.Data.DAL;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
|
|
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSFACTORYAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
FormICSFactoryUIModel factoryUIModel;
|
|
int flag;
|
|
public FormICSFACTORYAdd()
|
|
{
|
|
InitializeComponent();
|
|
chargeFormState("Add");
|
|
|
|
txtWorkPointCode.Text=AppConfig.WorkPointCode;
|
|
//txtFACCODE.Text = Convert.ToString(Convert.ToInt32(ICSFACTORYBLL.SearchMaxCode(AppConfig.AppConnectString)) + 1);
|
|
|
|
flag = 0;
|
|
}
|
|
public FormICSFACTORYAdd(string FACCODE)
|
|
{
|
|
InitializeComponent();
|
|
chargeFormState("Edit");
|
|
SearchTypeInfo(FACCODE);
|
|
txtWorkPointCode.Text = AppConfig.WorkPointCode;
|
|
flag = 1;
|
|
}
|
|
private void chargeFormState(string state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case "Add":
|
|
txtFACCODE.Properties.ReadOnly = false;
|
|
txtFACDESC.Properties.ReadOnly = false;
|
|
txtMuser.Text = AppConfig.UserName;
|
|
txtMtime.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
|
|
txtMuser.Properties.ReadOnly = true;
|
|
txtMtime.Properties.ReadOnly = true;
|
|
break;
|
|
case "Edit":
|
|
txtFACCODE.Properties.ReadOnly = true;
|
|
txtFACDESC.Properties.ReadOnly = false;
|
|
txtMuser.Text = AppConfig.UserName;
|
|
txtMtime.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd HH:mm:ss").ToString();
|
|
txtMuser.Properties.ReadOnly = true;
|
|
txtMtime.Properties.ReadOnly = true;
|
|
break;
|
|
}
|
|
}
|
|
private void SearchTypeInfo(string FACCODE)
|
|
{
|
|
factoryUIModel=ICSFACTORYBLL.SearchFactoryInfoByCode(FACCODE, AppConfig.AppConnectString);
|
|
txtFACCODE.Text = factoryUIModel.FACCODE;
|
|
txtFACDESC.Text = factoryUIModel.FACDESC;
|
|
|
|
|
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (txtFACCODE.Text.Trim() == "")
|
|
throw new Exception("不能为空");
|
|
if (flag == 0)
|
|
{
|
|
bool b = ICSFACTORYBLL.IsIncluding(txtFACCODE.Text.Trim(), AppConfig.AppConnectString);
|
|
if (!b)
|
|
throw new Exception("工厂代码已经存在");
|
|
//if (txtFACCODE.Text.Substring(0, 3) != "110")
|
|
// throw new Exception("班制代码为110格式,1101000001~1101999999");
|
|
//if (txtFACCODE.Text.Length>3||txtFACCODE.Text.Length<3)
|
|
// throw new Exception("长度为3,001~999");
|
|
}
|
|
|
|
|
|
|
|
FormICSFactoryUIModel factoryInfo = new FormICSFactoryUIModel();
|
|
factoryInfo.FACCODE = txtFACCODE.Text;
|
|
factoryInfo.FACDESC = txtFACDESC.Text;
|
|
factoryInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
//以下DAL中做了处理
|
|
// factoryInfo.ID = AppConfig.GetGuid();
|
|
//typeInfo.EFFDATE = Convert.ToDateTime(txtEffDate.Text);
|
|
//typeInfo.IVLDATE = Convert.ToDateTime(txtIvlDate.Text);
|
|
//factoryInfo.MUSER = AppConfig.UserId;
|
|
//factoryInfo.MUSERName = AppConfig.UserName;
|
|
//factoryInfo.MTIME = DateTime.Now;
|
|
|
|
|
|
ICSFACTORYBLL.Add(factoryInfo, AppConfig.AppConnectString);
|
|
|
|
ICSBaseSimpleCode.AppshowMessageBox("保存成功!");
|
|
|
|
}
|
|
catch (Exception ex) {
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
#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 txtShiftTypeCode_KeyPress(object sender, KeyPressEventArgs e)
|
|
//{
|
|
// if (!Char.IsNumber(e.KeyChar))
|
|
// e.Handled = true;
|
|
|
|
|
|
//}
|
|
|
|
//private void txtShiftTypeCode_KeyDown(object sender, KeyEventArgs e)
|
|
//{
|
|
// this.txtShiftTypeCode.Text = "110"+e.KeyValue;
|
|
//}
|
|
}
|
|
}
|