private TrackerTools.ContactPreferedItems SetPrepAndDeliveryValues(long pCustomerID) { DateTime _DeliveryDate = DateTime.Now.Date; TrackerTools _TT = new classes.TrackerTools(); // . from TrackerDotNet.classes. DateTime _dtNextRoastDay = _TT.GetNextRoastDateByCustomerID(pCustomerID, ref _DeliveryDate); TrackerTools.ContactPreferedItems _ContactPreferedItems = _TT.RetrieveCustomerPrefs(pCustomerID); // set dates tbxRoastDate.Text = String.Format("{0:d}", _dtNextRoastDay); tbxRequiredByDate.Text = String.Format("{0:d}", _DeliveryDate); // make sure the default delivery person can delvier on that day PersonsTbl _Person = new PersonsTbl(); int _DeliveryBy = _Person.IsNormalDeliveryDoW(_ContactPreferedItems.DeliveryByID, (int)(_DeliveryDate.DayOfWeek) + 1) ? _ContactPreferedItems.DeliveryByID : TrackerTools.CONST_DEFAULT_DELIVERYBYID; // ad a note if we changed it if (!_DeliveryBy.Equals(_ContactPreferedItems.DeliveryByID)) { tbxNotes.Text += ((tbxNotes.Text.Length > 0) ? " " : "") + "!!!default delivery person changed due to DoW calculation"; } if (ddlToBeDeliveredBy.Items.FindByValue(_DeliveryBy.ToString()) != null) { ddlToBeDeliveredBy.SelectedValue = _DeliveryBy.ToString(); } if (_ContactPreferedItems.RequiresPurchOrder) { tbxPurchaseOrder.Text = TrackerTools.CONST_POREQUIRED; } return(_ContactPreferedItems); }
protected void ddlCustomer_SelectedIndexChanged(object sender, EventArgs e) { QOnT.classes.TrackerTools tt = new classes.TrackerTools(); DropDownList _ddlCustomers = (DropDownList)sender; // roast day vars DateTime _dtNextRoastDay; // = Convert.ToDateTime(((TextBox)myDetailsView.FindControl(DV_CONTROL_ROAST_DATE)).Text); DateTime _dtDelivery = DateTime.Now; // preference vars; Int64 _CustID = Convert.ToInt64(_ddlCustomers.SelectedValue); int _preferredDlvryBy = 1; // = ((DropDownList)myDetailsView.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedValue ; int _preferredItem = 1; // = ((DropDownList)myDetailsView.FindControl(DV_CONTROL_ITEMDESC)).SelectedValue; double _preferredQty = 1; _dtNextRoastDay = tt.GetNextRoastDateByCustomerID(_CustID, ref _dtDelivery); tt.RetrieveCustomerPrefs(_CustID, ref _preferredDlvryBy, ref _preferredItem, ref _preferredQty); ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_ROAST_DATE)).Text = String.Format("{0:d}", _dtNextRoastDay); ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_REQUIRED_BY_DATE)).Text = String.Format("{0:d}", _dtDelivery); DropDownList _ddl = (DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY); int i = 0; while ((i < _ddl.Items.Count) && (_ddl.Items[i].Value != _preferredDlvryBy.ToString())) { i++; } if (i < _ddl.Items.Count) { ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedIndex = i; } // ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_DELIVERY_BY)).SelectedValue = _preferredDlvryBy.ToString(); //((TextBox)dvOrderEdit.FindControl(DV_CONTROL_QTY)).Text = "1"; ((DropDownList)dvOrderEdit.FindControl(DV_CONTROL_ITEMDESC)).SelectedValue = _preferredItem.ToString(); ((TextBox)dvOrderEdit.FindControl(DV_CONTROL_QTY)).Text = String.Format("{0:N}", _preferredQty); }