227 lines
6.9 KiB
C#
227 lines
6.9 KiB
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Data;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
using WinformGeneralDeveloperFrame;
|
||
|
|
using WinformGeneralDeveloperFrame.Commons;
|
||
|
|
using DevExpress.XtraLayout;
|
||
|
|
using MES.Entity;
|
||
|
|
using System.Data.Entity.Migrations;
|
||
|
|
using System.Data.Entity;
|
||
|
|
namespace MES.Form
|
||
|
|
{
|
||
|
|
public partial class FrmproductMaterialOutWarehouseDetail : FrmBaseForm
|
||
|
|
{
|
||
|
|
private Dictionary<string, string> fieldDictionary = new Dictionary<string, string>();
|
||
|
|
public FrmproductMaterialOutWarehouseDetail()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
}
|
||
|
|
private void FrmproductMaterialOutWarehouseDetail_Load(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
InitFrom(xtraTabControl1,grdList,grdListView,new LayoutControlGroup[]{layoutControlGroup1},new productMaterialOutWarehouseDetailInfo());
|
||
|
|
InitSearchDicData();
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 数据源初始化
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
private void Init()
|
||
|
|
{
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 搜索字段
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
private void InitSearchDicData()
|
||
|
|
{
|
||
|
|
fieldDictionary.Add("id","id");
|
||
|
|
fieldDictionary.Add("主表id","masterid");
|
||
|
|
fieldDictionary.Add("生产领料出库单号","mastercode");
|
||
|
|
fieldDictionary.Add("生产领料出库明细单号","detailcode");
|
||
|
|
fieldDictionary.Add("生产领料单号","pickcode");
|
||
|
|
fieldDictionary.Add("生产领料明细单号","pickdetailcode");
|
||
|
|
fieldDictionary.Add("工单号","wocode");
|
||
|
|
fieldDictionary.Add("物料","materialid");
|
||
|
|
fieldDictionary.Add("物料编码","materialcode");
|
||
|
|
fieldDictionary.Add("规格型号","materialspec");
|
||
|
|
fieldDictionary.Add("物料类型","materialtype");
|
||
|
|
fieldDictionary.Add("出库数量","number");
|
||
|
|
fieldDictionary.Add("计量单位","unit");
|
||
|
|
fieldDictionary.Add("仓库","warehouse");
|
||
|
|
fieldDictionary.Add("备注","remark");
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void InitgrdListDataSource()
|
||
|
|
{
|
||
|
|
using (var con=new MESDB())///
|
||
|
|
{
|
||
|
|
grdList.DataSource=con.productMaterialOutWarehouseDetailInfo.ToList();
|
||
|
|
}
|
||
|
|
Init();
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 字段为空校验
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public override bool CheckInput()
|
||
|
|
{
|
||
|
|
if(string.IsNullOrEmpty(txtmasterid.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"主表id不能为空".ShowWarning();
|
||
|
|
txtmasterid.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtmastercode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"生产领料出库单号不能为空".ShowWarning();
|
||
|
|
txtmastercode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtdetailcode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"生产领料出库明细单号不能为空".ShowWarning();
|
||
|
|
txtdetailcode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtpickcode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"生产领料单号不能为空".ShowWarning();
|
||
|
|
txtpickcode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtpickdetailcode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"生产领料明细单号不能为空".ShowWarning();
|
||
|
|
txtpickdetailcode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtwocode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"工单号不能为空".ShowWarning();
|
||
|
|
txtwocode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtmaterialid.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"物料不能为空".ShowWarning();
|
||
|
|
txtmaterialid.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtmaterialcode.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"物料编码不能为空".ShowWarning();
|
||
|
|
txtmaterialcode.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtmaterialspec.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"规格型号不能为空".ShowWarning();
|
||
|
|
txtmaterialspec.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtmaterialtype.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"物料类型不能为空".ShowWarning();
|
||
|
|
txtmaterialtype.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtnumber.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"出库数量不能为空".ShowWarning();
|
||
|
|
txtnumber.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtunit.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"计量单位不能为空".ShowWarning();
|
||
|
|
txtunit.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtwarehouse.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"仓库不能为空".ShowWarning();
|
||
|
|
txtwarehouse.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
if(string.IsNullOrEmpty(txtremark.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"备注不能为空".ShowWarning();
|
||
|
|
txtremark.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 保存
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public override bool SaveFunction()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
productMaterialOutWarehouseDetailInfo info= (productMaterialOutWarehouseDetailInfo)this.ControlDataToModel(new productMaterialOutWarehouseDetailInfo());
|
||
|
|
using (var db = new MESDB())
|
||
|
|
{
|
||
|
|
db.productMaterialOutWarehouseDetailInfo.AddOrUpdate(info);
|
||
|
|
db.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
ex.Message.ShowError();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 删除
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public override bool DelFunction()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
productMaterialOutWarehouseDetailInfo info = (productMaterialOutWarehouseDetailInfo)this.ControlDataToModel(new productMaterialOutWarehouseDetailInfo());
|
||
|
|
using (var db = new MESDB())
|
||
|
|
{
|
||
|
|
db.Entry(info).State=EntityState.Deleted;
|
||
|
|
db.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
ex.Message.ShowError();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
/// <summary>
|
||
|
|
/// 搜索
|
||
|
|
/// </summary>
|
||
|
|
/// <returns></returns>
|
||
|
|
public override void SearchFunction()
|
||
|
|
{
|
||
|
|
FrmSearch frm = new FrmSearch(fieldDictionary);
|
||
|
|
if (frm.ShowDialog()==DialogResult.OK)
|
||
|
|
{
|
||
|
|
string sql = frm.sql;
|
||
|
|
using (var db = new MESDB())
|
||
|
|
{
|
||
|
|
if (string.IsNullOrEmpty(sql))
|
||
|
|
{
|
||
|
|
grdList.DataSource = db.productMaterialOutWarehouseDetailInfo.SqlQuery("select * from productMaterialOutWarehouseDetail").ToList();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
grdList.DataSource = db.productMaterialOutWarehouseDetailInfo.SqlQuery($"select * from productMaterialOutWarehouseDetail where {sql}").ToList();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|