213 lines
6.2 KiB
C#
213 lines
6.2 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 FrmbuyerInWarehouseDetail : FrmBaseForm
|
|
{
|
|
private Dictionary<string, string> fieldDictionary = new Dictionary<string, string>();
|
|
public FrmbuyerInWarehouseDetail()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void FrmbuyerInWarehouseDetail_Load(object sender, EventArgs e)
|
|
{
|
|
InitFrom(xtraTabControl1,grdList,grdListView,new LayoutControlGroup[]{layoutControlGroup1},new buyerInWarehouseDetailInfo());
|
|
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("采购明细单号","buyerdetailcode");
|
|
fieldDictionary.Add("采购单号","buyercode");
|
|
fieldDictionary.Add("物料","materialid");
|
|
fieldDictionary.Add("物料编号","materialcode");
|
|
fieldDictionary.Add("规格型号","materialspec");
|
|
fieldDictionary.Add("入库数量","number");
|
|
fieldDictionary.Add("计量单位","unit");
|
|
fieldDictionary.Add("仓库","warehouse");
|
|
fieldDictionary.Add("remark","remark");
|
|
}
|
|
|
|
public override void InitgrdListDataSource()
|
|
{
|
|
using (var con=new MESDB())///
|
|
{
|
|
grdList.DataSource=con.buyerInWarehouseDetailInfo.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(txtbuyerdetailcode.EditValue.ToString()))
|
|
{
|
|
"采购明细单号不能为空".ShowWarning();
|
|
txtbuyerdetailcode.Focus();
|
|
return false;
|
|
}
|
|
if(string.IsNullOrEmpty(txtbuyercode.EditValue.ToString()))
|
|
{
|
|
"采购单号不能为空".ShowWarning();
|
|
txtbuyercode.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(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()))
|
|
{
|
|
"remark不能为空".ShowWarning();
|
|
txtremark.Focus();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override bool SaveFunction()
|
|
{
|
|
try
|
|
{
|
|
buyerInWarehouseDetailInfo info= (buyerInWarehouseDetailInfo)this.ControlDataToModel(new buyerInWarehouseDetailInfo());
|
|
using (var db = new MESDB())
|
|
{
|
|
db.buyerInWarehouseDetailInfo.AddOrUpdate(info);
|
|
db.SaveChanges();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.Message.ShowError();
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public override bool DelFunction()
|
|
{
|
|
try
|
|
{
|
|
buyerInWarehouseDetailInfo info = (buyerInWarehouseDetailInfo)this.ControlDataToModel(new buyerInWarehouseDetailInfo());
|
|
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.buyerInWarehouseDetailInfo.SqlQuery("select * from buyerInWarehouseDetail").ToList();
|
|
}
|
|
else
|
|
{
|
|
grdList.DataSource = db.buyerInWarehouseDetailInfo.SqlQuery($"select * from buyerInWarehouseDetail where {sql}").ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |