Example #1
0
    public bool CreateSortedItem(ScannedItemDS items)
    {
        //
        bool ret = false;

        try {
            if (items.ScannedItemTable.Rows.Count > 0)
            {
                ScannedItemDS.ScannedItemTableRow item = items.ScannedItemTable[0];
                object[] _item = new object[] { item.ItemNumber, item.TerminalID, item.ScannerID, item.FreightID, item.SortDate, item.ScanString, item.UserID };
                ret = executeNonQuery(USP_SORTEDITEM_NEW, _item);
            }
            else
            {
                throw new ApplicationException("No scanned item to create.");
            }
        }
        catch (Exception ex) { throw new ApplicationException("Failed to create scanned item.", ex); }
        return(ret);
    }
Example #2
0
        private void OnScanChanged(object sender, EventArgs e)
        {
            //Event handler for change in scan text
            Cursor.Current = Cursors.WaitCursor;
            try {
                if (this.txtItem.Text.Trim().Length > 0)
                {
                    //Generate a sorted item number for this object; format: yMMddssssswww
                    //Get the number of elasped seconds since midnight; format: 00000
                    //***Scanning faster than 1sec produces duplicates: limt to 1sec/scan (Thread.Sleep) or change formula???
                    DateTime dt  = DateTime.Now;
                    int      sec = ((3600 * dt.Hour) + (60 * dt.Minute) + dt.Second);

                    ScannedItemDS items = new ScannedItemDS();
                    ScannedItemDS.ScannedItemTableRow item = items.ScannedItemTable.NewScannedItemTableRow();
                    item.ItemNumber = dt.ToString("yyyy").Substring(3, 1) + dt.ToString("MM") + dt.ToString("dd") + sec + this.mAssignment.ScannerAssignmentTable[0].ScannerNumber.Trim().PadLeft(3, '0');
                    item.TerminalID = this.mAssignment.ScannerAssignmentTable[0].TerminalID;
                    item.ScannerID  = this.mAssignment.ScannerAssignmentTable[0].ScannerID;
                    item.FreightID  = this.mAssignment.ScannerAssignmentTable[0].FreightID;
                    item.SortDate   = DateTime.Now;
                    item.ScanString = this.txtItem.Text;
                    item.UserID     = this.lblUser.Text;
                    items.ScannedItemTable.AddScannedItemTableRow(item);

                    Argix.Freight.ScannerService scannerSvc = new ScannerService();
                    scannerSvc.Url = Settings.Default.WebServiceURL;
                    bool ret = scannerSvc.CreateSortedItem(items);
                    if (ret)
                    {
                        this.txtItem.Text = "";
                    }
                }
            }
            catch (Exception ex) { App.ReportError(ex); }
            finally { Cursor.Current = Cursors.Default; }
        }