using Gs.DevApp.Entity;
|
using Gs.DevApp.ToolBox;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using System;
|
using System.Data;
|
using System.Dynamic;
|
using System.Windows.Forms;
|
|
namespace Gs.DevApp.DevFrm.Work
|
{
|
public partial class Frm_Work01Fg : DevExpress.XtraEditors.XtraForm
|
{
|
string _webServiceName = "WorkCollect/";
|
string dianJianPath = "";//电检取值路径
|
string goodTag = "√";
|
string badTag = "×";
|
string fGxTouRu = "G001:投入";
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="_fGx">工序</param>
|
/// <param name="_fBc">班次</param>
|
/// <param name="_strinOther">目前为电检路径</param>
|
/// <param name="chkWater">是否水检</param>
|
public Frm_Work01Fg(string _fGx, string _fBc)
|
{
|
InitializeComponent();
|
System.Drawing.Font ft1 = new System.Drawing.Font("宋体", 35F);//大按钮
|
System.Drawing.Font ft2 = new System.Drawing.Font("宋体", 25F);//中按钮
|
System.Drawing.Font ft3 = new System.Drawing.Font("宋体", 15F);//grid
|
System.Drawing.Font ft4 = new System.Drawing.Font("宋体", 12F);//head
|
System.Drawing.Font ft5 = new System.Drawing.Font("宋体", 12F);//表头
|
//设置字体大小
|
this.btnGood.Appearance.Font = ft1;
|
this.btnBad.Appearance.Font = ft1;
|
this.simpleButton3.Appearance.Font = ft2;
|
this.simpleButton7.Appearance.Font = ft2;
|
this.simpleButton5.Appearance.Font = ft2;
|
this.simpleButton4.Appearance.Font = ft2;
|
this.simpleButton6.Appearance.Font = ft2;
|
this.lbSum1.Appearance.Font = ft2;
|
this.lbSum2.Appearance.Font = ft2;
|
this.lbSum3.Appearance.Font = ft2;
|
this.lbSum4.Appearance.Font = ft2;
|
this.gvMx1.Appearance.Row.Font = ft3;
|
this.gvMx2.Appearance.Row.Font = ft3;
|
this.layoutControlItem1.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem2.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem3.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem4.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem5.AppearanceItemCaption.Font = ft4;
|
this.layShuiJian.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem7.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem8.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem10.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem11.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem12.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem13.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem14.AppearanceItemCaption.Font = ft4;
|
this.layoutControlItem15.AppearanceItemCaption.Font = ft4;
|
this.txt_gdbh.Properties.Appearance.Font = ft5;
|
this.txt_itemNo.Properties.Appearance.Font = ft5;
|
this.txt_itemModel.Properties.Appearance.Font = ft5;
|
this.txt_gx.Properties.Appearance.Font = ft5;
|
this.txt_bc.Properties.Appearance.Font = ft5;
|
this.txt_itemName.Properties.Appearance.Font = ft5;
|
this.txt_yjDate.Properties.Appearance.Font = ft5;
|
this.txt_collectBy.Properties.Appearance.Font = ft5;
|
this.txt_sbNo.Properties.Appearance.Font = ft5;
|
this.txt_sjXt.Properties.Appearance.Font = ft5;
|
this.txt_sjDate.Properties.Appearance.Font = ft5;
|
this.txt_barCode.Properties.Appearance.Font = ft5;
|
this.txt_currentBarCode.Properties.Appearance.Font = ft5;
|
this.txt_OldLiuShuiMa.Properties.Appearance.Font = ft5;
|
gvMx1.IndicatorWidth = 60;
|
gvMx1.CustomDrawRowIndicator += (s, e) =>
|
{
|
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
|
e.Info.DisplayText = (e.RowHandle + 1).ToString();
|
};
|
txt_gx.Text = _fGx;
|
txt_bc.Text = _fBc;
|
this.Text = "工序采集【" + _fGx + " - " + _fBc + "】";
|
label8.Text = _fGx + "数量";
|
//追溯码框回车事件
|
txt_barCode.KeyDown += (s, e) =>
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
txt_OldLiuShuiMa.Focus();
|
}
|
};
|
//流水码框回车事件
|
txt_OldLiuShuiMa.KeyDown += (s, e) =>
|
{
|
if (e.KeyCode == Keys.Enter)
|
{
|
if (txt_OldLiuShuiMa.Text.Trim().Length <= 0)
|
{
|
Toast vm = new Toast(-1, "操作失败@n请先扫追溯码");
|
vm.Show();
|
this.ActiveControl = this.txt_OldLiuShuiMa;
|
txt_OldLiuShuiMa.Focus();
|
return;
|
}
|
addModel(goodTag);
|
}
|
};
|
//良品按钮事件
|
btnGood.Click += (s, e) =>
|
{
|
addModel(goodTag);
|
};
|
//不良品按钮事件
|
btnBad.Click += (s, e) =>
|
{
|
int idx = tabMx.SelectedTabPageIndex;
|
if (idx > 0)
|
{
|
Toast vm = new Toast(-1, "请重新操作@n已帮你切换到【良品明细】");
|
vm.Show();
|
tabMx.SelectedTabPageIndex = 0;
|
return;
|
}
|
string _collectGuid = "";
|
string _collCode = "";
|
var dr = gvMx1.GetFocusedDataRow();
|
if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
|
{
|
|
}
|
else
|
{
|
_collectGuid = dr["guid"].ToString();
|
_collCode = dr["barCode"].ToString();
|
}
|
if (_collectGuid.Length < 30)
|
{
|
Toast vm = new Toast(-1, "操作失败@n请先选择追溯码");
|
vm.Show();
|
return;
|
}
|
string _msg = "你准备将【" + _collCode + "】变更为不良";
|
string _type = "";
|
if (txt_gx.Text.Trim() == fGxTouRu)
|
_type = "工序G001:投入不良描述";
|
string condition = $" pid<>'00000000-0000-0000-0000-000000000000' ";
|
if (txt_orgId.Text.Trim() == "104554") // 电器
|
{
|
condition += $" and a.s_type = '{_type}' ";
|
}
|
if (txt_orgId.Text.Trim() == "104540") // 魔凡
|
{
|
condition += $" and a.s_type = '魔凡{_type}' ";
|
}
|
|
UcDictionarySelect frm = new UcDictionarySelect(_type, condition, _msg);
|
frm.UpdateParent += (ss, ee) =>
|
{
|
System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
|
var lst = ee.DynamicList;
|
foreach (dynamic dym in lst)
|
{
|
if (stringBuilder.Length > 0)
|
stringBuilder.Append("&");
|
stringBuilder.Append(dym.dicTxt);
|
}
|
string _txt = stringBuilder.ToString();
|
if (string.IsNullOrEmpty(_txt))
|
{
|
Toast vm = new Toast(-1, "操作失败@n请选择不良项目");
|
vm.Show();
|
}
|
else
|
addModel(badTag, _txt, _collectGuid);
|
};
|
frm.ShowDialog();
|
this.ActiveControl = this.txt_barCode;
|
txt_barCode.Focus();
|
};
|
this.ActiveControl = this.txt_barCode;
|
txt_barCode.Focus();
|
}
|
|
/// <summary>
|
/// 根据工序,构造不同类型的实体,读取不同的数据
|
/// </summary>
|
/// <param name="_barCode">条码</param>
|
/// <param name="_checkResult">结果</param>
|
/// <param name="_badDescription">不良描述</param>
|
/// <param name="_collectGuid">采集guid,如果是不良,需要collectGuid</param>
|
/// <returns></returns>
|
private dynamic getObj(string _barCode, string _checkResult, string _badDescription = "", string _collectGuid = "")
|
{
|
dynamic _obj = new ExpandoObject();
|
_obj.barCode = _barCode;
|
_obj.checkResult = _checkResult;//检测结果
|
_obj.processNo = txt_gx.Text.Trim();//工序
|
_obj.banCi = txt_bc.Text.Trim();//班次
|
_obj.gongWei = "";//工位
|
_obj.badDescription = _badDescription.Trim();//不良描述
|
_obj.collectGuid = _collectGuid;
|
_obj.oldLiushuima = txt_OldLiuShuiMa.Text.Trim();
|
//不良,直接提交
|
if (!string.IsNullOrEmpty(_collectGuid))
|
{
|
return _obj;
|
}
|
//投入,直接提交
|
if (txt_gx.Text.Trim() == fGxTouRu)
|
{
|
return _obj;
|
}
|
return null;
|
}
|
|
/// <summary>
|
/// 上报实体
|
/// </summary>
|
/// <param name="_checkResult">结果:√</param>
|
/// <param name="_badDescription">不良描述</param>
|
private void addModel(string _checkResult, string _badDescription = "", string _collectGuid = "")
|
{
|
string _barCode = txt_barCode.Text.Trim();
|
if (string.IsNullOrEmpty(_collectGuid))
|
{
|
if (string.IsNullOrEmpty(_barCode))
|
{
|
Toast vm = new Toast(-1, "操作失败@n请先扫描追溯码");
|
vm.Show();
|
this.ActiveControl = this.txt_barCode;
|
txt_barCode.Focus();
|
return;
|
}
|
}
|
dynamic _obj = getObj(_barCode, _checkResult, _badDescription, _collectGuid);
|
try
|
{
|
string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj));
|
ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson);
|
if (_rtn.rtnCode > 0)
|
{
|
dynamic dy = _rtn.rtnData;
|
//表头和汇总
|
UtilityHelper.SetValueByObj(this.layoutMx1.Controls, dy, false);
|
lbSum1.Text = dy.lbSum1;
|
lbSum2.Text = dy.lbSum2;
|
lbSum3.Text = dy.lbSum3;
|
lbSum4.Text = dy.lbSum4;
|
prog1.Position = dy.jd;
|
txt_barCode.ReadOnly = false;
|
txt_OldLiuShuiMa.ReadOnly = false;
|
//良品列表
|
JObject _job = JObject.Parse(strJson);
|
JArray array = new JArray();
|
foreach (var a in _job["rtnData"]["list"])
|
{
|
array.Add(a);
|
}
|
DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString());
|
if (dt.Rows.Count > 0)
|
{
|
gcMx1.BindingContext = new BindingContext();
|
gcMx1.DataSource = dt;
|
gcMx1.ForceInitialize();
|
gvMx1.BestFitColumns();
|
Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx1);
|
}
|
else
|
{
|
Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1);
|
}
|
//不良品列表
|
JArray array2 = new JArray();
|
foreach (var a in _job["rtnData"]["list2"])
|
{
|
array2.Add(a);
|
}
|
DataTable dt2 = JsonConvert.DeserializeObject<DataTable>(array2.ToString());
|
if (dt2.Rows.Count > 0)
|
{
|
gcMx2.BindingContext = new BindingContext();
|
gcMx2.DataSource = dt2;
|
gcMx2.ForceInitialize();
|
gvMx2.BestFitColumns();
|
Gs.DevApp.ToolBox.UtilityHelper.SetGridLayout(gvMx2);
|
}
|
else
|
{
|
Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx2, gvMx2);
|
}
|
string _msg = _rtn.rtnMsg;
|
if (!string.IsNullOrEmpty(_msg))
|
{
|
// Toast vm = new Toast((goodTag == "√" ? 1 : -1), _msg); 2025-08-20 修改提示外观
|
Toast vm;
|
if (_msg.EndsWith("."))
|
vm = new Toast(-1, _rtn.rtnMsg);
|
else
|
vm = new Toast(1, _rtn.rtnMsg);
|
vm.Show();
|
}
|
}
|
else
|
{
|
Toast vm = new Toast(-1, _rtn.rtnMsg);
|
vm.Show();
|
}
|
}
|
catch (Exception ex)
|
{
|
Toast vm = new Toast(-1, ex.Message);
|
vm.Show();
|
}
|
txt_barCode.Text = "";
|
txt_OldLiuShuiMa.Text = "";
|
this.ActiveControl = this.txt_barCode;
|
txt_barCode.Focus();
|
}
|
}
|
}
|