/// <summary> /// Validates the frequency. Throws an <see cref="ArgumentOutOfRangeException"/> /// if the frequency is not in range. /// </summary> /// <param name="freq"> /// The frequency to validate. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="freq"/> must be between 40Hz and 1000Hz. /// </exception> private void ValidateFrequency(Decimal freq) { if ((freq.CompareTo(MIN_FREQUENCY) == -1) || (freq.CompareTo(MAX_FREQUENCY) == 1)) { throw new ArgumentOutOfRangeException("Frequency [" + freq.ToString() + "] must be between 40.0 and 1000.0 Hz."); } }
public void TestCompareTo() { // Int32 Decimal.CompareTo(Decimal) Decimal d = 456; Assert.IsTrue(d.CompareTo(456m) == 0); Assert.IsTrue(d.CompareTo(457m) < 0); Assert.IsTrue(d.CompareTo(455m) > 0); }
/** * Initializes a new instance of the SqlMoney instance using the supplied long value. * @param value The long value to be stored as a SqlMoney instance. */ public SqlMoney(long value) { _value = new Decimal(value); if (_value.CompareTo(MaxValue.Value) > 0 || _value.CompareTo(MinValue.Value) < 0) { throw new OverflowException("overflow - the value is out of range " + value); } _isNull = false; }
/** * Initializes a new instance of the SqlMoney instance using the supplied Decimal value. * @param value The Decimal value to be stored as a SqlMoney instance. */ public SqlMoney(Decimal value) { if ((value.CompareTo(MaxValue.Value) > 0 || value.CompareTo(MinValue.Value) < 0)) { throw new OverflowException("overflow - the value is out of range " + value); } _value = value; _isNull = false; }
/// <summary> /// Criteria apply /// </summary> /// <param name="Value">amt or qty</param> /// <param name="M_Product_ID">product</param> /// <param name="M_Product_Category_ID">category</param> /// <returns>true if criteria met</returns> public bool Applies(Decimal Value, int M_Product_ID, int M_Product_Category_ID) { if (!IsActive()) { return(false); } // below break value if (Value.CompareTo(GetBreakValue()) < 0) { return(false); } // No Product / Category if (GetM_Product_ID() == 0 && GetM_Product_Category_ID() == 0) { return(true); } // Product if (GetM_Product_ID() == M_Product_ID) { return(true); } // Category if (M_Product_Category_ID != 0) { return(GetM_Product_Category_ID() == M_Product_Category_ID); } // Look up Category of Product return(MProductCategory.IsCategory(GetM_Product_Category_ID(), M_Product_ID)); }
/// <summary> /// Currect Accounting Amount. /// <pre> /// Example: 1 -1 1 -1 /// Old 100/0 100/0 0/100 0/100 /// New 99/0 101/0 0/99 0/101 /// </pre> /// </summary> /// <param name="deltaAmount">delta amount</param> public void CurrencyCorrect(Decimal deltaAmount) { bool negative = deltaAmount.CompareTo(Env.ZERO) < 0; bool adjustDr = Math.Abs(GetAmtAcctDr()).CompareTo(Math.Abs(GetAmtAcctCr())) > 0; log.Fine(deltaAmount.ToString() + "; Old-AcctDr=" + GetAmtAcctDr() + ",AcctCr=" + GetAmtAcctCr() + "; Negative=" + negative + "; AdjustDr=" + adjustDr); if (adjustDr) { if (negative) { SetAmtAcctDr(Decimal.Subtract(GetAmtAcctDr(), deltaAmount)); } else { SetAmtAcctDr(Decimal.Subtract(GetAmtAcctDr(), deltaAmount)); } } else { if (negative) { SetAmtAcctCr(Decimal.Add(GetAmtAcctCr(), deltaAmount)); } else { SetAmtAcctCr(Decimal.Add(GetAmtAcctCr(), deltaAmount)); } } log.Fine("New-AcctDr=" + GetAmtAcctDr() + ",AcctCr=" + GetAmtAcctCr()); }
/// <summary> /// Get SO CreditStatus with additional amount /// </summary> /// <param name="additionalAmt">additional amount in Accounting Currency</param> /// <returns>sinulated credit status</returns> public String GetSOCreditStatus(Decimal?additionalAmt) { if (additionalAmt == null || Env.Signum((Decimal)additionalAmt) == 0) { return(GetSOCreditStatus()); } // Decimal creditLimit = GetSO_CreditLimit(); // Nothing to do if (SOCREDITSTATUS_NoCreditCheck.Equals(GetSOCreditStatus()) || SOCREDITSTATUS_CreditStop.Equals(GetSOCreditStatus()) || Env.ZERO.CompareTo(creditLimit) == 0) { return(GetSOCreditStatus()); } // Above (reduced) Credit Limit creditLimit = Decimal.Subtract(creditLimit, (Decimal)additionalAmt); if (creditLimit.CompareTo(GetTotalOpenBalance(!_TotalOpenBalanceSet)) < 0) { return(SOCREDITSTATUS_CreditHold); } // Above Watch Limit Decimal watchAmt = Decimal.Multiply(creditLimit, GetCreditWatchRatio()); if (watchAmt.CompareTo(GetTotalOpenBalance()) < 0) { return(SOCREDITSTATUS_CreditWatch); } // is OK return(SOCREDITSTATUS_CreditOK); }
/// <summary> /// Set Credit Status /// </summary> public void SetSOCreditStatus() { Decimal creditLimit = GetSO_CreditLimit(); // Nothing to do if (SOCREDITSTATUS_NoCreditCheck.Equals(GetSOCreditStatus()) || SOCREDITSTATUS_CreditStop.Equals(GetSOCreditStatus()) || Env.ZERO.CompareTo(creditLimit) == 0) { return; } // Above Credit Limit if (creditLimit.CompareTo(GetTotalOpenBalance(!_TotalOpenBalanceSet)) < 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditHold); } else { // Above Watch Limit Decimal watchAmt = Decimal.Multiply(creditLimit, GetCreditWatchRatio()); if (watchAmt.CompareTo(GetTotalOpenBalance()) < 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditWatch); } else // is OK { SetSOCreditStatus(SOCREDITSTATUS_CreditOK); } } log.Fine("SOCreditStatus=" + GetSOCreditStatus()); }
/** * The multiplication operator computes the product of the two SqlMoney operands. * @param x A SqlMoney instance * @param y A SqlMoney instance * @return The product of the two SqlMoney operands. */ public static SqlMoney Multiply(SqlMoney x, SqlMoney y) { if (x.IsNull || y.IsNull) { return(SqlMoney.Null); } Decimal res = Decimal.Multiply(x._value, y._value); if (res.CompareTo(MaxValue.Value) > 0 || res.CompareTo(MinValue.Value) < 0) { throw new OverflowException("overflow - the multiply value is out of range " + res); } return(new SqlMoney(res)); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">new</param> /// <returns>true, on Save</returns> protected override Boolean BeforeSave(Boolean newRecord) { MPayment payment = new MPayment(GetCtx(), GetC_Payment_ID(), Get_TrxName()); if ((newRecord || Is_ValueChanged("C_Invoice_ID")) && (payment.GetC_Charge_ID() != 0 || payment.GetC_Invoice_ID() != 0 || payment.GetC_Order_ID() != 0)) { log.SaveError("PaymentIsAllocated", ""); return(false); } // during saving a new record, system will check same invoice schedule reference exist on same payment or not if (newRecord && Get_ColumnIndex("C_InvoicePaySchedule_ID") >= 0 && GetC_InvoicePaySchedule_ID() > 0) { if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(*) FROM C_PaymentAllocate WHERE C_Payment_ID = " + GetC_Payment_ID() + @" AND IsActive = 'Y' AND C_InvoicePaySchedule_ID = " + GetC_InvoicePaySchedule_ID(), null, Get_Trx())) > 0) { //"Error" not required //log.SaveError("Error", Msg.GetMsg(GetCtx(), "VIS_NotSaveDuplicateRecord")); log.SaveError("", Msg.GetMsg(GetCtx(), "VIS_NotSaveDuplicateRecord")); return(false); } } // check schedule is hold or not, if hold then no to save record if (Get_ColumnIndex("C_InvoicePaySchedule_ID") >= 0 && GetC_InvoicePaySchedule_ID() > 0) { if (payment.IsHoldpaymentSchedule(GetC_InvoicePaySchedule_ID())) { log.SaveError("", Msg.GetMsg(GetCtx(), "VIS_PaymentisHold")); return(false); } } if (!Env.IsModuleInstalled("VA009_")) { Decimal check = Decimal.Add(Decimal.Add(Decimal.Add(GetAmount(), GetDiscountAmt()), GetWriteOffAmt()), GetOverUnderAmt()); if (check.CompareTo(GetInvoiceAmt()) != 0) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@InvoiceAmt@(" + GetInvoiceAmt() + ") <> @Totals@(" + check + ")")); return(false); } } // Org if (newRecord || Is_ValueChanged("C_Invoice_ID")) { GetInvoice(); if (_invoice != null) { SetAD_Org_ID(_invoice.GetAD_Org_ID()); } } return(true); }
//@UICallout public void setQtyEntered(String oldQtyEntered, String newQtyEntered, int windowNo) { if (newQtyEntered == null || newQtyEntered.Trim().Length == 0) { return; } if (GetC_UOM_ID() == 0) { return; } Decimal QtyEntered = VAdvantage.Utility.Util.GetValueOfDecimal(newQtyEntered); //BigDecimal QtyEntered1 = QtyEntered.setScale( // MUOM.getPrecision(getCtx(), getC_UOM_ID()), BigDecimal.ROUND_HALF_UP); Decimal QtyEntered1 = Decimal.Round((QtyEntered), VAdvantage.Model.MUOM.GetPrecision(GetCtx(), GetC_UOM_ID())); if (QtyEntered.CompareTo(QtyEntered1) != 0) { log.Fine("Corrected QtyEntered Scale UOM=" + GetC_UOM_ID() + "; QtyEntered=" + QtyEntered + "->" + QtyEntered1); QtyEntered = QtyEntered1; SetVAMFG_QtyEntered(QtyEntered); } }
/// <summary> /// Set Max Allocation if greater /// </summary> /// <param name="max">allocation</param> /// <param name="set">set to max</param> public void SetMaxAllocation(Decimal max, bool set) { if (set || max.CompareTo(_maxAllocation) > 0) { _maxAllocation = max; } }
/** * Before Save * @param newRecord new * @return true */ protected override Boolean BeforeSave(Boolean newRecord) { MPayment payment = new MPayment(GetCtx(), GetC_Payment_ID(), Get_TrxName()); if ((newRecord || Is_ValueChanged("C_Invoice_ID")) && (payment.GetC_Charge_ID() != 0 || payment.GetC_Invoice_ID() != 0 || payment.GetC_Order_ID() != 0)) { log.SaveError("PaymentIsAllocated", ""); return(false); } Decimal check = Decimal.Add(Decimal.Add(Decimal.Add(GetAmount(), GetDiscountAmt()), GetWriteOffAmt()), GetOverUnderAmt()); if (check.CompareTo(GetInvoiceAmt()) != 0) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@InvoiceAmt@(" + GetInvoiceAmt() + ") <> @Totals@(" + check + ")")); return(false); } // Org if (newRecord || Is_ValueChanged("C_Invoice_ID")) { GetInvoice(); if (_invoice != null) { SetAD_Org_ID(_invoice.GetAD_Org_ID()); } } return(true); }
/// <summary> /// Set Credit Status /// </summary> public void SetSOCreditStatus() { MBPartner bp = new MBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName()); Decimal creditLimit = GetSO_CreditLimit(); // Nothing to do if (SOCREDITSTATUS_NoCreditCheck.Equals(GetSOCreditStatus()) || SOCREDITSTATUS_CreditStop.Equals(GetSOCreditStatus()) || Env.ZERO.CompareTo(creditLimit) == 0) { return; } // Above Credit Limit // changed this function for fetching open balance because in case of void it calculates again and fetches wrong value of open balance // Lokesh Chauhan //if (creditLimit.CompareTo(GetTotalOpenBalance(!_TotalOpenBalanceSet)) < 0) if (creditLimit.CompareTo(GetTotalOpenBalance()) <= 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditHold); } else { // Above Watch Limit Decimal watchAmt = Decimal.Multiply(creditLimit, bp.GetCreditWatchRatio()); if (watchAmt.CompareTo(GetTotalOpenBalance()) < 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditWatch); } else // is OK { SetSOCreditStatus(SOCREDITSTATUS_CreditOK); } } log.Fine("SOCreditStatus=" + GetSOCreditStatus()); }
protected override ValidationResult IsValid(object value, ValidationContext validationContext) { ValidationResult validationResult = ValidationResult.Success; try { // Using reflection we can get a reference to the other property, in this example the project Start price var otherPropertyInfo = validationContext.ObjectType.GetProperty(_otherPropertyName); // Let's check that otherProperty is of type Decimal as we expect it to be if (otherPropertyInfo.PropertyType == new Decimal().GetType()) { Decimal toValidate = (Decimal)value; Decimal referenceProperty = (Decimal)otherPropertyInfo.GetValue(validationContext.ObjectInstance, null); // if the end date is lower than the start date, than the validationResult will be set to false and return // a properly formatted error message if (toValidate.CompareTo(referenceProperty) < 1) { validationResult = new ValidationResult(ErrorMessageString); } } else { validationResult = new ValidationResult("An error occurred while validating the property. OtherProperty is not of type Decimal"); } } catch (Exception ex) { // Do stuff, i.e. log the exception // Let it go through the upper levels, something bad happened throw ex; } return(validationResult); }
/** * Apply Payment Term with schedule to Invoice * @param invoice invoice * @return true if payment schedule is valid */ private bool ApplySchedule(MInvoice invoice) { DeleteInvoicePaySchedule(invoice.GetC_Invoice_ID(), invoice.Get_TrxName()); // Create Schedule MInvoicePaySchedule ips = null; Decimal remainder = invoice.GetGrandTotal(); for (int i = 0; i < _schedule.Length; i++) { ips = new MInvoicePaySchedule(invoice, _schedule[i]); ips.Save(invoice.Get_TrxName()); log.Fine(ips.ToString()); remainder = Decimal.Subtract(remainder, ips.GetDueAmt()); } // for all schedules // Remainder - update last if (remainder.CompareTo(Env.ZERO) != 0 && ips != null) { ips.SetDueAmt(Decimal.Add(ips.GetDueAmt(), remainder)); ips.Save(invoice.Get_TrxName()); log.Fine("Remainder=" + remainder + " - " + ips); } // updateInvoice if (invoice.GetC_PaymentTerm_ID() != GetC_PaymentTerm_ID()) { invoice.SetC_PaymentTerm_ID(GetC_PaymentTerm_ID()); } return(invoice.ValidatePaySchedule()); }
/** * Calcuates the sum of the two SqlMoney operators. * @param x A SqlMoney instance. * @param y A SqlMoney instance. * @return A new SqlMoney instance whose Value property contains the sum. * If one of the parameters or their value is null return SqlMoney.Null. */ public static SqlMoney Add(SqlMoney x, SqlMoney y) { if (x.IsNull || y.IsNull) { return(SqlMoney.Null); } Decimal res = Decimal.Add(x._value, y._value); if (res.CompareTo(MaxValue.Value) > 0 || res.CompareTo(MinValue.Value) < 0) { throw new OverflowException("overflow - the sum of the 2 parameters can not be SqlMoney : " + res); } return(new SqlMoney(res)); }
public static bool FloatIsWithinEpsilon(float x, float y) { Decimal dx = new Decimal(x); Decimal dy = new Decimal(y); Decimal diff = Math.Abs(Decimal.Subtract(dx, dy)); return(diff.CompareTo(Epsilon) <= 0); }
public static bool DoubleIsWithinEpsilon(double x, double y) { Decimal dx = new Decimal(x); Decimal dy = new Decimal(y); Decimal diff = Math.Abs(Decimal.Subtract(dx, dy)); return(diff.CompareTo(Epsilon) <= 0); }
/// <summary> /// Create Material Allocations for new Instances /// </summary> /// <param name="updateQtyBooked"></param> public void CreateMA(bool updateQtyBooked) { VAdvantage.Model.MInventoryLine INVLine = new VAdvantage.Model.MInventoryLine(GetCtx(), GetM_InventoryLine_ID(), Get_TrxName()); int delMA = MInventoryLineMA.DeleteInventoryLineMA(GetM_InventoryLine_ID(), Get_TrxName()); log.Info("DeletedMA=" + delMA); MStorage[] storages = MStorage.GetAll(GetCtx(), GetM_Product_ID(), GetM_Locator_ID(), Get_TrxName()); bool allZeroASI = true; for (int i = 0; i < storages.Length; i++) { if (storages[i].GetM_AttributeSetInstance_ID() != 0) { allZeroASI = false; break; } } if (allZeroASI) { return; } MInventoryLineMA ma = null; Decimal sum = Env.ZERO; for (int i = 0; i < storages.Length; i++) { MStorage storage = storages[i]; // nnayak - ignore negative layers if (Env.Signum(storage.GetQtyOnHand()) <= 0) { continue; } if (ma != null && ma.GetM_AttributeSetInstance_ID() == storage.GetM_AttributeSetInstance_ID()) { ma.SetMovementQty(Decimal.Add(ma.GetMovementQty(), storage.GetQtyOnHand())); } else { ma = new MInventoryLineMA(INVLine, storage.GetM_AttributeSetInstance_ID(), storage.GetQtyOnHand()); } if (!ma.Save()) { ; } sum = Decimal.Add(sum, storage.GetQtyOnHand()); } if (updateQtyBooked && sum.CompareTo(GetQtyBook()) != 0) { log.Warning("QtyBook=" + GetQtyBook() + " corrected to Sum of MA=" + sum); SetQtyBook(sum); } }
/// <summary> /// Get Location with highest Locator Priority and a sufficient OnHand Qty /// </summary> /// <param name="M_Warehouse_ID">warehouse</param> /// <param name="M_Product_ID">product</param> /// <param name="M_AttributeSetInstance_ID"></param> /// <param name="Qty"></param> /// <param name="trx">transaction</param> /// <returns></returns> public static int GetLocatorID(int M_Warehouse_ID, int M_Product_ID, int M_AttributeSetInstance_ID, Decimal Qty, Trx trx) { int M_Locator_ID = 0; int firstM_Locator_ID = 0; String sql = "SELECT s.M_Locator_ID, s.Qty " + "FROM M_STORAGE s" + " INNER JOIN M_Locator l ON (s.M_Locator_ID=l.M_Locator_ID)" + " INNER JOIN M_Product p ON (s.M_Product_ID=p.M_Product_ID)" + " LEFT OUTER JOIN M_AttributeSet mas ON (p.M_AttributeSet_ID=mas.M_AttributeSet_ID) " + "WHERE l.M_Warehouse_ID=" + M_Warehouse_ID + " AND s.M_Product_ID=" + M_Product_ID + " AND (mas.IsInstanceAttribute IS NULL OR mas.IsInstanceAttribute='N' OR s.M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID + ")" + " AND l.IsActive='Y' " + " AND s.QtyType='H' " + "ORDER BY l.PriorityNo DESC, s.Qty DESC"; IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, trx); while (idr.Read()) { Decimal QtyOnHand = Util.GetValueOfDecimal(idr[1]); if (Qty.CompareTo(QtyOnHand) <= 0) { M_Locator_ID = Util.GetValueOfInt(idr[0]); break; } if (firstM_Locator_ID == 0) { firstM_Locator_ID = Util.GetValueOfInt(idr[0]); } } } catch (Exception ex) { _log.Log(Level.SEVERE, sql, ex); } finally { if (idr != null) { idr.Close(); idr = null; } } if (M_Locator_ID != 0) { return(M_Locator_ID); } return(firstM_Locator_ID); }
public int Compare(object x, object y) { int result; DataGridViewRow dgvX, dgvY; dgvX = (DataGridViewRow)x; dgvY = (DataGridViewRow)y; string sx = dgvX.Cells[ColumnIndex].Value.ToString(); string sy = dgvY.Cells[ColumnIndex].Value.ToString(); //null handling if (sx == String.Empty && sy == String.Empty) { result = 0; } else if (sx == String.Empty && sy != String.Empty) { result = -1; } else if (sx != String.Empty && sy == String.Empty) { result = 1; } else { switch (mySortTypeCode) { case TypeCode.Decimal: Decimal nx = Convert.ToDecimal(sx); Decimal ny = Convert.ToDecimal(sy); result = nx.CompareTo(ny); break; case TypeCode.DateTime: DateTime dx = Convert.ToDateTime(sx); DateTime dy = Convert.ToDateTime(sy); result = dx.CompareTo(dy); break; case TypeCode.String: result = (new CaseInsensitiveComparer()).Compare(sx, sy); break; default: result = (new CaseInsensitiveComparer()).Compare(sx, sy); break; } } if (OrderOfSort == SortOrder.Descending) { result = (-result); } return(result); }
public override bool Filter(Literal resource, SelectableSource targetModel) { string v = resource.Value; try { Decimal i = Decimal.Parse(v); int c = i.CompareTo(Number); return(CompareFilter(c, Type)); } catch (Exception) { return(false); } }
public override void Execute(OID oid, AttributeValuesMap values) { var number = Convert.ToDecimal(values[AttributeName]); var bd = ValuesUtil.Convert(number); if (_minValue.CompareTo(bd) <= 0) { return; } _oidOfMinValues = oid; _minValue = bd; }
/// <summary> /// Set Credit Status /// </summary> public void SetSOCreditStatus() { MBPartner bp = new MBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName()); Decimal creditLimit = GetSO_CreditLimit(); // Nothing to do if (SOCREDITSTATUS_NoCreditCheck.Equals(GetSOCreditStatus()) || SOCREDITSTATUS_CreditStop.Equals(GetSOCreditStatus()) || Env.ZERO.CompareTo(creditLimit) == 0) { return; } // Above Credit Limit // changed this function for fetching open balance because in case of void it calculates again and fetches wrong value of open balance // Lokesh Chauhan //if (creditLimit.CompareTo(GetTotalOpenBalance(!_TotalOpenBalanceSet)) < 0) if (creditLimit.CompareTo(GetTotalOpenBalance()) <= 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditHold); } else { // Above Watch Limit //Peference check if credit watch per is zero on header then gets the value from bpgroup Decimal watchAmt; if (bp.Get_ColumnIndex("CreditWatchPercent") > 0) { if (bp.GetCreditWatchPercent() == 0) { watchAmt = Decimal.Multiply(creditLimit, bp.GetCreditWatchRatio()); } else { watchAmt = Decimal.Multiply(creditLimit, bp.GetCustomerCreditWatch()); } } else { watchAmt = Decimal.Multiply(creditLimit, bp.GetCreditWatchRatio()); } if (watchAmt.CompareTo(GetTotalOpenBalance()) < 0) { SetSOCreditStatus(SOCREDITSTATUS_CreditWatch); } else // is OK { SetSOCreditStatus(SOCREDITSTATUS_CreditOK); } } log.Fine("SOCreditStatus=" + GetSOCreditStatus()); }
/// <summary> /// Get Distibution Lines. /// Add/Correct also Total Ratio /// </summary> /// <returns>array of lines</returns> public MDistributionListLine[] GetLines() { List <MDistributionListLine> list = new List <MDistributionListLine>(); Decimal ratioTotal = Env.ZERO; // String sql = "SELECT * FROM M_DistributionListLine WHERE M_DistributionList_ID=" + GetM_DistributionList_ID(); DataTable dt = null; IDataReader idr = null; try { idr = DataBase.DB.ExecuteReader(sql, null, Get_TrxName()); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { MDistributionListLine line = new MDistributionListLine(GetCtx(), dr, Get_TrxName()); list.Add(line); Decimal ratio = line.GetRatio(); if (ratio != 0) { ratioTotal = Decimal.Add(ratioTotal, ratio); } } } catch (Exception e) { if (idr != null) { idr.Close(); } log.Log(Level.SEVERE, "getLines", e); } finally { dt = null; } // Update Ratio if (ratioTotal.CompareTo(GetRatioTotal()) != 0) { log.Info("getLines - Set RatioTotal from " + GetRatioTotal() + " to " + ratioTotal); SetRatioTotal(ratioTotal); Save(); } MDistributionListLine[] retValue = new MDistributionListLine[list.Count]; retValue = list.ToArray(); return(retValue); }
private static bool IsExecutionForOrder(Com.Lmax.Api.Order.Order order, Execution execution) { Decimal quantity = order.Quantity; int num1 = quantity.CompareTo(new Decimal(0)); quantity = execution.Quantity; int num2 = quantity.CompareTo(new Decimal(0)); int num3; if (num1 != num2) { Decimal num4 = order.Quantity; int num5 = num4.CompareTo(new Decimal(0)); num4 = execution.CancelledQuantity; int num6 = num4.CompareTo(new Decimal(0)); num3 = num5 == num6 ? 1 : 0; } else { num3 = 1; } return(num3 != 0); }
} // setC_Period_ID /// <summary> /// Set Currency Info /// </summary> /// <param name="C_Currency_ID">currenct</param> /// <param name="C_ConversionType_ID">type</param> /// <param name="CurrencyRate">rate</param> public void SetCurrency(int C_Currency_ID, int C_ConversionType_ID, Decimal CurrencyRate) { if (C_Currency_ID != 0) { SetC_Currency_ID(C_Currency_ID); } if (C_ConversionType_ID != 0) { SetC_ConversionType_ID(C_ConversionType_ID); } if (CurrencyRate.CompareTo(Env.ZERO) == 0) { SetCurrencyRate(CurrencyRate); } } // setCurrency
public override bool Filter(Resource resource, Store targetModel) { string v = ((Literal)resource).Value; try { Decimal i = Decimal.Parse(v); int c = i.CompareTo(number); if (compare == 0) { return((c == 0) ^ !eq); } return(c == compare || (c == 0 && eq)); } catch (Exception e) { return(false); } }
public int Compare(object obj1, object obj2) { ListViewItem item1 = (ListViewItem)obj1; ListViewItem item2 = (ListViewItem)obj2; string string1 = item1.Text; string string2 = item2.Text; if (listView.LastSortedColumn != 0) { if (item1.SubItems.Count > listView.LastSortedColumn) { string1 = item1.SubItems[listView.LastSortedColumn].Text; } else { string1 = ""; } if (item2.SubItems.Count > listView.LastSortedColumn) { string2 = item2.SubItems[listView.LastSortedColumn].Text; } else { string2 = ""; } } if (string1 == "") { string1 = "0"; } if (string2 == "") { string2 = "0"; } Decimal dec1 = decimal.Parse(string1); Decimal dec2 = decimal.Parse(string2); int result = dec1.CompareTo(dec2); if (listView.SortingOrder == SortOrder.Descending) { result *= -1; } return(result); }