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.
273 lines
9.8 KiB
273 lines
9.8 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 FormICSSEGAdd : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
FormICSSEGUIModel segUIModel;
|
|
int flag;
|
|
public FormICSSEGAdd()
|
|
{
|
|
InitializeComponent();
|
|
chargeFormState("Add");
|
|
flag = 0;
|
|
}
|
|
public FormICSSEGAdd(string code)
|
|
{
|
|
InitializeComponent();
|
|
chargeFormState("Edit");
|
|
SearchSEGInfo(code);
|
|
flag = 1;
|
|
}
|
|
|
|
private void chargeFormState(string state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case "Add":
|
|
txtSEGCODE.Properties.ReadOnly = false;
|
|
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":
|
|
txtSEGCODE.Properties.ReadOnly = true;
|
|
txtMUSERName.Text = AppConfig.UserName;
|
|
txtMTIME.Text = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss").ToString();
|
|
txtMUSERName.Properties.ReadOnly = true;
|
|
txtMTIME.Properties.ReadOnly = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
private void SearchSEGInfo(string segCODE)
|
|
{
|
|
segUIModel = ICSSEGBLL.SearchSEGInfoByCode(segCODE, AppConfig.AppConnectString);
|
|
txtSEGCODE.Text = segUIModel.SEGCODE;
|
|
//txtSEGSEQ.Text = Convert.ToString(segUIModel.SEGSEQ);
|
|
txtSEGDESC.Text = segUIModel.SEGDESC;
|
|
//txtSEGManager.Text = segUIModel.SEGManager;
|
|
//txtSHIFTTYPECODE.Tag = segUIModel.shifType as FormICSShifTypeUIModel;
|
|
txtSHIFTTYPECODE.Text = "";
|
|
if (segUIModel.fac != null)
|
|
{
|
|
txtFACCODE.Tag = segUIModel.fac as FormICSFactoryUIModel;
|
|
txtFACCODE.Text = segUIModel.fac.FACDESC;
|
|
}
|
|
}
|
|
#region 车间主任代码按钮
|
|
private void txtSEGManager_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select distinct ID as [人员ID],UserCode as [人员代码],USERName as [人员名称] from dbo.Sys_User with(nolock)
|
|
WHERE 1=1";
|
|
//object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
|
|
//if (obj == null)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
|
|
|
|
//}
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "人员信息";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
reForm.HideCols.Add("人员ID");
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
//reForm.FilterKey = btn.Text;
|
|
//grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
txtSEGManager.Text = dr["人员代码"].ToString();
|
|
//username = dr["人员名称"].ToString();
|
|
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 工厂
|
|
private void txtFACCODE_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
DataTable dt = ICSSEGBLL.SearchFacInfoList(AppConfig.AppConnectString);
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "工厂";
|
|
reForm.DataSource = dt;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
reForm.HideCols.Add("guid");
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
FormICSFactoryUIModel fac = new FormICSFactoryUIModel();
|
|
fac.ID = dr["guid"].ToString();
|
|
fac.FACCODE = dr["工厂代码"].ToString();
|
|
fac.FACDESC = dr["工厂描述"].ToString();
|
|
txtFACCODE.Text = fac.FACCODE;
|
|
txtFACCODE.Tag = fac;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
#region 关闭
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
|
|
private void btnCancle_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
#endregion
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
#region 判断是否为空
|
|
if (txtSEGCODE.Text.Trim() == "")
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("车间代码不能为空");
|
|
return;
|
|
}
|
|
//if (txtSEGSEQ.Text.Trim() == "")
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("车间次序不能为空");
|
|
// return;
|
|
//}
|
|
//if (txtSEGManager.Text.Trim() == "")
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("请选择车间主任");
|
|
// return;
|
|
//}
|
|
//if (txtSHIFTTYPECODE.Text.Trim() == "")
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox("班制不能为空");
|
|
// return;
|
|
//}
|
|
#endregion
|
|
if (flag == 0)
|
|
{
|
|
bool b = ICSSEGBLL.IsIncluding(txtSEGCODE.Text.Trim(), AppConfig.AppConnectString);
|
|
if (b)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("车间代码已经存在");
|
|
return;
|
|
}
|
|
}
|
|
FormICSSEGUIModel segInfo = new FormICSSEGUIModel();
|
|
segInfo.SEGCODE = txtSEGCODE.Text;
|
|
//segInfo.SEGSEQ = Convert.ToInt32(txtSEGSEQ.Text);
|
|
segInfo.SEGDESC = txtSEGDESC.Text;
|
|
segInfo.SEGManager = "";
|
|
segInfo.MUSER = AppConfig.UserCode;
|
|
segInfo.MUSERName = AppConfig.UserName;
|
|
segInfo.MTIME = System.DateTime.Parse(txtMTIME.Text);
|
|
segInfo.WorkPoint = AppConfig.WorkPointCode;
|
|
|
|
//segInfo.shifType = new FormICSShifTypeUIModel();
|
|
//segInfo.shifType = txtSHIFTTYPECODE.Tag as FormICSShifTypeUIModel;
|
|
|
|
if (txtFACCODE.Tag != null)
|
|
{
|
|
segInfo.fac = new FormICSFactoryUIModel();
|
|
segInfo.fac = txtFACCODE.Tag as FormICSFactoryUIModel;
|
|
}
|
|
|
|
ICSSEGBLL.Add(segInfo,AppConfig.AppConnectString);
|
|
if (flag == 0)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("增加成功");
|
|
}
|
|
else if (flag == 1)
|
|
{
|
|
ICSBaseSimpleCode.AppshowMessageBox("修改成功");
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
this.Close();
|
|
this.DialogResult = DialogResult.Yes;
|
|
}
|
|
|
|
//private void txtSHIFTTYPECODE_KeyDown(object sender, KeyEventArgs e)
|
|
//{
|
|
// this.txtSHIFTTYPECODE.Text = "";
|
|
// this.txtSHIFTTYPECODE.Tag = null;
|
|
|
|
//}
|
|
//private void txtFACCODE_KeyDown(object sender, KeyEventArgs e)
|
|
//{
|
|
// this.txtFACCODE.Text = "";
|
|
// this.txtFACCODE.Tag = null;
|
|
|
|
//}
|
|
|
|
//private void txtSHIFTTYPECODE_KeyPress(object sender, KeyPressEventArgs e)
|
|
//{
|
|
// if (e.KeyChar != (char)Keys.Back)
|
|
// {
|
|
// e.Handled = true;
|
|
// }
|
|
//}
|
|
|
|
//private void txtFACCODE_KeyPress(object sender, KeyPressEventArgs e)
|
|
//{
|
|
// if (e.KeyChar != (char)Keys.Back)
|
|
// {
|
|
// e.Handled = true;
|
|
// }
|
|
//}
|
|
|
|
//private void txtSEGSEQ_KeyPress(object sender, KeyPressEventArgs e)
|
|
//{
|
|
// if (!(Char.IsNumber(e.KeyChar)) && e.KeyChar != (char)8)
|
|
// {
|
|
// e.Handled = true;
|
|
|
|
// }
|
|
//}
|
|
|
|
|
|
}
|
|
}
|