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.

139 lines
5.5 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using AUCMA.STORE.Common;
using AUCMA.STORE.Entity.DAO;
using AUCMA.STORE.SqlSugar;
using AUCMA.STORE.SqlSugar.serviceImpl;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace AUCMA.STORE
{
public partial class ChangeMaterialType : Form
{
public InStoreForm InStoreForm = null;
public Action<string,string> RecAutoDataAction;
public ChangeMaterialType()
{
InitializeComponent();
this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterScreen;
}
private void ChangeMaterialType_FormClosed(object sender, FormClosedEventArgs e)
{
//RecAutoDataAction?.Invoke("1111");
}
private void ChangeMaterialType_Load(object sender, EventArgs e)
{
try
{
this.Text = "型号切换";
//for (int i = 0;i< 5 ;i++)
//{
// int index = this.dataGridView1.Rows.Add(); //添加行的索引
// this.dataGridView1.Rows[index].Cells[0].Value = DateTime.Now.ToString("yyyyMMddHHmmssfff");
// this.dataGridView1.Rows[index].Cells[1].Value = "222";
//}
_ = SelectMaterialTypeAsync();
}
catch (Exception ex)
{
}
}
private async Task SelectMaterialTypeAsync()
{
try
{
SqlSugarClient sqlServerDB = SqlGenerator.GetOracleInstance();
//string sql = "select DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME from IMOS_TE_BOM where DETIAL_TYPE_CODE_D = '1000' group by DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME,DETIAL_TYPE_CODE_D,DETIAL_MATERIAL_NAME";
string sql = "select DETIAL_MATERIAL_CODE,Product_Name MASTER_MATERIAL_NAME from view_imos_bom_list where DETIAL_TYPE_CODE_D = '1000' ";
var MaterialTypeList = sqlServerDB.Ado.SqlQuery<MesMaterialTypeBom>(sql,
new List<SugarParameter>()
);
//var MaterialTypeList = await new BaseServices<MesMaterialTypeBom>().QueryBySql<MesMaterialTypeBom>("select DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME from IMOS_TE_BOM where DETIAL_TYPE_CODE_D = '1000' group by DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME,DETIAL_TYPE_CODE_D,DETIAL_MATERIAL_NAME "
// ,
// new List<SugarParameter>()
// );
//Expression<Func<MesMaterialTypeBom, bool>> exp = s1 => true;
//exp = exp.And(s1 => s1.detialTypeCodeD == ConfigHelper.GetConfig("detialTypeCodeD"));
//List<MesMaterialTypeBom> MaterialTypeList = await new BaseServices<MesMaterialTypeBom>().Query(exp);
if (MaterialTypeList.Count() > 0)
{
dataGridView1.DataSource = MaterialTypeList;
}
}
catch (Exception ex)
{
}
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || e.ColumnIndex < 0)
{
return;
}
string buttonText = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
if (buttonText == "切换型号")
{
//更新记录
string MaterialTypeCode = this.dataGridView1.Rows[e.RowIndex].Cells[1].Value.ToString();
string MaterialTypeName = this.dataGridView1.Rows[e.RowIndex].Cells[2].Value.ToString();
RecAutoDataAction?.Invoke(MaterialTypeCode, MaterialTypeName);
this.Close();
}
}
private void btn_SchMaterialType_Click(object sender, EventArgs e)
{
try
{
string sql = "";
if (tb_MaterialCode.Text != null && tb_MaterialCode.Text != "")
{
sql = " and DETIAL_MATERIAL_CODE like '%"+ tb_MaterialCode.Text + "%'" ;
}
if (tb_MaterialName.Text != null && tb_MaterialName.Text != "")
{
sql = " and Product_Name like '%" + tb_MaterialName.Text + "%'";
}
SqlSugarClient sqlServerDB = SqlGenerator.GetOracleInstance();
//string sql = "select DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME from IMOS_TE_BOM where DETIAL_TYPE_CODE_D = '1000' group by DETIAL_MATERIAL_CODE,MASTER_MATERIAL_NAME,DETIAL_TYPE_CODE_D,DETIAL_MATERIAL_NAME";
string sqlstr = "select DETIAL_MATERIAL_CODE,Product_Name MASTER_MATERIAL_NAME from view_imos_bom_list where DETIAL_TYPE_CODE_D = '1000' "+ sql;
var MaterialTypeList = sqlServerDB.Ado.SqlQuery<MesMaterialTypeBom>(sqlstr,
new List<SugarParameter>()
);
if (MaterialTypeList.Count() > 0)
{
dataGridView1.DataSource = MaterialTypeList;
}
else
{
MessageBox.Show("未查询到物料请联系MES维护BOM!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
LogHelper.Error(ex.ToString());
}
}
}
}