Example #1
0
        public SortableSearchableBindingList<ItemHistoryTransaction> GetHistory(ItemHistoryView enuItemHistoryView, string strJobNo = null, int intSuffix = 0)
        {
            SortableSearchableBindingList<ItemHistoryTransaction> objItemHistoryList = new SortableSearchableBindingList<ItemHistoryTransaction>();
            ItemHistoryTransaction objItemHistoryTransaction;
            SqlCommand objSQLCommand;
            ExtraSytelineTablesSettings objExtraSytelineTableSettings;
            SqlDataReader objDataReader;
            string strSQL;
            string strJobParameter;

            objExtraSytelineTableSettings = new ExtraSytelineTablesSettings();

            if (strJobNo != null)
                strJobParameter = " AND job = '" + strJobNo + "' AND suffix = " + intSuffix.ToString();
            else
                strJobParameter = string.Empty;

            switch (enuItemHistoryView)
            {
                case ItemHistoryView.All:
                    strSQL = QueryDefinitions.GetQuery("SelectAllItemHistory", new string[] { ItemID, strJobParameter });
                    break;
                case ItemHistoryView.Shipped:
                    strSQL = QueryDefinitions.GetQuery("SelectShippedItemHistory", new string[] { ItemID, strJobParameter });
                    break;
                case ItemHistoryView.Recieved:
                    strSQL = QueryDefinitions.GetQuery("SelectRecievedItemHistory", new string[] { ItemID, strJobParameter });
                    break;
                default:
                    strSQL = string.Empty;
                    break;
            }

            objExtraSytelineTableSettings.SQLConnection.Open();
            objSQLCommand = objExtraSytelineTableSettings.SQLConnection.CreateCommand();
            objSQLCommand.CommandText = strSQL;

            objDataReader = objSQLCommand.ExecuteReader();

            while (objDataReader.Read())
            {
                objItemHistoryTransaction = new ItemHistoryTransaction();

                objItemHistoryTransaction.LabelSequence = int.Parse(objDataReader["LabelSequence"].ToString());
                objItemHistoryTransaction.ItemID = objDataReader["item"].ToString();
                objItemHistoryTransaction.Job = objDataReader["job"].ToString();
                objItemHistoryTransaction.CustomerOrderNumber = objDataReader["co"].ToString();
                objItemHistoryTransaction.Quantity = int.Parse(objDataReader["Quantity"].ToString());
                objItemHistoryTransaction.RecievedTimeStamp = string.Format("{0:MM/dd/yyyy hh:mm:ss tt}", objDataReader["ReceivedTimestamp"]);
                objItemHistoryTransaction.ShippedTimeStamp = string.Format("{0:MM/dd/yyyy hh:mm:ss tt}", objDataReader["ShippedTimestamp"]);
                objItemHistoryTransaction.Operator = objDataReader["operator"].ToString();
                objItemHistoryTransaction.GrossWeight = double.Parse(objDataReader["GrossWgt"].ToString());
                objItemHistoryTransaction.PalletCount = int.Parse(objDataReader["PalletCt"].ToString());
                objItemHistoryTransaction.RecievedItemID = int.Parse(objDataReader["ReceivedItemID"].ToString());
                objItemHistoryTransaction.Suffix = int.Parse(objDataReader["suffix"].ToString());

                objItemHistoryList.Add(objItemHistoryTransaction);
            }

            return objItemHistoryList;
        }
Example #2
0
        public static bool ShipItemFromInventory(ItemHistoryTransaction objItemHistoryTransaction)
        {
            SqlCommand objSQLCommand;
            string strSQL;
            ExtraSytelineTablesSettings objExtraSytelineTableSettings;
            SqlDataReader objDataReader;

            if (!string.IsNullOrEmpty(objItemHistoryTransaction.ShippedTimeStamp))
                throw new Exception("History Transaction " + objItemHistoryTransaction.RecievedItemID + " was already shipped on " + objItemHistoryTransaction.ShippedTimeStamp);

            objExtraSytelineTableSettings = new ExtraSytelineTablesSettings();
            strSQL = QueryDefinitions.GetQuery("SelectRecievedAccumulatorID", new string[] { objItemHistoryTransaction.ItemID, objItemHistoryTransaction.Job, objItemHistoryTransaction.Suffix.ToString() });
            objExtraSytelineTableSettings.SQLConnection.Open();
            objSQLCommand = objExtraSytelineTableSettings.SQLConnection.CreateCommand();
            objSQLCommand.CommandText = strSQL;

            objDataReader = objSQLCommand.ExecuteReader();

            if (objDataReader.Read())
                strSQL = QueryDefinitions.GetQuery("UpdateRecievedItemAccumulator",//fix this
                    new string[] { "- " + objItemHistoryTransaction.Quantity, DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss"), objDataReader["JobOrderNumber"].ToString(), objDataReader["ReceivedItemAccumulatorID"].ToString() });
            else
                throw new Exception("No accumulator record found for job " + objItemHistoryTransaction.Job);

            objDataReader.Close();
            objSQLCommand.CommandText = strSQL;
            if (objSQLCommand.ExecuteNonQuery() == 1)//the appropriate row was affected
                return ShipItem(objItemHistoryTransaction.RecievedItemID);
            else
                throw new Exception("Unable to update accumulator record for job " + objItemHistoryTransaction.Job);
        }