/// <summary> /// Get Quota /// </summary> /// <param name="treatyNo">Treaty number</param> /// <param name="eProdType">Product type</param> /// <param name="dOutQuota">Quota</param> /// <returns>True or false</returns> public bool GetQuota(ref teTreatyNo treatyNo, ref mPrivateGlobals.teProductEnum eProdType, ref double dOutQuota) { treatyNo.CheckInit(); // for real time validation SITE and Jan 12, 2015 for FNGTR validation this validation not required // moved in processing sale to display the remaining qty if (_policyManager.SITE_RTVAL || _policyManager.TAX_EXEMPT_FNGTR) { return(true); } // end var sFieldName = GetQuotaField(eProdType); dOutQuota = _treatyService.GetQuota(sFieldName, treatyNo.TreatyNumber); if (_policyManager.TE_Type != "SITE") { return(true); } if (eProdType == mPrivateGlobals.teProductEnum.eCigar | eProdType == mPrivateGlobals.teProductEnum.eLooseTobacco) { dOutQuota = dOutQuota * _teSystemManager.GetCigaretteEquivalentUnits((mPrivateGlobals.teTobaccoEnum)System.Convert.ToInt16(eProdType)); } return(true); }
//Name: AddToQuota //Description: Adds the given quantity to the purchaser's current quota. This // function will take care of cigarette equivalency math, the caller only // needs to enter the quantity sold. For example, if a 30g pouch of tobacco // is sold, this function will look up the cigarette equivalency and do the // appropriate conversion internally. //Inputs: eProdType, the product type that was sold. // dQuantity: The amount sold, grams for tobacco, number of cigarettes, number // of cigars or number of liters of fuel. //Outputs: Returns True if function worked ok. If False, check GetLastError() //Postconditions: On success, the appropriate amount will be added to the person's // quota. Note, all cigartte equivalency conversions are done internally. /// <summary> /// Method to add to quota /// </summary> /// <param name="treatyNo">Treaty umber</param> /// <param name="eProdType">Product type</param> /// <param name="dQuantity">Quantity</param> /// <returns>True or false</returns> public bool AddToQuota(teTreatyNo treatyNo, ref mPrivateGlobals.teProductEnum eProdType, double dQuantity) { treatyNo.CheckInit(); if (string.IsNullOrEmpty(treatyNo.GetTreatyNo())) { return(false); } var dConvertedQuantity = dQuantity; if (eProdType == mPrivateGlobals.teProductEnum.eCigar | eProdType == mPrivateGlobals.teProductEnum.eLooseTobacco) { dConvertedQuantity = dConvertedQuantity * mPrivateGlobals.theSystem.teGetCigaretteEquivalentUnits((mPrivateGlobals.teTobaccoEnum)System.Convert.ToInt16(eProdType)); } //Check if an entry in TreatyNo exists for this person. var sSql = "SELECT * FROM TreatyNo WHERE TreatyNo=\'" + treatyNo.GetTreatyNo() + "\'"; var oRecs = _treatyService.GetTreatyNumbers(sSql); var sField = GetQuotaField(eProdType); if (oRecs.Count == 0) { //Record does not exist, so insert a new one // New info - Treaty name // "VALUES ('" & psTreatyNo & "', " & dConvertedQuantity & ")" sSql = "INSERT INTO TreatyNo ( TreatyNo, " + sField + ",TreatyName ) " + "VALUES (\'" + treatyNo.GetTreatyNo() + "\', " + System.Convert.ToString(dConvertedQuantity) + ", \'" + treatyNo.Name + "\')"; //shiny end } else { foreach (var treaty in oRecs) { if (treaty.TreatyNumber != treatyNo.GetTreatyNo()) { continue; } double quantity = sField == "TobaccoQuota" ? treaty.TobaccoQuota : treaty.GasQuota; dConvertedQuantity = System.Convert.ToDouble(dConvertedQuantity + quantity); goto resumeOutofLoop; } resumeOutofLoop: //Record exists, so update the current quota with the new value // Update Treaty name sSql = "UPDATE TreatyNo " + "SET " + sField + "=" + (dConvertedQuantity) + " " + " , TreatyName =\'" + treatyNo.Name + "\' WHERE TreatyNo=\'" + treatyNo.GetTreatyNo() + "\'"; } _treatyService.UpdateTreatyNumber(sSql); return(true); }