private bool SendStatusChangeEmail(RepairsTbl pRepair) { //EmailCls _Email = new EmailCls(); //EquipTypeTbl _EquipTypes = new EquipTypeTbl(); //RepairStatusesTbl _RepairStatuses = new RepairStatusesTbl(); //_Email.SetEmailTo(pRepair.ContactEmail); //_Email.SetEmailSubject("Change to repair status - notification."); //_Email.AddStrAndNewLineToBody("<b>Repair Status Change Notification</b>"); //_Email.AddFormatToBody("Dear {0}, <br /><br />", pRepair.ContactName); //_Email.AddFormatToBody("Please note that repair status of the {0}, serial number: {1}, has changed to <b>{2}</b>.<br /><br />", // _EquipTypes.GetEquipName(pRepair._MachineTypeID), // pRepair.MachineSerialNumber, _RepairStatuses.GetRepairStatusDesc(pRepair.RepairStatusID)); //_Email.AddStrAndNewLineToBody("You are receiving this status update since your email address was assigned to the tracking of this repair.<br />"); //_Email.AddStrAndNewLineToBody("Please note that Quaffee DOES NOT run a coffee machine repair workshop. As a service to our current coffee " + // "purchasing clients we will take the coffee machine to the workshop, give a swop out machine to the client, if available, and " + // "charge what we are charged by the workshop plus a small admin fee. Please note: we are not able to quote these repairs, if you would like " + // "to contact the workshop directly, please ask us for their details.<br />"); //_Email.AddStrAndNewLineToBody("For clients that are not currently using our coffee, or have not used our coffee consistently over" + // " the last 3 months, we may at our discretion offer a swop out machine, at a fee, and also change a collection and delivery fee.<br />"); //_Email.AddStrAndNewLineToBody("Any warantee on the repairs is carried by the workshop not by Quaffee.<br />"); //_Email.AddStrAndNewLineToBody("The Quaffee Team"); //_Email.AddStrAndNewLineToBody("web: <a href='http://www.quaffee.co.za'>quaffee.co.za</a>"); //return _Email.SendEmail(); return(false); }
public string UpdateRepair(RepairsTbl RepairItem, int orig_RepairID) { string _result = String.Empty; TrackerDb _TrackerDb = new TrackerDb(); _TrackerDb.AddParams(RepairItem.CustomerID, DbType.Int64); _TrackerDb.AddParams(RepairItem.ContactName, DbType.String); _TrackerDb.AddParams(RepairItem.ContactEmail, DbType.String); _TrackerDb.AddParams(RepairItem.JobCardNumber, DbType.String); _TrackerDb.AddParams(RepairItem.DateLogged, DbType.Date); _TrackerDb.AddParams(RepairItem.LastStatusChange, DbType.Date); _TrackerDb.AddParams(RepairItem.MachineTypeID, DbType.Int32); _TrackerDb.AddParams(RepairItem.MachineSerialNumber, DbType.String); _TrackerDb.AddParams(RepairItem.SwopOutMachineID, DbType.Int32); _TrackerDb.AddParams(RepairItem.MachineConditionID, DbType.Int32); _TrackerDb.AddParams(RepairItem.TakenFrother, DbType.Boolean); _TrackerDb.AddParams(RepairItem.TakenBeanLid, DbType.Boolean); _TrackerDb.AddParams(RepairItem.TakenWaterLid, DbType.Boolean); _TrackerDb.AddParams(RepairItem.BrokenFrother, DbType.Boolean); _TrackerDb.AddParams(RepairItem.BrokenBeanLid, DbType.Boolean); _TrackerDb.AddParams(RepairItem.BrokenWaterLid, DbType.Boolean); _TrackerDb.AddParams(RepairItem.RepairFaultID, DbType.Int32); _TrackerDb.AddParams(RepairItem.RepairFaultDesc, DbType.String); _TrackerDb.AddParams(RepairItem.RepairStatusID, DbType.Int32); _TrackerDb.AddParams(RepairItem.RelatedOrderID, DbType.Int64); _TrackerDb.AddParams(RepairItem.Notes, DbType.String); _TrackerDb.AddWhereParams(orig_RepairID, DbType.Int32); _result = _TrackerDb.ExecuteNonQuerySQL(CONST_SQL_UPDATE); _TrackerDb.Close(); return(_result); }
public bool InsertRepair(RepairsTbl DataItem) { bool _result = false; TrackerDb _TrackerDb = new TrackerDb(); _TrackerDb.AddParams(DataItem.CustomerID, DbType.Int64); _TrackerDb.AddParams(DataItem.ContactName, DbType.String); _TrackerDb.AddParams(DataItem.ContactEmail, DbType.String); _TrackerDb.AddParams(DataItem.JobCardNumber, DbType.String); _TrackerDb.AddParams(DataItem.DateLogged, DbType.Date); _TrackerDb.AddParams(DataItem.LastStatusChange, DbType.Date); _TrackerDb.AddParams(DataItem.MachineTypeID, DbType.Int32); _TrackerDb.AddParams(DataItem.MachineSerialNumber, DbType.String); _TrackerDb.AddParams(DataItem.SwopOutMachineID, DbType.Int32); _TrackerDb.AddParams(DataItem.MachineConditionID, DbType.Int32); _TrackerDb.AddParams(DataItem.TakenFrother, DbType.Boolean); _TrackerDb.AddParams(DataItem.TakenBeanLid, DbType.Boolean); _TrackerDb.AddParams(DataItem.TakenWaterLid, DbType.Boolean); _TrackerDb.AddParams(DataItem.BrokenFrother, DbType.Boolean); _TrackerDb.AddParams(DataItem.BrokenBeanLid, DbType.Boolean); _TrackerDb.AddParams(DataItem.BrokenWaterLid, DbType.Boolean); _TrackerDb.AddParams(DataItem.RepairFaultID, DbType.Int32); _TrackerDb.AddParams(DataItem.RepairFaultDesc, DbType.String); _TrackerDb.AddParams(DataItem.RepairStatusID, DbType.Int32); _TrackerDb.AddParams(DataItem.RelatedOrderID, DbType.Int64); _TrackerDb.AddParams(DataItem.Notes, DbType.String); _result = String.IsNullOrEmpty(_TrackerDb.ExecuteNonQuerySQL(CONST_SQL_INSERT)); _TrackerDb.Close(); return(_result); }
private List <RepairsTbl> GetAllRepairs(string SortBy, string pSQL, List <OdbcParameter> pWhereParams) { List <RepairsTbl> _DataItems = new List <RepairsTbl>(); TrackerDb _TrackerDb = new TrackerDb(); pSQL += " ORDER BY " + (String.IsNullOrEmpty(SortBy) ? "DateLogged DESC" : SortBy); // Add order by string // params would go here if need if (pWhereParams != null) { _TrackerDb.WhereParams = pWhereParams; } IDataReader _DataReader = _TrackerDb.ExecuteSQLGetDataReader(pSQL); if (_DataReader != null) { while (_DataReader.Read()) { RepairsTbl _DataItem = new RepairsTbl(); _DataItem.RepairID = (_DataReader["RepairID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairID"]); _DataItem.CustomerID = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]); _DataItem.ContactName = (_DataReader["ContactName"] == DBNull.Value) ? string.Empty : _DataReader["ContactName"].ToString(); _DataItem.ContactEmail = (_DataReader["ContactEmail"] == DBNull.Value) ? string.Empty : _DataReader["ContactEmail"].ToString(); _DataItem.JobCardNumber = (_DataReader["JobCardNumber"] == DBNull.Value) ? string.Empty : _DataReader["JobCardNumber"].ToString(); _DataItem.DateLogged = (_DataReader["DateLogged"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateLogged"]).Date; _DataItem.LastStatusChange = (_DataReader["LastStatusChange"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["LastStatusChange"]).Date; _DataItem.MachineTypeID = (_DataReader["MachineTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineTypeID"]); _DataItem.MachineSerialNumber = (_DataReader["MachineSerialNumber"] == DBNull.Value) ? string.Empty : _DataReader["MachineSerialNumber"].ToString(); _DataItem.SwopOutMachineID = (_DataReader["SwopOutMachineID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SwopOutMachineID"]); _DataItem.MachineConditionID = (_DataReader["MachineConditionID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineConditionID"]); _DataItem.TakenFrother = (_DataReader["TakenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenFrother"]); _DataItem.TakenBeanLid = (_DataReader["TakenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenBeanLid"]); _DataItem.TakenWaterLid = (_DataReader["TakenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenWaterLid"]); _DataItem.BrokenFrother = (_DataReader["BrokenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenFrother"]); _DataItem.BrokenBeanLid = (_DataReader["BrokenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenBeanLid"]); _DataItem.BrokenWaterLid = (_DataReader["BrokenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenWaterLid"]); _DataItem.RepairFaultID = (_DataReader["RepairFaultID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairFaultID"]); _DataItem.RepairFaultDesc = (_DataReader["RepairFaultDesc"] == DBNull.Value) ? string.Empty : _DataReader["RepairFaultDesc"].ToString(); _DataItem.RepairStatusID = (_DataReader["RepairStatusID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairStatusID"]); _DataItem.RelatedOrderID = (_DataReader["RelatedOrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["RelatedOrderID"]); _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString(); _DataItems.Add(_DataItem); } _DataReader.Close(); } _TrackerDb.Close(); return(_DataItems); }
private bool LogARepair(RepairsTbl pRepair, bool pCalcOrderData) { bool _Success = false; // create a new order for delivery [RoastDate] OrderCls _OrderData = new OrderCls(); DateTime _RequiredByDate = DateTime.Now.Date.AddDays(7); // add the default data to order _OrderData.HeaderData.CustomerID = pRepair.CustomerID; _OrderData.HeaderData.Notes = "Collect/Swop out Machine for Service"; List <OrderDetailData> orderDetailDatas = new List <OrderDetailData>(); OrderDetailData orderDetailData = new OrderDetailData(); orderDetailData.ItemTypeID = ItemTypeTbl.CONST_SERVICEITEMID; orderDetailData.QuantityOrdered = 1; // Calculate the Data from the customer details if (pCalcOrderData) { TrackerTools _TT = new TrackerTools(); _OrderData.HeaderData.RoastDate = _TT.GetNextRoastDateByCustomerID(pRepair.CustomerID, ref _RequiredByDate); TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(pRepair.CustomerID); _OrderData.HeaderData.OrderDate = DateTime.Now.Date; _OrderData.HeaderData.RequiredByDate = _RequiredByDate; if (_ContactPreferedItems.RequiresPurchOrder) { _OrderData.HeaderData.PurchaseOrder = TrackerTools.CONST_POREQUIRED; } _OrderData.HeaderData.ToBeDeliveredBy = _ContactPreferedItems.DeliveryByID; } else { _OrderData.HeaderData.RoastDate = _OrderData.HeaderData.OrderDate = DateTime.Now.Date; _OrderData.HeaderData.RequiredByDate = _RequiredByDate; } // save the data to the orders OrderTbl _Order = new OrderTbl(); _Order.InsertNewOrderLine(_OrderData); pRepair.RelatedOrderID = _Order.GetLastOrderAdded(_OrderData.HeaderData.CustomerID, _OrderData.HeaderData.OrderDate, ItemTypeTbl.CONST_SERVICEITEMID); return(_Success); }
public RepairsTbl GetRepairById(int pRepairID) { RepairsTbl _DataItem = null; if (pRepairID > 0) { TrackerDb _TrackerDb = new TrackerDb(); // params would go here if need _TrackerDb.AddWhereParams(pRepairID, DbType.Int32); IDataReader _DataReader = _TrackerDb.ExecuteSQLGetDataReader(CONST_SQL_SELECTBYREPAIRID); if (_DataReader != null) { if (_DataReader.Read()) { _DataItem = new RepairsTbl(); _DataItem.RepairID = pRepairID; _DataItem.CustomerID = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]); _DataItem.ContactName = (_DataReader["ContactName"] == DBNull.Value) ? string.Empty : _DataReader["ContactName"].ToString(); _DataItem.ContactEmail = (_DataReader["ContactEmail"] == DBNull.Value) ? string.Empty : _DataReader["ContactEmail"].ToString(); _DataItem.JobCardNumber = (_DataReader["JobCardNumber"] == DBNull.Value) ? string.Empty : _DataReader["JobCardNumber"].ToString(); _DataItem.DateLogged = (_DataReader["DateLogged"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateLogged"]).Date; _DataItem.LastStatusChange = (_DataReader["LastStatusChange"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["LastStatusChange"]).Date; _DataItem.MachineTypeID = (_DataReader["MachineTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineTypeID"]); _DataItem.MachineSerialNumber = (_DataReader["MachineSerialNumber"] == DBNull.Value) ? string.Empty : _DataReader["MachineSerialNumber"].ToString(); _DataItem.SwopOutMachineID = (_DataReader["SwopOutMachineID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SwopOutMachineID"]); _DataItem.MachineConditionID = (_DataReader["MachineConditionID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineConditionID"]); _DataItem.TakenFrother = (_DataReader["TakenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenFrother"]); _DataItem.TakenBeanLid = (_DataReader["TakenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenBeanLid"]); _DataItem.TakenWaterLid = (_DataReader["TakenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenWaterLid"]); _DataItem.BrokenFrother = (_DataReader["BrokenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenFrother"]); _DataItem.BrokenBeanLid = (_DataReader["BrokenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenBeanLid"]); _DataItem.BrokenWaterLid = (_DataReader["BrokenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenWaterLid"]); _DataItem.RepairFaultID = (_DataReader["RepairFaultID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairFaultID"]); _DataItem.RepairFaultDesc = (_DataReader["RepairFaultDesc"] == DBNull.Value) ? string.Empty : _DataReader["RepairFaultDesc"].ToString(); _DataItem.RepairStatusID = (_DataReader["RepairStatusID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairStatusID"]); _DataItem.RelatedOrderID = (_DataReader["RelatedOrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["RelatedOrderID"]); _DataItem.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString(); } _DataReader.Close(); } _TrackerDb.Close(); } return(_DataItem); }
public List <RepairsTbl> GetListOfRelatedTempOrders() { List <RepairsTbl> _RelatedRepairs = new List <RepairsTbl>(); // should only be one but check TrackerDb _TDB = new TrackerDb(); IDataReader _DataReader = _TDB.ExecuteSQLGetDataReader(CONST_SQL_SELECTITEMWITHANORDER); if (_DataReader != null) { while (_DataReader.Read()) { RepairsTbl _RelatedRepair = new RepairsTbl(); _RelatedRepair.RepairID = (_DataReader["RepairID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairID"]); _RelatedRepair.CustomerID = (_DataReader["CustomerID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["CustomerID"]); _RelatedRepair.ContactName = (_DataReader["ContactName"] == DBNull.Value) ? string.Empty : _DataReader["ContactName"].ToString(); _RelatedRepair.ContactEmail = (_DataReader["ContactEmail"] == DBNull.Value) ? string.Empty : _DataReader["ContactEmail"].ToString(); _RelatedRepair.JobCardNumber = (_DataReader["JobCardNumber"] == DBNull.Value) ? string.Empty : _DataReader["JobCardNumber"].ToString(); _RelatedRepair.DateLogged = (_DataReader["DateLogged"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["DateLogged"]).Date; _RelatedRepair.LastStatusChange = (_DataReader["LastStatusChange"] == DBNull.Value) ? System.DateTime.Now.Date : Convert.ToDateTime(_DataReader["LastStatusChange"]).Date; _RelatedRepair.MachineTypeID = (_DataReader["MachineTypeID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineTypeID"]); _RelatedRepair.MachineSerialNumber = (_DataReader["MachineSerialNumber"] == DBNull.Value) ? string.Empty : _DataReader["MachineSerialNumber"].ToString(); _RelatedRepair.SwopOutMachineID = (_DataReader["SwopOutMachineID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["SwopOutMachineID"]); _RelatedRepair.MachineConditionID = (_DataReader["MachineConditionID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["MachineConditionID"]); _RelatedRepair.TakenFrother = (_DataReader["TakenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenFrother"]); _RelatedRepair.TakenBeanLid = (_DataReader["TakenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenBeanLid"]); _RelatedRepair.TakenWaterLid = (_DataReader["TakenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["TakenWaterLid"]); _RelatedRepair.BrokenFrother = (_DataReader["BrokenFrother"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenFrother"]); _RelatedRepair.BrokenBeanLid = (_DataReader["BrokenBeanLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenBeanLid"]); _RelatedRepair.BrokenWaterLid = (_DataReader["BrokenWaterLid"] == DBNull.Value) ? false : Convert.ToBoolean(_DataReader["BrokenWaterLid"]); _RelatedRepair.RepairFaultID = (_DataReader["RepairFaultID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairFaultID"]); _RelatedRepair.RepairFaultDesc = (_DataReader["RepairFaultDesc"] == DBNull.Value) ? string.Empty : _DataReader["RepairFaultDesc"].ToString(); _RelatedRepair.RepairStatusID = (_DataReader["RepairStatusID"] == DBNull.Value) ? 0 : Convert.ToInt32(_DataReader["RepairStatusID"]); _RelatedRepair.RelatedOrderID = (_DataReader["RelatedOrderID"] == DBNull.Value) ? 0 : Convert.ToInt64(_DataReader["RelatedOrderID"]); _RelatedRepair.Notes = (_DataReader["Notes"] == DBNull.Value) ? string.Empty : _DataReader["Notes"].ToString(); _RelatedRepairs.Add(_RelatedRepair); } _DataReader.Close(); } _TDB.Close(); return(_RelatedRepairs); }
public bool HandleAndUpdateRepairStatusChange(RepairsTbl pRepair) { // send email and handle status change bool _Success = true; switch (pRepair.RepairStatusID) { case CONST_REPAIRSTATUS_LOGGED: { _Success = LogARepair(pRepair, true); break; } case CONST_REPAIRSTATUS_COLLECTED: { if (pRepair.RelatedOrderID.Equals(0)) { _Success = LogARepair(pRepair, true); } else { OrderTbl _Order = new OrderTbl(); _Order.UpdateIncDeliveryDateBy7(pRepair.RelatedOrderID); } break; } case CONST_REPAIRSTATUS_WORKSHOP: { if (pRepair.RelatedOrderID.Equals(0)) { _Success = LogARepair(pRepair, false); } else { OrderTbl _Order = new OrderTbl(); _Order.UpdateIncDeliveryDateBy7(pRepair.RelatedOrderID); } if (!String.IsNullOrEmpty(pRepair.MachineSerialNumber)) { // if we have no serial number in the current Customer Tbl then update CustomersTbl _Customers = new CustomersTbl(); _Customers.SetEquipDetailsIfEmpty(pRepair.MachineTypeID, pRepair.MachineSerialNumber, pRepair.CustomerID); } break; } case CONST_REPAIRSTATUS_READY: { if (pRepair.RelatedOrderID > 0) { OrderTbl _Order = new OrderTbl(); NextRoastDateByCityTbl _NextDates = new NextRoastDateByCityTbl(); _Order.UpdateOrderDeliveryDate(_NextDates.GetNextDeliveryDate(pRepair.CustomerID), pRepair.RelatedOrderID); } break; } case CONST_REPAIRSTATUS_DONE: { if (pRepair.RelatedOrderID > 0) { OrderTbl _Order = new OrderTbl(); _Order.UpdateSetDoneByID(true, pRepair.RelatedOrderID); // ??? should we do this since it interupts with the Preiction Calculations } break; } default: { break; } } _Success = String.IsNullOrEmpty(UpdateRepair(pRepair)); _Success = _Success && SendStatusChangeEmail(pRepair); return(_Success); }
public string UpdateRepair(RepairsTbl RepairItem) { return(UpdateRepair(RepairItem, RepairItem.RepairID)); }