From 54d11d559978f73574fe74d9dbcfdd0d35fa2f60 Mon Sep 17 00:00:00 2001 From: "liulb@mesnac.com" Date: Wed, 8 Nov 2023 09:25:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BinManage/BinHelper.cs | 31 +++- .../Entity/Warehouse/Hw_WareHouse_Sub.cs | 29 +++- .../Warehouse/FrmNewMaterial.Designer.cs | 146 ++++++++++++------ .../Warehouse/FrmNewMaterial.cs | 117 +++++++++++--- .../Warehouse/InsertAction.cs | 19 ++- .../Warehouse/WarehouseHelper.cs | 54 +++---- .../Data/MCProject/nodeForm/frmWarehouse.xml | 51 ++++-- 7 files changed, 332 insertions(+), 115 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BinManage/BinHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BinManage/BinHelper.cs index f186465..b86afe8 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BinManage/BinHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/BinManage/BinHelper.cs @@ -1,4 +1,5 @@ -using Mesnac.Action.ChemicalWeighing.Entity; +using DevExpress.Xpo.Helpers; +using Mesnac.Action.ChemicalWeighing.Entity; using Mesnac.Action.ChemicalWeighing.Entity.material; using Mesnac.Codd.Session; using System; @@ -35,8 +36,6 @@ namespace Mesnac.Action.ChemicalWeighing.BinManage #endregion - - #region 获取物料名与ID对象集合 /// /// 获取所有物料对象集合 @@ -127,5 +126,31 @@ namespace Mesnac.Action.ChemicalWeighing.BinManage } #endregion + #region 获取物料 + public static DataTable GetBinMaterial() + { + string sql = @"select distinct m.ID MaterialID,m.Material_code MaterialCode, m.Material_name MaterialName + FROM Pmt_Bin b inner join xl_material m ON b.Material_ID= m.ID"; + + IFreeSql fsql = DBHelper.FreeHelper.Instance; + + DataTable dt = fsql.Select().WithSql(sql).ToDataTable("*"); + return dt; + } + #endregion + + #region 获取物料 + public static DataTable GetBinMaterial2() + { + string sql = @"select distinct m.ID MaterialID,m.Material_code MaterialCode, m.Material_name MaterialName + FROM Pmt_Bin b inner join xl_material m ON b.Material_ID= m.ID"; + + IFreeSql fsql = DBHelper.FreeHelper.Instance; + + DataTable dt = fsql.Select().WithSql(sql).ToDataTable("*"); + return dt; + } + #endregion + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Warehouse/Hw_WareHouse_Sub.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Warehouse/Hw_WareHouse_Sub.cs index 8f94454..b501194 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Warehouse/Hw_WareHouse_Sub.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Entity/Warehouse/Hw_WareHouse_Sub.cs @@ -1,4 +1,5 @@ -using System; +using FreeSql.DataAnnotations; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,13 +7,39 @@ using System.Threading.Tasks; namespace Mesnac.Action.ChemicalWeighing.Entity { + /// + /// 反应釜子表 + /// public class Hw_WareHouse_Sub { + /// + /// 主键Id + /// + [Column(IsIdentity =true,IsPrimary =true)] public int ID { get; set; } + /// + /// 父类主键ID + /// public int MainId { get; set; } + /// + /// 计划编码 + /// + public string PId { get; set; } + /// + /// 物料ID + /// public string MaterialID { get; set; } + /// + /// 物料名称 + /// public string MaterialName { get; set; } + /// + /// 与物料ID + /// public string Material_Code { get; set; } + /// + /// 设置重量 + /// public string SetWeight { get; set; } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.Designer.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.Designer.cs index 581eae6..55e709c 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.Designer.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.Designer.cs @@ -31,104 +31,156 @@ this.btnCancel = new System.Windows.Forms.Button(); this.btnOk = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); - this.cmbMaterial = new System.Windows.Forms.ComboBox(); - this.txtSetWeight = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); - this.txtMaterialCode = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); + this.txtSetWeight = new System.Windows.Forms.TextBox(); + this.cmbMaterial = new System.Windows.Forms.ComboBox(); + this.txtMaterialCode = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.txtPlanId = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnCancel.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnCancel.Location = new System.Drawing.Point(227, 179); + this.btnCancel.Location = new System.Drawing.Point(370, 299); this.btnCancel.Margin = new System.Windows.Forms.Padding(4); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(108, 48); + this.btnCancel.Size = new System.Drawing.Size(147, 48); this.btnCancel.TabIndex = 23; - this.btnCancel.Text = "取消(&C)"; + this.btnCancel.Text = "取消"; this.btnCancel.UseVisualStyleBackColor = true; this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); // // btnOk // this.btnOk.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btnOk.Location = new System.Drawing.Point(96, 179); + this.btnOk.Location = new System.Drawing.Point(190, 299); this.btnOk.Margin = new System.Windows.Forms.Padding(4); this.btnOk.Name = "btnOk"; - this.btnOk.Size = new System.Drawing.Size(108, 48); + this.btnOk.Size = new System.Drawing.Size(145, 48); this.btnOk.TabIndex = 22; - this.btnOk.Text = "确定(&O)"; + this.btnOk.Text = "确定"; this.btnOk.UseVisualStyleBackColor = true; this.btnOk.Click += new System.EventHandler(this.btnOk_Click); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(37, 50); + this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold); + this.label1.Location = new System.Drawing.Point(37, 92); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(89, 18); + this.label1.Size = new System.Drawing.Size(149, 29); this.label1.TabIndex = 19; this.label1.Text = "物料名称:"; // - // cmbMaterial + // label3 // - this.cmbMaterial.FormattingEnabled = true; - this.cmbMaterial.Location = new System.Drawing.Point(133, 41); - this.cmbMaterial.Name = "cmbMaterial"; - this.cmbMaterial.Size = new System.Drawing.Size(202, 26); - this.cmbMaterial.TabIndex = 24; - this.cmbMaterial.SelectedIndexChanged += new System.EventHandler(this.cmbMaterial_SelectedIndexChanged); + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold); + this.label3.Location = new System.Drawing.Point(34, 237); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(149, 29); + this.label3.TabIndex = 20; + this.label3.Text = "设置重量:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold); + this.label2.Location = new System.Drawing.Point(94, 164); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(89, 29); + this.label2.TabIndex = 20; + this.label2.Text = "条码:"; // // txtSetWeight // - this.txtSetWeight.Location = new System.Drawing.Point(133, 130); - this.txtSetWeight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.txtSetWeight.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtSetWeight.Location = new System.Drawing.Point(190, 231); + this.txtSetWeight.Margin = new System.Windows.Forms.Padding(4); this.txtSetWeight.Name = "txtSetWeight"; - this.txtSetWeight.Size = new System.Drawing.Size(202, 28); - this.txtSetWeight.TabIndex = 18; + this.txtSetWeight.Size = new System.Drawing.Size(327, 40); + this.txtSetWeight.TabIndex = 25; // - // label3 + // cmbMaterial // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(34, 135); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(89, 18); - this.label3.TabIndex = 20; - this.label3.Text = "设置重量:"; + this.cmbMaterial.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.cmbMaterial.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.cmbMaterial.FormattingEnabled = true; + this.cmbMaterial.Items.AddRange(new object[] { + "1", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "11", + "12", + "13", + "14", + "14", + "15", + "17", + "18", + "19", + "20"}); + this.cmbMaterial.Location = new System.Drawing.Point(190, 87); + this.cmbMaterial.Margin = new System.Windows.Forms.Padding(4); + this.cmbMaterial.Name = "cmbMaterial"; + this.cmbMaterial.Size = new System.Drawing.Size(327, 37); + this.cmbMaterial.TabIndex = 26; + this.cmbMaterial.SelectedIndexChanged += new System.EventHandler(this.cmbMaterial_SelectedIndexChanged_1); // // txtMaterialCode // - this.txtMaterialCode.Location = new System.Drawing.Point(133, 84); - this.txtMaterialCode.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.txtMaterialCode.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtMaterialCode.Location = new System.Drawing.Point(190, 158); + this.txtMaterialCode.Margin = new System.Windows.Forms.Padding(4); this.txtMaterialCode.Name = "txtMaterialCode"; this.txtMaterialCode.ReadOnly = true; - this.txtMaterialCode.Size = new System.Drawing.Size(202, 28); - this.txtMaterialCode.TabIndex = 18; + this.txtMaterialCode.Size = new System.Drawing.Size(327, 40); + this.txtMaterialCode.TabIndex = 25; // - // label2 + // label4 // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(70, 87); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(53, 18); - this.label2.TabIndex = 20; - this.label2.Text = "条码:"; + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold); + this.label4.Location = new System.Drawing.Point(37, 22); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(149, 29); + this.label4.TabIndex = 19; + this.label4.Text = "计划编码:"; + // + // txtPlanId + // + this.txtPlanId.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtPlanId.Location = new System.Drawing.Point(190, 17); + this.txtPlanId.Margin = new System.Windows.Forms.Padding(4); + this.txtPlanId.Name = "txtPlanId"; + this.txtPlanId.Size = new System.Drawing.Size(327, 40); + this.txtPlanId.TabIndex = 25; // // FrmNewMaterial // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(380, 257); + this.ClientSize = new System.Drawing.Size(553, 381); this.Controls.Add(this.cmbMaterial); + this.Controls.Add(this.txtPlanId); + this.Controls.Add(this.txtMaterialCode); + this.Controls.Add(this.txtSetWeight); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnOk); this.Controls.Add(this.label2); + this.Controls.Add(this.label4); this.Controls.Add(this.label3); this.Controls.Add(this.label1); - this.Controls.Add(this.txtMaterialCode); - this.Controls.Add(this.txtSetWeight); this.Name = "FrmNewMaterial"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "物料信息"; @@ -143,10 +195,12 @@ private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnOk; private System.Windows.Forms.Label label1; - private System.Windows.Forms.ComboBox cmbMaterial; - private System.Windows.Forms.TextBox txtSetWeight; private System.Windows.Forms.Label label3; - private System.Windows.Forms.TextBox txtMaterialCode; private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtSetWeight; + private System.Windows.Forms.ComboBox cmbMaterial; + private System.Windows.Forms.TextBox txtMaterialCode; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox txtPlanId; } } \ No newline at end of file diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.cs index 2f5e3dd..9e815cb 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/FrmNewMaterial.cs @@ -1,5 +1,7 @@ using ICSharpCode.Core; +using Mesnac.Action.ChemicalWeighing.BinManage; using Mesnac.Action.ChemicalWeighing.Entity; +using Mesnac.Action.ChemicalWeighing.Entity.material; using System; using System.Collections; using System.Collections.Generic; @@ -15,7 +17,7 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse { public partial class FrmNewMaterial : Form { - private List pmt_Materials = new List(); //所有物料集合 + private List xl_Materials = new List(); //所有物料集合 public ActionType _actionType; public Hw_WareHouse_Sub _sub = null; @@ -43,10 +45,25 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse /// public void InitCombox() { - pmt_Materials = Product.PptPlan.PlanHelper.GetAllPmt_material(); - cmbMaterial.DataSource = pmt_Materials; - cmbMaterial.DisplayMember = "Material_name"; - cmbMaterial.ValueMember = "ID"; + xl_Materials = Product.XlPlan.PlanHelper.GetAllMaterial(); + //cmbMaterial.DataSource = pmt_Materials; + //cmbMaterial.DisplayMember = "Material_name"; + //cmbMaterial.ValueMember = "ID"; + var table = BinHelper.GetBinMaterial(); + if (table != null) + { + //以下向下拉列表框中插入“请选择” + + DataRow dr = table.NewRow(); + dr[0] = "0"; + dr[1] = "请选择"; + dr[2] = "请选择"; + table.Rows.InsertAt(dr, 0); + + this.cmbMaterial.DataSource = table; + cmbMaterial.DisplayMember = "MaterialName"; + cmbMaterial.ValueMember = "MaterialID";//仓库编码 + } } private void FrmNewMaterial_Load(object sender, EventArgs e) @@ -70,15 +87,23 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse this.txtSetWeight.Text = _sub.SetWeight; this.Text = "修改物料"; } + this.btnOk.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnOK")); this.btnCancel.Text = StringParser.Parse(ResourceService.GetString("Mesnac_Dialog_btnCancel")); } private void btnOk_Click(object sender, EventArgs e) { + if (String.IsNullOrEmpty(this.txtPlanId.Text)) + { + MessageBox.Show("请输入计划编码!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); + this.txtPlanId.Focus(); + return; + } if (String.IsNullOrEmpty(this.cmbMaterial.Text)) { MessageBox.Show("请选择物料的名称!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); + this.cmbMaterial.Focus(); return; } if (_actionType == ActionType.Add && WarehouseHelper.IsExistsName((string)this.cmbMaterial.SelectedValue, this.cmbMaterial.Text, _sub.MainId)) @@ -91,7 +116,8 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse MessageBox.Show("选择物料重复!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } - _sub.MaterialID = (string)this.cmbMaterial.SelectedValue; + _sub.PId = this.txtPlanId.Text; + _sub.MaterialID = txtMaterialCode.Text; //(string)this.cmbMaterial.SelectedValue; _sub.MaterialName = this.cmbMaterial.Text; _sub.Material_Code = txtMaterialCode.Text; _sub.SetWeight = this.txtSetWeight.Text; @@ -102,14 +128,41 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse public void SetComboBoxSelected(ComboBox comboBox, Pmt_material key) { - for (int i = 0; i < comboBox.Items.Count; i++) + //for (int i = 0; i < comboBox.Items.Count; i++) + //{ + // dynamic obj = comboBox.Items[i]; + // if (obj.ID.ToString() == key.ID) + // { + // string text = obj.Material_name.ToString(); + // comboBox.SelectedIndex = comboBox.FindString(text); + // } + //} + var table = BinHelper.GetBinMaterial(); + if (table != null) { - dynamic obj = comboBox.Items[i]; - if (obj.ID.ToString() == key.ID) - { - string text = obj.Material_name.ToString(); - comboBox.SelectedIndex = comboBox.FindString(text); - } + //以下向下拉列表框中插入“请选择” + + DataRow dr = table.NewRow(); + dr[0] = "0"; + dr[1] = "请选择"; + dr[2] = "请选择"; + dr[3] = "请选择"; + dr[4] = "请选择"; + dr[5] = "0"; + table.Rows.InsertAt(dr, 0); + + this.cmbMaterial.DataSource = table; + cmbMaterial.DisplayMember = "MaterialName"; + cmbMaterial.ValueMember = "MaterialID";//仓库编码 + } + + if (_actionType == ActionType.Modify) + { + cmbMaterial.SelectedValue = key.ID; + } + if (_actionType == ActionType.Add) + { + cmbMaterial.SelectedValue = 0; } } @@ -118,20 +171,46 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse this.Dispose(); } - private void cmbMaterial_SelectedIndexChanged(object sender, EventArgs e) + + private void cmbMaterial_SelectedIndexChanged_1(object sender, EventArgs e) { if (_actionType == ActionType.Add) { - var name = this.cmbMaterial.Text; - txtMaterialCode.Text = pmt_Materials.SingleOrDefault(d => d.Material_name == name).Material_code; + string name = this.cmbMaterial.Text.ToString(); + if (string.IsNullOrEmpty(name)) + { + txtMaterialCode.Text = ""; + return; + } + string id = this.cmbMaterial.SelectedValue.ToString(); + if (string.IsNullOrEmpty(id)) + { + txtMaterialCode.Text = ""; + return; + } + var obj = xl_Materials.SingleOrDefault(d => d.ID.Equals(id)); + if (obj == null) return; + txtMaterialCode.Text = obj.Material_code; } if (_actionType == ActionType.Modify) { - var name = this.cmbMaterial.Text; - txtMaterialCode.Text = pmt_Materials.FirstOrDefault(d => d.Material_name == name).Material_code; + string name = this.cmbMaterial.Text.ToString(); + if (string.IsNullOrEmpty(name)) + { + txtMaterialCode.Text = ""; + return; + } + string id = this.cmbMaterial.SelectedValue.ToString(); + if (string.IsNullOrEmpty(id)) + { + txtMaterialCode.Text = ""; + return; + } + var obj = xl_Materials.SingleOrDefault(d => d.ID.Equals(id)); + if (obj == null) return; + txtMaterialCode.Text = obj.Material_code; } - } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/InsertAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/InsertAction.cs index bd1ba4c..b8f379b 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/InsertAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/InsertAction.cs @@ -66,22 +66,30 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse DbMCControl gridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Warehouse").FirstOrDefault(); if (gridControl == null || !(gridControl.BaseControl is DataGridView)) { - ICSharpCode.Core.LoggingService.Error("{投料管理—添加物料}缺少物料控件..."); + ICSharpCode.Core.LoggingService.Error("{反应釜管理—添加物料}缺少物料控件..."); return; } DataGridView subridView = gridControl.BaseControl as DataGridView; if (subridView.SelectedRows.Count == 1) { int selectId = (int)subridView.SelectedRows[0].Cells["ID"].Value; - + FrmNewMaterial frmNewMaterial = new FrmNewMaterial(ActionType.Add, selectId); frmNewMaterial.ShowDialog(this._runtime.BaseControl.MCRoot as Control); if (frmNewMaterial.DialogResult == DialogResult.OK) { var ware = frmNewMaterial._sub; - WarehouseHelper.InsertWareHouseSub(ware); - + bool result = WarehouseHelper.InsertWareHouseSub(ware); + if (result) + { + frmNewMaterial.Dispose(); + MessageBox.Show("新物料添加成功!"); + } + else + { + MessageBox.Show("保存失败!"); + } #region 触发事件 if (OnInsert != null) @@ -90,8 +98,7 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse } #endregion - frmNewMaterial.Dispose(); - MessageBox.Show("新物料添加成功!"); + } else { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/WarehouseHelper.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/WarehouseHelper.cs index 0970669..f586377 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/WarehouseHelper.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Warehouse/WarehouseHelper.cs @@ -7,6 +7,7 @@ using System.Data; using Mesnac.Codd.Session; using Mesnac.Action.ChemicalWeighing.Entity; using System.Windows.Forms; +using Mesnac.Action.ChemicalWeighing.DBHelper; namespace Mesnac.Action.ChemicalWeighing.Warehouse { @@ -161,9 +162,9 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); } dbHelper.CommandType = CommandType.Text; - string strSql = "SELECT ID,MaterialID,MaterialName,SetWeight FROM Hw_WareHouse_Sub where MainId=@MainId"; + string strSql = "SELECT ID,PId,MaterialID,MaterialName,SetWeight FROM Hw_WareHouse_Sub where MainId=@MainId"; dbHelper.CommandText = strSql; - dbHelper.ClearParameter(); + dbHelper.ClearParameter(); dbHelper.AddParameter("@MainId", MId); DataTable table = dbHelper.ToDataTable(); if (table != null && table.Rows.Count > 0) @@ -245,7 +246,6 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse #endregion - #region 判断是否存在条码 /// @@ -283,10 +283,6 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse } #endregion - - - - /// /// 保存物料信息 /// @@ -294,27 +290,33 @@ namespace Mesnac.Action.ChemicalWeighing.Warehouse /// public static bool InsertWareHouseSub(Hw_WareHouse_Sub sub) { - DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); - if (dbHelper == null) + //DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local); + //if (dbHelper == null) + //{ + // throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); + //} + //dbHelper.CommandType = CommandType.Text; + //string sqlstr = @"INSERT INTO Hw_WareHouse_Sub(MainId,MaterialID,MaterialName,Material_Code,SetWeight)VALUES(@MainId,@MaterialID,@MaterialName,@Material_Code,@SetWeight)"; + + //dbHelper.ClearParameter(); + //dbHelper.CommandText = sqlstr; + + //dbHelper.AddParameter("@ID", sub.ID); + //dbHelper.AddParameter("@MainId", sub.MainId); + //dbHelper.AddParameter("@MaterialID", sub.MaterialID); + //dbHelper.AddParameter("@MaterialName", sub.MaterialName); + //dbHelper.AddParameter("@Material_Code", sub.Material_Code); + //dbHelper.AddParameter("@SetWeight", sub.SetWeight); + + //dbHelper.ExecuteNonQuery(); + sub.ID = 0; + IFreeSql fsql = FreeHelper.Instance; + var result = fsql.Insert(sub).ExecuteAffrows(); + if (result>0) { - throw new Exception(Mesnac.Basic.LanguageHelper.DataBaseConnectError); + return true; } - dbHelper.CommandType = CommandType.Text; - string sqlstr = @"INSERT INTO Hw_WareHouse_Sub(MainId,MaterialID,MaterialName,Material_Code,SetWeight)VALUES(@MainId,@MaterialID,@MaterialName,@Material_Code,@SetWeight)"; - - dbHelper.ClearParameter(); - dbHelper.CommandText = sqlstr; - - dbHelper.AddParameter("@ID", sub.ID); - dbHelper.AddParameter("@MainId", sub.MainId); - dbHelper.AddParameter("@MaterialID", sub.MaterialID); - dbHelper.AddParameter("@MaterialName", sub.MaterialName); - dbHelper.AddParameter("@Material_Code", sub.Material_Code); - dbHelper.AddParameter("@SetWeight", sub.SetWeight); - - dbHelper.ExecuteNonQuery(); - - return true; + return false; } /// diff --git a/Main/MCEdit/Data/MCProject/nodeForm/frmWarehouse.xml b/Main/MCEdit/Data/MCProject/nodeForm/frmWarehouse.xml index 4b60072..352fbfd 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/frmWarehouse.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/frmWarehouse.xml @@ -28,12 +28,11 @@ Query True True - False False Fill 3, 25 MCDataGridView1 - 636, 633 + 523, 633 3 False @@ -42,20 +41,20 @@ 宋体, 14.25pt 0, 0 GroupBox1 - 642, 661 - 9 + 529, 661 + 11 Fill 0, 0 Panel4 - 642, 661 + 529, 661 False - AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJoBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EYXRhR3JpZFZpZXdDb2x1bW5zLCBNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGxdXQMAAAAGX2l0ZW1zBV9zaXplCF92ZXJzaW9uBAAAKk1lc25hYy5Db250cm9scy5CYXNlLkRhdGFHcmlkVmlld0NvbHVtbnNbXQIAAAAICAkDAAAABAAAAD8AAAAHAwAAAAABAAAABAAAAAQoTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGF0YUdyaWRWaWV3Q29sdW1ucwIAAAAJBAAAAAkFAAAACQYAAAAJBwAAAAUEAAAAKE1lc25hYy5Db250cm9scy5CYXNlLkRhdGFHcmlkVmlld0NvbHVtbnMCAAAACl9maWxlZERhdGEMX2Rpc3BsYXlOYW1lAQECAAAABggAAAACSUQGCQAAAAbluo/lj7cBBQAAAAQAAAAGCgAAAAxNYXRlcmlhbE5hbWUGCwAAAAznianmlpnlkI3np7ABBgAAAAQAAAAGDAAAAApNYXRlcmlhbElEBg0AAAAM54mp5paZ57yW56CBAQcAAAAEAAAABg4AAAAJU2V0V2VpZ2h0Bg8AAAAM54mp5paZ6YeN6YePCw== + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJoBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EYXRhR3JpZFZpZXdDb2x1bW5zLCBNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGxdXQMAAAAGX2l0ZW1zBV9zaXplCF92ZXJzaW9uBAAAKk1lc25hYy5Db250cm9scy5CYXNlLkRhdGFHcmlkVmlld0NvbHVtbnNbXQIAAAAICAkDAAAABAAAAFYAAAAHAwAAAAABAAAACAAAAAQoTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGF0YUdyaWRWaWV3Q29sdW1ucwIAAAAJBAAAAAkFAAAACQYAAAAJBwAAAA0EBQQAAAAoTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGF0YUdyaWRWaWV3Q29sdW1ucwIAAAAKX2ZpbGVkRGF0YQxfZGlzcGxheU5hbWUBAQIAAAAGCAAAAANQSWQGCQAAAAzorqHliJLnvJbnoIEBBQAAAAQAAAAGCgAAAAxNYXRlcmlhbE5hbWUGCwAAAAznianmlpnlkI3np7ABBgAAAAQAAAAGDAAAAApNYXRlcmlhbElEBg0AAAAM54mp5paZ57yW56CBAQcAAAAEAAAABg4AAAAJU2V0V2VpZ2h0Bg8AAAAM54mp5paZ6YeN6YePCw== AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAAAAAAABwMAAAAAAQAAAAAAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAL @@ -77,12 +76,11 @@ None True True - False False Fill 3, 25 MCDataGridView2 - 434, 633 + 547, 633 4 False @@ -91,13 +89,13 @@ 宋体, 14.25pt 0, 0 GroupBox2 - 440, 661 + 553, 661 8 Right - 642, 0 + 529, 0 Panel3 - 440, 661 + 553, 661 Fill 0, 40 @@ -125,11 +123,36 @@ DarkGray 导入物料 宋体, 14.25pt - 325, 5 + 423, 5 MCButton7 100, 30 15 + + + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAOAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIDZBM0E5N0M5NzNGNEU0OEFCNzdCOTkwQUIwQTQ2RUUzBgYAAAAG5re75YqgBgcAAAAG5re75YqgCw== + + + + False + + + + None + True + True + False + + + Red + DarkGray + 新增物料 + 宋体, 14.25pt + 126, 5 + MCButton3 + 100, 30 + 15 + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAEAAAAMAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAAJBAAAAA0DBQQAAAAhTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uAwAAABU8R1VJRD5rX19CYWNraW5nRmllbGQVPE5hbWU+a19fQmFja2luZ0ZpZWxkFzxSZW1hcms+a19fQmFja2luZ0ZpZWxkAQEBAgAAAAYFAAAAIEZCMzc1MkMwNDg0OEM3QkY1M0UzRTIzMDUxOUM4RTNFBgYAAAAG5Yi35pawBgcAAAAG5Yi35pawCw== @@ -150,7 +173,7 @@ DarkGray 刷新 宋体, 14.25pt - 224, 5 + 324, 5 MCButton5 100, 30 15 @@ -176,7 +199,7 @@ Transparent 删除 宋体, 14.25pt - 126, 5 + 225, 5 MCButton4 100, 30 12