forked from wenjy/HighWayIot
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.
103 lines
3.4 KiB
C#
103 lines
3.4 KiB
C#
using HighWayIot.Repository.domain;
|
|
using HighWayIot.Repository.service;
|
|
using Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace HighWayIot.Winform.UserControlPages.SysConfigPages
|
|
{
|
|
public partial class MaterialAddForm : Form
|
|
{
|
|
/// <summary>
|
|
/// 物料子类型服务类实例
|
|
/// </summary>
|
|
ZxMaterialChildTypeService zxMaterialChildTypeService = ZxMaterialChildTypeService.Instance;
|
|
|
|
/// <summary>
|
|
/// 物料子类型数组
|
|
/// </summary>
|
|
string[] MaterialChildTypeArray;
|
|
|
|
/// <summary>
|
|
/// 物料类型服务类实例
|
|
/// </summary>
|
|
ZxMaterialTypeService zxMaterialTypeService = ZxMaterialTypeService.Instance;
|
|
|
|
/// <summary>
|
|
/// 物料类型数组
|
|
/// </summary>
|
|
string[] MaterialTypeArray;
|
|
|
|
/// <summary>
|
|
/// 物料数据库业务实例
|
|
/// </summary>
|
|
ZxMaterialService zxMaterialService = ZxMaterialService.Instance;
|
|
|
|
public MaterialAddForm()
|
|
{
|
|
InitializeComponent();
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
//绑定物料类型
|
|
MaterialTypeArray = zxMaterialTypeService.GetMaterialTypeInfos().Select(x => x.MaterialTypeName).ToArray();
|
|
Array.Resize(ref MaterialTypeArray, MaterialTypeArray.Length + 1);
|
|
Array.Copy(MaterialTypeArray, 0, MaterialTypeArray, 1, MaterialTypeArray.Length - 1);
|
|
MaterialTypeArray[0] = string.Empty;
|
|
|
|
MaterialTypeComboBox.DataSource = MaterialTypeArray;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 确认添加按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void ConfrimAddButton_Click(object sender, EventArgs e)
|
|
{
|
|
ZxMaterialEntity entity = new ZxMaterialEntity()
|
|
{
|
|
MaterialCode = MaterialCodeTextBox.Text,
|
|
MaterialName = MaterialNameTextBox.Text,
|
|
MaterialType = MaterialTypeComboBox.Text,
|
|
ChildType = ChildComboBox.Text,
|
|
IsUse = IsUseCheckBox.Checked,
|
|
IsDeleted = false
|
|
};
|
|
|
|
if (!zxMaterialService.InsertMaterialInfo(entity))
|
|
{
|
|
MessageBox.Show("物料信息添加失败,请尝试重新添加。");
|
|
return;
|
|
}
|
|
|
|
this.Close();
|
|
this.Dispose();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 主物料类型选择改变事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void MaterialTypeComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
MaterialChildTypeArray = zxMaterialChildTypeService.GetMaterialChildTypeInfos(x => x.MaterialTypeName == MaterialTypeComboBox.Text).Select(x => x.MaterialChlidTypeName).ToArray();
|
|
Array.Resize(ref MaterialChildTypeArray, MaterialChildTypeArray.Length + 1);
|
|
Array.Copy(MaterialChildTypeArray, 0, MaterialChildTypeArray, 1, MaterialChildTypeArray.Length - 1);
|
|
MaterialChildTypeArray[0] = string.Empty;
|
|
|
|
ChildComboBox.DataSource = MaterialChildTypeArray;
|
|
}
|
|
}
|
|
}
|