Commit 6af4d630 LN

元器件修改时若pn库位重复时提示是否确定保存。

1 个父辈 92e3c8f2
...@@ -96,6 +96,8 @@ namespace TSA_V.Common ...@@ -96,6 +96,8 @@ namespace TSA_V.Common
public static MyConfig<bool> Device_HandsVideo= false; public static MyConfig<bool> Device_HandsVideo= false;
[MyConfigComment("是否启用元器件计数功能")] [MyConfigComment("是否启用元器件计数功能")]
public static MyConfig<bool> Device_UsePNCount = true; public static MyConfig<bool> Device_UsePNCount = true;
[MyConfigComment("位号是否可以修改")]
public static MyConfig<bool> Device_CanModifyTagNo = false ;
[MyConfigComment("手势服务器端口")] [MyConfigComment("手势服务器端口")]
public static MyConfig<int> Hand_ServerPort = 8765; public static MyConfig<int> Hand_ServerPort = 8765;
[MyConfigComment("手势范围设置:x,y,w,h")] [MyConfigComment("手势范围设置:x,y,w,h")]
......
...@@ -128,6 +128,85 @@ namespace TSA_V ...@@ -128,6 +128,85 @@ namespace TSA_V
} }
private string getListMsg(List<string> list)
{
string msg = "";
foreach (string str in list)
{
msg += str + ",";
}
return msg.Substring(0, msg.Length - 1);
}
private bool ProcessComData(string bomName, ComponetInfo currCom)
{
Dictionary<string, List<string>> PnPositonMap = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> positionPNMap = new Dictionary<string, List<string>>();
List<ComponetInfo> currComList = CSVBomManager.GetComList(bomName);
string showMsg = "";
//PN相同库位相同的,不需要配置
List<ComponetInfo> vars = (from m in currComList where m.Id != currCom.Id && m.PN.Equals(currCom.PN) && m.PositionNum.Equals(currCom.PositionNum) select m).ToList();
if (vars.Count > 0)
{
showMsg += ResourceCulture.GetString(ResourceCulture.PnHasPos, "元器件【{0}】已配置位置【{1}】,请重新输入位置", vars[0].PN, vars[0].PositionNum) + "\r\n";
MessageBox.Show(showMsg, ResourceCulture.GetString(ResourceCulture.MsgTitle, "提示"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
cmbPositionNumList.Focus();
return false;
}
showMsg = "";
//PN不同库位相同的,
vars = (from m in currComList where m.Id != currCom.Id && m.PositionNum.Equals(currCom.PositionNum) select m).ToList();
List<string> pns = new List<string>();
pns.Add(currCom.PN);
if (vars.Count > 0)
{
foreach (ComponetInfo component in vars)
{
pns.Add(component.PN);
}
if (pns.Count > 1)
{
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPn,
"位置【{0}】配置多个元器件【{1}】", currCom.PositionNum, getListMsg(pns)) + "\r\n";
DialogResult result = MessageBox.Show(showMsg, ResourceCulture.GetString(ResourceCulture.MsgTitle, "提示"), MessageBoxButtons.OKCancel); ;
if (!result.Equals(DialogResult.OK))
{
cmbPositionNumList.Focus();
return false;
}
}
}
showMsg = "";
//PN相同库位相同的,不需要配置
vars = (from m in currComList where m.Id != currCom.Id && m.PN.Equals(currCom.PN) select m).ToList();
List<string> positions = new List<string>();
positions.Add(currCom.PositionNum);
if (vars.Count > 0)
{
foreach (ComponetInfo component in vars)
{
positions.Add(component.PositionNum);
}
if (positions.Count > 1)
{
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPosition, "元器件【{0}】配置多个位置【{1}】,是否确定导入?", currCom.PN, getListMsg(positions)) + "\r\n";
DialogResult result = MessageBox.Show(showMsg, ResourceCulture.GetString(ResourceCulture.MsgTitle, "提示"), MessageBoxButtons.OKCancel); ;
if (!result.Equals(DialogResult.OK))
{
cmbPositionNumList.Focus();
return false;
}
}
}
return true;
}
private void btnSave_Click(object sender, EventArgs e) private void btnSave_Click(object sender, EventArgs e)
{ {
if (IsNew) if (IsNew)
...@@ -225,6 +304,12 @@ namespace TSA_V ...@@ -225,6 +304,12 @@ namespace TSA_V
} }
} }
bool sureSave = ProcessComData(cmbList.Text, obj);
if(!sureSave)
{
return;
}
bool result = CSVBomManager.UpdateComponet(cmbList.Text, obj); bool result = CSVBomManager.UpdateComponet(cmbList.Text, obj);
if (result) if (result)
{ {
...@@ -298,7 +383,13 @@ namespace TSA_V ...@@ -298,7 +383,13 @@ namespace TSA_V
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ComExists, "元器件已存在")); MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ComExists, "元器件已存在"));
} }
} }
obj.Id = (from m in allList orderby m.Id descending select m.Id).First() + 1;
bool sureSave = ProcessComData(cmbList.Text, obj);
if (!sureSave)
{
return null;
}
List<ComponetInfo> list = CSVBomManager.AddCom(cmbList.Text, obj); List<ComponetInfo> list = CSVBomManager.AddCom(cmbList.Text, obj);
if (list == null) if (list == null)
......
...@@ -2788,4 +2788,5 @@ ...@@ -2788,4 +2788,5 @@
<data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> List </value> </data> <data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> List </value> </data>
<data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> Cancel Addition </value> </data> <data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> Cancel Addition </value> </data>
<data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> Confirm Addition </value> </data> <data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> Confirm Addition </value> </data>
<data name = "PnHasPos" xml:space = "preserve"> <value> The component [{0}] has been configured at position [{1}], please re-enter the position </value> </data>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -2766,4 +2766,5 @@ ...@@ -2766,4 +2766,5 @@
<data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> 列表 </value> </data> <data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> 列表 </value> </data>
<data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> 放弃添加 </value> </data> <data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> 放弃添加 </value> </data>
<data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> 确认添加 </value> </data> <data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> 确认添加 </value> </data>
<data name = "PnHasPos" xml:space = "preserve"> <value> 元器件【{0}】已配置位置【{1}】,请重新输入位置 </value> </data>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -3009,5 +3009,6 @@ ...@@ -3009,5 +3009,6 @@
<data name = "FrmSureAddCom_label1_Text" xml:space = "preserve"> <value> 新元器件添加到以下程序 </value> </data> <data name = "FrmSureAddCom_label1_Text" xml:space = "preserve"> <value> 新元器件添加到以下程序 </value> </data>
<data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> 列表 </value> </data> <data name = "FrmSureAddCom_焊点列表_Text" xml:space = "preserve"> <value> 列表 </value> </data>
<data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> 放弃添加 </value> </data> <data name = "FrmSureAddCom_btnClose_Text" xml:space = "preserve"> <value> 放弃添加 </value> </data>
<data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> 确认添加 </value> </data> <data name = "FrmSureAddCom_btnSave_Text" xml:space = "preserve"> <value> 确认添加 </value> </data>
<data name = "PnHasPos" xml:space = "preserve"> <value> 元器件【{0}】已配置位置【{1}】,请重新输入位置 </value> </data>
</root> </root>
\ No newline at end of file \ No newline at end of file
...@@ -927,6 +927,10 @@ namespace TSA_V ...@@ -927,6 +927,10 @@ namespace TSA_V
/// NoSaveBack=不保存直接返回 /// NoSaveBack=不保存直接返回
/// </summary> /// </summary>
internal static readonly string NoSaveBack= "NoSaveBack"; internal static readonly string NoSaveBack= "NoSaveBack";
/// <summary>
/// 元器件【{0}】已配置位置【{1}】,请重新输入位置
/// </summary>
public static string PnHasPos = "PnHasPos";
} }
} }
...@@ -607,15 +607,7 @@ namespace TSA_V ...@@ -607,15 +607,7 @@ namespace TSA_V
if (positions.Count > 1) if (positions.Count > 1)
{ {
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPosition, showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPosition,
"元器件【{0}】配置多个位置【{1}】,是否确定导入?", pnKey, getListMsg(positions)) + "\r\n"; "元器件【{0}】配置多个位置【{1}】,是否确定导入?", pnKey, getListMsg(positions)) + "\r\n";
// DialogResult result = MessageBox.Show(ResourceCulture.GetString(ResourceCulture.SureImportPosition,
// "元器件【{0}】配置多个位置【{1}】,是否确定导入?", pnKey, getListMsg(positions), "",
// MessageBoxButtons.OKCancel)); ;
// if (!result.Equals(DialogResult.OK))
// {
// uploadPointList = new List<ComponetInfo>();
// return false ;
// }
} }
} }
if (showMsg != "") if (showMsg != "")
...@@ -635,15 +627,7 @@ namespace TSA_V ...@@ -635,15 +627,7 @@ namespace TSA_V
if (pnList.Count > 1) if (pnList.Count > 1)
{ {
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPn, showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPn,
"位置【{0}】配置多个元器件【{1}】,是否确定导入?", key, getListMsg(pnList)) + "\r\n"; "位置【{0}】配置多个元器件【{1}】,是否确定导入?", key, getListMsg(pnList)) + "\r\n";
//DialogResult result = MessageBox.Show(ResourceCulture.GetString(ResourceCulture.SureImportPn,
// "位置【{0}】配置多个元器件【{1}】,是否确定导入?", key, getListMsg(pnList), "",
// MessageBoxButtons.OKCancel)); ;
//if (!result.Equals(DialogResult.OK))
//{
// uploadPointList = new List<ComponetInfo>();
// return false ;
//}
} }
} }
......
...@@ -44,13 +44,12 @@ namespace TSA_V ...@@ -44,13 +44,12 @@ namespace TSA_V
} }
public FrmPointInfo(BoardInfo board, string name, double x, double y, double nodex, double nodey) public FrmPointInfo(BoardInfo board, string name, double x, double y, double nodex, double nodey)
{ {
InitializeComponent(); InitializeComponent();
loadPositionList();
this.boardInfo = board; this.boardInfo = board;
isNewPoint = true; isNewPoint = true;
this.Text = "新增组装信息"; this.Text = "新增组装信息";
this.txtTagNo.Text = name; this.txtTagNo.Text = name;
updateFrom(true); updateFrom(true,null);
LoadControl(x, y, nodex, nodey); LoadControl(x, y, nodex, nodey);
} }
...@@ -81,28 +80,43 @@ namespace TSA_V ...@@ -81,28 +80,43 @@ namespace TSA_V
} }
private void updateFrom(bool isNew) private void updateFrom(bool isNew,SMTPointInfo point )
{ {
this.txtPn.Enabled = false; this.txtPn.Enabled = false;
this.txtTagNo.Enabled = isNew;
btnSaveAndNext.Visible = !isNew; btnSaveAndNext.Visible = !isNew;
this.txtPn.Visible = !isNew; this.txtPn.Visible = !isNew;
this.txtTagNo.Enabled = isNew;
cmbPnList.Visible = isNew; cmbPnList.Visible = isNew;
this.txtPn.Text = ""; this.txtPn.Text = "";
List<string> pnList = new List<string>();
List<ComponetInfo> list = CSVBomManager.GetComList(this.boardInfo.bomName);
foreach (ComponetInfo obj in list)
{
if (!pnList.Contains(obj.PN))
{
pnList.Add(obj.PN);
}
}
if (isNew) if (isNew)
{ {
cmbPnList.Items.Clear();
List<string> pnList = new List<string>(); cmbPnList.DataSource = pnList;
List<ComponetInfo> list = CSVBomManager.GetComList(this.boardInfo.bomName); }
foreach (ComponetInfo obj in list) else if(Setting_NInit.Device_CanModifyTagNo&& point!=null)
{
if (!pnList.Contains(point.PN))
{ {
if (!pnList.Contains(obj.PN)) pnList.Insert(0,point.PN);
{
pnList.Add(obj.PN);
}
} }
cmbPnList.Items.Clear(); cmbPnList.Items.Clear();
cmbPnList.DataSource = pnList; cmbPnList.DataSource = pnList;
cmbPnList.SelectedIndex = pnList.IndexOf(point.PN);
txtPn.Visible = false;
txtTagNo.Enabled = true;
cmbPnList.Enabled = true;
cmbPnList.Visible = true;
} }
} }
...@@ -126,16 +140,6 @@ namespace TSA_V ...@@ -126,16 +140,6 @@ namespace TSA_V
}); });
return true; return true;
} }
//private List<TSAVPosition> allPosition = new List<TSAVPosition>(CSVPositionReader<TSAVPosition>.allPositionMap.Values);
private void loadPositionList()
{
//cmbPositionNumList.DataSource = null;
//cmbPositionNumList.DataSource = allPosition;
//cmbPositionNumList.DisplayMember = "PositionNum";
//cmbPositionNumList.ValueMember = "PositionNum";
}
public List<SMTPointInfo> PointList = new List<SMTPointInfo>(); public List<SMTPointInfo> PointList = new List<SMTPointInfo>();
public int CurrIndex = -1; public int CurrIndex = -1;
...@@ -158,29 +162,19 @@ namespace TSA_V ...@@ -158,29 +162,19 @@ namespace TSA_V
private void ShowPoint(SMTPointInfo prePoint) private void ShowPoint(SMTPointInfo prePoint)
{ {
updateFrom(false);
btnSave.Visible = true; btnSave.Visible = true;
this.smtPointInfo = PointList[CurrIndex]; this.smtPointInfo = PointList[CurrIndex];
updateFrom(false, smtPointInfo);
if (smtPointInfo.CheckOK) if (smtPointInfo.CheckOK)
{ {
rdbPro.Checked = true; rdbPro.Checked = true;
} }
else else
{ {
//if (Setting_NInit.Device_AutoGuoBan) rdbImg.Checked = true;
//{
// rdbImg.Checked = true;
//}
//else
//{
// rdbPro.Checked = true;
//}
rdbImg.Checked = true;
} }
this.Text = "修改组装信息【" + smtPointInfo.PN + "】 "; this.Text = "修改组装信息【" + smtPointInfo.PN + "】 ";
loadPositionList();
this.txtPn.Text = smtPointInfo.PN; this.txtPn.Text = smtPointInfo.PN;
...@@ -282,24 +276,34 @@ namespace TSA_V ...@@ -282,24 +276,34 @@ namespace TSA_V
} }
string tagNo = FormUtil.getValue(txtTagNo); string tagNo = FormUtil.getValue(txtTagNo);
int checkCount = 0;
if (isNewPoint) if (isNewPoint)
{ {
if (tagNo.Equals("")) }
else
{
if (tagNo != smtPointInfo.TagNo)
{ {
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
txtTagNo.Focus();
return false;
} }
List<SMTPointInfo> pos = (from m in boardInfo.smtList where m.pointNum != smtPointInfo.pointNum && m.TagNo.Equals(tagNo) select m).ToList(); else
if (pos.Count > 0) {
{ checkCount = 1;
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
txtTagNo.Text = smtPointInfo.TagNo;
txtTagNo.Focus();
return false;
} }
} }
if (tagNo.Equals(""))
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
txtTagNo.Focus();
return false;
}
List<SMTPointInfo> pos = (from m in boardInfo.smtList where m.pointNum != smtPointInfo.pointNum && m.TagNo.Equals(tagNo) select m).ToList();
if (pos.Count > checkCount)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
txtTagNo.Text = smtPointInfo.TagNo;
txtTagNo.Focus();
return false;
}
smtPointInfo.PN = pn; smtPointInfo.PN = pn;
smtPointInfo.TagNo = tagNo; smtPointInfo.TagNo = tagNo;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!