ProcedureDlg : 1. Qtg is displayed when ORACLE_DB defined, 2. Qtg can be changed when procedure is not protected.

This commit is contained in:
Milan Hanajik 2022-12-07 09:59:04 +01:00
parent b1bebbff50
commit 67ebe0718a

View File

@ -1,7 +1,7 @@
///
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
#if KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END
#if ORACLE_DB || KEMPNO_50 || KRAKOW_50 || TORUN_50 || WARSAW_50 || WARSAW_END
#define SHOW_Q_TG
#endif
@ -921,16 +921,16 @@ namespace TBF.UI.Procedures
double dtmp;
#if SHOW_Q_TG
if (test.QtgTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qtg].Text, out dtmp))
test.Qtg = (float)Units.ConvertFrom(test.FlowUnit, dtmp);
test.Qtg = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
#endif
if (test.QfromTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qfrom].Text, out dtmp))
test.Qfrom = (float)Units.ConvertFrom(test.FlowUnit, dtmp);
test.Qfrom = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
if (test.QtoTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Qto].Text, out dtmp))
test.Qto = (float)Units.ConvertFrom(test.FlowUnit, dtmp);
test.Qto = Convert.ToSingle(Units.ConvertFrom(test.FlowUnit, dtmp));
if (test.VolumeTextChngd && Utils.TryParseUDouble(lvi.SubItems[(int)MtrlgyClmn.Volume].Text, out dtmp))
test.Volume = (float)Units.ConvertFrom(test.VolumeUnit, dtmp);
test.Volume = Convert.ToSingle(Units.ConvertFrom(test.VolumeUnit, dtmp));
if (Utils.TryParseUFloat(lvi.SubItems[(int)MtrlgyClmn.TestTime].Text, out tmp)) test.TestTime = tmp;
@ -951,9 +951,6 @@ namespace TBF.UI.Procedures
{
MtrlgyClmn column = (MtrlgyClmn)e.SubItem;
#if SHOW_Q_TG
if (e.SubItem == (int)MtrlgyClmn.Qtg) return;
#endif
/// Unit change is allowed when locked
if ((column != MtrlgyClmn.FlowUnit && column != MtrlgyClmn.VolumeUnit) &&
(!unlocked || column >= MtrlgyClmn.ColumnsCount))
@ -964,6 +961,9 @@ namespace TBF.UI.Procedures
MtrlgyClmn[] protectedColumns = new MtrlgyClmn[]
{
MtrlgyClmn.Name,
#if SHOW_Q_TG
MtrlgyClmn.Qtg,
#endif
MtrlgyClmn.Qfrom, MtrlgyClmn.Qto,
MtrlgyClmn.ErrLimLo, MtrlgyClmn.ErrLimHi,
};
@ -974,9 +974,6 @@ namespace TBF.UI.Procedures
void metrology1ListViewEx_SubItemRightClicked(object sender, SubItemEventArgs e)
{
#if SHOW_Q_TG
if (e.SubItem == (int)MtrlgyClmn.Qtg) return;
#endif
if (!unlocked || e.SubItem >= (int)MtrlgyClmn.ColumnsCount) return;
if (DialogResult.Yes == MessageBox.Show(Strings.Do_you_want_to_copy_this_value_to_all_cells_below_this_cell,
@ -1126,6 +1123,12 @@ namespace TBF.UI.Procedures
if (calculateTime)
{
if (Math.Abs(qAveLps) <= float.Epsilon)
{
e.Item.SubItems[(int)MtrlgyClmn.TestTime].Text = "0"; /// Prevent division by 0
return;
}
float volumeLtr = Units.ConvertFrom(test.VolumeUnit, volume);
testTime = volumeLtr / qAveLps;
e.Item.SubItems[(int)MtrlgyClmn.TestTime].Text = testTime.ToString();
@ -1322,11 +1325,11 @@ namespace TBF.UI.Procedures
lvi.SubItems.Add(((Publish)test.Publish).ToDescription());
lvi.SubItems.Add(test.DoEvaluate ? Strings.yes : Strings.no);
#if ORACLE_DB
lvi.SubItems.Add(test.OraId.ToString());
lvi.SubItems.Add(test.OraIdRepetMulti.ToString());
lvi.SubItems.Add((test.OraId == 0) ? string.Empty : test.OraId.ToString());
lvi.SubItems.Add((test.OraIdRepetMulti == 0) ? string.Empty : test.OraIdRepetMulti.ToString());
lvi.SubItems.Add((test.OraDesignation != null) ? test.OraDesignation : string.Empty);
lvi.SubItems.Add(test.RawDataId.ToString());
lvi.SubItems.Add(test.RawDataIdRepetMulti.ToString());
lvi.SubItems.Add((test.RawDataId == 0) ? string.Empty : test.RawDataId.ToString());
lvi.SubItems.Add((test.RawDataIdRepetMulti == 0) ? string.Empty : test.RawDataIdRepetMulti.ToString());
lvi.SubItems.Add((test.RawDataDesignation != null) ? test.RawDataDesignation : string.Empty);
#endif
metrology2ListViewEx.Items.Add(lvi);
@ -1366,11 +1369,15 @@ namespace TBF.UI.Procedures
}
}
#if ORACLE_DB
entity.OraId = int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.OraId].Text);
entity.OraIdRepetMulti = int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.OraId].Text);
entity.OraId = string.IsNullOrEmpty(lvi.SubItems[(int)Mtrlgy2Clmn.OraId].Text)
? 0 : int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.OraId].Text);
entity.OraIdRepetMulti = string.IsNullOrEmpty(lvi.SubItems[(int)Mtrlgy2Clmn.OraIdRepetM].Text)
? 0 : int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.OraIdRepetM].Text);
entity.OraDesignation = lvi.SubItems[(int)Mtrlgy2Clmn.OraDesig].Text;
entity.RawDataId = int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataId].Text);
entity.RawDataIdRepetMulti = int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataId].Text);
entity.RawDataId = string.IsNullOrEmpty(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataId].Text)
? 0 : int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataId].Text);
entity.RawDataIdRepetMulti = string.IsNullOrEmpty(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataIdRepetM].Text)
? 0 : int.Parse(lvi.SubItems[(int)Mtrlgy2Clmn.RawDataIdRepetM].Text);
entity.RawDataDesignation = lvi.SubItems[(int)Mtrlgy2Clmn.RawDataDesig].Text;
#endif
}
@ -1491,7 +1498,8 @@ namespace TBF.UI.Procedures
case Mtrlgy2Clmn.OraIdRepetM:
case Mtrlgy2Clmn.RawDataId:
case Mtrlgy2Clmn.RawDataIdRepetM:
if (int.TryParse(e.DisplayText, out dummy)) return; /// OK
if (string.IsNullOrEmpty(e.DisplayText)) return; /// OK
if (int.TryParse(e.DisplayText, out dummy)) return; /// OK
break;
case Mtrlgy2Clmn.OraDesig: