Browse Source

喷涂用户登陆的优化.其它细节问题优化

master
ruoxing.wang 3 weeks ago
parent
commit
0be1d3cd90
  1. 3
      PaintingPC/FrmLogin.cs
  2. 380
      PaintingPC/FrmQuality.cs
  3. 22
      PaintingPC/Function.cs
  4. 1
      PaintingPC/Program.cs

3
PaintingPC/FrmLogin.cs

@ -67,7 +67,8 @@ namespace PaintingPC
if (dt != null && dt.Rows.Count > 0)
{
this.Visible = false;
Form fr = new FrmQuality(false);
Program.UserName = textBox1.Text.Trim();
Form fr = new FrmQuality(false);
fr.Show();
}

380
PaintingPC/FrmQuality.cs

@ -313,35 +313,44 @@ namespace PaintingPC
/// <param name="e"></param>
private void btnOk_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
try
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
ShowHint("");
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName,ref partName) == false) return;
#endregion
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
ShowHint("");
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
bool rr = SaveBeforeVerify("合格");
if(rr == false)
#endregion
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
bool rr = SaveBeforeVerify("合格");
if (rr == false)
{
return;
}
//if (lastRst.Contains("合格"))
//{
// MessageBox.Show("条码已判定为合格,无需重复判定");
// Clear();
// return;
//}
SaveRst("合格", colorName, partName, 1);
}
catch(Exception ex)
{
return;
ShowHint("执行合格判定发生异常,异常原因:" + ex.Message);
MessageBox.Show("执行合格判定发生异常,异常原因:" + ex.Message);
Clear();
}
//if (lastRst.Contains("合格"))
//{
// MessageBox.Show("条码已判定为合格,无需重复判定");
// Clear();
// return;
//}
SaveRst("合格", colorName, partName,1);
}
void Clear()
@ -358,175 +367,205 @@ namespace PaintingPC
/// <param name="e"></param>
private void btnNok_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行[其它]判定?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
ShowHint("");
#region 必须选择缺陷位置与缺陷原因,否则无法保存
if (CheckDefect() == false) return;
#endregion
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
int cs = Function.OtherTimes(txtBarCode.Text.Trim());
if (cs > 0)
{
MessageBox.Show("条码"+ txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
ShowHint("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
Clear();
return;
}
bool rr = SaveBeforeVerify("其它");
if (rr == false)
{
return;
}
SaveRst("其它", colorName, partName,4);
}
/// <summary>
/// 返喷按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnRepair_Click(object sender, EventArgs e)
{
#region 可回喷次数 =1,不能打磨, =2 可以, 不能有两次质检结果为打磨
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
try
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行返喷操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
ShowHint("");
string barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim());
int cs = Function.YiDaMoCiShu(barcode); //记录中已返喷次数
int keHuiPen = Function.keHuiPen(barcode); //基础数据中,可返喷次数
if (keHuiPen > 1)
keHuiPen = 1;
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
if (keHuiPen > 0 && cs < keHuiPen)
{
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行[其它]判定?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
ShowHint("");
#region 必须选择缺陷位置与缺陷原因,否则无法保存
if (CheckDefect() == false) return;
#endregion
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
ClearControlColor(SetControlGroup());
btnRepair.BackColor = Color.Yellow;
//string lastRst = GetLastInspectRst(txtBarCode.Text.Trim());
//if (lastRst.Contains("打磨"))
//{
// ShowHint("条码已判定为返喷,无需重复判定");
// MessageBox.Show("条码已判定为返喷,无需重复判定");
// Clear();
// return;
//}
string s = _isWmsQuality == false ? "打磨" : "打磨WMS";
int cs = Function.OtherTimes(txtBarCode.Text.Trim());
if (cs > 0)
{
MessageBox.Show("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
ShowHint("条码" + txtBarCode.Text.Trim() + "已存在判定为其它的记录,只允许判定1次.");
Clear();
return;
}
bool rr = SaveBeforeVerify("返喷");
bool rr = SaveBeforeVerify("其它");
if (rr == false)
{
return;
}
SaveRst(s, colorName, partName,9);
SaveRst("其它", colorName, partName, 4);
}
else
catch(Exception ex)
{
ShowHint("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
MessageBox.Show("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
ShowHint("执行其它判定发生异常,异常原因:" + ex.Message);
MessageBox.Show("执行其它判定发生异常,异常原因:" + ex.Message);
Clear();
return;
}
#endregion
}
/// <summary>
/// 报废按钮
/// 返喷按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAbt_Click(object sender, EventArgs e)
private void btnRepair_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
try
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
// if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行报废操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
UserInput(userName => {
if (string.IsNullOrEmpty(userName))
#region 可回喷次数 =1,不能打磨, =2 可以, 不能有两次质检结果为打磨
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("报废必须录入用户名.");
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
else
if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行返喷操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
ShowHint("");
string barcode = Function.UniteBarCodeToOne(txtBarCode.Text.Trim());
int cs = Function.YiDaMoCiShu(barcode); //记录中已返喷次数
int keHuiPen = Function.keHuiPen(barcode); //基础数据中,可返喷次数
if (keHuiPen > 1)
keHuiPen = 1;
if (keHuiPen > 0 && cs < keHuiPen)
{
ShowHint("");
#region 必须选择缺陷位置与缺陷原因,否则无法保存
if (CheckDefect() == false) return;
#endregion
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
ClearControlColor(SetControlGroup());
btnRepair.BackColor = Color.Yellow;
//string lastRst = GetLastInspectRst(txtBarCode.Text.Trim());
//if (lastRst.Contains("合格"))
//if (lastRst.Contains("打磨"))
//{
// MessageBox.Show("条码已判定为合格,无法重新判定为报废");
// Clear();
// return;
//}
//if (lastRst.Contains("报废"))
//{
// MessageBox.Show("条码已判定为报废,无需重复报废");
// ShowHint("条码已判定为返喷,无需重复判定");
// MessageBox.Show("条码已判定为返喷,无需重复判定");
// Clear();
// return;
//}
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
string s = _isWmsQuality == false ? "打磨" : "打磨WMS";
bool rr = SaveBeforeVerify("报废");
bool rr = SaveBeforeVerify("返喷");
if (rr == false)
{
return;
}
SaveRst(s, colorName, partName, 9);
SaveRst("报废", colorName, partName,2, userName);
}
});
else
{
ShowHint("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
MessageBox.Show("根据该零件可回喷次数设置,不能判定为返喷或已超过返喷次数!");
Clear();
return;
}
#endregion
}
catch(Exception ex)
{
ShowHint("执行返喷操作发生异常,异常原因:"+ex.Message);
MessageBox.Show("执行返喷操作发生异常,异常原因:" + ex.Message);
Clear();
}
}
/// <summary>
/// 报废按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnAbt_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(txtBarCode.Text.Trim()))
{
MessageBox.Show("请先扫描数据,然后操作.");
return;
}
// if (MessageBox.Show($"确认对[{txtBarCode.Text}]进行报废操作?", "操作确认", MessageBoxButtons.OKCancel) == DialogResult.Cancel) return;
//UserInput(userName => {
//string userName = Program.UserName;
// if (string.IsNullOrEmpty(userName))
// {
// MessageBox.Show("报废必须录入用户名.");
// return;
// }
// else
// {
ShowHint("");
#region 必须选择缺陷位置与缺陷原因,否则无法保存
if (CheckDefect() == false) return;
#endregion
#region 判断产品是否有颜色
string colorName = string.Empty;
string partName = string.Empty;
if (CheckColor(ref colorName, ref partName) == false) return;
#endregion
//string lastRst = GetLastInspectRst(txtBarCode.Text.Trim());
//if (lastRst.Contains("合格"))
//{
// MessageBox.Show("条码已判定为合格,无法重新判定为报废");
// Clear();
// return;
//}
//if (lastRst.Contains("报废"))
//{
// MessageBox.Show("条码已判定为报废,无需重复报废");
// Clear();
// return;
//}
ClearControlColor(SetControlGroup());
btnAbt.BackColor = Color.Red;
bool rr = SaveBeforeVerify("报废");
if (rr == false)
{
return;
}
SaveRst("报废", colorName, partName, 2);
// }
// });
}
catch(Exception ex)
{
ShowHint("执行报废操作发生异常,异常原因:" + ex.Message);
MessageBox.Show("执行报废操作发生异常,异常原因:" + ex.Message);
Clear();
}
}
/// <summary>
///
@ -537,7 +576,15 @@ namespace PaintingPC
/// <param name="isOK">0-不合格;1-合格;9-返喷 8-其他 </param>
void SaveRst(string state, string colorName, string partName,int isOK,string userName="")
{
if (string.IsNullOrEmpty(userName))
{
userName = Program.UserName;
}
if (string.IsNullOrEmpty(userName))
{
}
string bcode = txtBarCode.Text.Trim();
//保存
string id = SaveInspect(state, colorName, partName, userName);
@ -545,10 +592,11 @@ namespace PaintingPC
{
if (!string.IsNullOrEmpty(id))
{
bool rst = SendToWms(txtBarCode.Text.Trim(), isOK);
string interfaceMsg = string.Empty;
bool rst = SendToWms(txtBarCode.Text.Trim(), isOK,ref interfaceMsg);
if (rst == false)
{
DeleteRepectRst(id);
DeleteRepectRst(id, "Web接口调用返回false,原因:" + interfaceMsg, bcode);
}
else
{
@ -565,14 +613,19 @@ namespace PaintingPC
}
catch (Exception ex)
{
ShowHint("合格WMS报工异常,原因:" + ex.Message);
MessageBox.Show("合格WMS报工异常,原因:" + ex.Message);
LogHelper.WriteErrLogBase("合格WMS报工调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
if (ex.Message.Contains("WMS"))
{
DeleteRepectRst(id,"Web接口调用抛出异常,异常原因:" + ex.Message , bcode);
}
ShowHint(state+"-WMS报工异常,原因:" + ex.Message);
MessageBox.Show(state+"-WMS报工异常,原因:" + ex.Message);
LogHelper.WriteErrLogBase(state+"-WMS报工调用WMS接口:" + ex.ToString(), MethodBase.GetCurrentMethod().Name);
}
}
private void DeleteRepectRst(string id)
private void DeleteRepectRst(string id,string msg,string oneBarCode)
{
Function.DelInspectRst(id);
LogHelper.WriteErrLogBase($"接口异常,删除塑件[{oneBarCode}]喷涂质检记录,异常内容:" + msg, MethodBase.GetCurrentMethod().Name);
}
/// <summary>
@ -595,9 +648,10 @@ namespace PaintingPC
/// </summary>
/// <param name="scanBarCode"></param>
/// <param name="isOk">0:报废 1:合格 9:返喷 </param>
bool SendToWms(string scanBarCode, int isOk)
bool SendToWms(string scanBarCode, int isOk,ref string errorMsg)
{
try
{
WMSWebService webService = new WMSWebService();
webService.Url = ConfigurationManager.AppSettings["WMSWebServiceURL"].ToString();
//webService.Timeout = 1200000;
@ -605,25 +659,29 @@ namespace PaintingPC
//上次异常提交
if (_lastJustDict.Count > 0)
{
bool rst2 = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(_lastJustDict.First().Key), int.Parse( _lastJustDict.First().Value), out errorReason);
bool rst2 = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(_lastJustDict.First().Key), int.Parse(_lastJustDict.First().Value), out errorReason);
}
bool rst = webService.WMSSprayingForCS(Function.UniteBarCodeToOne(scanBarCode), isOk, out errorReason);
if (rst == false)
{
MessageBox.Show("调用远程接口失败" );
ShowHint("调用远程接口失败: " + errorReason);
MessageBox.Show("调用远程接口失败");
ShowHint("调用远程接口失败: " + errorReason);
_lastJustDict.Clear();
_lastJustDict.Add(scanBarCode, isOk.ToString());
return false;
}
_lastJustDict.Clear();
return true;
_lastJustDict.Clear();
return true;
}
catch(Exception ex)
{
throw new Exception("WMS接口调用异常,异常原因:" + ex.Message);
}
}
/// <summary>
@ -1125,7 +1183,17 @@ namespace PaintingPC
{
string paintError = string.Empty;
//喷涂线边质检,没有质检结果,查询老外数据库,取产品信息
string[] info = Function.GetProductInfo2(barcode,ref paintError).Split(',');
string foreignVal = Function.GetProductInfo2(barcode, ref paintError);
if (!string.IsNullOrEmpty(paintError))
{
lbForeig.Text = paintError;
}
if (string.IsNullOrEmpty(foreignVal))
{
return;
}
string[] info = foreignVal.Split(',');
if (!string.IsNullOrEmpty(paintError))
{
ShowHint(paintError);

22
PaintingPC/Function.cs

@ -130,7 +130,7 @@ namespace PaintingPC
sql = " select * from tb_Product where PartNo = '" + partNo.Trim() + @"'";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
}
LogHelper.WriteSysLogBase("[入参:]barcode=" + barcode+"[sql:]"+ sql, MethodBase.GetCurrentMethod().Name);
//LogHelper.WriteSysLogBase("[入参:]barcode=" + barcode+"[sql:]"+ sql, MethodBase.GetCurrentMethod().Name);
return res;
}
catch (Exception ex)
@ -148,7 +148,7 @@ namespace PaintingPC
{
string sql = @" select * from tb_Defect where LineID = (select LineID from tb_Station where StationNo = '"+ stationNo +@"') ";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
LogHelper.WriteSysLogBase("[入参:]stationNo=" + stationNo + "[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
//LogHelper.WriteSysLogBase("[入参:]stationNo=" + stationNo + "[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
return res;
}
catch (Exception ex)
@ -365,7 +365,7 @@ namespace PaintingPC
}
LogHelper.WriteSysLogBase("[入参:]skidNo=" + skidNo + ";[出参:]colorInfo=" + colorInfo, MethodBase.GetCurrentMethod().Name);
//LogHelper.WriteSysLogBase("[入参:]skidNo=" + skidNo + ";[出参:]colorInfo=" + colorInfo, MethodBase.GetCurrentMethod().Name);
return res;
}
catch (Exception ex)
@ -1687,7 +1687,7 @@ namespace PaintingPC
UNION
SELECT * from (select TOP 30 * from tb_InspectResult where barcode = '" + barcode + @"' AND InspectTimes = '3' ORDER BY createTime DESC) cc) dd order by createTime DESC ";
res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null);
LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
// LogHelper.WriteSysLogBase("[sql:]" + sql, MethodBase.GetCurrentMethod().Name);
return res;
}
catch (Exception ex)
@ -1811,7 +1811,7 @@ namespace PaintingPC
return "";
}
}
private static string foreignSqlConnString = string.Empty;
public static string GetProductInfo2(string barcode,ref string errorMsg)
{
string res = "";
@ -1863,9 +1863,9 @@ namespace PaintingPC
OR LTrim(RTrim(Side2_Data5))= @barcode
OR LTrim(RTrim(Side2_Data6))= @barcode
";
string sqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
foreignSqlConnString = ConfigurationManager.ConnectionStrings["SqlConnStringForeign"].ToString();
//object aa = SqlHelper.ExecuteScalar(sqlConnString, CommandType.Text, sql, null);
DataTable dtColor = SqlHelper.GetDataDateTable(sqlConnString, CommandType.Text, sql, null);
DataTable dtColor = SqlHelper.GetDataDateTable(foreignSqlConnString, CommandType.Text, sql, null);
if (dtColor != null && dtColor.Rows.Count > 0)
@ -1966,6 +1966,14 @@ namespace PaintingPC
{
LogHelper.WriteLogManager(ex);
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name);
if(ex.Message.Contains("TCP Provider"))
{
errorMsg = "外库网络连接失败!";
}
else
{
errorMsg = ex.Message;
}
return res;
}
}

1
PaintingPC/Program.cs

@ -16,6 +16,7 @@ namespace PaintingPC
public static string IP;
public static string PicturePath;
public static string station;
public static string UserName;
/// <summary>
/// 应用程序的主入口点。

Loading…
Cancel
Save