Esempio n. 1
0
        public List <TempOrdersLinesTbl> GetAll(string SortBy)
        {
            List <TempOrdersLinesTbl> _DataItems = new List <TempOrdersLinesTbl>();
            string _connectionStr = ConfigurationManager.ConnectionStrings[QOnT.classes.TrackerDb.CONST_CONSTRING].ConnectionString;;

            using (OleDbConnection _conn = new OleDbConnection(_connectionStr))
            {
                string _sqlCmd = CONST_SQL_SELECT;
                if (!String.IsNullOrEmpty(SortBy))
                {
                    _sqlCmd += " ORDER BY " + SortBy;                            // Add order by string
                }
                OleDbCommand _cmd = new OleDbCommand(_sqlCmd, _conn);            // run the qurey we have built
                _conn.Open();
                OleDbDataReader _DataReader = _cmd.ExecuteReader();
                while (_DataReader.Read())
                {
                    TempOrdersLinesTbl _DataItem = new TempOrdersLinesTbl();

                    _DataItem.TOLineID        = (_DataReader["TOLineID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["TOLineID"]);
                    _DataItem.TOHeaderID      = (_DataReader["TOHeaderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["TOHeaderID"]);
                    _DataItem.ItemID          = (_DataReader["ItemID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ItemID"]);
                    _DataItem.ServiceTypeID   = (_DataReader["ServiceTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ServiceTypeID"]);
                    _DataItem.Qty             = (_DataReader["Qty"] == DBNull.Value) ? 0.0 : Convert.ToDouble(_DataReader["Qty"]);
                    _DataItem.PackagingID     = (_DataReader["PackagingID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["PackagingID"]);
                    _DataItem.OriginalOrderID = (_DataReader["OriginalOrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["OriginalOrderID"]);
                    _DataItems.Add(_DataItem);
                }
            }
            return(_DataItems);
        }
Esempio n. 2
0
        public string SetStatusDoneByTempOrder()
        {
            string            _Result         = String.Empty;
            List <RepairsTbl> _RelatedRepairs = GetListOfRelatedTempOrders();

            if (_RelatedRepairs.Count > 0)
            {
                TempOrdersLinesTbl _TOLines = new TempOrdersLinesTbl();

                for (int i = 0; i < _RelatedRepairs.Count; i++)
                {
                    if (_RelatedRepairs[i].RepairStatusID <= CONST_REPAIRSTATUS_WORKSHOP)
                    {
                        _TOLines.DeleteByOriginalID(_RelatedRepairs[i].RelatedOrderID);
                        OrderTbl _Order = new OrderTbl();
                        _Order.UpdateIncDeliveryDateBy7(_RelatedRepairs[i].RelatedOrderID);
                    }
                    else
                    {
                        TrackerDb _TDB = new TrackerDb();
                        _TDB.AddParams(CONST_REPAIRSTATUS_DONE, DbType.Int32);
                        _Result += _TDB.ExecuteNonQuerySQL(CONST_SQL_SETDONEBYID);
                        _TDB.Close();
                    }
                }
            }
            return(_Result);
        }
Esempio n. 3
0
        /// <summary>
        /// DeleteAll the data ion both TempOrderTables
        /// </summary>
        /// <returns></returns>
        public bool KillTempOrdersData()
        {
            bool _Success = false;

            TempOrdersHeaderTbl _HeaderDAL = new TempOrdersHeaderTbl();
            TempOrdersLinesTbl  _LinesDAL  = new TempOrdersLinesTbl();

            _Success = (_HeaderDAL.DeleteAllRecords());
            _Success = (_LinesDAL.DeleteAllRecords()) && _Success; // prevent short circut bool eval

            return(_Success);
        }
Esempio n. 4
0
        public bool Insert(TempOrdersLinesTbl pLineData)
        {
            bool _Success = false;

            string _connectionStr = ConfigurationManager.ConnectionStrings[TrackerDb.CONST_CONSTRING].ConnectionString;

            using (OleDbConnection _conn = new OleDbConnection(_connectionStr))
            {
                OleDbCommand _cmd = new OleDbCommand(CONST_SQL_INSERT, _conn);
                #region Parameters
                // Add data sent   in order: TOHeaderID, ItemID, ServiceTypeID, Qty, PackagingID, OriginalOrderID
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.TOHeaderID
                });
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.ItemID
                });
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.ServiceTypeID
                });
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.Qty
                });
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.PackagingID
                });
                _cmd.Parameters.Add(new OleDbParameter {
                    Value = pLineData.OriginalOrderID
                });
                #endregion
                try
                {
                    _conn.Open();
                    _Success = (_cmd.ExecuteNonQuery() > 0);
                }
                catch (OleDbException oleErr)
                { _Success = oleErr.ErrorCode != 0; }
                finally
                { _conn.Close(); }

                _cmd.Dispose();
            }
            return(_Success);
        }
Esempio n. 5
0
        public bool Insert(TempOrdersData pTempOrder)
        {
            bool _Success = false;
            int  _LineNo  = 0;
            TempOrdersHeaderTbl _HeaderDAL = new TempOrdersHeaderTbl();
            TempOrdersLinesTbl  _LinesDAL  = new TempOrdersLinesTbl();

            _Success = _HeaderDAL.Insert(pTempOrder.HeaderData);
            long _TOHeaderID = _HeaderDAL.GetCurrentTOHeaderID();

            while ((_Success) && (pTempOrder.OrdersLines.Count > _LineNo))
            {
                pTempOrder.OrdersLines[_LineNo].TOHeaderID = _TOHeaderID;
                _Success = _LinesDAL.Insert(pTempOrder.OrdersLines[_LineNo]);
                _LineNo++;
            }

            return(_Success);
        }