You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
9.3 KiB
C#

using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;
using ZJ_BYD.Common;
using ZJ_BYD.DB;
using ZJ_BYD.Model;
using ZJ_BYD.Untils;
namespace ZJ_BYD.UserControls.MaskCode
{
public partial class EditMaskCode : XtraForm
{
private static int _id;
public EditMaskCode(int id = 0)
{
InitializeComponent();
this.Top = 0;
this.Left = 0;
this.Width = Screen.PrimaryScreen.WorkingArea.Width;
this.Height = Screen.PrimaryScreen.WorkingArea.Height;
_id = id;
if (id > 0)
{
GetMarkCodeById(id);
}
else
{
var maxSortIndex = MskCodeHelper.GetMaxSortIndex();
txtSortIndex.Text = maxSortIndex == 0 ? maxSortIndex.ToString() : (maxSortIndex + 5).ToString();
}
}
private void EditMaskCode1_Load(object sender, EventArgs e)
{
BindCombox.BindStationForLookUp(lkStation);
}
private void GetMarkCodeById(int id)
{
var model = MskCodeHelper.QueryMskCodes().First(m => m.Id == id);
if (model != null)
{
txtCategory.Text = model.Category;
lkStation.EditValue = model.StationCode;
txtProductSfcCode.Text = model.ProductSfcCode;
txtSfcDsp.Text = model.SfcDsp;
txtItemCode.Text = model.ItemCode;
txtItemVersion.Text = model.ItemVersion;
txtItemType.Text = model.ItemType;
txtSub1SfcCode.Text = model.Sub1SfcCode;
txtSub1SfcDsp.Text = model.Sub1SfcDsp;
txtSub1SfcItemCode.Text = model.Sub1SfcItemCode;
txtSub1ItemVersion.Text = model.Sub1ItemVersion;
txtSub1ItemType.Text = model.Sub1ItemType;
txtSub2SfcCode.Text = model.Sub2SfcCode;
txtSub2SfcDsp.Text = model.Sub2SfcDsp;
txtSub2SfcItemCode.Text = model.Sub2SfcItemCode;
txtSub2ItemVersion.Text = model.Sub2ItemVersion;
txtSub2ItemType.Text = model.Sub2ItemType;
txtSub3SfcCode.Text = model.Sub3SfcCode;
txtSub3SfcDsp.Text = model.Sub3SfcDsp;
txtSub3SfcItemCode.Text = model.Sub3SfcItemCode;
txtSub3ItemVersion.Text = model.Sub3ItemVersion;
txtSub3ItemType.Text = model.Sub3ItemType;
txtSub4SfcCode.Text = model.Sub4SfcCode;
txtSub4SfcDsp.Text = model.Sub4SfcDsp;
txtSub4SfcItemCode.Text = model.Sub4SfcItemCode;
txtSub4ItemVersion.Text = model.Sub4ItemVersion;
txtSub4ItemType.Text = model.Sub4ItemType;
txtSub5SfcCode.Text = model.Sub5SfcCode;
txtSub5SfcDsp.Text = model.Sub5SfcDsp;
txtSub5SfcItemCode.Text = model.Sub5SfcItemCode;
txtSub5ItemVersion.Text = model.Sub5ItemVersion;
txtSub5ItemType.Text = model.Sub5ItemType;
txtWeightStandar.Text = model.WeightStandar;
txtCarMode.Text = model.CarMode;
txtSite.Text = model.Site;
txtResource.Text = model.Resource;
txtProcedure.Text = model.Procedure;
txtNgCode.Text = model.NgCode;
txtLastStationSite.Text = model.LastStationSite;
txtLastStationResource.Text = model.LastStationResource;
txtLastStationProcedure.Text = model.LastStationProcedure;
txtBarCodeChar.Text = model.BarCodeChar;////2A2
txtPrintBarCode.Text = model.PrintBarcode;//D
txtSortIndex.Text = model.SortIndex.ToString();
txtUseStatus.Text = model.IsUsed ? "使用中" : "未使用";
txtSoftCode.Text = model.SoftCode;
txtGuideVersion.Text = model.GuideVersion;
txtVoltageMax.Text = model.VoltageMax;
txtVoltageMin.Text = model.VoltageMin;
txtProgramBolckNum.Text = model.ProgramBlockNum.ToString();
txtSoftVersionLen.Text = model.SoftVersionLen.ToString();
ckIsSerialNum.Checked = model.IsSerialNum;
txt_PartsCode.Text=model.PartCode;
}
}
private void btnSave_Click(object sender, EventArgs e)
{
Save();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnTopCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnTopSave_Click(object sender, EventArgs e)
{
Save();
}
private void Save()
{
int row;
var flag = this.RegexSave(new Control[] { txtProductSfcCode, txtCategory, txtItemCode, txtItemVersion, txtItemType, txtSite, txtResource, txtProcedure, txtNgCode, txtSortIndex }, out _);
if (!flag)
{
return;
}
//程序块号
int.TryParse(txtProgramBolckNum.Text.Trim(), out int programBlockNum);
//软件版本号长度
int.TryParse(txtSoftVersionLen.Text.Trim(), out int softVersionLen);
#region model赋值
var t_MaskCode = new T_MaskCode
{
LineCode = Program.CurrentLineCode,
Category = txtCategory.Text.Trim(),
StationCode = lkStation.EditValue.ToString(),
ProductSfcCode = txtProductSfcCode.Text.Trim(),
SfcDsp = txtSfcDsp.Text.Trim(),
ItemCode = txtItemCode.Text.Trim(),
ItemVersion = txtItemVersion.Text.Trim(),
ItemType = txtItemType.Text.Trim(),
Sub1SfcCode = txtSub1SfcCode.Text.Trim(),
Sub1SfcDsp = txtSub1SfcDsp.Text.Trim(),
Sub1SfcItemCode = txtSub1SfcItemCode.Text.Trim(),
Sub1ItemVersion = txtSub1ItemVersion.Text.Trim(),
Sub1ItemType = txtSub1ItemType.Text.Trim(),
Sub2SfcCode = txtSub2SfcCode.Text.Trim(),
Sub2SfcDsp = txtSub2SfcDsp.Text.Trim(),
Sub2SfcItemCode = txtSub2SfcItemCode.Text.Trim(),
Sub2ItemVersion = txtSub2ItemVersion.Text.Trim(),
Sub2ItemType = txtSub2ItemType.Text.Trim(),
Sub3SfcCode = txtSub3SfcCode.Text.Trim(),
Sub3SfcDsp = txtSub3SfcDsp.Text.Trim(),
Sub3SfcItemCode = txtSub3SfcItemCode.Text.Trim(),
Sub3ItemVersion = txtSub3ItemVersion.Text.Trim(),
Sub3ItemType = txtSub3ItemType.Text.Trim(),
Sub4SfcCode = txtSub4SfcCode.Text.Trim(),
Sub4SfcDsp = txtSub4SfcDsp.Text.Trim(),
Sub4SfcItemCode = txtSub4SfcItemCode.Text.Trim(),
Sub4ItemVersion = txtSub4ItemVersion.Text.Trim(),
Sub4ItemType = txtSub4ItemType.Text.Trim(),
Sub5SfcCode = txtSub5SfcCode.Text.Trim(),
Sub5SfcDsp = txtSub5SfcDsp.Text.Trim(),
Sub5SfcItemCode = txtSub5SfcItemCode.Text.Trim(),
Sub5ItemVersion = txtSub5ItemVersion.Text.Trim(),
Sub5ItemType = txtSub5ItemType.Text.Trim(),
WeightStandar = txtWeightStandar.Text.Trim(),
Site = txtSite.Text.Trim(),
Resource = txtResource.Text.Trim(),
Procedure = txtProcedure.Text.Trim(),
NgCode = txtNgCode.Text.Trim(),
LastStationSite = txtLastStationSite.Text.Trim(),
LastStationResource = txtLastStationResource.Text.Trim(),
LastStationProcedure = txtLastStationProcedure.Text.Trim(),
BarCodeChar = txtBarCodeChar.Text.Trim(),//2A2
PrintBarcode = txtPrintBarCode.Text.Trim(),//D
SortIndex = int.Parse(txtSortIndex.Text.Trim()),
CarMode = txtCarMode.Text.Trim(),
IsUsed = txtUseStatus.Text.Trim() == "使用中" ? true : false,
SoftCode = txtSoftCode.Text.Trim(),
GuideVersion = txtGuideVersion.Text.Trim(),
VoltageMax = txtVoltageMax.Text.Trim(),
VoltageMin = txtVoltageMin.Text.Trim(),
ProgramBlockNum = programBlockNum,
SoftVersionLen = softVersionLen,
IsSerialNum=ckIsSerialNum.Checked,
PartCode = txt_PartsCode.Text.Trim()
};
#endregion
if (_id == 0)
{
t_MaskCode.CreatedTime = DateTime.Now;
t_MaskCode.CreatedBy = CurrentUser.UserName;
row = MskCodeHelper.AddMaskCode(t_MaskCode);
}
else
{
t_MaskCode.Id = _id;
t_MaskCode.UpdatedBy = CurrentUser.UserName;
t_MaskCode.UpdatedTime = DateTime.Now;
row = MskCodeHelper.UpdateMakCode(t_MaskCode);
}
if (row <= 0)
{
XtraMessageBox.Show("操作失败!");
return;
}
XtraMessageBox.Show("操作成功!");
this.DialogResult = DialogResult.OK;
this.Close();
}
}
}