private void SalesOrderPopup_Execute(object sender, PopupWindowShowActionExecuteEventArgs e) { SOHeader so = (SOHeader)e.PopupWindowViewCurrentObject; string erromsg; ComplianceBL CBL = new ComplianceBL(Application); MessageOptions options = new MessageOptions(); if (CBL.SoComplianceCheck(so, out erromsg) == 0) { options.Duration = 20000; options.Message = string.Format("Sales Order for {0} has been entered", so.CustomerNumber.CustomerName); options.Type = InformationType.Success; options.Web.Position = InformationPosition.Right; options.Win.Caption = "Success"; options.Win.Type = WinMessageType.Alert; so.SOStatus = SalesOrderStatus.Submitted; if (so.SalesOrderNumber == null || so.SalesOrderNumber?.Length < 2) { so.SalesOrderNumber = so.AccountingSONumber; } so.Save(); } else { options.Duration = 20000; options.Message = string.Format("Sales Order for {0} has been entered is in Compliance due to the following {1}", so.CustomerNumber.CustomerName, erromsg); options.Type = InformationType.Warning; options.Web.Position = InformationPosition.Right; options.Win.Caption = "Success Need Compliance"; options.Win.Type = WinMessageType.Alert; so.SOStatus = SalesOrderStatus.ComplianceCheck; if (so.SalesOrderNumber == null || so.SalesOrderNumber?.Length < 2) { so.SalesOrderNumber = so.AccountingSONumber; } so.Save(); } Application.ShowViewStrategy.ShowMessage(options); string msg = string.Format("Sales order: {2} entered by {0} {1} ", SecuritySystem.CurrentUserName, System.Environment.NewLine, so.SalesOrderNumber); foreach (SODetails det in so.SODetails) { msg = msg + string.Format(det.ItemNumber.ItemNumber.ToString() + " {0:C2} @ {1} {2} ", det.QtyOrdered, det.UnitPrice, System.Environment.NewLine); } so.CustomerNumber.AddNote(so.CustomerNumber, msg); so.Session.CommitTransaction(); View.Refresh(); }
/// <summary> /// Checks for the following /// 1) valid DEA Number and Exp Date /// 2) Has a State License and state Exp date or state Pharma License /// 3) whse has license to ship into cust state. /// 4) All CI and CII drugs has a 222 form attached. /// /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <returns></returns> public int SoComplianceCheck(SOHeader SO, out string erromsg) { string errmsg = ""; int errcount = 0; // Check dea if (IsValidDEANumber(SO.CustomerNumber.DeaNo) < 0) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ") Invalid Dea Number. Does not comply with the format of AA####### ." + Environment.NewLine; } if (!(SO.CustomerNumber.DeaExpDate >= DateTime.Now)) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ") Expired DEA Number '" + SO.CustomerNumber.DeaExpDate + "' " + Environment.NewLine; } if (string.IsNullOrEmpty(SO.CustomerNumber.StateLicense) || SO.CustomerNumber.StateLicense.Trim().Length < 4) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ") Invalid State License Must be longer then 4" + Environment.NewLine; } if (!(SO.CustomerNumber.StateLicExpDate >= DateTime.Now)) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ") Expired State License '" + SO.CustomerNumber.DeaExpDate + "' " + Environment.NewLine; } if (!AbleToShipInto(SO.DistributionCenterWhse.DistributionCenter, SO.CustomerNumber.ShipState)) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ")" + string.Format("Unable to ship into ? from ? ", SO.CustomerNumber.ShipState.StateCode, SO.DistributionCenterWhse.DistributionCenter.DCName) + Environment.NewLine; } if (!ControlLinesHas222(SO)) { errcount++; errmsg = errmsg + "(" + errcount.ToString() + ") No 222 Form attached" + Environment.NewLine; } SO.LastComplianceMsg = errmsg; SO.Save(); if (errcount > 0) { erromsg = errmsg; SO.CustomerNumber.AddNote(SO.CustomerNumber, errmsg); return(errcount); } erromsg = ""; return(0); }
private int LoadScan(Dictionary <string, string> ScanDecodeDictionary, ObjectChangedEventArgs e) { bool addCount = false; string pstring; ScanDecodeDictionary.TryGetValue("01", out pstring); string pItemnumber = pstring; ScanDecodeDictionary.TryGetValue("17", out pstring); string pExpDt = pstring; ScanDecodeDictionary.TryGetValue("10", out pstring); string pLot = pstring; ScanDecodeDictionary.TryGetValue("21", out pstring); string pSerialNumber = pstring; int cc = 0; cc = cc++; IObjectSpace objectSpace = Application.CreateObjectSpace(); SOHeader SOH = objectSpace.CreateObject <SOHeader>(); SOH = objectSpace.GetObject <SOHeader>((SOHeader)View.CurrentObject); SOItemDistibution SID = new SOItemDistibution(SOH.Session); // lets see if the serial number exists in so CriteriaOperator SerialCriteria = CriteriaOperator.Parse("[ItemNumber] = ? and [SerialNumber] = ?", pItemnumber, pSerialNumber); SOPackingSerialNo SOPSN = (SOPackingSerialNo)objectSpace.FindObject(typeof(SOPackingSerialNo), SerialCriteria); if (SOPSN != null) { return(-1); } else // Lets add the serial number in the serial packing list { SOPSN = new SOPackingSerialNo(SOH.Session); SOPSN.SalesOrder = SOH; SOPSN.ItemNumber = pItemnumber.Substring(3); SOPSN.ShipQty = 1; SOPSN.Lot = pLot; SOPSN.ShipQty = 1; SOPSN.SerialNumber = pSerialNumber; SOPSN.Lot = pLot; SOPSN.DateEntered = System.DateTime.Today; SOPSN.UserName = SecuritySystem.CurrentUserName; SOPSN.ExpirationDate = DateTime.ParseExact(pExpDt, "yyMMdd", CultureInfo.CurrentCulture); SOPSN.Save(); SOH.Session.CommitTransaction(); addCount = true; } // lets see if item exists on the SO Packing table CriteriaOperator ItemCriteria = CriteriaOperator.Parse("[ItemNumber] = ? ", pItemnumber); SOPacking SOP = (SOPacking)objectSpace.FindObject(typeof(SOPacking), ItemCriteria); if (addCount) { if (SOP != null) { SOP.ItemQty = SOP.ItemQty++; } else { SOP = new SOPacking(SOH.Session); SOP.ItemNumber = pItemnumber; SOP.SalesOrder = SOH; SOP.ItemQty = 1; } SOP.Save(); } SOH.Save(); SOH.Session.CommitTransaction(); SOH.Reload(); SOH.SOPacking.Reload(); SOH.SoPackingSerialNumbers.Reload(); SOH.Scan = null; return(0); }