1
0
Fork 0

add - 物料管理基本框架开发完毕

master
SoulStar 2 months ago
parent 12c51fe42d
commit 4e536ec720

@ -28,8 +28,13 @@ namespace HighWayIot.Repository.service
/// <summary>
/// 查询所有物料信息
/// </summary>
/// <param name="materialName">物料名</param>
/// <param name="materialType">类型</param>
/// <param name="childType">子类型</param>
/// <param name="isAvaliableUse">是否按是否使用查询</param>
/// <param name="isUse">是否使用</param>
/// <returns></returns>
public List<ZxMaterialEntity> GetMaterialInfos(string materialName = null, string materialType = null, string childType = null)
public List<ZxMaterialEntity> GetMaterialInfos(string materialName = null, string materialType = null, string childType = null, bool isAvaliableUse = false, bool isUse = false)
{
try
{
@ -43,14 +48,19 @@ namespace HighWayIot.Repository.service
{
if(!string.IsNullOrEmpty(childType))
{
entity.Where(x => x.MaterialType == materialType && x.ChildType == childType).ToList();
entity = entity.Where(x => x.MaterialType == materialType && x.ChildType == childType).ToList();
}
else
{
entity.Where(x => x.MaterialType == materialType).ToList();
entity = entity.Where(x => x.MaterialType == materialType).ToList();
}
}
if(isAvaliableUse == true)
{
entity = entity.Where(x => x.IsUse == isUse).ToList();
}
return entity;
}
catch (Exception ex)

@ -130,6 +130,8 @@
// IsUseCheckBox
//
this.IsUseCheckBox.AutoSize = true;
this.IsUseCheckBox.Checked = true;
this.IsUseCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
this.IsUseCheckBox.Location = new System.Drawing.Point(128, 133);
this.IsUseCheckBox.Name = "IsUseCheckBox";
this.IsUseCheckBox.Size = new System.Drawing.Size(72, 16);

@ -76,7 +76,7 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
if (!zxMaterialService.InsertMaterialInfo(entity))
{
MessageBox.Show("物料信息添加失败,请尝试重新添加。");
MessageBox.Show("物料信息添加失败,请检查物料编号是否重复或为空!");
return;
}

@ -32,11 +32,6 @@ namespace HighWayIot.Winform.UserControlPages
private void InitializeComponent()
{
this.MaterialDataGridView = new System.Windows.Forms.DataGridView();
this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ChildType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsUse = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.AddMaterial = new System.Windows.Forms.Button();
this.ButtonPanel = new System.Windows.Forms.Panel();
this.MaterialNameTextbox = new System.Windows.Forms.TextBox();
@ -48,6 +43,13 @@ namespace HighWayIot.Winform.UserControlPages
this.MaterialTypeComboBox = new System.Windows.Forms.ComboBox();
this.ChildComboBox = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.MaterialCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.MaterialName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.MaterialType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ChildType = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.IsUse = new System.Windows.Forms.DataGridViewCheckBoxColumn();
this.IsAvailableUseCheckBox = new System.Windows.Forms.CheckBox();
this.IsUseCheckBox = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.MaterialDataGridView)).BeginInit();
this.ButtonPanel.SuspendLayout();
this.SuspendLayout();
@ -73,40 +75,6 @@ namespace HighWayIot.Winform.UserControlPages
this.MaterialDataGridView.TabIndex = 0;
this.MaterialDataGridView.Tag = "";
//
// MaterialCode
//
this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialCode.DataPropertyName = "MaterialCode";
this.MaterialCode.HeaderText = "物料编码";
this.MaterialCode.Name = "MaterialCode";
//
// MaterialName
//
this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialName.DataPropertyName = "MaterialName";
this.MaterialName.HeaderText = "物料名称";
this.MaterialName.Name = "MaterialName";
//
// MaterialType
//
this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialType.DataPropertyName = "MaterialType";
this.MaterialType.HeaderText = "物料类型";
this.MaterialType.Name = "MaterialType";
//
// ChildType
//
this.ChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ChildType.DataPropertyName = "ChildType";
this.ChildType.HeaderText = "物料子类型";
this.ChildType.Name = "ChildType";
//
// IsUse
//
this.IsUse.DataPropertyName = "IsUse";
this.IsUse.HeaderText = "是否启用";
this.IsUse.Name = "IsUse";
//
// AddMaterial
//
this.AddMaterial.Location = new System.Drawing.Point(11, 11);
@ -122,6 +90,8 @@ namespace HighWayIot.Winform.UserControlPages
//
this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.ButtonPanel.Controls.Add(this.IsUseCheckBox);
this.ButtonPanel.Controls.Add(this.IsAvailableUseCheckBox);
this.ButtonPanel.Controls.Add(this.ChildComboBox);
this.ButtonPanel.Controls.Add(this.label3);
this.ButtonPanel.Controls.Add(this.MaterialTypeComboBox);
@ -203,6 +173,7 @@ namespace HighWayIot.Winform.UserControlPages
this.MaterialTypeComboBox.Name = "MaterialTypeComboBox";
this.MaterialTypeComboBox.Size = new System.Drawing.Size(124, 20);
this.MaterialTypeComboBox.TabIndex = 8;
this.MaterialTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.MaterialTypeComboBox_SelectedIndexChanged);
//
// ChildComboBox
//
@ -221,6 +192,62 @@ namespace HighWayIot.Winform.UserControlPages
this.label3.TabIndex = 9;
this.label3.Text = "子类型:";
//
// MaterialCode
//
this.MaterialCode.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialCode.DataPropertyName = "MaterialCode";
this.MaterialCode.HeaderText = "物料编码";
this.MaterialCode.Name = "MaterialCode";
//
// MaterialName
//
this.MaterialName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialName.DataPropertyName = "MaterialName";
this.MaterialName.HeaderText = "物料名称";
this.MaterialName.Name = "MaterialName";
//
// MaterialType
//
this.MaterialType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.MaterialType.DataPropertyName = "MaterialType";
this.MaterialType.HeaderText = "物料类型";
this.MaterialType.Name = "MaterialType";
//
// ChildType
//
this.ChildType.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
this.ChildType.DataPropertyName = "ChildType";
this.ChildType.HeaderText = "物料子类型";
this.ChildType.Name = "ChildType";
//
// IsUse
//
this.IsUse.DataPropertyName = "IsUse";
this.IsUse.HeaderText = "是否启用";
this.IsUse.Name = "IsUse";
this.IsUse.Resizable = System.Windows.Forms.DataGridViewTriState.True;
this.IsUse.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
//
// IsAvailableUseCheckBox
//
this.IsAvailableUseCheckBox.AutoSize = true;
this.IsAvailableUseCheckBox.Location = new System.Drawing.Point(1079, 11);
this.IsAvailableUseCheckBox.Name = "IsAvailableUseCheckBox";
this.IsAvailableUseCheckBox.Size = new System.Drawing.Size(120, 16);
this.IsAvailableUseCheckBox.TabIndex = 11;
this.IsAvailableUseCheckBox.Text = "是否查询启用状态";
this.IsAvailableUseCheckBox.UseVisualStyleBackColor = true;
//
// IsUseCheckBox
//
this.IsUseCheckBox.AutoSize = true;
this.IsUseCheckBox.Location = new System.Drawing.Point(1079, 34);
this.IsUseCheckBox.Name = "IsUseCheckBox";
this.IsUseCheckBox.Size = new System.Drawing.Size(72, 16);
this.IsUseCheckBox.TabIndex = 12;
this.IsUseCheckBox.Text = "是否启用";
this.IsUseCheckBox.UseVisualStyleBackColor = true;
//
// MaterialConfigPage
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
@ -248,14 +275,16 @@ namespace HighWayIot.Winform.UserControlPages
private Button SelectMaterial;
private TextBox MaterialNameTextbox;
private Label label1;
private DataGridViewTextBoxColumn MaterialCode;
private DataGridViewTextBoxColumn MaterialName;
private DataGridViewTextBoxColumn MaterialType;
private DataGridViewTextBoxColumn ChildType;
private DataGridViewTextBoxColumn IsUse;
private ComboBox ChildComboBox;
private Label label3;
private ComboBox MaterialTypeComboBox;
private Label label2;
private DataGridViewTextBoxColumn MaterialCode;
private DataGridViewTextBoxColumn MaterialName;
private DataGridViewTextBoxColumn MaterialType;
private DataGridViewTextBoxColumn ChildType;
private DataGridViewCheckBoxColumn IsUse;
private CheckBox IsUseCheckBox;
private CheckBox IsAvailableUseCheckBox;
}
}

@ -16,6 +16,26 @@ namespace HighWayIot.Winform.UserControlPages
{
public partial class MaterialConfigPage : UserControl
{
/// <summary>
/// 物料子类型服务类实例
/// </summary>
ZxMaterialChildTypeService zxMaterialChildTypeService = ZxMaterialChildTypeService.Instance;
/// <summary>
/// 物料子类型数组
/// </summary>
string[] MaterialChildTypeArray;
/// <summary>
/// 物料类型服务类实例
/// </summary>
ZxMaterialTypeService zxMaterialTypeService = ZxMaterialTypeService.Instance;
/// <summary>
/// 物料类型数组
/// </summary>
string[] MaterialTypeArray;
/// <summary>
/// 物料信息服务类实例
/// </summary>
@ -36,7 +56,13 @@ namespace HighWayIot.Winform.UserControlPages
{
MaterialDataGridView.AutoGenerateColumns = false;
//绑定物料类型
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;
Lists = zxMaterialService.GetMaterialInfos();
@ -88,6 +114,19 @@ namespace HighWayIot.Winform.UserControlPages
/// <param name="e"></param>
private void DeleteMaterial_Click(object sender, EventArgs e)
{
int a = MaterialDataGridView.CurrentRow.Index;
string s = MaterialDataGridView.Rows[a].Cells["MaterialCode"].Value.ToString();
if(MessageBox.Show($"是否要删除编号为{s}的物料?", "确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
{
return;
}
if (!zxMaterialService.DeleteMaterialInfoByMaterialCode(s))
{
MessageBox.Show($"编号为{s}的物料删除失败" ,"提示");
}
Lists = zxMaterialService.GetMaterialInfos();
MaterialDataGridView.DataSource = null;
MaterialDataGridView.DataSource = Lists;
@ -100,9 +139,24 @@ namespace HighWayIot.Winform.UserControlPages
/// <param name="e"></param>
private void SelectMaterial_Click(object sender, EventArgs e)
{
Lists = zxMaterialService.GetMaterialInfos(MaterialNameTextbox.Text.Trim(), MaterialTypeComboBox.Text.Trim(), ChildComboBox.Text.Trim());
Lists = zxMaterialService.GetMaterialInfos(MaterialNameTextbox.Text.Trim(), MaterialTypeComboBox.Text.Trim(), ChildComboBox.Text.Trim(), IsAvailableUseCheckBox.Checked, IsUseCheckBox.Checked);
MaterialDataGridView.DataSource = null;
MaterialDataGridView.DataSource = Lists;
}
/// <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;
}
}
}

@ -85,6 +85,7 @@
this.MaterialTypeComboBox.Name = "MaterialTypeComboBox";
this.MaterialTypeComboBox.Size = new System.Drawing.Size(136, 20);
this.MaterialTypeComboBox.TabIndex = 19;
this.MaterialTypeComboBox.SelectedIndexChanged += new System.EventHandler(this.MaterialTypeComboBox_SelectedIndexChanged);
//
// label4
//

@ -10,11 +10,32 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
public partial class MaterialUpdateForm : Form
{
/// <summary>
/// 物料子类型服务类实例
/// </summary>
ZxMaterialChildTypeService zxMaterialChildTypeService = ZxMaterialChildTypeService.Instance;
/// <summary>
/// 物料子类型数组
/// </summary>
string[] MaterialChildTypeArray;
/// <summary>
/// 物料类型服务类实例
/// </summary>
ZxMaterialTypeService zxMaterialTypeService = ZxMaterialTypeService.Instance;
/// <summary>
/// 物料类型数组
/// </summary>
string[] MaterialTypeArray;
/// <summary>
/// 物料数据库业务实例
/// </summary>
@ -29,6 +50,41 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
{
InitializeComponent();
_entity = entity;
Init();
}
//初始化选择
private void Init()
{
MaterialNameTextBox.Text = _entity.MaterialName;
MaterialCodeTextBox.Text = _entity.MaterialCode;
//绑定物料类型
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;
for (int i = 0; i < MaterialTypeComboBox.Items.Count; i++)
{
if (MaterialTypeComboBox.GetItemText(MaterialTypeComboBox.Items[i]) == _entity.MaterialType)
{
MaterialTypeComboBox.SelectedIndex = i;
}
}
for (int i = 0; i < ChildComboBox.Items.Count; i++)
{
if (ChildComboBox.GetItemText(ChildComboBox.Items[i]) == _entity.ChildType)
{
ChildComboBox.SelectedIndex = i;
}
}
IsUseCheckBox.Checked = _entity.IsUse.Value;
}
/// <summary>
@ -38,7 +94,44 @@ namespace HighWayIot.Winform.UserControlPages.SysConfigPages
/// <param name="e"></param>
private void ConfrimAddButton_Click(object sender, EventArgs e)
{
ZxMaterialEntity entity = new ZxMaterialEntity()
{
MaterialName = MaterialNameTextBox.Text.Trim(),
MaterialCode = MaterialCodeTextBox.Text.Trim(),
MaterialType = MaterialTypeComboBox.Text.Trim(),
ChildType = ChildComboBox.Text.Trim(),
IsUse = IsUseCheckBox.Checked,
IsDeleted = _entity.IsDeleted.Value,
};
if (zxMaterialService.UpdateMaterialInfo(entity))
{
MessageBox.Show("物料信息修改成功!", "提示");
}
else
{
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;
}
}
}

Loading…
Cancel
Save