public List <TempOrdersHeaderTbl> GetAll(string SortBy) { List <TempOrdersHeaderTbl> _DataItems = new List <TempOrdersHeaderTbl>(); 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()) { TempOrdersHeaderTbl _DataItem = new TempOrdersHeaderTbl(); _DataItem.TOHeaderID = (_DataReader["TOHeaderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["TOHeaderID"]); _DataItem.CustomerID = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]); _DataItem.OrderDate = (_DataReader["OrderDate"] == DBNull.Value) ? System.DateTime.Now : Convert.ToDateTime(_DataReader["OrderDate"]); _DataItem.RoastDate = (_DataReader["RoastDate"] == DBNull.Value) ? System.DateTime.Now : Convert.ToDateTime(_DataReader["RoastDate"]); _DataItem.RequiredByDate = (_DataReader["RequiredByDate"] == DBNull.Value) ? System.DateTime.Now : Convert.ToDateTime(_DataReader["RequiredByDate"]); _DataItem.ToBeDeliveredByID = (_DataReader["ToBeDeliveredByID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["ToBeDeliveredByID"]); _DataItem.Confirmed = (_DataReader["Confirmed"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Confirmed"]); _DataItem.Done = (_DataReader["Done"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["Done"]); _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString(); _DataItems.Add(_DataItem); } } return(_DataItems); }
/// <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); }
public bool Insert(TempOrdersHeaderTbl pHeaderData) { 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 CustomerId, OrderDate, RoastDate, RequiredByDate, ToBeDeliveredByID, Confirmed, Done, Notes _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.CustomerID }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.OrderDate }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.RoastDate }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.RequiredByDate }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.ToBeDeliveredByID }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.Confirmed }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.Done }); _cmd.Parameters.Add(new OleDbParameter { Value = pHeaderData.Notes }); #endregion try { _conn.Open(); _Success = (_cmd.ExecuteNonQuery() >= 0); } catch (OleDbException oleErr) { _Success = oleErr.ErrorCode != 0; } finally { _conn.Close(); } _cmd.Dispose(); } return(_Success); }
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); }
public TempOrdersData() { _TempOrdersHeaderTbl = new TempOrdersHeaderTbl(); _TempOrdersLines = new List <TempOrdersLinesTbl>(); }