Commit 6af4d630 LN

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

1 个父辈 92e3c8f2
......@@ -96,6 +96,8 @@ namespace TSA_V.Common
public static MyConfig<bool> Device_HandsVideo= false;
[MyConfigComment("是否启用元器件计数功能")]
public static MyConfig<bool> Device_UsePNCount = true;
[MyConfigComment("位号是否可以修改")]
public static MyConfig<bool> Device_CanModifyTagNo = false ;
[MyConfigComment("手势服务器端口")]
public static MyConfig<int> Hand_ServerPort = 8765;
[MyConfigComment("手势范围设置:x,y,w,h")]
......
......@@ -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)
{
if (IsNew)
......@@ -225,6 +304,12 @@ namespace TSA_V
}
}
bool sureSave = ProcessComData(cmbList.Text, obj);
if(!sureSave)
{
return;
}
bool result = CSVBomManager.UpdateComponet(cmbList.Text, obj);
if (result)
{
......@@ -298,7 +383,13 @@ namespace TSA_V
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);
if (list == null)
......
......@@ -2788,4 +2788,5 @@
<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_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>
\ No newline at end of file
......@@ -2766,4 +2766,5 @@
<data name = "FrmSureAddCom_焊点列表_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 = "PnHasPos" xml:space = "preserve"> <value> 元器件【{0}】已配置位置【{1}】,请重新输入位置 </value> </data>
</root>
\ No newline at end of file
......@@ -3010,4 +3010,5 @@
<data name = "FrmSureAddCom_焊点列表_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 = "PnHasPos" xml:space = "preserve"> <value> 元器件【{0}】已配置位置【{1}】,请重新输入位置 </value> </data>
</root>
\ No newline at end of file
......@@ -927,6 +927,10 @@ namespace TSA_V
/// NoSaveBack=不保存直接返回
/// </summary>
internal static readonly string NoSaveBack= "NoSaveBack";
/// <summary>
/// 元器件【{0}】已配置位置【{1}】,请重新输入位置
/// </summary>
public static string PnHasPos = "PnHasPos";
}
}
......@@ -608,14 +608,6 @@ namespace TSA_V
{
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPosition,
"元器件【{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 != "")
......@@ -636,14 +628,6 @@ namespace TSA_V
{
showMsg += ResourceCulture.GetString(ResourceCulture.SureImportPn,
"位置【{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 ;
//}
}
}
......
......@@ -45,12 +45,11 @@ namespace TSA_V
public FrmPointInfo(BoardInfo board, string name, double x, double y, double nodex, double nodey)
{
InitializeComponent();
loadPositionList();
this.boardInfo = board;
isNewPoint = true;
this.Text = "新增组装信息";
this.txtTagNo.Text = name;
updateFrom(true);
updateFrom(true,null);
LoadControl(x, y, nodex, nodey);
}
......@@ -81,16 +80,15 @@ namespace TSA_V
}
private void updateFrom(bool isNew)
private void updateFrom(bool isNew,SMTPointInfo point )
{
this.txtPn.Enabled = false;
this.txtTagNo.Enabled = isNew;
btnSaveAndNext.Visible = !isNew;
this.txtPn.Visible = !isNew;
this.txtTagNo.Enabled = isNew;
cmbPnList.Visible = isNew;
this.txtPn.Text = "";
if (isNew)
{
List<string> pnList = new List<string>();
List<ComponetInfo> list = CSVBomManager.GetComList(this.boardInfo.bomName);
......@@ -101,9 +99,25 @@ namespace TSA_V
pnList.Add(obj.PN);
}
}
if (isNew)
{
cmbPnList.Items.Clear();
cmbPnList.DataSource = pnList;
}
else if(Setting_NInit.Device_CanModifyTagNo&& point!=null)
{
if (!pnList.Contains(point.PN))
{
pnList.Insert(0,point.PN);
}
cmbPnList.Items.Clear();
cmbPnList.DataSource = pnList;
cmbPnList.SelectedIndex = pnList.IndexOf(point.PN);
txtPn.Visible = false;
txtTagNo.Enabled = true;
cmbPnList.Enabled = true;
cmbPnList.Visible = true;
}
}
private bool projectorControl_ShowPointEvent(ProjectorPInfo p)
......@@ -127,16 +141,6 @@ namespace TSA_V
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 int CurrIndex = -1;
public FrmPointInfo( BoardInfo board, List<SMTPointInfo> list, int currIndex,NextDel fun=null)
......@@ -158,29 +162,19 @@ namespace TSA_V
private void ShowPoint(SMTPointInfo prePoint)
{
updateFrom(false);
btnSave.Visible = true;
this.smtPointInfo = PointList[CurrIndex];
updateFrom(false, smtPointInfo);
if (smtPointInfo.CheckOK)
{
rdbPro.Checked = true;
}
else
{
//if (Setting_NInit.Device_AutoGuoBan)
//{
// rdbImg.Checked = true;
//}
//else
//{
// rdbPro.Checked = true;
//}
rdbImg.Checked = true;
}
this.Text = "修改组装信息【" + smtPointInfo.PN + "】 ";
loadPositionList();
this.txtPn.Text = smtPointInfo.PN;
......@@ -282,9 +276,20 @@ namespace TSA_V
}
string tagNo = FormUtil.getValue(txtTagNo);
int checkCount = 0;
if (isNewPoint)
{
}
else
{
if (tagNo != smtPointInfo.TagNo)
{
}
else
{
checkCount = 1;
}
}
if (tagNo.Equals(""))
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
......@@ -292,14 +297,13 @@ namespace TSA_V
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 > 0)
if (pos.Count > checkCount)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WritePartNumber, "请输入位号!"));
txtTagNo.Text = smtPointInfo.TagNo;
txtTagNo.Focus();
return false;
}
}
smtPointInfo.PN = pn;
smtPointInfo.TagNo = tagNo;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!