//private OleDbConnection OpenTrackerOleDBConnection() //{ // OleDbConnection pConn = null; // string _connectionString; // if (ConfigurationManager.ConnectionStrings[CONST_CONSTRING] == null || // ConfigurationManager.ConnectionStrings[CONST_CONSTRING].ConnectionString.Trim() == "") // { // throw new Exception("A connection string named " + CONST_CONSTRING + " with a valid connection string " + // "must exist in the <connectionStrings> configuration section for the application."); // } // _connectionString = ConfigurationManager.ConnectionStrings[CONST_CONSTRING].ConnectionString; // pConn = new OleDbConnection(_connectionString); // return pConn; //} protected void SetContactByID(string pCoNameID) { // Set the Contact Name to string passed // check for null string if (!string.IsNullOrEmpty(pCoNameID)) { // now find it if (ddlContacts.Items.FindByValue(pCoNameID) != null) { ddlContacts.SelectedValue = pCoNameID; TrackerTools tt = new TrackerTools(); TrackerTools.ContactPreferedItems _ContactPreferedItems = tt.RetrieveCustomerPrefs(Convert.ToInt64(pCoNameID)); if (ddlToBeDeliveredBy.Items.FindByValue(_ContactPreferedItems.DeliveryByID.ToString()) != null) { ddlToBeDeliveredBy.SelectedValue = _ContactPreferedItems.DeliveryByID.ToString(); } } else { // did not find company to set it to generic ddlContacts.SelectedValue = CONST_ZZNAME_DEFAULTID; tbxNotes.Text += "ID note found: " + pCoNameID + ": "; } } }
protected bool AddLastOrder(bool pSetDates) { //string _LastOrderSQL, _sFrom, _sWhere; //string _sCustID; bool _LastOrder = (Session[CONST_LINESADDED] != null) ? (bool)Session[CONST_LINESADDED] : false; if (ddlContacts.SelectedValue != null) { SetUpdateBools(); // retrieve the last order items from the database. long _CustID = Convert.ToInt64(ddlContacts.SelectedValue); // if they want us to set the delivery and roast dates if (pSetDates) { SetPrepAndDeliveryValues(_CustID); } ItemUsageTbl _ItemUsage = new ItemUsageTbl(); List <ItemUsageTbl> _LastItemsOrdered = _ItemUsage.GetLastItemsUsed(_CustID, TrackerTools.CONST_SERVTYPECOFFEE); if (_LastItemsOrdered.Count > 0) { foreach (ItemUsageTbl _LastItemOrder in _LastItemsOrdered) { if (_LastItemOrder.ItemProvidedID > 0) // now a a order line { _LastOrder = (AddNewOrderLine(_LastItemOrder.ItemProvidedID, _LastItemOrder.AmountProvided, _LastItemOrder.PackagingID) || (_LastOrder)); if (!string.IsNullOrEmpty(_LastItemOrder.Notes)) { tbxNotes.Text += String.Format("{0}last order used a group item, so next item in group selected.", (tbxNotes.Text.Length > 0) ? "; " : ""); } } } } else { TrackerTools _TT = new TrackerTools(); TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(_CustID); _LastOrder = (AddNewOrderLine(_ContactPreferedItems.PreferedItem, _ContactPreferedItems.PreferedQty, _ContactPreferedItems.PrefPackagingID) || (_LastOrder)); } Session[CONST_LINESADDED] = _LastOrder; } return(_LastOrder); }
private bool LogARepair(RepairsTbl pRepair, bool pCalcOrderData) { bool _Success = false; // create a new order for delivery [RoastDate] OrderTblData _OrderData = new OrderTblData(); DateTime _RequiredByDate = DateTime.Now.Date.AddDays(7); // add the default data to order _OrderData.CustomerId = pRepair.CustomerID; _OrderData.ItemTypeID = ItemTypeTbl.CONST_SERVICEITEMID; _OrderData.QuantityOrdered = 1; _OrderData.Notes = "Collect/Swop out Machine for Service"; // Calculate the Data from the customer details if (pCalcOrderData) { TrackerTools _TT = new TrackerTools(); _OrderData.RoastDate = _TT.GetNextRoastDateByCustomerID(pRepair.CustomerID, ref _RequiredByDate); TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(pRepair.CustomerID); _OrderData.OrderDate = DateTime.Now.Date; _OrderData.RequiredByDate = _RequiredByDate; if (_ContactPreferedItems.RequiresPurchOrder) { _OrderData.PurchaseOrder = TrackerTools.CONST_POREQUIRED; } _OrderData.ToBeDeliveredBy = _ContactPreferedItems.DeliveryByID; } else { _OrderData.RoastDate = _OrderData.OrderDate = DateTime.Now.Date; _OrderData.RequiredByDate = _RequiredByDate; } // save the data to the orders OrderTbl _Order = new OrderTbl(); _Order.InsertNewOrderLine(_OrderData); pRepair.RelatedOrderID = _Order.GetLastOrderAdded(_OrderData.CustomerId, _OrderData.OrderDate, ItemTypeTbl.CONST_SERVICEITEMID); return(_Success); }
protected void SetContactValue(string pCoName, string pName, string pEmail) { // Set the Contact Name to string passed int i = 0; // force null string if (pCoName == null) { pCoName = ""; } if (pName == null) { pName = ""; } // now find it but make it ignore case while ((i < ddlContacts.Items.Count) && (!pCoName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { i++; } if ((i < ddlContacts.Items.Count) && (pCoName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { ddlContacts.SelectedValue = ddlContacts.Items[i].Value; } else { pCoName += "_" + pCoName; // see if they are disabled while ((i < ddlContacts.Items.Count) && (!pCoName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { i++; } if ((i < ddlContacts.Items.Count) && (pCoName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { ddlContacts.SelectedValue = ddlContacts.Items[i].Value; } else { // did not find co, now look for name if (pCoName != pName) { i = 0; while ((i < ddlContacts.Items.Count) && (!pName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { i++; } if ((i < ddlContacts.Items.Count) && (pName.Equals(ddlContacts.Items[i].Text, StringComparison.OrdinalIgnoreCase))) { ddlContacts.SelectedValue = ddlContacts.Items[i].Value; } else { // did not find company check email CustomersTbl _CustomerTbl = new CustomersTbl(); List <CustomersTbl> _Customers = _CustomerTbl.GetAllCustomerWithEmailLIKE(pEmail); if (_Customers.Count > 0) { SetContactByID(_Customers[0].CustomerID.ToString()); } else { // did not fine the name to set it to generic ddlContacts.SelectedValue = CONST_ZZNAME_DEFAULTID; if (String.IsNullOrEmpty(pCoName)) { tbxNotes.Text += pName + ": "; } else { tbxNotes.Text += pCoName + ", " + pName + ": "; } if (!String.IsNullOrEmpty(pEmail)) { tbxNotes.Text += " [#" + pEmail + "#]"; } } } } else { // did not find company to set it to generic ddlContacts.SelectedValue = CONST_ZZNAME_DEFAULTID; tbxNotes.Text += pCoName + ": "; } } } if ((ddlContacts.SelectedIndex > 0) && (ddlContacts.SelectedValue != CONST_ZZNAME_DEFAULTID)) { TrackerTools tt = new TrackerTools(); TrackerTools.ContactPreferedItems _ContactPreferedItems = tt.RetrieveCustomerPrefs(Convert.ToInt64(ddlContacts.SelectedValue)); if (ddlToBeDeliveredBy.Items.FindByValue(_ContactPreferedItems.DeliveryByID.ToString()) != null) { ddlToBeDeliveredBy.SelectedValue = _ContactPreferedItems.DeliveryByID.ToString(); } } }